use of com.aerospike.client.policy.QueryPolicy in project aerospike-client-java by aerospike.
the class TestQueryFilterExp method queryMap4.
@Test
public void queryMap4() {
int begin = 1;
int end = 10;
Statement stmt = new Statement();
stmt.setNamespace(args.namespace);
stmt.setSetName(setName);
stmt.setFilter(Filter.range(binName, begin, end));
// Map bin does not contains value "AAA"
QueryPolicy policy = new QueryPolicy();
policy.filterExp = Exp.build(Exp.eq(MapExp.getByValue(MapReturnType.COUNT, Exp.val("AAA"), Exp.mapBin("mapbin")), Exp.val(0)));
RecordSet rs = client.query(policy, 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.policy.QueryPolicy in project aerospike-client-java by aerospike.
the class TestQueryFilterSet method queryVoidTime.
@Test
public void queryVoidTime() {
Statement stmt = new Statement();
stmt.setNamespace(args.namespace);
stmt.setSetName(set1);
GregorianCalendar now = new GregorianCalendar();
GregorianCalendar end = new GregorianCalendar();
end.add(Calendar.MINUTE, 2);
QueryPolicy policy = new QueryPolicy();
policy.filterExp = Exp.build(Exp.and(Exp.ge(Exp.voidTime(), Exp.val(now)), Exp.lt(Exp.voidTime(), Exp.val(end))));
RecordSet rs = client.query(policy, stmt);
try {
int count = 0;
while (rs.next()) {
count++;
}
assertEquals(2, count);
} finally {
rs.close();
}
}
use of com.aerospike.client.policy.QueryPolicy in project aerospike-client-java by aerospike.
the class TestQueryFilterSet method querySetName.
@Test
public void querySetName() {
Statement stmt = new Statement();
stmt.setNamespace(args.namespace);
QueryPolicy policy = new QueryPolicy();
policy.filterExp = Exp.build(Exp.eq(Exp.setName(), Exp.val(set2)));
RecordSet rs = client.query(policy, stmt);
try {
int count = 0;
while (rs.next()) {
count++;
}
assertEquals(3, count);
} finally {
rs.close();
}
}
use of com.aerospike.client.policy.QueryPolicy in project aerospike-client-java by aerospike.
the class TestQueryFilterSet method queryKeyString.
@Test
public void queryKeyString() {
Statement stmt = new Statement();
stmt.setNamespace(args.namespace);
stmt.setSetName(set3);
QueryPolicy policy = new QueryPolicy();
policy.filterExp = Exp.build(Exp.regexCompare("^key-.*-35$", 0, Exp.key(Exp.Type.STRING)));
RecordSet rs = client.query(policy, stmt);
try {
int count = 0;
while (rs.next()) {
count++;
}
assertEquals(1, count);
} finally {
rs.close();
}
}
use of com.aerospike.client.policy.QueryPolicy in project aerospike-client-java by aerospike.
the class TestQueryFilterSet method queryTTL.
@Test
public void queryTTL() {
Statement stmt = new Statement();
stmt.setNamespace(args.namespace);
stmt.setSetName(set1);
QueryPolicy policy = new QueryPolicy();
policy.filterExp = Exp.build(Exp.le(Exp.ttl(), Exp.val(60)));
RecordSet rs = client.query(policy, stmt);
try {
int count = 0;
while (rs.next()) {
count++;
}
assertEquals(1, count);
} finally {
rs.close();
}
}
Aggregations