Skip to content

Commit

Permalink
add colon
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Ye <benye@amazon.com>
  • Loading branch information
yeya24 committed Jun 2, 2023
1 parent ccda44d commit 9030da9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
10 changes: 2 additions & 8 deletions pkg/store/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@ var (
ulidSize = uint64(len(ulid.ULID{}))
)

type PostingsCodec string

const (
CodecHeaderSnappy PostingsCodec = "dvs" // As in "diff+varint+snappy".
CodecHeaderStreamedSnappy PostingsCodec = "dss" // As in "diffvarint+streamed snappy".
)

// IndexCache is the interface exported by index cache backends.
// Store operations do not support context.Context, deadlines need to be
// supported by the backends themselves. This is because Set operations are
Expand Down Expand Up @@ -86,7 +79,8 @@ func (c cacheKey) string() string {
// which would end up in wrong query results.
lbl := c.key.(cacheKeyPostings)
lblHash := blake2b.Sum256([]byte(lbl.Name + ":" + lbl.Value))
return "P:" + c.block + ":" + base64.RawURLEncoding.EncodeToString(lblHash[0:])
// Add : at the end to force using a new cache key for postings.
return "P:" + c.block + ":" + base64.RawURLEncoding.EncodeToString(lblHash[0:]) + ":"
case cacheKeySeries:
return "S:" + c.block + ":" + strconv.FormatUint(uint64(c.key.(cacheKeySeries)), 10)
default:
Expand Down
2 changes: 1 addition & 1 deletion pkg/store/postings_codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func estimateSnappyStreamSize(length int) int {

func diffVarintSnappyStreamedEncode(p index.Postings, length int) ([]byte, error) {
compressedBuf := bytes.NewBuffer(make([]byte, 0, estimateSnappyStreamSize(length)))
if n, err := compressedBuf.WriteString(string(codecHeaderStreamedSnappy)); err != nil {
if n, err := compressedBuf.WriteString(codecHeaderStreamedSnappy); err != nil {
return nil, fmt.Errorf("writing streamed snappy header")
} else if n != len(codecHeaderStreamedSnappy) {
return nil, fmt.Errorf("short-write streamed snappy header")
Expand Down

0 comments on commit 9030da9

Please sign in to comment.