@@ -773,26 +773,30 @@ func (it *prefixCompressedPostings) Seek(x uint64) bool {
773773 if it .inside && it .key == curKey {
774774 // Fast path for x in current block.
775775 return it .seekInBlock (x )
776- } else {
777- i := sort .Search (it .numBlock - it .blockIdx , func (i int ) bool {
778- off := int (binary .BigEndian .Uint32 (it .bs [it .footerAddr + ((it .blockIdx + i )<< 2 ):]))
779- k := binary .BigEndian .Uint64 (it .bs [off :])
780- return k >= curKey
781- })
782- if i == it .numBlock - it .blockIdx {
783- return false
784- }
785- it .blockIdx += i
786- if i > 0 {
787- it .idx = int (binary .BigEndian .Uint32 (it .bs [it .footerAddr + ((it .blockIdx )<< 2 ):]))
788- }
776+ }
777+ i := sort .Search (it .numBlock - it .blockIdx , func (i int ) bool {
778+ off := int (binary .BigEndian .Uint32 (it .bs [it .footerAddr + ((it .blockIdx + i )<< 2 ):]))
779+ k := binary .BigEndian .Uint64 (it .bs [off :])
780+ return k >= curKey
781+ })
782+ if i == it .numBlock - it .blockIdx {
783+ return false
784+ }
785+ it .blockIdx += i
786+ if i > 0 {
787+ it .idx = int (binary .BigEndian .Uint32 (it .bs [it .footerAddr + ((it .blockIdx )<< 2 ):]))
789788 }
790789 it .key = binary .BigEndian .Uint64 (it .bs [it .idx :])
791790 it .idx += 8
792791
793792 it .inside = true
794793
795794 it .nextBlock = int (binary .BigEndian .Uint32 (it .bs [it .footerAddr + ((it .blockIdx + 1 )<< 2 ):]))
795+ if it .key != curKey {
796+ it .cur = it .key | uint64 (binary .BigEndian .Uint16 (it .bs [it .idx :]))
797+ it .idx += 2
798+ return true
799+ }
796800 return it .seekInBlock (x )
797801}
798802
@@ -834,7 +838,6 @@ func writePrefixCompressedPostings(e *encoding.Encbuf, arr []uint64) {
834838 if curKey != key {
835839 // Move to next block.
836840 if idx != 0 {
837- // We don't need to store the starting offset of the first block because it won't be used.
838841 startingOffs = append (startingOffs , uint32 (len (e .B )))
839842 writePrefixCompressedPostingsBlock (e , vals , key , c )
840843 vals = vals [:0 ]
0 commit comments