// called to flush all in-flight data public void Checkpoint(string name, long position) { _buffer.Flush(); using (var tx = _env.Write()) { var bufferDto = _buffer.GetState(); //Console.WriteLine("Checkpoint buffer at {0}+{1}", bufferDto.GetBufferStartPos(), bufferDto.GetBufferPos()); Lmdb.SetBuffer(tx, 0, bufferDto); Lmdb.SetStreamPosition(tx, name, position); Lmdb.SetCellarMeta(tx, 0, Lmdb.NewCellarDto() .SetCellarMaxKeySize(_maxKeySize) .SetCellarMaxValSize(_maxValSize)); tx.Commit(); } }
void SetNewBuffer(Tx tx, long newStartPos) { if (_buffer != null) { throw new InvalidOperationException("Previous buffer wasn't cleaned up"); } var name = string.Format("{0:0000000000}.blob", newStartPos); var newBuffer = Lmdb .NewBufferDto() .SetBufferPos(0) .SetBufferStartPos(newStartPos) .SetBufferMaxBytes(_maxBufferBytes) .SetBufferRecords(0) .SetBufferFileName(name); Lmdb.SetBuffer(tx, 0, newBuffer); _buffer = new Buffer(newBuffer, _folder); _buffer.OpenOrCreate(); }