public void RunWithDefaultSerializedBin() { Key key = new Key(NS, SET, "accountId"); object value1 = new CompoundObject("IBM", 100); object value2 = new CompoundObject("GE", 500); object value3 = new CompoundObject("AAPL", 75); // 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"); // 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["value"] = Value.Get(value1); list.Add(Value.Get(dict)); DateTime timestamp2 = new DateTime(2014, 6, 26, 9, 33, 17); dict["key"] = Value.Get(timestamp2.Ticks); dict["value"] = Value.Get(value2); list.Add(Value.Get(dict)); DateTime timestamp3 = new DateTime(2014, 6, 27, 14, 40, 19); dict["key"] = Value.Get(timestamp3.Ticks); dict["value"] = Value.Get(value3); 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. ValidateDefault(results, 0, timestamp2, value2); ValidateDefault(results, 1, timestamp3, value3); Console.WriteLine("Data matched."); }
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 RunWithSerializedBin() { 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"); // Write trades Dictionary <string, Value> dict = new Dictionary <string, Value>(); MemoryStream ms = new MemoryStream(500); DateTime timestamp1 = new DateTime(2014, 6, 25, 12, 18, 43); dict["key"] = Value.Get(timestamp1.Ticks); BinaryWriter writer = new BinaryWriter(ms); writer.Write("IBM"); // ticker writer.Write(100); // qty writer.Write(181.82); // price dict["value"] = Value.Get(ms.ToArray()); list.Add(Value.Get(dict)); DateTime timestamp2 = new DateTime(2014, 6, 26, 9, 33, 17); dict["key"] = Value.Get(timestamp2.Ticks); ms.SetLength(0); writer = new BinaryWriter(ms); writer.Write("GE"); // ticker writer.Write(500); // qty writer.Write(26.36); // price dict["value"] = Value.Get(ms.ToArray()); list.Add(Value.Get(dict)); DateTime timestamp3 = new DateTime(2014, 6, 27, 14, 40, 19); dict["key"] = Value.Get(timestamp3.Ticks); ms.SetLength(0); writer = new BinaryWriter(ms); writer.Write("AAPL"); // ticker writer.Write(75); // qty writer.Write(91.85); // price dict["value"] = Value.Get(ms.ToArray()); 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. ValidateWithSerializedBin(results, 0, timestamp2, "GE", 500, 26.36); ValidateWithSerializedBin(results, 1, timestamp3, "AAPL", 75, 91.85); Console.WriteLine("Data matched."); }
public void RunSimpleExample() { Key key = new Key(NS, SET, "setkey"); string binName = LIST_BIN; // Delete record if it already exists. client.Delete(null, key); // Initialize large set operator. Aerospike.Helper.Collections.LargeList llist = new Aerospike.Helper.Collections.LargeList(client, null, key, binName); string orig1 = "llistValue1"; string orig2 = "llistValue2"; string orig3 = "llistValue3"; // Write values. llist.Add(Value.Get(orig1)); llist.Add(Value.Get(orig2)); llist.Add(Value.Get(orig3)); Assert.AreEqual(llist.Size(), 3); // Config is not supported // IDictionary map = llist.GetConfig(); // // foreach (DictionaryEntry entry in map) // { // Console.WriteLine(entry.Key.ToString() + ',' + entry.Value); // } IList rangeList = llist.Range(Value.Get(orig2), Value.Get(orig3)); Assert.IsNotNull(rangeList); Assert.AreEqual(rangeList.Count, 2); string v2 = (string)rangeList[0]; string v3 = (string)rangeList[1]; if (v2.Equals(orig2) && v3.Equals(orig3)) { Console.WriteLine("Range Query matched: v2=" + orig2 + " v3=" + orig3); } else { Assert.Fail("Range Content mismatch. Expected (" + orig2 + ":" + orig3 + ") Received (" + v2 + ":" + v3 + ")"); } // Remove last value. llist.Remove(Value.Get(orig3)); int size = llist.Size(); if (size != 2) { throw new Exception("Size mismatch. Expected 2 Received " + size); } IList listReceived = llist.Find(Value.Get(orig2)); string expected = orig2; if (listReceived == null) { Console.WriteLine("Data mismatch: Expected " + expected + " Received null"); Assert.Fail(); } string stringReceived = (string)listReceived[0]; if (stringReceived != null && stringReceived.Equals(expected)) { Console.WriteLine("Data matched: namespace=" + key.ns + " set=" + key.setName + " key=" + key.userKey + " value=" + stringReceived); } else { Console.WriteLine("Data mismatch: Expected " + expected + " Received " + stringReceived); Assert.Fail(); } }
public void RunSimpleExample() { Key key = new Key(NS, SET, "setkey"); string binName = LIST_BIN; // Delete record if it already exists. client.Delete(null, key); // Initialize large set operator. Aerospike.Helper.Collections.LargeList llist = new Aerospike.Helper.Collections.LargeList(client, null, key, binName); string orig1 = "llistValue1"; string orig2 = "llistValue2"; string orig3 = "llistValue3"; // Write values. llist.Add(Value.Get(orig1)); llist.Add(Value.Get(orig2)); llist.Add(Value.Get(orig3)); Assert.AreEqual (llist.Size(), 3); // Config is not supported // IDictionary map = llist.GetConfig(); // // foreach (DictionaryEntry entry in map) // { // Console.WriteLine(entry.Key.ToString() + ',' + entry.Value); // } IList rangeList = llist.Range(Value.Get(orig2), Value.Get(orig3)); Assert.IsNotNull (rangeList); Assert.AreEqual (rangeList.Count, 2); string v2 = (string) rangeList[0]; string v3 = (string) rangeList[1]; if (v2.Equals(orig2) && v3.Equals(orig3)) { Console.WriteLine("Range Query matched: v2=" + orig2 + " v3=" + orig3); } else { Assert.Fail("Range Content mismatch. Expected (" + orig2 + ":" + orig3 + ") Received (" + v2 + ":" + v3 + ")"); } // Remove last value. llist.Remove(Value.Get(orig3)); int size = llist.Size(); if (size != 2) { throw new Exception("Size mismatch. Expected 2 Received " + size); } IList listReceived = llist.Find(Value.Get(orig2)); string expected = orig2; if (listReceived == null) { Console.WriteLine("Data mismatch: Expected " + expected + " Received null"); Assert.Fail(); } string stringReceived = (string) listReceived[0]; if (stringReceived != null && stringReceived.Equals(expected)) { Console.WriteLine("Data matched: namespace=" + key.ns + " set=" + key.setName + " key=" + key.userKey + " value=" + stringReceived); } else { Console.WriteLine("Data mismatch: Expected " + expected + " Received " + stringReceived); Assert.Fail(); } }
public void RunWithSerializedBin() { 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"); // Write trades Dictionary<string, Value> dict = new Dictionary<string, Value>(); MemoryStream ms = new MemoryStream(500); DateTime timestamp1 = new DateTime(2014, 6, 25, 12, 18, 43); dict["key"] = Value.Get(timestamp1.Ticks); BinaryWriter writer = new BinaryWriter(ms); writer.Write("IBM"); // ticker writer.Write(100); // qty writer.Write(181.82); // price dict["value"] = Value.Get(ms.ToArray()); list.Add(Value.Get(dict)); DateTime timestamp2 = new DateTime(2014, 6, 26, 9, 33, 17); dict["key"] = Value.Get(timestamp2.Ticks); ms.SetLength(0); writer = new BinaryWriter(ms); writer.Write("GE"); // ticker writer.Write(500); // qty writer.Write(26.36); // price dict["value"] = Value.Get(ms.ToArray()); list.Add(Value.Get(dict)); DateTime timestamp3 = new DateTime(2014, 6, 27, 14, 40, 19); dict["key"] = Value.Get(timestamp3.Ticks); ms.SetLength(0); writer = new BinaryWriter(ms); writer.Write("AAPL"); // ticker writer.Write(75); // qty writer.Write(91.85); // price dict["value"] = Value.Get(ms.ToArray()); 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. ValidateWithSerializedBin(results, 0, timestamp2, "GE", 500, 26.36); ValidateWithSerializedBin(results, 1, timestamp3, "AAPL", 75, 91.85); Console.WriteLine("Data matched."); }
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 RunWithDefaultSerializedBin() { Key key = new Key(NS, SET, "accountId"); object value1 = new CompoundObject("IBM", 100); object value2 = new CompoundObject("GE", 500); object value3 = new CompoundObject("AAPL", 75); // 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"); // 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["value"] = Value.Get(value1); list.Add(Value.Get(dict)); DateTime timestamp2 = new DateTime(2014, 6, 26, 9, 33, 17); dict["key"] = Value.Get(timestamp2.Ticks); dict["value"] = Value.Get(value2); list.Add(Value.Get(dict)); DateTime timestamp3 = new DateTime(2014, 6, 27, 14, 40, 19); dict["key"] = Value.Get(timestamp3.Ticks); dict["value"] = Value.Get(value3); 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. ValidateDefault(results, 0, timestamp2, value2); ValidateDefault(results, 1, timestamp3, value3); Console.WriteLine("Data matched."); }