|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package tsdb
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"encoding/binary"
|
|
|
|
|
"sort"
|
|
|
|
|
"strings"
|
|
|
|
|
)
|
|
|
|
@ -240,6 +241,40 @@ func (it *listPostings) Err() error {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type bytePostings struct {
|
|
|
|
|
list []byte
|
|
|
|
|
idx int
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func newBytePostings(list []byte) *bytePostings {
|
|
|
|
|
return &bytePostings{list: list, idx: -1}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (it *bytePostings) At() uint32 {
|
|
|
|
|
idx := 4 * it.idx
|
|
|
|
|
return binary.BigEndian.Uint32(it.list[idx : idx+4])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (it *bytePostings) Next() bool {
|
|
|
|
|
it.idx++
|
|
|
|
|
return it.idx*4 < len(it.list)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (it *bytePostings) Seek(x uint32) bool {
|
|
|
|
|
num := len(it.list) / 4
|
|
|
|
|
// Do binary search between current position and end.
|
|
|
|
|
it.idx += sort.Search(num-it.idx, func(i int) bool {
|
|
|
|
|
idx := 4 * (it.idx + i)
|
|
|
|
|
val := binary.BigEndian.Uint32(it.list[idx : idx+4])
|
|
|
|
|
return val >= x
|
|
|
|
|
})
|
|
|
|
|
return it.idx*4 < len(it.list)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (it *bytePostings) Err() error {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type stringset map[string]struct{}
|
|
|
|
|
|
|
|
|
|
func (ss stringset) set(s string) {
|
|
|
|
|