use of com.aerospike.client.query.RecordSet in project aerospike-client-java by aerospike.
the class QueryPredExp method runQuery2.
private void runQuery2(AerospikeClient client, Parameters params, String binName) throws Exception {
int begin = 10;
int end = 40;
console.info("Query Predicate: Record updated on 2017-01-15");
Calendar beginTime = new GregorianCalendar(2017, 0, 15);
Calendar endTime = new GregorianCalendar(2017, 0, 16);
Statement stmt = new Statement();
stmt.setNamespace(params.namespace);
stmt.setSetName(params.set);
stmt.setFilter(Filter.range(binName, begin, end));
stmt.setPredExp(PredExp.recLastUpdate(), PredExp.integerValue(beginTime), PredExp.integerGreaterEq(), PredExp.recLastUpdate(), PredExp.integerValue(endTime), PredExp.integerLess(), PredExp.and(2));
RecordSet rs = client.query(null, stmt);
try {
while (rs.next()) {
Record record = rs.getRecord();
console.info("Record: " + record.toString());
}
} finally {
rs.close();
}
}
use of com.aerospike.client.query.RecordSet in project aerospike-client-java by aerospike.
the class TestQueryPredExp method queryPredicate4.
@Test
public void queryPredicate4() {
int begin = 1;
int end = 10;
Statement stmt = new Statement();
stmt.setNamespace(args.namespace);
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"));
/*
stmt.setPredicate(
Predicate.listInclude("listbin", "x", Predicate.var("x").equal(4))
);
*/
RecordSet rs = client.query(null, stmt);
try {
int count = 0;
while (rs.next()) {
// System.out.println(rs.getRecord().toString());
count++;
}
assertEquals(1, count);
} finally {
rs.close();
}
}
use of com.aerospike.client.query.RecordSet in project aerospike-client-java by aerospike.
the class TestQueryPredExp method queryPredicate9.
@Test
public void queryPredicate9() {
int begin = 1;
int end = 10;
Statement stmt = new Statement();
stmt.setNamespace(args.namespace);
stmt.setSetName(setName);
stmt.setFilter(Filter.range(binName, begin, end));
stmt.setPredExp(PredExp.stringVar("x"), PredExp.stringValue("AAA"), PredExp.stringUnequal(), PredExp.mapBin("mapbin"), PredExp.mapValIterateAnd("x"));
/*
stmt.setPredicate(
Predicate.mapValueExclude("mapbin", "x", Predicate.var("x").equal("AAA"))
);
*/
RecordSet rs = client.query(null, stmt);
try {
int count = 0;
while (rs.next()) {
// System.out.println(rs.getRecord().toString());
count++;
}
assertEquals(7, count);
} finally {
rs.close();
}
}
use of com.aerospike.client.query.RecordSet in project aerospike-client-java by aerospike.
the class TestQueryPredExp method queryPredicate10.
@Test
public void queryPredicate10() {
int begin = 1;
int end = 10;
Statement stmt = new Statement();
stmt.setNamespace(args.namespace);
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()) {
// System.out.println(rs.getRecord().toString());
count++;
}
assertEquals(2, count);
} finally {
rs.close();
}
}
use of com.aerospike.client.query.RecordSet in project aerospike-client-java by aerospike.
the class TestQueryPredExp method queryPredicate5.
@Test
public void queryPredicate5() {
int begin = 1;
int end = 10;
Statement stmt = new Statement();
stmt.setNamespace(args.namespace);
stmt.setSetName(setName);
stmt.setFilter(Filter.range(binName, begin, end));
stmt.setPredExp(PredExp.integerVar("x"), PredExp.integerValue(5), PredExp.integerUnequal(), PredExp.listBin("listbin"), PredExp.listIterateAnd("x"));
/*
stmt.setPredicate(
Predicate.listExclude("listbin", "x", Predicate.var("x").equal(5))
);
*/
RecordSet rs = client.query(null, stmt);
try {
int count = 0;
while (rs.next()) {
// System.out.println(rs.getRecord().toString());
count++;
}
assertEquals(8, count);
} finally {
rs.close();
}
}
Aggregations