|
|
|
@ -5,7 +5,6 @@ import ( |
|
|
|
|
"context" |
|
|
|
|
"encoding/binary" |
|
|
|
|
"fmt" |
|
|
|
|
|
|
|
|
|
"io" |
|
|
|
|
"math" |
|
|
|
|
"time" |
|
|
|
@ -252,13 +251,15 @@ func (hb *unorderedHeadBlock) Iterator(ctx context.Context, direction logproto.D |
|
|
|
|
// cutting of blocks.
|
|
|
|
|
streams := map[string]*logproto.Stream{} |
|
|
|
|
baseHash := pipeline.BaseLabels().Hash() |
|
|
|
|
var structuredMetadata labels.Labels |
|
|
|
|
_ = hb.forEntries( |
|
|
|
|
ctx, |
|
|
|
|
direction, |
|
|
|
|
mint, |
|
|
|
|
maxt, |
|
|
|
|
func(statsCtx *stats.Context, ts int64, line string, structuredMetadataSymbols symbols) error { |
|
|
|
|
newLine, parsedLbs, matches := pipeline.ProcessString(ts, line, hb.symbolizer.Lookup(structuredMetadataSymbols)...) |
|
|
|
|
structuredMetadata = hb.symbolizer.Lookup(structuredMetadataSymbols, structuredMetadata) |
|
|
|
|
newLine, parsedLbs, matches := pipeline.ProcessString(ts, line, structuredMetadata...) |
|
|
|
|
if !matches { |
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
@ -294,7 +295,13 @@ func (hb *unorderedHeadBlock) Iterator(ctx context.Context, direction logproto.D |
|
|
|
|
for _, stream := range streams { |
|
|
|
|
streamsResult = append(streamsResult, *stream) |
|
|
|
|
} |
|
|
|
|
return iter.NewStreamsIterator(streamsResult, direction) |
|
|
|
|
|
|
|
|
|
return iter.EntryIteratorWithClose(iter.NewStreamsIterator(streamsResult, direction), func() error { |
|
|
|
|
if structuredMetadata != nil { |
|
|
|
|
structuredMetadataPool.Put(structuredMetadata) // nolint:staticcheck
|
|
|
|
|
} |
|
|
|
|
return nil |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// nolint:unused
|
|
|
|
@ -306,13 +313,15 @@ func (hb *unorderedHeadBlock) SampleIterator( |
|
|
|
|
) iter.SampleIterator { |
|
|
|
|
series := map[string]*logproto.Series{} |
|
|
|
|
baseHash := extractor.BaseLabels().Hash() |
|
|
|
|
var structuredMetadata labels.Labels |
|
|
|
|
_ = hb.forEntries( |
|
|
|
|
ctx, |
|
|
|
|
logproto.FORWARD, |
|
|
|
|
mint, |
|
|
|
|
maxt, |
|
|
|
|
func(statsCtx *stats.Context, ts int64, line string, structuredMetadataSymbols symbols) error { |
|
|
|
|
value, parsedLabels, ok := extractor.ProcessString(ts, line, hb.symbolizer.Lookup(structuredMetadataSymbols)...) |
|
|
|
|
structuredMetadata = hb.symbolizer.Lookup(structuredMetadataSymbols, structuredMetadata) |
|
|
|
|
value, parsedLabels, ok := extractor.ProcessString(ts, line, structuredMetadata...) |
|
|
|
|
if !ok { |
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
@ -355,6 +364,9 @@ func (hb *unorderedHeadBlock) SampleIterator( |
|
|
|
|
for _, s := range series { |
|
|
|
|
SamplesPool.Put(s.Samples) |
|
|
|
|
} |
|
|
|
|
if structuredMetadata != nil { |
|
|
|
|
structuredMetadataPool.Put(structuredMetadata) // nolint:staticcheck
|
|
|
|
|
} |
|
|
|
|
return nil |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
@ -445,7 +457,7 @@ func (hb *unorderedHeadBlock) Convert(version HeadBlockFmt, symbolizer *symboliz |
|
|
|
|
0, |
|
|
|
|
math.MaxInt64, |
|
|
|
|
func(_ *stats.Context, ts int64, line string, structuredMetadataSymbols symbols) error { |
|
|
|
|
_, err := out.Append(ts, line, hb.symbolizer.Lookup(structuredMetadataSymbols)) |
|
|
|
|
_, err := out.Append(ts, line, hb.symbolizer.Lookup(structuredMetadataSymbols, nil)) |
|
|
|
|
return err |
|
|
|
|
}, |
|
|
|
|
) |
|
|
|
@ -585,8 +597,7 @@ func (hb *unorderedHeadBlock) LoadBytes(b []byte) error { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if _, err := hb.Append(ts, line, hb.symbolizer.Lookup(structuredMetadataSymbols)); err != nil { |
|
|
|
|
if _, err := hb.Append(ts, line, hb.symbolizer.Lookup(structuredMetadataSymbols, nil)); err != nil { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|