use of com.aerospike.client.policy.QueryPolicy in project aerospike-client-java by aerospike.
the class QueryExp method runQuery1.
private void runQuery1(AerospikeClient client, Parameters params, String binName) throws Exception {
int begin = 10;
int end = 40;
console.info("Query Predicate: (bin2 > 126 && bin2 <= 140) || (bin2 = 360)");
Statement stmt = new Statement();
stmt.setNamespace(params.namespace);
stmt.setSetName(params.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.
QueryPolicy policy = new QueryPolicy(client.queryPolicyDefault);
policy.filterExp = Exp.build(Exp.or(Exp.and(Exp.gt(Exp.intBin("bin2"), Exp.val(126)), Exp.le(Exp.intBin("bin2"), Exp.val(140))), Exp.eq(Exp.intBin("bin2"), Exp.val(360))));
RecordSet rs = client.query(policy, stmt);
try {
while (rs.next()) {
Record record = rs.getRecord();
console.info("Record: " + record.toString());
}
} finally {
rs.close();
}
}
Aggregations