Exemplo n.º 1
0
        public override void SetUp()
        {
            base.SetUp();
            var config = new RelationalStoreConfiguration(ConnectionString);

            config.DocumentMaps.Register(new BigObjectMap(Format));

            store           = new RelationalStore(config);
            readTransaction = store.BeginReadTransaction();

            using var writer = store.BeginWriteTransaction();
            var rand         = new Random(42);
            var randomString = new Func <string>(() =>
            {
                var buffer = new byte[3];
                rand.NextBytes(buffer);
                return(Convert.ToBase64String(buffer));
            });
            var historyEntries = Enumerable.Range(1, DocumentSize / 256).Select(n => new BigObjectHistoryEntry
            {
                Id = Guid.NewGuid(), Comment = randomString(), LuckyNumbers = Enumerable.Range(0, rand.Next(130, 330)).ToArray(), Date = DateTime.Today.AddDays(n)
            });

            writer.Insert(new BigObject {
                Id = "BigObject-1", History = historyEntries.OfType <object>().ToList()
            });
            writer.Commit();
        }
Exemplo n.º 2
0
 public QueryBuilderStateFixture()
 {
     transaction = Substitute.For <IReadTransaction>();
     transaction.ExecuteScalar <int>(Arg.Do <string>(q => executedQueries.Add(q)), Arg.Any <CommandParameterValues>());
     // ReSharper disable once ReturnValueOfPureMethodIsNotUsed
     transaction.Stream <object>(Arg.Do <string>(q => executedQueries.Add(q)), Arg.Any <CommandParameterValues>());
 }
Exemplo n.º 3
0
        public override void SetUp()
        {
            base.SetUp();

            var config = new RelationalStoreConfiguration(ConnectionString);

            config.DocumentMaps.Register(new CustomerMap());

            store       = new RelationalStore(config);
            transaction = store.BeginReadTransaction();
        }
Exemplo n.º 4
0
        public override void SetUp()
        {
            base.SetUp();
            var config = new RelationalStoreConfiguration(ConnectionString);

            config.DocumentMaps.Register(new CustomerMap());

            store       = new RelationalStore(config);
            transaction = store.BeginReadTransaction();

            allIdsRandomlySorted = transaction.Query <Customer>().ToList().Select(p => p.Id).OrderByDescending(p => Guid.NewGuid()).ToList();
        }
Exemplo n.º 5
0
 public TableSourceQueryBuilder(string tableOrViewName,
                                string schemaName,
                                IReadTransaction readQueryExecutor,
                                ITableAliasGenerator tableAliasGenerator,
                                IUniqueParameterNameGenerator uniqueParameterNameGenerator,
                                CommandParameterValues parameterValues,
                                Parameters parameters,
                                ParameterDefaults parameterDefaults)
     : base(readQueryExecutor, tableAliasGenerator, uniqueParameterNameGenerator, parameterValues, parameters, parameterDefaults)
 {
     this.schemaName      = schemaName;
     this.tableOrViewName = tableOrViewName;
 }
 void IReadInvokeCallback.ServerInvokeCallback(IReadTransaction transaction, IMessageHandlerPublishBus bus)
 {
     Contract.Requires(transaction != null);
     Contract.Requires(bus != null);
 }
Exemplo n.º 7
0
 public TransactionController(IReadBankAccount readBankAccount, IReadTransaction readTransaction, IWriteTransaction writeTransaction)
 {
     this._readBankAccount  = readBankAccount;
     this._readTransaction  = readTransaction;
     this._writeTransaction = writeTransaction;
 }
        public override void SetUp()
        {
            base.SetUp();
            var config = new RelationalStoreConfiguration(ConnectionString);

            config.DocumentMaps.Register(new BigObjectMap(JsonStorageFormat.TextOnly));

            store           = new RelationalStore(config);
            readTransaction = store.BeginReadTransaction();

            using var writer = store.BeginWriteTransaction();

            var history = GenerateHistory();
            var doc1    = history.Take(1).ToList();
            var doc10   = history.Take(10).ToList();
            var doc100  = history.Take(100).ToList();
            var doc500  = history.Take(500).ToList();

            var rand = new Random(42);

            for (var i = 0; i < 1000; i++)
            {
                var doc = new BigObject {
                    Name = "Document " + i
                };

                var distribution = rand.Next(1, 100);
                if (distribution < 70)
                {
                    doc.History = doc1;
                }
                else if (distribution < 85)
                {
                    doc.History = doc10;
                }
                else if (distribution < 95)
                {
                    doc.History = doc100;
                }
                else if (distribution <= 100)
                {
                    doc.History = doc500;
                }

                writer.Insert(doc, new InsertOptions {
                    CommandTimeout = TimeSpan.FromSeconds(180)
                });
                if (i % 100 == 0)
                {
                    Console.WriteLine($"Inserted: {i} history: {doc.History.Count} rand: {distribution}");
                }
            }

            foreach (var item in writer.Stream <(long?Bucket, int?Count)>(
                         "select len([JSON]) as Bucket, count(*) from BigObject group by len([JSON]) order by len([JSON])"))
            {
                Console.WriteLine($"{item.Bucket} bytes: {item.Count} documents");
            }

            writer.Commit();
        }