예제 #1
0
        private static IJournal <T> ToJournal <T>(T item)
        {
            TestShared.Utils.ClearDir("ThriftSerializerFactoryTests");
            var j = new JournalBuilder()
                    .WithAccess(EFileAccess.ReadWrite)
                    .WithLocation("ThriftSerializerFactoryTests")
                    .WithSerializerFactoryName(MetadataConstants.THRIFT_SERIALIZER_NAME)
                    .ToJournal <T>();

            using (var wr = j.OpenWriteTx())
            {
                wr.Append(item);
                wr.Commit();
            }

            return(j);
        }
예제 #2
0
        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());
            }
        }