mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-13 06:47:28 -08:00
Rename bytePostings To bigEndianPostings
* To be more specific about the contents of the byte slice.
This commit is contained in:
parent
efb0dfe1be
commit
7b94a4e17d
2
index.go
2
index.go
|
@ -702,7 +702,7 @@ func (r *indexReader) Postings(name, value string) (Postings, error) {
|
|||
if len(b)%4 != 0 {
|
||||
return nil, errors.Wrap(errInvalidSize, "plain postings entry")
|
||||
}
|
||||
return newBytePostings(b), nil
|
||||
return newBigEndianPostings(b), nil
|
||||
}
|
||||
|
||||
type stringTuples struct {
|
||||
|
|
16
postings.go
16
postings.go
|
@ -241,26 +241,28 @@ func (it *listPostings) Err() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
type bytePostings struct {
|
||||
// bigEndianPostings implements the Postings interface over a byte stream of
|
||||
// big endian numbers.
|
||||
type bigEndianPostings struct {
|
||||
list []byte
|
||||
idx int
|
||||
}
|
||||
|
||||
func newBytePostings(list []byte) *bytePostings {
|
||||
return &bytePostings{list: list, idx: -1}
|
||||
func newBigEndianPostings(list []byte) *bigEndianPostings {
|
||||
return &bigEndianPostings{list: list, idx: -1}
|
||||
}
|
||||
|
||||
func (it *bytePostings) At() uint32 {
|
||||
func (it *bigEndianPostings) At() uint32 {
|
||||
idx := 4 * it.idx
|
||||
return binary.BigEndian.Uint32(it.list[idx : idx+4])
|
||||
}
|
||||
|
||||
func (it *bytePostings) Next() bool {
|
||||
func (it *bigEndianPostings) Next() bool {
|
||||
it.idx++
|
||||
return it.idx*4 < len(it.list)
|
||||
}
|
||||
|
||||
func (it *bytePostings) Seek(x uint32) bool {
|
||||
func (it *bigEndianPostings) 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 {
|
||||
|
@ -271,7 +273,7 @@ func (it *bytePostings) Seek(x uint32) bool {
|
|||
return it.idx*4 < len(it.list)
|
||||
}
|
||||
|
||||
func (it *bytePostings) Err() error {
|
||||
func (it *bigEndianPostings) Err() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue