@@ -16,6 +16,7 @@ import (
16
16
"github.com/pkg/errors"
17
17
"github.com/prometheus/prometheus/model/labels"
18
18
19
+ "github.com/grafana/loki/v3/pkg/compression"
19
20
"github.com/grafana/loki/v3/pkg/iter"
20
21
"github.com/grafana/loki/v3/pkg/logproto"
21
22
"github.com/grafana/loki/v3/pkg/logql/log"
@@ -131,7 +132,7 @@ type MemChunk struct {
131
132
head HeadBlock
132
133
133
134
format byte
134
- encoding Encoding
135
+ encoding compression. Encoding
135
136
headFmt HeadBlockFmt
136
137
137
138
// compressed size of chunk. Set when chunk is cut or while decoding chunk from storage.
@@ -196,7 +197,7 @@ func (hb *headBlock) Append(ts int64, line string, _ labels.Labels) (bool, error
196
197
return false , nil
197
198
}
198
199
199
- func (hb * headBlock ) Serialise (pool WriterPool ) ([]byte , error ) {
200
+ func (hb * headBlock ) Serialise (pool compression. WriterPool ) ([]byte , error ) {
200
201
inBuf := serializeBytesBufferPool .Get ().(* bytes.Buffer )
201
202
defer func () {
202
203
inBuf .Reset ()
@@ -354,7 +355,7 @@ type entry struct {
354
355
}
355
356
356
357
// NewMemChunk returns a new in-mem chunk.
357
- func NewMemChunk (chunkFormat byte , enc Encoding , head HeadBlockFmt , blockSize , targetSize int ) * MemChunk {
358
+ func NewMemChunk (chunkFormat byte , enc compression. Encoding , head HeadBlockFmt , blockSize , targetSize int ) * MemChunk {
358
359
return newMemChunkWithFormat (chunkFormat , enc , head , blockSize , targetSize )
359
360
}
360
361
@@ -369,7 +370,7 @@ func panicIfInvalidFormat(chunkFmt byte, head HeadBlockFmt) {
369
370
}
370
371
371
372
// NewMemChunk returns a new in-mem chunk.
372
- func newMemChunkWithFormat (format byte , enc Encoding , head HeadBlockFmt , blockSize , targetSize int ) * MemChunk {
373
+ func newMemChunkWithFormat (format byte , enc compression. Encoding , head HeadBlockFmt , blockSize , targetSize int ) * MemChunk {
373
374
panicIfInvalidFormat (format , head )
374
375
375
376
symbolizer := newSymbolizer ()
@@ -413,10 +414,10 @@ func newByteChunk(b []byte, blockSize, targetSize int, fromCheckpoint bool) (*Me
413
414
bc .format = version
414
415
switch version {
415
416
case ChunkFormatV1 :
416
- bc .encoding = EncGZIP
417
+ bc .encoding = compression . EncGZIP
417
418
case ChunkFormatV2 , ChunkFormatV3 , ChunkFormatV4 :
418
419
// format v2+ has a byte for block encoding.
419
- enc := Encoding (db .byte ())
420
+ enc := compression . Encoding (db .byte ())
420
421
if db .err () != nil {
421
422
return nil , errors .Wrap (db .err (), "verifying encoding" )
422
423
}
@@ -535,7 +536,7 @@ func newByteChunk(b []byte, blockSize, targetSize int, fromCheckpoint bool) (*Me
535
536
if fromCheckpoint {
536
537
bc .symbolizer = symbolizerFromCheckpoint (lb )
537
538
} else {
538
- symbolizer , err := symbolizerFromEnc (lb , GetReaderPool (bc .encoding ))
539
+ symbolizer , err := symbolizerFromEnc (lb , compression . GetReaderPool (bc .encoding ))
539
540
if err != nil {
540
541
return nil , err
541
542
}
@@ -653,7 +654,7 @@ func (c *MemChunk) writeTo(w io.Writer, forCheckpoint bool) (int64, error) {
653
654
}
654
655
} else {
655
656
var err error
656
- n , crcHash , err = c .symbolizer .SerializeTo (w , GetWriterPool (c .encoding ))
657
+ n , crcHash , err = c .symbolizer .SerializeTo (w , compression . GetWriterPool (c .encoding ))
657
658
if err != nil {
658
659
return offset , errors .Wrap (err , "write structured metadata" )
659
660
}
@@ -776,7 +777,7 @@ func MemchunkFromCheckpoint(chk, head []byte, desiredIfNotUnordered HeadBlockFmt
776
777
}
777
778
778
779
// Encoding implements Chunk.
779
- func (c * MemChunk ) Encoding () Encoding {
780
+ func (c * MemChunk ) Encoding () compression. Encoding {
780
781
return c .encoding
781
782
}
782
783
@@ -941,7 +942,7 @@ func (c *MemChunk) cut() error {
941
942
return nil
942
943
}
943
944
944
- b , err := c .head .Serialise (GetWriterPool (c .encoding ))
945
+ b , err := c .head .Serialise (compression . GetWriterPool (c .encoding ))
945
946
if err != nil {
946
947
return err
947
948
}
@@ -1172,7 +1173,7 @@ func (c *MemChunk) Rebound(start, end time.Time, filter filter.Func) (Chunk, err
1172
1173
// then allows us to bind a decoding context to a block when requested, but otherwise helps reduce the
1173
1174
// chances of chunk<>block encoding drift in the codebase as the latter is parameterized by the former.
1174
1175
type encBlock struct {
1175
- enc Encoding
1176
+ enc compression. Encoding
1176
1177
format byte
1177
1178
symbolizer * symbolizer
1178
1179
block
@@ -1182,14 +1183,14 @@ func (b encBlock) Iterator(ctx context.Context, pipeline log.StreamPipeline) ite
1182
1183
if len (b .b ) == 0 {
1183
1184
return iter .NoopEntryIterator
1184
1185
}
1185
- return newEntryIterator (ctx , GetReaderPool (b .enc ), b .b , pipeline , b .format , b .symbolizer )
1186
+ return newEntryIterator (ctx , compression . GetReaderPool (b .enc ), b .b , pipeline , b .format , b .symbolizer )
1186
1187
}
1187
1188
1188
1189
func (b encBlock ) SampleIterator (ctx context.Context , extractor log.StreamSampleExtractor ) iter.SampleIterator {
1189
1190
if len (b .b ) == 0 {
1190
1191
return iter .NoopSampleIterator
1191
1192
}
1192
- return newSampleIterator (ctx , GetReaderPool (b .enc ), b .b , b .format , extractor , b .symbolizer )
1193
+ return newSampleIterator (ctx , compression . GetReaderPool (b .enc ), b .b , b .format , extractor , b .symbolizer )
1193
1194
}
1194
1195
1195
1196
func (b block ) Offset () int {
@@ -1339,7 +1340,7 @@ type bufferedIterator struct {
1339
1340
stats * stats.Context
1340
1341
1341
1342
reader io.Reader
1342
- pool ReaderPool
1343
+ pool compression. ReaderPool
1343
1344
symbolizer * symbolizer
1344
1345
1345
1346
err error
@@ -1358,7 +1359,7 @@ type bufferedIterator struct {
1358
1359
closed bool
1359
1360
}
1360
1361
1361
- func newBufferedIterator (ctx context.Context , pool ReaderPool , b []byte , format byte , symbolizer * symbolizer ) * bufferedIterator {
1362
+ func newBufferedIterator (ctx context.Context , pool compression. ReaderPool , b []byte , format byte , symbolizer * symbolizer ) * bufferedIterator {
1362
1363
stats := stats .FromContext (ctx )
1363
1364
stats .AddCompressedBytes (int64 (len (b )))
1364
1365
return & bufferedIterator {
@@ -1619,7 +1620,7 @@ func (si *bufferedIterator) close() {
1619
1620
si .origBytes = nil
1620
1621
}
1621
1622
1622
- func newEntryIterator (ctx context.Context , pool ReaderPool , b []byte , pipeline log.StreamPipeline , format byte , symbolizer * symbolizer ) iter.EntryIterator {
1623
+ func newEntryIterator (ctx context.Context , pool compression. ReaderPool , b []byte , pipeline log.StreamPipeline , format byte , symbolizer * symbolizer ) iter.EntryIterator {
1623
1624
return & entryBufferedIterator {
1624
1625
bufferedIterator : newBufferedIterator (ctx , pool , b , format , symbolizer ),
1625
1626
pipeline : pipeline ,
@@ -1671,7 +1672,7 @@ func (e *entryBufferedIterator) Close() error {
1671
1672
return e .bufferedIterator .Close ()
1672
1673
}
1673
1674
1674
- func newSampleIterator (ctx context.Context , pool ReaderPool , b []byte , format byte , extractor log.StreamSampleExtractor , symbolizer * symbolizer ) iter.SampleIterator {
1675
+ func newSampleIterator (ctx context.Context , pool compression. ReaderPool , b []byte , format byte , extractor log.StreamSampleExtractor , symbolizer * symbolizer ) iter.SampleIterator {
1675
1676
return & sampleBufferedIterator {
1676
1677
bufferedIterator : newBufferedIterator (ctx , pool , b , format , symbolizer ),
1677
1678
extractor : extractor ,
0 commit comments