public async Task fill_size() { var mapper = new BsonMapper(); mapper.Entity <LiteDBChunk>() .Field(x => x.Index, "i") .Field(x => x.OperationId, "o") .Field(x => x.PartitionId, "s") .Field(x => x.Position, "po") .Field(x => x.StreamOperation, "so") .Field(x => x.StreamSequence, "se") .Field(x => x.Payload, "pa"); var options = new LiteDBPersistenceOptions ( new LiteDBSerializer(), NStoreNullLoggerFactory.Instance, mapper ) { ConnectionString = "test_for_size.litedb" }; if (File.Exists(options.ConnectionString)) { File.Delete(options.ConnectionString); } var store = new LiteDBPersistence(options); store.DeleteDataFiles(); store.Init(); var tasks = Enumerable.Range(1, 10_000). Select(x => store.AppendAsync( $"{x:D10}", x, null, null, CancellationToken.None ) ); await Task.WhenAll(tasks); store.Dispose(); var fi = new FileInfo(options.ConnectionString); _output.WriteLine($"File size is {fi.Length} bytes"); }
protected IPersistence Create(bool dropOnInit) { var pathToFile = $"{_testRunId}.litedb"; _logger.LogInformation("Starting test #{number}", _testRunId); var serializer = new LiteDBSerializer(); var options = new LiteDBPersistenceOptions(serializer, LoggerFactory) { ConnectionString = pathToFile, StreamsCollectionName = "streams" }; var lite = new LiteDBPersistence(options); if (dropOnInit) { lite.DeleteDataFiles(); } lite.Init(); return(lite); }