use of com.aerospike.client.query.RecordSet in project aerospike-client-java by aerospike.
the class TestQueryKey method queryKey.
@Test
public void queryKey() {
int begin = 2;
int end = 5;
Statement stmt = new Statement();
stmt.setNamespace(args.namespace);
stmt.setSetName(args.set);
stmt.setBinNames(binName);
stmt.setFilter(Filter.range(binName, begin, end));
RecordSet rs = client.query(null, stmt);
try {
int count = 0;
while (rs.next()) {
Key key = rs.getKey();
assertNotNull(key.userKey);
Object userkey = key.userKey.getObject();
assertNotNull(userkey);
count++;
}
assertEquals(4, count);
} finally {
rs.close();
}
}
use of com.aerospike.client.query.RecordSet in project aerospike-client-java by aerospike.
the class TestQueryString method queryString.
@Test
public void queryString() {
String filter = valuePrefix + 3;
Statement stmt = new Statement();
stmt.setNamespace(args.namespace);
stmt.setSetName(args.set);
stmt.setBinNames(binName);
stmt.setFilter(Filter.equal(binName, filter));
RecordSet rs = client.query(null, stmt);
try {
int count = 0;
while (rs.next()) {
Record record = rs.getRecord();
String result = record.getString(binName);
assertEquals(filter, result);
count++;
}
assertNotEquals(0, count);
} finally {
rs.close();
}
}
use of com.aerospike.client.query.RecordSet in project aerospike-client-java by aerospike.
the class TestQueryExecute method validateRecords.
private void validateRecords() {
int begin = 1;
int end = size + 100;
Statement stmt = new Statement();
stmt.setNamespace(args.namespace);
stmt.setSetName(args.set);
stmt.setFilter(Filter.range(binName1, begin, end));
RecordSet rs = client.query(null, stmt);
try {
int[] expectedList = new int[] { 1, 2, 3, 104, 5, 106, 7, 108, -1, 10 };
int expectedSize = size - 1;
int count = 0;
while (rs.next()) {
Record record = rs.getRecord();
int value1 = record.getInt(binName1);
int value2 = record.getInt(binName2);
int val1 = value1;
if (val1 == 9) {
fail("Data mismatch. value1 " + val1 + " should not exist");
}
if (val1 == 5) {
if (value2 != 0) {
fail("Data mismatch. value2 " + value2 + " should be null");
}
} else if (value1 != expectedList[value2 - 1]) {
fail("Data mismatch. Expected " + expectedList[value2 - 1] + ". Received " + value1);
}
count++;
}
assertEquals(expectedSize, count);
} finally {
rs.close();
}
}
use of com.aerospike.client.query.RecordSet in project aerospike-client-java by aerospike.
the class TestQueryFilterExp method queryLastUpdate.
@Test
public void queryLastUpdate() {
int begin = 10;
int end = 45;
Statement stmt = new Statement();
stmt.setNamespace(args.namespace);
stmt.setSetName(setName);
stmt.setFilter(Filter.range(binName, begin, end));
// record last update time > (currentTimeMillis() * 1000000L + 100)
QueryPolicy policy = new QueryPolicy();
policy.filterExp = Exp.build(Exp.gt(Exp.lastUpdate(), Exp.val(System.currentTimeMillis() * 1000000L + 100)));
RecordSet rs = client.query(policy, stmt);
try {
while (rs.next()) {
// Record record = rs.getRecord();
// System.out.println(record.getValue(binName).toString() + ' ' + record.expiration);
// count++;
}
// Do not asset count since some tests can run after this one.
// assertEquals(0, count);
} finally {
rs.close();
}
}
use of com.aerospike.client.query.RecordSet in project aerospike-client-java by aerospike.
the class TestQueryFilterExp method queryBinType.
@Test
public void queryBinType() {
int begin = 1;
int end = 10;
Statement stmt = new Statement();
stmt.setNamespace(args.namespace);
stmt.setSetName(setName);
stmt.setFilter(Filter.range(binName, begin, end));
QueryPolicy policy = new QueryPolicy();
policy.filterExp = Exp.build(Exp.eq(Exp.binType("listbin"), Exp.val(ParticleType.LIST)));
RecordSet rs = client.query(policy, stmt);
try {
int count = 0;
while (rs.next()) {
count++;
}
assertEquals(9, count);
} finally {
rs.close();
}
}
Aggregations