Skip to content

Commit 1d6f8d5

Browse files
authored
feat: Introduce a new Object Storage WAL format. (#13253)
1 parent 467eb1b commit 1d6f8d5

23 files changed

+35338
-19
lines changed

pkg/storage/stores/shipper/indexshipper/tsdb/index/index.go

+1-8
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ func (m *Metadata) EnsureBounds(from, through int64) {
176176
if m.Through == 0 || through > m.Through {
177177
m.Through = through
178178
}
179-
180179
}
181180

182181
// NewTOCFromByteSlice return parsed TOC from given index byte slice.
@@ -1646,7 +1645,6 @@ func readFingerprintOffsetsTable(bs ByteSlice, off uint64) (FingerprintOffsets,
16461645
}
16471646

16481647
return res, d.Err()
1649-
16501648
}
16511649

16521650
// Close the reader and its underlying resources.
@@ -2074,7 +2072,7 @@ func (dec *Decoder) Postings(b []byte) (int, Postings, error) {
20742072
if len(l) != 4*n {
20752073
return 0, nil, fmt.Errorf("unexpected postings length, should be %d bytes for %d postings, got %d bytes", 4*n, n, len(l))
20762074
}
2077-
return n, newBigEndianPostings(l), nil
2075+
return n, NewBigEndianPostings(l), nil
20782076
}
20792077

20802078
// LabelNamesOffsetsFor decodes the offsets of the name symbols for a given series.
@@ -2335,7 +2333,6 @@ func (dec *Decoder) readChunkStatsV3(d *encoding.Decbuf, from, through int64) (r
23352333
}
23362334

23372335
return res, d.Err()
2338-
23392336
}
23402337

23412338
func (dec *Decoder) accumulateChunkStats(d *encoding.Decbuf, nChunks int, from, through int64) (res ChunkStats, err error) {
@@ -2372,16 +2369,13 @@ func (dec *Decoder) readChunkStatsPriorV3(d *encoding.Decbuf, seriesRef storage.
23722369
} else if chk.MinTime >= through {
23732370
break
23742371
}
2375-
23762372
}
23772373

23782374
return res, nil
2379-
23802375
}
23812376

23822377
// Series decodes a series entry from the given byte slice into lset and chks.
23832378
func (dec *Decoder) Series(version int, b []byte, seriesRef storage.SeriesRef, from int64, through int64, lbls *labels.Labels, chks *[]ChunkMeta) (uint64, error) {
2384-
23852379
d, fprint, err := dec.prepSeries(b, lbls, chks)
23862380
if err != nil {
23872381
return 0, err
@@ -2392,7 +2386,6 @@ func (dec *Decoder) Series(version int, b []byte, seriesRef storage.SeriesRef, f
23922386
return 0, errors.Wrapf(err, "series %s", lbls.String())
23932387
}
23942388
return fprint, nil
2395-
23962389
}
23972390

23982391
func (dec *Decoder) readChunks(version int, d *encoding.Decbuf, seriesRef storage.SeriesRef, from int64, through int64, chks *[]ChunkMeta) error {

pkg/storage/stores/shipper/indexshipper/tsdb/index/postings.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -777,22 +777,22 @@ func (it *ListPostings) Err() error {
777777
return nil
778778
}
779779

780-
// bigEndianPostings implements the Postings interface over a byte stream of
780+
// BigEndianPostings implements the Postings interface over a byte stream of
781781
// big endian numbers.
782-
type bigEndianPostings struct {
782+
type BigEndianPostings struct {
783783
list []byte
784784
cur uint32
785785
}
786786

787-
func newBigEndianPostings(list []byte) *bigEndianPostings {
788-
return &bigEndianPostings{list: list}
787+
func NewBigEndianPostings(list []byte) *BigEndianPostings {
788+
return &BigEndianPostings{list: list}
789789
}
790790

791-
func (it *bigEndianPostings) At() storage.SeriesRef {
791+
func (it *BigEndianPostings) At() storage.SeriesRef {
792792
return storage.SeriesRef(it.cur)
793793
}
794794

795-
func (it *bigEndianPostings) Next() bool {
795+
func (it *BigEndianPostings) Next() bool {
796796
if len(it.list) >= 4 {
797797
it.cur = binary.BigEndian.Uint32(it.list)
798798
it.list = it.list[4:]
@@ -801,7 +801,7 @@ func (it *bigEndianPostings) Next() bool {
801801
return false
802802
}
803803

804-
func (it *bigEndianPostings) Seek(x storage.SeriesRef) bool {
804+
func (it *BigEndianPostings) Seek(x storage.SeriesRef) bool {
805805
if storage.SeriesRef(it.cur) >= x {
806806
return true
807807
}
@@ -821,7 +821,7 @@ func (it *bigEndianPostings) Seek(x storage.SeriesRef) bool {
821821
return false
822822
}
823823

824-
func (it *bigEndianPostings) Err() error {
824+
func (it *BigEndianPostings) Err() error {
825825
return nil
826826
}
827827

pkg/storage/stores/shipper/indexshipper/tsdb/index/postings_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ func TestBigEndian(t *testing.T) {
716716
}
717717

718718
t.Run("Iteration", func(t *testing.T) {
719-
bep := newBigEndianPostings(beLst)
719+
bep := NewBigEndianPostings(beLst)
720720
for i := 0; i < num; i++ {
721721
require.True(t, bep.Next())
722722
require.Equal(t, storage.SeriesRef(ls[i]), bep.At())
@@ -764,7 +764,7 @@ func TestBigEndian(t *testing.T) {
764764
},
765765
}
766766

767-
bep := newBigEndianPostings(beLst)
767+
bep := NewBigEndianPostings(beLst)
768768

769769
for _, v := range table {
770770
require.Equal(t, v.found, bep.Seek(storage.SeriesRef(v.seek)))

pkg/storage/stores/shipper/indexshipper/tsdb/index_client.go

-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,6 @@ func (c *IndexClient) Volume(ctx context.Context, userID string, from, through m
281281
}
282282

283283
func (c *IndexClient) GetShards(ctx context.Context, userID string, from, through model.Time, targetBytesPerShard uint64, predicate chunk.Predicate) (*logproto.ShardsResponse, error) {
284-
285284
// TODO(owen-d): perf, this is expensive :(
286285
var mtx sync.Mutex
287286

pkg/storage/wal/README.md

+183
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)