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 QueryPredicate2() { 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(15), PredExp.IntegerGreaterEq(), PredExp.IntegerBin("bin2"), PredExp.IntegerValue(42), PredExp.IntegerLessEq(), PredExp.And(2), PredExp.Not() ); RecordSet rs = client.Query(null, stmt); try { int count = 0; while (rs.Next()) { //Console.WriteLine(rs.Record.GetValue(binName)); count++; } // 10, 11, 12, 13, 43, 44, 45 Assert.AreEqual(8, count); } finally { rs.Close(); } }