NewBlockWriter creates a new block writer. The returned writer accumulates all the series in the Head block until `Flush` is called. Note that the writer will not check if the target directory exists or contains anything at all. It is the caller's responsibility to ensure that the resulting blocks
(logger *slog.Logger, dir string, blockSize int64)
| 50 | // ensure that the resulting blocks do not overlap etc. |
| 51 | // Writer ensures the block flush is atomic (via rename). |
| 52 | func NewBlockWriter(logger *slog.Logger, dir string, blockSize int64) (*BlockWriter, error) { |
| 53 | w := &BlockWriter{ |
| 54 | logger: logger, |
| 55 | destinationDir: dir, |
| 56 | blockSize: blockSize, |
| 57 | } |
| 58 | if err := w.initHead(); err != nil { |
| 59 | return nil, err |
| 60 | } |
| 61 | return w, nil |
| 62 | } |
| 63 | |
| 64 | // initHead creates and initialises a new TSDB head. |
| 65 | func (w *BlockWriter) initHead() error { |
searching dependent graphs…