Better top implementation.
Better top implementation.

When selecting the top k of n, it is common that k << n.
Using a heap is O(n log k) while select algorithms can
achieve O(n + k log k).

This also avoids the ugliness that heapq does not take the
comparator as an argument, resulting in _HeapItem classes that
were cumbersome and expensive to serialize.

chamikaramj/beam,rangadi/beam,RyanSkraba/beam,RyanSkraba/beam,charlesccychen/incubator-beam,wangyum/beam,chamikaramj/beam,robertwb/incubator-beam,RyanSkraba/beam,vikkyrk/incubator-beam,jbonofre/beam,peihe/incubator-beam,robertwb/incubator-beam,rangadi/incubator-beam,rangadi/beam,dhalperi/incubator-beam,yk5/beam,lukecwik/incubator-beam,tgroh/incubator-beam,manuzhang/beam,chamikaramj/beam,ravwojdyla/incubator-beam,manuzhang/incubator-beam,charlesccychen/beam,vikkyrk/incubator-beam,vikkyrk/incubator-beam,apache/beam,amitsela/incubator-beam,robertwb/incubator-beam,lukecwik/incubator-beam,yk5/beam,amarouni/incubator-beam,lukecwik/incubator-beam,xsm110/Apache-Beam,lukecwik/incubator-beam,apache/beam,apache/beam,markflyhigh/incubator-beam,apache/beam,wangyum/beam,manuzhang/incubator-beam,jbonofre/beam,rangadi/incubator-beam,apache/beam,robertwb/incubator-beam,jbonofre/beam,manuzhang/beam,staslev/beam,xsm110/Apache-Beam,charlesccychen/beam,tgroh/beam,amarouni/incubator-beam,ravwojdyla/incubator-beam,lukecwik/incubator-beam,robertwb/incubator-beam,jasonkuster/beam,apache/beam,yk5/beam,chamikaramj/beam,wtanaka/beam,tgroh/beam,staslev/incubator-beam,charlesccychen/incubator-beam,charlesccychen/beam,charlesccychen/beam,chamikaramj/beam,apache/beam,chamikaramj/incubator-beam,peihe/incubator-beam,dhalperi/beam,eljefe6a/incubator-beam,rangadi/beam,lukecwik/incubator-beam,rangadi/beam,robertwb/incubator-beam,eljefe6a/incubator-beam,jbonofre/incubator-beam,mxm/incubator-beam,markflyhigh/incubator-beam,tgroh/beam,apache/beam,amitsela/beam,rangadi/incubator-beam,rangadi/beam,markflyhigh/incubator-beam,chamikaramj/beam,RyanSkraba/beam,amitsela/incubator-beam,markflyhigh/incubator-beam,tgroh/incubator-beam,jbonofre/incubator-beam,markflyhigh/incubator-beam,robertwb/incubator-beam,staslev/beam,chamikaramj/beam,wtanaka/beam,markflyhigh/incubator-beam,lukecwik/incubator-beam,chamikaramj/beam,tgroh/beam,charlesccychen/beam,chamikaramj/beam,RyanSkraba/beam,charlesccychen/beam,staslev/beam,peihe/incubator-beam,dhalperi/incubator-beam,charlesccychen/incubator-beam,sammcveety/incubator-beam,jasonkuster/beam,apache/beam,mxm/incubator-beam,wangyum/beam,sammcveety/incubator-beam,iemejia/incubator-beam,robertwb/incubator-beam,staslev/incubator-beam,rangadi/beam,jasonkuster/beam,jbonofre/beam,lukecwik/incubator-beam,dhalperi/beam,ravwojdyla/incubator-beam,manuzhang/beam,eljefe6a/incubator-beam,chamikaramj/incubator-beam,wangyum/beam,lukecwik/incubator-beam,rangadi/beam,dhalperi/beam,xsm110/Apache-Beam,jasonkuster/incubator-beam,wtanaka/beam,amitsela/beam,sammcveety/incubator-beam,robertwb/incubator-beam,amitsela/beam,iemejia/incubator-beam,jasonkuster/incubator-beam,lukecwik/incubator-beam,RyanSkraba/beam,robertwb/incubator-beam,apache/beam,RyanSkraba/beam,markflyhigh/incubator-beam,chamikaramj/beam,apache/beam,charlesccychen/beam