-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* marshalable chunks * wal record types custom serialization * proto types for wal checkpoints * byteswith output unaffected by buffer
- Loading branch information
Showing
10 changed files
with
1,402 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package ingester | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/grafana/loki/pkg/chunkenc" | ||
) | ||
|
||
// The passed wireChunks slice is for re-use. | ||
func toWireChunks(descs []*chunkDesc, wireChunks []Chunk) ([]Chunk, error) { | ||
if cap(wireChunks) < len(descs) { | ||
wireChunks = make([]Chunk, len(descs)) | ||
} else { | ||
wireChunks = wireChunks[:len(descs)] | ||
} | ||
for i, d := range descs { | ||
from, to := d.chunk.Bounds() | ||
wireChunk := Chunk{ | ||
From: from, | ||
To: to, | ||
Closed: d.closed, | ||
FlushedAt: d.flushed, | ||
} | ||
|
||
slice := wireChunks[i].Data[:0] // try to re-use the memory from last time | ||
if cap(slice) < d.chunk.CompressedSize() { | ||
slice = make([]byte, 0, d.chunk.CompressedSize()) | ||
} | ||
|
||
out, err := d.chunk.BytesWith(slice) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
wireChunk.Data = out | ||
wireChunks[i] = wireChunk | ||
} | ||
return wireChunks, nil | ||
} | ||
|
||
func fromWireChunks(conf *Config, wireChunks []Chunk) ([]*chunkDesc, error) { | ||
descs := make([]*chunkDesc, 0, len(wireChunks)) | ||
for _, c := range wireChunks { | ||
desc := &chunkDesc{ | ||
closed: c.Closed, | ||
flushed: c.FlushedAt, | ||
lastUpdated: time.Now(), | ||
} | ||
|
||
mc, err := chunkenc.NewByteChunk(c.Data, conf.BlockSize, conf.TargetChunkSize) | ||
if err != nil { | ||
return nil, err | ||
} | ||
desc.chunk = mc | ||
|
||
descs = append(descs, desc) | ||
} | ||
return descs, nil | ||
} |
Oops, something went wrong.