static async Task prog_main()
        {
            var sdb = new ScaledAzureDb(new AzureDatabase[] { new AzureDatabase(File.ReadAllLines("C:\\data\\config.txt")[0], "doesntmatter") });
            var db  = new TableDb(sdb);
            /*var rdb = new RangedTableDb(new ScaledAzureDb(new AzureDatabase[] { new AzureDatabase(File.ReadAllLines("C:\\data\\config.txt")[0], "doesntmatter") }));*/

            /*await rdb["testtable"].Retrieve(50, 100, m => {
             *      foreach(var iable in m) {
             *              Console.WriteLine(iable.Key + " == " + iable["Value"]);
             *      }
             *      return true;
             * });*/

            await sdb.Retrieve(null, null, cb => {
                foreach (var iable in cb)
                {
                    Console.WriteLine("Got entity?");
                    Console.WriteLine(Encoding.UTF8.GetString(iable.Key).Substring(6));
                }
                return(true);
            });

            while (true)
            {
                string name = Console.ReadLine();
                var    id   = new Identity()
                {
                    Key = name, PublicKey = new byte[0], Used = false
                };
                await db["keys"].Upsert(id);
            }
        }
Esempio n. 2
0
        static async Task prog_main()
        {
            using (ScalableDb db = new ScaledAzureDb(File.ReadAllLines("C:\\data\\config.txt").Select(m => new AzureDatabase(m, "testabletables")).ToList().ToArray()))
            {
                ScalableDb mdb = db;
                //mdb = new MemoryDb();
                List <ScalableEntity> ents   = new List <ScalableEntity>();
                Stopwatch             pwatch = new Stopwatch();
                pwatch.Start();
                await db.Retrieve(null, null, rows => {
                    lock (ents)
                    {
                        ents.AddRange(rows);
                    }
                    return(true);
                });

                pwatch.Stop();
                Console.WriteLine("Loaded " + ents.Count + " in " + pwatch.Elapsed);
                ents = null;
                while (true)
                {
                    Console.WriteLine("Enter number of entities to test");
                    int       count    = int.Parse(Console.ReadLine());
                    var       entities = GenerateEntities().Take(count).ToList();
                    Stopwatch mwatch   = new Stopwatch();
                    mwatch.Start();
                    await mdb.Upsert(entities);

                    mwatch.Stop();
                    Console.WriteLine("Upsert took " + mwatch.Elapsed);
                    mwatch = new Stopwatch();
                    var retrieves = entities.Select(m => m.Key).ToList();
                    entities.Clear();
                    mwatch.Start();
                    await mdb.Retrieve(retrieves, data => {
                        lock (entities)
                        {
                            entities.AddRange(data);
                        }
                        return(true);
                    });

                    mwatch.Stop();
                    Console.WriteLine("Retrieved " + entities.Count + " in " + mwatch.Elapsed);
                }
            }
        }