@@ -773,26 +773,30 @@ func (it *prefixCompressedPostings) Seek(x uint64) bool {
773
773
if it .inside && it .key == curKey {
774
774
// Fast path for x in current block.
775
775
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 ):]))
789
788
}
790
789
it .key = binary .BigEndian .Uint64 (it .bs [it .idx :])
791
790
it .idx += 8
792
791
793
792
it .inside = true
794
793
795
794
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
+ }
796
800
return it .seekInBlock (x )
797
801
}
798
802
@@ -834,7 +838,6 @@ func writePrefixCompressedPostings(e *encoding.Encbuf, arr []uint64) {
834
838
if curKey != key {
835
839
// Move to next block.
836
840
if idx != 0 {
837
- // We don't need to store the starting offset of the first block because it won't be used.
838
841
startingOffs = append (startingOffs , uint32 (len (e .B )))
839
842
writePrefixCompressedPostingsBlock (e , vals , key , c )
840
843
vals = vals [:0 ]
0 commit comments