use of com.aerospike.client.query.RecordSet 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();
}
}
use of com.aerospike.client.query.RecordSet in project aerospike-client-java by aerospike.
the class TestQueryRPS method scan.
@Test
public void scan() {
Statement stmt = new Statement();
stmt.setNamespace(args.namespace);
stmt.setSetName(args.set);
stmt.setRecordsPerSecond(rps);
RecordSet rs = client.query(null, stmt);
drainRecords(rs);
for (Node n : client.getNodes()) {
checkRuntime(n, stmt);
}
}
use of com.aerospike.client.query.RecordSet in project aerospike-client-java by aerospike.
the class QueryGeoCollection method runQuery.
private void runQuery(AerospikeClient client, Parameters params, String binName, String binName2, IndexCollectionType indexType) throws Exception {
console.info("Query for: ns=%s set=%s bin=%s %s within <region>", params.namespace, params.set, binName, indexType.toString());
StringBuilder rgnsb = generateQueryRegion();
Statement stmt = new Statement();
stmt.setNamespace(params.namespace);
stmt.setSetName(params.set);
stmt.setFilter(Filter.geoWithinRegion(binName, indexType, rgnsb.toString()));
RecordSet rs = client.query(null, stmt);
try {
int count = 0;
Set<String> uniques = new HashSet<String>();
while (rs.next()) {
Record record = rs.getRecord();
uniques.add(record.getString(binName2));
count++;
}
if (count != 697) {
console.error("Query failed. %d records expected. %d returned.", 697, count);
} else if (uniques.size() != 21) {
console.error("Query failed. %d unique records expected. %d unique returned.", 21, uniques.size());
} else {
console.info("query succeeded with %d records %d unique", count, uniques.size());
}
} finally {
rs.close();
}
}
use of com.aerospike.client.query.RecordSet in project aerospike-client-java by aerospike.
the class QueryRegion method runRadiusQuery.
private void runRadiusQuery(AerospikeClient client, Parameters params, String indexName, String binName) throws Exception {
double lon = -122.0;
double lat = 37.5;
double radius = 50000.0;
console.info("QueryRadius for: ns=%s set=%s index=%s bin=%s within long=%f lat=%f radius=%f", params.namespace, params.set, indexName, binName, lon, lat, radius);
Statement stmt = new Statement();
stmt.setNamespace(params.namespace);
stmt.setSetName(params.set);
stmt.setBinNames(binName);
stmt.setFilter(Filter.geoWithinRadius(binName, lon, lat, radius));
RecordSet rs = client.query(null, stmt);
try {
int count = 0;
while (rs.next()) {
Key key = rs.getKey();
Record record = rs.getRecord();
String result = record.getGeoJSONString(binName);
console.info("Record found: ns=%s set=%s bin=%s digest=%s value=%s", key.namespace, key.setName, binName, Buffer.bytesToHexString(key.digest), result);
count++;
}
if (count != 4) {
console.error("Query count mismatch. Expected 4. Received " + count);
}
} finally {
rs.close();
}
}
use of com.aerospike.client.query.RecordSet in project aerospike-client-java by aerospike.
the class QueryRegion method runQuery.
private void runQuery(AerospikeClient client, Parameters params, String indexName, String binName) throws Exception {
StringBuilder rgnsb = new StringBuilder();
rgnsb.append("{ ");
rgnsb.append(" \"type\": \"Polygon\", ");
rgnsb.append(" \"coordinates\": [ ");
rgnsb.append(" [[-122.500000, 37.000000],[-121.000000, 37.000000], ");
rgnsb.append(" [-121.000000, 38.080000],[-122.500000, 38.080000], ");
rgnsb.append(" [-122.500000, 37.000000]] ");
rgnsb.append(" ] ");
rgnsb.append(" } ");
console.info("QueryRegion for: ns=%s set=%s index=%s bin=%s within %s", params.namespace, params.set, indexName, binName, rgnsb);
Statement stmt = new Statement();
stmt.setNamespace(params.namespace);
stmt.setSetName(params.set);
stmt.setBinNames(binName);
stmt.setFilter(Filter.geoWithinRegion(binName, rgnsb.toString()));
RecordSet rs = client.query(null, stmt);
try {
int count = 0;
while (rs.next()) {
Key key = rs.getKey();
Record record = rs.getRecord();
String result = record.getGeoJSONString(binName);
console.info("Record found: ns=%s set=%s bin=%s digest=%s value=%s", key.namespace, key.setName, binName, Buffer.bytesToHexString(key.digest), result);
count++;
}
if (count != 6) {
console.error("Query count mismatch. Expected 6. Received " + count);
}
} finally {
rs.close();
}
}
Aggregations