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 QueryPredicate3() { 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.RecLastUpdate(), PredExp.IntegerValue(DateTime.UtcNow.Add(TimeSpan.FromSeconds(1.0))), PredExp.IntegerGreater() ); RecordSet rs = client.Query(null, stmt); try { //int count = 0; while (rs.Next()) { //Record record = rs.Record; //Console.WriteLine(record.GetValue(binName).ToString() + ' ' + record.expiration); //count++; } // Do not asset count since some tests can run after this one. //Assert.AreEqual(0, count); } finally { rs.Close(); } }