private static void RunQuery(AerospikeClient client, string ns, string set, string indexName, string binName) { Console.WriteLine("Query"); Statement stmt = new Statement(); stmt.SetNamespace(ns); stmt.SetSetName(set); stmt.SetBinNames(binName); stmt.SetFilter(Filter.Range(binName, 14, 18)); RecordSet rs = client.Query(null, stmt); try { while (rs.Next()) { Key key = rs.Key; Record record = rs.Record; object result = record.GetValue(binName); Console.WriteLine("Record found: ns=" + key.ns + " set=" + key.setName + " bin=" + binName + " digest=" + ByteUtil.BytesToHexString(key.digest) + " value=" + result); } } finally { rs.Close(); } }
public void TestBytesToHex() { byte[] src = new byte[] { 0x22, 0x0F, 0x1E, 0x2D, 0x3C, 0x4B, 0x5A, 0x69, 0x78, 0x87, 0x96, 0xA5, 0xB4, 0xC3, 0xD2, 0xE1, 0xF0, 0xFF, 0x33 }; string exp = "0F*1E*2D*3C*4B*5A*69*78*#87*96*A5*B4*C3*D2*E1*F0*#FF"; string comp = ByteUtil.BytesToHexString(src, 1, 17, '*', '#'); Assert.Equal(exp, comp); }
public virtual void OnRecord(Key key, Record record) { Log.Level level = Log.Level.ERROR; object value = null; if (record != null) { level = Log.Level.INFO; value = record.GetValue(parent.binName); } parent.console.Write(level, "Record: namespace={0} set={1} key={2} bin={3} value={4}", key.ns, key.setName, ByteUtil.BytesToHexString(key.digest), parent.binName, value); }
private void RunQuery(AerospikeClient client, Arguments args, string indexName, string binName, string valuePrefix) { string filter = valuePrefix + 3; console.Info("Query for: ns={0} set={1} index={2} bin={3} filter={4}", args.ns, args.set, indexName, binName, filter); Statement stmt = new Statement(); stmt.SetNamespace(args.ns); stmt.SetSetName(args.set); stmt.SetBinNames(binName); stmt.SetFilter(Filter.Equal(binName, filter)); RecordSet rs = client.Query(null, stmt); try { int count = 0; while (rs.Next()) { Key key = rs.Key; Record record = rs.Record; string result = (string)record.GetValue(binName); if (result.Equals(filter)) { console.Info("Record found: namespace={0} set={1} digest={2} bin={3} value={4}", key.ns, key.setName, ByteUtil.BytesToHexString(key.digest), binName, result); } else { console.Error("Query mismatch: Expected {0}. Received {1}.", filter, result); } count++; } if (count == 0) { console.Error("Query failed. No records returned."); } } finally { rs.Close(); } }
private void RunQuery(AerospikeClient client, Arguments args, string indexName, string binName) { int begin = 14; int end = 18; console.Info("Query for: ns={0} set={1} index={2} bin={3} >= {4} <= {5}", args.ns, args.set, indexName, binName, begin, end); Statement stmt = new Statement(); stmt.SetNamespace(args.ns); stmt.SetSetName(args.set); stmt.SetBinNames(binName); stmt.SetFilters(Filter.Range(binName, begin, end)); RecordSet rs = client.Query(null, stmt); try { int count = 0; while (rs.Next()) { Key key = rs.Key; Record record = rs.Record; long result = record.GetLong(binName); console.Info("Record found: namespace={0} set={1} digest={2} bin={3} value={4}", key.ns, key.setName, ByteUtil.BytesToHexString(key.digest), binName, result); count++; } if (count != 5) { console.Error("Query count mismatch. Expected 5. Received " + count); } } finally { rs.Close(); } }
public virtual void OnExists(Key key, bool exists) { parent.console.Info("Record: namespace={0} set={1} key={2} exists={3}", key.ns, key.setName, ByteUtil.BytesToHexString(key.digest), exists); }