public void Initialize() { predAEq1BPolicy = new BatchPolicy(); predAEq1RPolicy = new Policy(); predAEq1WPolicy = new WritePolicy(); predAEq1BPolicy.SetPredExp( PredExp.IntegerBin(binAName), PredExp.IntegerValue(1), PredExp.IntegerEqual()); predAEq1RPolicy.SetPredExp( PredExp.IntegerBin(binAName), PredExp.IntegerValue(1), PredExp.IntegerEqual()); predAEq1WPolicy.SetPredExp( PredExp.IntegerBin(binAName), PredExp.IntegerValue(1), PredExp.IntegerEqual()); client.Delete(null, keyA); client.Delete(null, keyB); client.Put(null, keyA, binA1); client.Put(null, keyB, binA2); }
public void QueryPredicate10() { int begin = 1; int end = 10; Statement stmt = new Statement(); stmt.SetNamespace(args.ns); stmt.SetSetName(setName); stmt.SetFilter(Filter.Range(binName, begin, end)); stmt.SetPredExp( PredExp.RecDigestModulo(3), PredExp.IntegerValue(1), PredExp.IntegerEqual() ); RecordSet rs = client.Query(null, stmt); try { int count = 0; while (rs.Next()) { //Console.WriteLine(rs.Record.ToString()); count++; } Assert.AreEqual(2, count); } finally { rs.Close(); } }
public void QueryPredicate1() { int begin = 10; int end = 45; Statement stmt = new Statement(); stmt.SetNamespace(args.ns); stmt.SetSetName(setName); stmt.SetFilter(Filter.Range(binName, begin, end)); stmt.SetPredExp( PredExp.IntegerBin("bin2"), PredExp.IntegerValue(40), PredExp.IntegerGreater(), PredExp.IntegerBin("bin2"), PredExp.IntegerValue(44), PredExp.IntegerLess(), PredExp.And(2), PredExp.IntegerBin("bin2"), PredExp.IntegerValue(22), PredExp.IntegerEqual(), PredExp.IntegerBin("bin2"), PredExp.IntegerValue(9), PredExp.IntegerEqual(), PredExp.Or(3), PredExp.IntegerBin(binName), PredExp.IntegerBin("bin2"), PredExp.IntegerEqual(), PredExp.And(2) ); RecordSet rs = client.Query(null, stmt); try { int count = 0; while (rs.Next()) { //Console.WriteLine(rs.Record.GetValue(binName)); count++; } // 22, 41, 42, 43 Assert.AreEqual(4, count); } finally { rs.Close(); } }
private void RunQuery1(AerospikeClient client, Arguments args, string binName) { int begin = 10; int end = 40; console.Info("Query Predicate: (bin2 > 126 && bin2 <= 140) or (bin2 = 360)"); Statement stmt = new Statement(); stmt.SetNamespace(args.ns); stmt.SetSetName(args.set); // Filter applied on query itself. Filter can only reference an indexed bin. stmt.SetFilter(Filter.Range(binName, begin, end)); // Predicates are applied on query results on server side. // Predicates can reference any bin. stmt.SetPredExp( PredExp.IntegerBin("bin2"), PredExp.IntegerValue(126), PredExp.IntegerGreater(), PredExp.IntegerBin("bin2"), PredExp.IntegerValue(140), PredExp.IntegerLessEq(), PredExp.And(2), PredExp.IntegerBin("bin2"), PredExp.IntegerValue(360), PredExp.IntegerEqual(), PredExp.Or(2) ); RecordSet rs = client.Query(null, stmt); try { while (rs.Next()) { Record record = rs.Record; console.Info("Record: " + record.ToString()); } } finally { rs.Close(); } }
public void QueryPredicate4() { int begin = 1; int end = 10; Statement stmt = new Statement(); stmt.SetNamespace(args.ns); stmt.SetSetName(setName); stmt.SetFilter(Filter.Range(binName, begin, end)); stmt.SetPredExp( PredExp.IntegerVar("x"), PredExp.IntegerValue(4), PredExp.IntegerEqual(), PredExp.ListBin("listbin"), PredExp.ListIterateOr("x") ); RecordSet rs = client.Query(null, stmt); try { int count = 0; while (rs.Next()) { //Console.WriteLine(rs.Record.ToString()); count++; } Xunit.Assert.Equal(1, count); } finally { rs.Close(); } }