public void RunVolumeInsert() { // This key has already been created in runSimpleExample(). Key key = new Key(args.ns, args.set, "setkey"); int itemCount = 2000; LargeList llist2 = client.GetLargeList(null, key, "NumberBin"); for (int i = itemCount; i > 0; i--) { llist2.Add(Value.Get(i)); } Assert.AreEqual(2000, llist2.Size()); }
public void SimpleLargeList() { Key key = new Key(args.ns, args.set, "setkey"); // Delete record if it already exists. client.Delete(null, key); // Initialize large set operator. LargeList llist = client.GetLargeList(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)); // Perform a Range Query -- look for "llistValue2" to "llistValue3" IList rangeList = llist.Range(Value.Get(orig2), Value.Get(orig3)); Assert.IsNotNull(rangeList); Assert.AreEqual(2, rangeList.Count); string v2 = (string)rangeList[0]; string v3 = (string)rangeList[1]; Assert.AreEqual(orig2, v2); Assert.AreEqual(orig3, v3); // Remove last value. llist.Remove(Value.Get(orig3)); int size = llist.Size(); Assert.AreEqual(2, size); IList listReceived = llist.Find(Value.Get(orig2)); string expected = orig2; Assert.IsNotNull(listReceived); string stringReceived = (string)listReceived[0]; Assert.IsNotNull(stringReceived); Assert.AreEqual(expected, stringReceived); }
public void SimpleLargeList() { if (!args.ValidateLDT()) { return; } Key key = new Key(args.ns, args.set, "setkey"); // Delete record if it already exists. client.Delete(null, key); // Initialize large set operator. LargeList llist = client.GetLargeList(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)); // Perform exists. bool b = llist.Exists(Value.Get(orig2)); Assert.IsTrue(b); b = llist.Exists(Value.Get("notfound")); Assert.IsFalse(b); // Test record not found. LargeList nflist = client.GetLargeList(null, new Key(args.ns, args.set, "sfdfdqw"), binName); b = nflist.Exists(Value.Get(orig2)); Assert.IsFalse(b); IList klist = new List <Value>(); klist.Add(Value.Get(orig2)); klist.Add(Value.Get(orig1)); klist.Add(Value.Get("notfound")); IList <bool> blist = llist.Exists(klist); Assert.IsTrue(blist[0]); Assert.IsTrue(blist[1]); Assert.IsFalse(blist[2]); // Test record not found. IList <bool> blist2 = nflist.Exists(klist); Assert.IsFalse(blist2[0]); Assert.IsFalse(blist2[1]); Assert.IsFalse(blist2[2]); // Perform a Range Query -- look for "llistValue2" to "llistValue3" IList rangeList = llist.Range(Value.Get(orig2), Value.Get(orig3)); Assert.IsNotNull(rangeList); Assert.AreEqual(2, rangeList.Count); string v2 = (string)rangeList[0]; string v3 = (string)rangeList[1]; Assert.AreEqual(orig2, v2); Assert.AreEqual(orig3, v3); // Remove last value. llist.Remove(Value.Get(orig3)); int size = llist.Size(); Assert.AreEqual(2, size); IList listReceived = llist.Find(Value.Get(orig2)); string expected = orig2; Assert.IsNotNull(listReceived); string stringReceived = (string)listReceived[0]; Assert.IsNotNull(stringReceived); Assert.AreEqual(expected, stringReceived); }
public void RunWithSerializedBin() { if (!args.ValidateLDT()) { return; } Key key = new Key(args.ns, args.set, "accountId"); // Delete record if it already exists. client.Delete(null, key); // Initialize large list operator. LargeList list = client.GetLargeList(null, key, "trades"); // Write trades Dictionary <string, Value> map = new Dictionary <string, Value>(); MemoryStream ms = new MemoryStream(500); DateTime timestamp1 = new DateTime(2014, 6, 25, 12, 18, 43); map["key"] = Value.Get(timestamp1.Ticks); BinaryWriter writer = new BinaryWriter(ms); writer.Write("IBM"); // ticker writer.Write(100); // qty writer.Write(181.82); // price map["value"] = Value.Get(ms.ToArray()); list.Add(Value.Get(map)); DateTime timestamp2 = new DateTime(2014, 6, 26, 9, 33, 17); map["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 map["value"] = Value.Get(ms.ToArray()); list.Add(Value.Get(map)); DateTime timestamp3 = new DateTime(2014, 6, 27, 14, 40, 19); map["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 map["value"] = Value.Get(ms.ToArray()); list.Add(Value.Get(map)); // Verify list size int size = list.Size(); Assert.AreEqual(3, size); // 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.IsNotNull(results); Assert.AreEqual(2, results.Count); // Verify data. ValidateWithSerializedBin(results, 0, timestamp2, "GE", 500, 26.36); ValidateWithSerializedBin(results, 1, timestamp3, "AAPL", 75, 91.85); }
public void DistinctBinsLargeList() { if (!args.ValidateLDT()) { return; } Key key = new Key(args.ns, args.set, "accountId"); // Delete record if it already exists. client.Delete(null, key); // Initialize large list operator. LargeList list = client.GetLargeList(null, key, "trades"); // Write trades Dictionary <string, Value> map = new Dictionary <string, Value>(); DateTime timestamp1 = new DateTime(2014, 6, 25, 12, 18, 43); map["key"] = Value.Get(timestamp1.Ticks); map["ticker"] = Value.Get("IBM"); map["qty"] = Value.Get(100); map["price"] = Value.Get(BitConverter.GetBytes(181.82)); list.Add(Value.Get(map)); DateTime timestamp2 = new DateTime(2014, 6, 26, 9, 33, 17); map["key"] = Value.Get(timestamp2.Ticks); map["ticker"] = Value.Get("GE"); map["qty"] = Value.Get(500); map["price"] = Value.Get(BitConverter.GetBytes(26.36)); list.Add(Value.Get(map)); DateTime timestamp3 = new DateTime(2014, 6, 27, 14, 40, 19); map["key"] = Value.Get(timestamp3.Ticks); map["ticker"] = Value.Get("AAPL"); map["qty"] = Value.Get(75); map["price"] = Value.Get(BitConverter.GetBytes(91.85)); list.Add(Value.Get(map)); // Verify list size int size = list.Size(); Assert.AreEqual(3, size); // 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.IsNotNull(results); Assert.AreEqual(2, results.Count); // Verify data. ValidateWithDistinctBins(results, 0, timestamp2, "GE", 500, 26.36); ValidateWithDistinctBins(results, 1, timestamp3, "AAPL", 75, 91.85); IList rows = list.Scan(); foreach (IDictionary row in rows) { foreach (DictionaryEntry entry in row) { //console.Info(entry.Key.ToString()); //console.Info(entry.Value.ToString()); } } }