use of com.aerospike.client.query.RecordSet in project aerospike-client-java by aerospike.
the class TestQueryPredExp method queryPredicate8.
@Test
public void queryPredicate8() {
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("D"), PredExp.stringUnequal(), PredExp.mapBin("mapbin"), PredExp.mapKeyIterateAnd("x"));
/*
stmt.setPredicate(
Predicate.mapKeyExclude("mapbin", "x", Predicate.var("x").equal("D"))
);
*/
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();
}
}
use of com.aerospike.client.query.RecordSet in project apex-malhar by apache.
the class AerospikeTestUtils method cleanMetaTable.
// removes all records from set AerospikeTransactionalStore.DEFAULT_META_SET (used to store
// committed window ids) in namespace NAMESPACE
//
static void cleanMetaTable() {
AerospikeClient client = null;
try {
client = new AerospikeClient(NODE, PORT);
Statement stmnt = new Statement();
stmnt.setNamespace(NAMESPACE);
stmnt.setSetName(AerospikeTransactionalStore.DEFAULT_META_SET);
RecordSet rs = client.query(null, stmnt);
while (rs.next()) {
client.delete(null, rs.getKey());
}
} catch (AerospikeException e) {
LOG.error("cleanMetaTable failed: {}", e);
throw e;
} finally {
if (null != client) {
client.close();
}
}
}
use of com.aerospike.client.query.RecordSet in project apex-malhar by apache.
the class AerospikeTestUtils method getNumOfEventsInStore.
// returns the number of records in set SET_NAME in namespace NAMESPACE
static long getNumOfEventsInStore() {
AerospikeClient client = null;
try {
long count = 0;
client = new AerospikeClient(NODE, PORT);
Statement stmnt = new Statement();
stmnt.setNamespace(NAMESPACE);
stmnt.setSetName(SET_NAME);
RecordSet rs = client.query(null, stmnt);
while (rs.next()) {
count++;
}
return count;
} catch (AerospikeException e) {
LOG.error("getNumOfEventsInStore failed: {}", e);
throw e;
} finally {
if (null != client) {
client.close();
}
}
}
use of com.aerospike.client.query.RecordSet in project apex-malhar by apache.
the class AerospikeTestUtils method cleanTable.
// removes all records from set SET_NAME in namespace NAMESPACE
static void cleanTable() {
AerospikeClient client = null;
try {
client = new AerospikeClient(NODE, PORT);
Statement stmnt = new Statement();
stmnt.setNamespace(NAMESPACE);
stmnt.setSetName(SET_NAME);
RecordSet rs = client.query(null, stmnt);
while (rs.next()) {
client.delete(null, rs.getKey());
}
} catch (AerospikeException e) {
LOG.error("cleanTable failed: {}", e);
throw e;
} finally {
if (null != client) {
client.close();
}
}
}
use of com.aerospike.client.query.RecordSet in project gora by apache.
the class AerospikeStore method execute.
/**
* {@inheritDoc}
*
* @param query the query to execute.
* @return the query result
*/
@Override
public Result<K, T> execute(Query<K, T> query) throws GoraException {
List<AerospikeResultRecord> resultRecords = new ArrayList<>();
String namespace = aerospikeParameters.getAerospikeMapping().getNamespace();
String set = aerospikeParameters.getAerospikeMapping().getSet();
try {
// Query execution without any keys
if (query.getStartKey() == null && query.getEndKey() == null) {
try (RecordSet recordSet = aerospikeClient.query(null, getStatement(namespace, set))) {
while (recordSet.next()) {
AerospikeResultRecord aerospikeRecord = new AerospikeResultRecord(recordSet.getKey(), recordSet.getRecord());
resultRecords.add(aerospikeRecord);
}
}
} else // Query execution for single key
if (query.getKey() != null) {
Key key = getAerospikeKey(query.getKey());
Record record = aerospikeClient.get(null, key);
if (record != null) {
resultRecords.add(new AerospikeResultRecord(key, record));
}
}
// }
return new AerospikeQueryResult<>(this, query, resultRecords, getFieldsToQuery(null));
} catch (Exception e) {
throw new GoraException(e);
}
}
Aggregations