Example #1
0
        public void ScanString()
        {
            Key key = new Key(NS, SET, "100-list-test-key-string");

            client.Delete(null, key);
            var ll = new Aerospike.Helper.Collections.LargeList(client, null, key, "100-string");

            WriteStringSubElements(ll, 100);
            IList values = ll.Scan();

            Assert.AreEqual(100, ll.Size());
            for (int x = 0; x < 100; x++)
            {
                Assert.AreEqual(values [x], "cats-dogs-" + x);
            }
            ll.Destroy();
            client.Delete(null, key);
        }
Example #2
0
        public void RunWithDistinctBins()
        {
            Key key = new Key(NS, SET, "accountId");

            // Delete record if it already exists.
            client.Delete(null, key);

            // Initialize large list operator.
            Aerospike.Helper.Collections.LargeList list = new Aerospike.Helper.Collections.LargeList(client, null, key, "trades");

            list.Size();

            // Write trades
            Dictionary <string, Value> dict = new Dictionary <string, Value>();

            DateTime timestamp1 = new DateTime(2014, 6, 25, 12, 18, 43);

            dict["key"]    = Value.Get(timestamp1.Ticks);
            dict["ticker"] = Value.Get("IBM");
            dict["qty"]    = Value.Get(100);
            dict["price"]  = Value.Get(BitConverter.GetBytes(181.82));
            list.Add(Value.Get(dict));

            DateTime timestamp2 = new DateTime(2014, 6, 26, 9, 33, 17);

            dict["key"]    = Value.Get(timestamp2.Ticks);
            dict["ticker"] = Value.Get("GE");
            dict["qty"]    = Value.Get(500);
            dict["price"]  = Value.Get(BitConverter.GetBytes(26.36));
            list.Add(Value.Get(dict));

            DateTime timestamp3 = new DateTime(2014, 6, 27, 14, 40, 19);

            dict["key"]    = Value.Get(timestamp3.Ticks);
            dict["ticker"] = Value.Get("AAPL");
            dict["qty"]    = Value.Get(75);
            dict["price"]  = Value.Get(BitConverter.GetBytes(91.85));
            list.Add(Value.Get(dict));

            // Verify list size
            int size = list.Size();

            Assert.AreEqual(size, 3);

            // Filter on range of timestamps
            DateTime begin   = new DateTime(2014, 6, 26);
            DateTime end     = new DateTime(2014, 6, 28);
            IList    results = list.Range(Value.Get(begin.Ticks), Value.Get(end.Ticks));

            Assert.AreEqual(results.Count, 2);

            // Verify data.
            ValidateWithDistinctBins(results, 0, timestamp2, "GE", 500, 26.36);
            ValidateWithDistinctBins(results, 1, timestamp3, "AAPL", 75, 91.85);

            Console.WriteLine("Data matched.");

            Console.WriteLine("Run large list scan.");
            IList rows = list.Scan();

            foreach (IDictionary row in rows)
            {
                foreach (DictionaryEntry entry in row)
                {
                    //Console.WriteLine(entry.Key.ToString());
                    //Console.WriteLine(entry.Value.ToString());
                }
            }
            Console.WriteLine("Large list scan complete.");
        }
 public void ScanString()
 {
     Key key = new Key (NS, SET, "100-list-test-key-string");
     client.Delete(null, key);
     var ll = new Aerospike.Helper.Collections.LargeList (client, null, key, "100-string");
     WriteStringSubElements (ll, 100);
     IList values = ll.Scan ();
     Assert.AreEqual (100, ll.Size ());
     for (int x = 0; x < 100; x++) {
         Assert.AreEqual (values [x], "cats-dogs-"+x);
     }
     ll.Destroy ();
     client.Delete(null, key);
 }
        public void RunWithDistinctBins()
        {
            Key key = new Key(NS, SET, "accountId");

            // Delete record if it already exists.
            client.Delete(null, key);

            // Initialize large list operator.
            Aerospike.Helper.Collections.LargeList list = new Aerospike.Helper.Collections.LargeList(client, null, key, "trades");

            list.Size ();

            // Write trades
            Dictionary<string,Value> dict = new Dictionary<string,Value>();

            DateTime timestamp1 = new DateTime(2014, 6, 25, 12, 18, 43);
            dict["key"] = Value.Get(timestamp1.Ticks);
            dict["ticker"] = Value.Get("IBM");
            dict["qty"] = Value.Get(100);
            dict["price"] = Value.Get(BitConverter.GetBytes(181.82));
            list.Add(Value.Get(dict));

            DateTime timestamp2 = new DateTime(2014, 6, 26, 9, 33, 17);
            dict["key"] = Value.Get(timestamp2.Ticks);
            dict["ticker"] = Value.Get("GE");
            dict["qty"] = Value.Get(500);
            dict["price"] = Value.Get(BitConverter.GetBytes(26.36));
            list.Add(Value.Get(dict));

            DateTime timestamp3 = new DateTime(2014, 6, 27, 14, 40, 19);
            dict["key"] = Value.Get(timestamp3.Ticks);
            dict["ticker"] = Value.Get("AAPL");
            dict["qty"] = Value.Get(75);
            dict["price"] = Value.Get(BitConverter.GetBytes(91.85));
            list.Add(Value.Get(dict));

            // Verify list size
            int size = list.Size();

            Assert.AreEqual (size, 3);

            // Filter on range of timestamps
            DateTime begin = new DateTime(2014, 6, 26);
            DateTime end = new DateTime(2014, 6, 28);
            IList results = list.Range(Value.Get(begin.Ticks), Value.Get(end.Ticks));

            Assert.AreEqual (results.Count, 2);

            // Verify data.
            ValidateWithDistinctBins(results, 0, timestamp2, "GE", 500, 26.36);
            ValidateWithDistinctBins(results, 1, timestamp3, "AAPL", 75, 91.85);

            Console.WriteLine("Data matched.");

            Console.WriteLine("Run large list scan.");
            IList rows = list.Scan();
            foreach (IDictionary row in rows)
            {
                foreach (DictionaryEntry entry in row)
                {
                    //Console.WriteLine(entry.Key.ToString());
                    //Console.WriteLine(entry.Value.ToString());
                }
            }
            Console.WriteLine("Large list scan complete.");
        }