use of com.aerospike.client.query.RecordSet 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.query.RecordSet in project aerospike-client-java by aerospike.
the class TestQueryFilterExp method queryAndOr.
@Test
public void queryAndOr() {
int begin = 10;
int end = 45;
Statement stmt = new Statement();
stmt.setNamespace(args.namespace);
stmt.setSetName(setName);
stmt.setFilter(Filter.range(binName, begin, end));
// ((bin2 > 40 && bin2 < 44) || bin2 == 22 || bin2 == 9) && (binName == bin2)
QueryPolicy policy = new QueryPolicy();
policy.filterExp = Exp.build(Exp.and(Exp.or(Exp.and(Exp.gt(Exp.intBin("bin2"), Exp.val(40)), Exp.lt(Exp.intBin("bin2"), Exp.val(44))), Exp.eq(Exp.intBin("bin2"), Exp.val(22)), Exp.eq(Exp.intBin("bin2"), Exp.val(9))), Exp.eq(Exp.intBin(binName), Exp.intBin("bin2"))));
RecordSet rs = client.query(policy, stmt);
try {
int count = 0;
while (rs.next()) {
// System.out.println(rs.getRecord().getValue(binName));
count++;
}
// 22, 41, 42, 43
assertEquals(4, count);
} finally {
rs.close();
}
}
use of com.aerospike.client.query.RecordSet 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.query.RecordSet 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.query.RecordSet 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();
}
}
Aggregations