protected override DbResult CreateDb(TFChunkDbCreationHelper dbCreator) { return(dbCreator .Chunk(Rec.Prepare(0, "$$bla", metadata: new StreamMetadata(null, TimeSpan.FromMinutes(1), null, null, null)), Rec.Commit(0, "$$bla"), Rec.Prepare(1, "bla", timestamp: DateTime.UtcNow - TimeSpan.FromMinutes(25)), Rec.Commit(1, "bla"), Rec.Prepare(2, "bla", timestamp: DateTime.UtcNow - TimeSpan.FromMinutes(20)), Rec.Prepare(2, "bla", timestamp: DateTime.UtcNow - TimeSpan.FromMinutes(10)), Rec.Prepare(2, "bla", timestamp: DateTime.UtcNow - TimeSpan.FromMinutes(5)), Rec.Prepare(2, "bla", timestamp: DateTime.UtcNow - TimeSpan.FromMinutes(3)), Rec.Commit(2, "bla")) .CompleteLastChunk() .CreateDb()); }
protected override DbResult CreateDb(TFChunkDbCreationHelper dbCreator) { return(dbCreator .Chunk(Rec.TransSt(0, "bla"), Rec.Prepare(0, "bla"), Rec.Prepare(0, "bla"), Rec.Prepare(0, "bla"), Rec.Prepare(0, "bla"), Rec.TransEnd(0, "bla"), Rec.Commit(0, "bla"), Rec.Delete(1, "bla"), Rec.Commit(1, "bla")) .CompleteLastChunk() .CreateDb()); }
protected override DbResult CreateDb(TFChunkDbCreationHelper <TLogFormat, TStreamId> dbCreator) { return(dbCreator .Chunk( Rec.Prepare(0, "$$test", metadata: new StreamMetadata(tempStream: true)), Rec.Commit(0, "$$test"), Rec.Prepare(1, "test"), Rec.Commit(1, "test"), Rec.Prepare(2, "test"), Rec.Commit(2, "test"), Rec.Prepare(3, "$$test", metadata: new StreamMetadata(truncateBefore: EventNumber.DeletedStream, tempStream: true)), Rec.Commit(3, "$$test")) .CompleteLastChunk() .CreateDb()); }
protected override DbResult CreateDb(TFChunkDbCreationHelper <TLogFormat, TStreamId> dbCreator) { return(dbCreator .Chunk( Rec.Prepare(0, "ES1", version: _version), Rec.Commit(0, "ES1", version: _version), Rec.Prepare(1, "ES1", version: _version), Rec.Commit(1, "ES1", version: _version)) .Chunk( Rec.Prepare(2, "ES2", version: _version), Rec.Commit(2, "ES2", version: _version), Rec.Prepare(3, "ES2", version: _version), Rec.Commit(3, "ES2", version: _version)) .CompleteLastChunk() .CreateDb()); }
public void CreateDb(params Rec[] records) { if (DbRes != null) { DbRes.Db.Close(); } var dbConfig = new TFChunkDbConfig(PathName, new VersionedPatternFileNamingStrategy(PathName, "chunk-"), 1024 * 1024, 0, new InMemoryCheckpoint(0), new InMemoryCheckpoint(0), new InMemoryCheckpoint(-1), new InMemoryCheckpoint(-1), inMemDb: true); var dbHelper = new TFChunkDbCreationHelper(dbConfig); DbRes = dbHelper.Chunk(records).CreateDb(); DbRes.Db.Config.WriterCheckpoint.Flush(); DbRes.Db.Config.ChaserCheckpoint.Write(DbRes.Db.Config.WriterCheckpoint.Read()); DbRes.Db.Config.ChaserCheckpoint.Flush(); var readers = new ObjectPool <ITransactionFileReader>( "Readers", 2, 2, () => new TFChunkReader(DbRes.Db, DbRes.Db.Config.WriterCheckpoint)); var lowHasher = new XXHashUnsafe(); var highHasher = new Murmur3AUnsafe(); TableIndex = new TableIndex(GetFilePathFor("index"), lowHasher, highHasher, () => new HashListMemTable(PTableVersions.IndexV3, MaxEntriesInMemTable * 2), () => new TFReaderLease(readers), PTableVersions.IndexV3, MaxEntriesInMemTable); ReadIndex = new ReadIndex(new NoopPublisher(), readers, TableIndex, 0, additionalCommitChecks: true, metastreamMaxCount: _metastreamMaxCount, hashCollisionReadLimit: Opts.HashCollisionReadLimitDefault, skipIndexScanOnReads: Opts.SkipIndexScanOnReadsDefault); ReadIndex.Init(DbRes.Db.Config.ChaserCheckpoint.Read()); }
protected override DbResult CreateDb(TFChunkDbCreationHelper dbCreator) { return(dbCreator.Chunk( Rec.Prepare(0, "$$test", metadata: new StreamMetadata(tempStream: true), version: LogRecordVersion.LogRecordV0), Rec.Commit(0, "$$test", version: LogRecordVersion.LogRecordV0), Rec.Prepare(1, "test", version: LogRecordVersion.LogRecordV0), Rec.Commit(1, "test", version: LogRecordVersion.LogRecordV0), Rec.Prepare(2, "test", version: LogRecordVersion.LogRecordV0), Rec.Commit(2, "test", version: LogRecordVersion.LogRecordV0), Rec.Prepare(3, "$$test", metadata: new StreamMetadata(truncateBefore: int.MaxValue, tempStream: true), version: LogRecordVersion.LogRecordV0), Rec.Commit(3, "$$test", version: LogRecordVersion.LogRecordV0)) .CompleteLastChunk() .CreateDb()); }
protected override DbResult CreateDb(TFChunkDbCreationHelper dbCreator) { var version = LogRecordVersion.LogRecordV0; return(dbCreator.Chunk(Rec.Prepare(0, "test", version: version), Rec.Commit(0, "test", version: version)) .Chunk(Rec.Prepare(1, "test", version: version), Rec.Commit(1, "test", version: version), Rec.Prepare(2, "$$test", metadata: new StreamMetadata(null, null, int.MaxValue, true, null, null), version: version), Rec.Commit(2, "$$test", version: version)) .Chunk( Rec.Prepare(3, "random", version: version), // Need an incomplete chunk to ensure writer checkpoints are correct Rec.Commit(3, "random", version: version)) .CreateDb()); }
public void CreateDb(params Rec[] records) { if (DbRes != null) { DbRes.Db.Close(); } var dbConfig = TFChunkHelper.CreateDbConfig(PathName, 0, chunkSize: 1024 * 1024); var dbHelper = new TFChunkDbCreationHelper(dbConfig); DbRes = dbHelper.Chunk(records).CreateDb(); DbRes.Db.Config.WriterCheckpoint.Flush(); DbRes.Db.Config.ChaserCheckpoint.Write(DbRes.Db.Config.WriterCheckpoint.Read()); DbRes.Db.Config.ChaserCheckpoint.Flush(); var readers = new ObjectPool <ITransactionFileReader>( "Readers", 2, 2, () => new TFChunkReader(DbRes.Db, DbRes.Db.Config.WriterCheckpoint)); var lowHasher = new XXHashUnsafe(); var highHasher = new Murmur3AUnsafe(); TableIndex = new TableIndex(GetFilePathFor("index"), lowHasher, highHasher, () => new HashListMemTable(PTableVersions.IndexV3, MaxEntriesInMemTable * 2), () => new TFReaderLease(readers), PTableVersions.IndexV3, int.MaxValue, Constants.PTableMaxReaderCountDefault, MaxEntriesInMemTable); ReadIndex = new ReadIndex(new NoopPublisher(), readers, TableIndex, 0, additionalCommitChecks: true, metastreamMaxCount: _metastreamMaxCount, hashCollisionReadLimit: Opts.HashCollisionReadLimitDefault, skipIndexScanOnReads: Opts.SkipIndexScanOnReadsDefault, replicationCheckpoint: DbRes.Db.Config.ReplicationCheckpoint, indexCheckpoint: DbRes.Db.Config.IndexCheckpoint); ((ReadIndex)ReadIndex).IndexCommitter.Init(DbRes.Db.Config.ChaserCheckpoint.Read()); }
protected override DbResult CreateDb(TFChunkDbCreationHelper dbCreator) { return(dbCreator.Chunk(Rec.Prepare(0, _deletedMetaStream, metadata: new StreamMetadata(tempStream: true), version: LogRecordVersion.LogRecordV0), Rec.Commit(0, _deletedMetaStream, version: LogRecordVersion.LogRecordV0), Rec.Prepare(1, _keptStream, version: LogRecordVersion.LogRecordV1), Rec.Commit(1, _keptStream, version: LogRecordVersion.LogRecordV1), Rec.Prepare(2, _keptStream, version: LogRecordVersion.LogRecordV0), Rec.Commit(2, _keptStream, version: LogRecordVersion.LogRecordV0), Rec.Prepare(3, _deletedStream, version: LogRecordVersion.LogRecordV1), Rec.Commit(3, _deletedStream, version: LogRecordVersion.LogRecordV0), Rec.Prepare(4, _deletedStream, version: LogRecordVersion.LogRecordV0), Rec.Commit(4, _deletedStream, version: LogRecordVersion.LogRecordV1), Rec.Prepare(5, _keptStream, version: LogRecordVersion.LogRecordV1), Rec.Commit(5, _keptStream, version: LogRecordVersion.LogRecordV1), Rec.Prepare(6, _deletedMetaStream, metadata: new StreamMetadata(truncateBefore: EventNumber.DeletedStream, tempStream: true), version: LogRecordVersion.LogRecordV1), Rec.Commit(6, _deletedMetaStream, version: LogRecordVersion.LogRecordV0)) .CompleteLastChunk() .CreateDb()); }
protected override DbResult CreateDb(TFChunkDbCreationHelper <TLogFormat, TStreamId> dbCreator) { return(dbCreator .Chunk(Rec.Prepare(0, "$$bla", metadata: new StreamMetadata(maxCount: 3)), Rec.Commit(0, "$$bla"), Rec.Prepare(1, "bla"), Rec.Commit(1, "bla"), Rec.Prepare(2, "bla"), Rec.Prepare(2, "bla"), Rec.Prepare(2, "bla"), Rec.Prepare(2, "bla"), Rec.Prepare(2, "bla"), Rec.Commit(2, "bla"), Rec.Prepare(3, "bla"), Rec.Prepare(3, "bla"), Rec.Prepare(3, "bla"), Rec.Prepare(3, "bla"), Rec.Commit(3, "bla")) .CompleteLastChunk() .CreateDb()); }
protected override DbResult CreateDb(TFChunkDbCreationHelper <TLogFormat, TStreamId> dbCreator) { return(dbCreator .Chunk(Rec.Prepare(0, "$$bla", metadata: new StreamMetadata(truncateBefore: 7)), Rec.Commit(0, "$$bla"), Rec.Prepare(1, "bla"), // event 0 Rec.Commit(1, "bla"), Rec.Prepare(2, "bla"), // event 1 Rec.Prepare(2, "bla"), // event 2 Rec.Prepare(2, "bla"), // event 3 Rec.Prepare(2, "bla"), // event 4 Rec.Prepare(2, "bla"), // event 5 Rec.Commit(2, "bla"), Rec.Prepare(3, "bla"), // event 6 Rec.Prepare(3, "bla"), // event 7 Rec.Prepare(3, "bla"), // event 8 Rec.Prepare(3, "bla"), // event 9 Rec.Commit(3, "bla")) .CompleteLastChunk() .CreateDb()); }
protected override DbResult CreateDb(TFChunkDbCreationHelper dbCreator) { return(dbCreator .Chunk(Rec.Prepare(0, "$$bla", metadata: new StreamMetadata(3, null, null, null)), Rec.Commit(0, "$$bla"), Rec.Prepare(1, "bla"), Rec.Commit(1, "bla"), Rec.Prepare(2, "bla"), Rec.Prepare(2, "bla"), Rec.Prepare(2, "bla"), Rec.Prepare(2, "bla"), Rec.Prepare(2, "bla"), Rec.Commit(2, "bla"), Rec.Prepare(3, "bla"), Rec.Prepare(3, "bla"), Rec.Prepare(3, "bla"), Rec.Prepare(3, "bla"), Rec.Commit(3, "bla")) .CompleteLastChunk() .CreateDb()); }
protected override DbResult CreateDb(TFChunkDbCreationHelper <TLogFormat, TStreamId> dbCreator) { return(dbCreator .Chunk( Rec.Prepare(0, "$$bla", metadata: new StreamMetadata(3, TimeSpan.FromMinutes(50), null, null, null)), Rec.Commit(0, "$$bla"), Rec.Prepare(3, "bla"), Rec.Commit(3, "bla"), Rec.Prepare(1, "bla", timestamp: DateTime.UtcNow - TimeSpan.FromMinutes(100)), Rec.Prepare(1, "bla", timestamp: DateTime.UtcNow - TimeSpan.FromMinutes(90)), Rec.Prepare(1, "bla", timestamp: DateTime.UtcNow - TimeSpan.FromMinutes(60)), Rec.Prepare(1, "bla", timestamp: DateTime.UtcNow - TimeSpan.FromMinutes(40)), Rec.Prepare(1, "bla", timestamp: DateTime.UtcNow - TimeSpan.FromMinutes(30)), Rec.Commit(1, "bla"), Rec.Prepare(2, "bla", timestamp: DateTime.UtcNow - TimeSpan.FromMinutes(20)), Rec.Prepare(2, "bla", timestamp: DateTime.UtcNow - TimeSpan.FromMinutes(3)), Rec.Prepare(2, "bla", timestamp: DateTime.UtcNow - TimeSpan.FromMinutes(2)), Rec.Prepare(2, "bla", timestamp: DateTime.UtcNow - TimeSpan.FromMinutes(1)), Rec.Commit(2, "bla")) .CompleteLastChunk() .CreateDb()); }
public void CreateDb(params Rec[] records) { if (DbRes != null) { DbRes.Db.Close(); } var indexDirectory = GetFilePathFor("index"); _logFormat = LogFormatHelper <TLogFormat, TStreamId> .LogFormatFactory.Create(new() { IndexDirectory = indexDirectory, }); var dbConfig = TFChunkHelper.CreateSizedDbConfig(PathName, 0, chunkSize: 1024 * 1024); var dbHelper = new TFChunkDbCreationHelper <TLogFormat, TStreamId>(dbConfig, _logFormat); DbRes = dbHelper.Chunk(records).CreateDb(); DbRes.Db.Config.WriterCheckpoint.Flush(); DbRes.Db.Config.ChaserCheckpoint.Write(DbRes.Db.Config.WriterCheckpoint.Read()); DbRes.Db.Config.ChaserCheckpoint.Flush(); var readers = new ObjectPool <ITransactionFileReader>( "Readers", 2, 2, () => new TFChunkReader(DbRes.Db, DbRes.Db.Config.WriterCheckpoint)); var lowHasher = _logFormat.LowHasher; var highHasher = _logFormat.HighHasher; var emptyStreamId = _logFormat.EmptyStreamId; TableIndex = new TableIndex <TStreamId>(indexDirectory, lowHasher, highHasher, emptyStreamId, () => new HashListMemTable(PTableVersions.IndexV3, MaxEntriesInMemTable * 2), () => new TFReaderLease(readers), PTableVersions.IndexV3, int.MaxValue, Constants.PTableMaxReaderCountDefault, MaxEntriesInMemTable); _logFormat.StreamNamesProvider.SetTableIndex(TableIndex); var readIndex = new ReadIndex <TStreamId>(new NoopPublisher(), readers, TableIndex, _logFormat.StreamNameIndexConfirmer, _logFormat.StreamIds, _logFormat.StreamNamesProvider, _logFormat.EmptyStreamId, _logFormat.StreamIdValidator, _logFormat.StreamIdSizer, _logFormat.StreamExistenceFilter, _logFormat.StreamExistenceFilterReader, _logFormat.EventTypeIndexConfirmer, streamInfoCacheCapacity: 0, additionalCommitChecks: true, metastreamMaxCount: _metastreamMaxCount, hashCollisionReadLimit: Opts.HashCollisionReadLimitDefault, skipIndexScanOnReads: Opts.SkipIndexScanOnReadsDefault, replicationCheckpoint: DbRes.Db.Config.ReplicationCheckpoint, indexCheckpoint: DbRes.Db.Config.IndexCheckpoint); readIndex.IndexCommitter.Init(DbRes.Db.Config.ChaserCheckpoint.Read()); ReadIndex = readIndex; }