Skip to content

Commit 3af0004

Browse files
authored
feat(blooms): Only write key and key=value to blooms (#14686)
1 parent 061bdfe commit 3af0004

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

docs/sources/operations/bloom-filters.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,10 @@ If there are new TSDB files or any of them have changed, the planner will create
176176
The builder pulls a task from the planner's queue and processes the containing streams and chunks.
177177
For a given stream, the builder will iterate through all the log lines inside its new chunks and build a bloom for the stream.
178178
In case of changes for a previously processed TSDB file, builders will try to reuse blooms from existing blocks instead of building new ones from scratch.
179-
The builder converts structured metadata from each log line of each chunk of a stream and appends the hash of each key, value, and key-value pair to the bloom, followed by the hashes combined with the chunk identifier.
179+
The builder converts structured metadata from each log line of each chunk of a stream and appends the hash of each key, and key-value pair to the bloom, followed by the hashes combined with the chunk identifier.
180180
The first set of hashes allows gateways to skip whole streams, while the latter is for skipping individual chunks.
181181

182-
For example, given structured metadata `foo=bar` in the chunk `c6dj8g`, we append to the stream bloom the following hashes: `hash("foo")`, `hash("bar")`, `hash("foo=bar")`, `hash("c6dj8g" + "foo")` ... `hash("c6dj8g" + "foo=bar")`.
182+
For example, given structured metadata `foo=bar` in the chunk `c6dj8g`, we append to the stream bloom the following hashes: `hash("foo")`, `hash("foo=bar")`, `hash("c6dj8g" + "foo")` and `hash("c6dj8g" + "foo=bar")`.
183183

184184
## Query sharding
185185

pkg/storage/bloom/v1/tokenizer.go

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ func (t *StructuredMetadataTokenizer) Tokens(kv push.LabelAdapter) iter.Iterator
2525
combined := fmt.Sprintf("%s=%s", kv.Name, kv.Value)
2626
t.tokens = append(t.tokens[:0],
2727
kv.Name, t.prefix+kv.Name,
28-
kv.Value, t.prefix+kv.Value,
2928
combined, t.prefix+combined,
3029
)
3130
return iter.NewSliceIter(t.tokens)

pkg/storage/bloom/v1/tokenizer_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func TestStructuredMetadataTokenizer(t *testing.T) {
1414
tokenizer := NewStructuredMetadataTokenizer("chunk")
1515

1616
metadata := push.LabelAdapter{Name: "pod", Value: "loki-1"}
17-
expected := []string{"pod", "chunkpod", "loki-1", "chunkloki-1", "pod=loki-1", "chunkpod=loki-1"}
17+
expected := []string{"pod", "chunkpod", "pod=loki-1", "chunkpod=loki-1"}
1818

1919
tokenIter := tokenizer.Tokens(metadata)
2020
got, err := v2.Collect(tokenIter)

0 commit comments

Comments
 (0)