@@ -24,7 +24,8 @@ import (
2424 "github.com/dgraph-io/dgraph/protos/pb"
2525)
2626
27- const jump = 32 // Jump size in InsersectWithJump.
27+ const jump = 32 // Jump size in InsersectWithJump.
28+ const linVsBinRatio = 10 // When is linear search better than binary
2829
2930// ApplyFilter applies a filter to our UIDList.
3031func ApplyFilter (u * pb.List , f func (uint64 , int ) bool ) {
@@ -60,7 +61,7 @@ func IntersectCompressedWith(pack *pb.UidPack, afterUID uint64, v, o *pb.List) {
6061
6162 // Select appropriate function based on heuristics.
6263 ratio := float64 (m ) / float64 (n )
63- if ratio < 10 {
64+ if ratio < linVsBinRatio {
6465 IntersectCompressedWithLinJump (& dec , v .Uids , & dst )
6566 } else {
6667 IntersectCompressedWithBin (& dec , v .Uids , & dst )
@@ -111,7 +112,7 @@ func IntersectCompressedWithBin(dec *codec.Decoder, q []uint64, o *[]uint64) {
111112 if len (blockUids ) == 0 {
112113 break
113114 }
114- if ld * 10 < len (q ) {
115+ if ld * linVsBinRatio < len (q ) {
115116 q = q [IntersectWithBin (blockUids , q , o ):]
116117 } else {
117118 // For small enough difference between two arrays, we should just
@@ -135,7 +136,7 @@ func IntersectCompressedWithBin(dec *codec.Decoder, q []uint64, o *[]uint64) {
135136 }
136137 u := q [qidx ]
137138 if len (uids ) == 0 || u > uids [len (uids )- 1 ] {
138- if lq * 10 < ld {
139+ if lq * linVsBinRatio < ld {
139140 uids = dec .LinearSeek (u )
140141 } else {
141142 uids = dec .SeekToBlock (u , codec .SeekCurrent )
0 commit comments