public void ReadWrite() { // Clean.. Utils.ClearJournal <PocoQuote>("c:\\temp\\quote"); // Create. var journal = new JournalBuilder() .WithRecordCountHint(1000000) .WithPartitionBy(EPartitionType.Day) .WithLocation("c:\\temp\\quote") .WithSymbolColumn("Sym", 20, 5, 5) .WithSymbolColumn("Ex", 20, 20, 20) .WithSymbolColumn("Mode", 20, 20, 20) .WithTimestampColumn("Timestamp") .WithAccess(EFileAccess.ReadWrite) .ToJournal <PocoQuote>(); // Append. var start = DateTime.Now.Date.AddMonths(-1); using (var wr = journal.OpenWriteTx()) { var quote = new PocoQuote(); for (int i = 0; i < 1000000; i++) { quote.Timestamp = start.AddSeconds(i); quote.Bid = i * 2.04; quote.Bid = i; quote.BidSize = i; quote.Ask = i * 50.09014; quote.AskSize = i; quote.Ex = "LXE"; quote.Mode = "Fast trading"; quote.Sym = "SYM" + i % 20; wr.Append(quote); } wr.Commit(); } // Query. // Read all where Sym = "SYM11". using (var rdr = journal.OpenReadTx()) { Console.WriteLine(rdr.Items.Where(i => i.Sym == "SYM0").Count()); } }
public long ShouldHandleDeletedPartitoinAfterRestart(bool clearPartition1, int days) { using (WriteJournal(EPartitionType.Month, TimeSpan.FromDays(1), days)) { } if (clearPartition1) { var newVersion = new PartitionDate(START_DATE, 0, EPartitionType.Month).Name; Directory.Delete(Path.Combine(_directoryPath, newVersion), true); } using (IJournal <PocoType> journal = new JournalBuilder() .WithLocation(_directoryPath) .ToJournal <PocoType>()) { using (var rtx = journal.OpenReadTx()) { return(rtx.All().Length ?? 0L); } } }