Skip to content
This repository has been archived by the owner on Aug 13, 2019. It is now read-only.

Commit

Permalink
add two more benchmarks
Browse files Browse the repository at this point in the history
Signed-off-by: naivewong <[email protected]>
  • Loading branch information
naivewong committed Aug 7, 2019
1 parent 9a858bc commit 8bac3f8
Show file tree
Hide file tree
Showing 2 changed files with 627 additions and 17 deletions.
31 changes: 17 additions & 14 deletions index/postings.go
Original file line number Diff line number Diff line change
Expand Up @@ -773,26 +773,30 @@ func (it *prefixCompressedPostings) Seek(x uint64) bool {
if it.inside && it.key == curKey {
// Fast path for x in current block.
return it.seekInBlock(x)
} else {
i := sort.Search(it.numBlock-it.blockIdx, func(i int) bool {
off := int(binary.BigEndian.Uint32(it.bs[it.footerAddr+((it.blockIdx+i)<<2):]))
k := binary.BigEndian.Uint64(it.bs[off:])
return k >= curKey
})
if i == it.numBlock-it.blockIdx {
return false
}
it.blockIdx += i
if i > 0 {
it.idx = int(binary.BigEndian.Uint32(it.bs[it.footerAddr+((it.blockIdx)<<2):]))
}
}
i := sort.Search(it.numBlock-it.blockIdx, func(i int) bool {
off := int(binary.BigEndian.Uint32(it.bs[it.footerAddr+((it.blockIdx+i)<<2):]))
k := binary.BigEndian.Uint64(it.bs[off:])
return k >= curKey
})
if i == it.numBlock-it.blockIdx {
return false
}
it.blockIdx += i
if i > 0 {
it.idx = int(binary.BigEndian.Uint32(it.bs[it.footerAddr+((it.blockIdx)<<2):]))
}
it.key = binary.BigEndian.Uint64(it.bs[it.idx:])
it.idx += 8

it.inside = true

it.nextBlock = int(binary.BigEndian.Uint32(it.bs[it.footerAddr+((it.blockIdx+1)<<2):]))
if it.key != curKey {
it.cur = it.key | uint64(binary.BigEndian.Uint16(it.bs[it.idx:]))
it.idx += 2
return true
}
return it.seekInBlock(x)
}

Expand Down Expand Up @@ -834,7 +838,6 @@ func writePrefixCompressedPostings(e *encoding.Encbuf, arr []uint64) {
if curKey != key {
// Move to next block.
if idx != 0 {
// We don't need to store the starting offset of the first block because it won't be used.
startingOffs = append(startingOffs, uint32(len(e.B)))
writePrefixCompressedPostingsBlock(e, vals, key, c)
vals = vals[:0]
Expand Down
Loading

0 comments on commit 8bac3f8

Please sign in to comment.