use of com.aerospike.client.Record in project aerospike-client-java by aerospike.
the class ScanCommand method parseRow.
@Override
protected void parseRow(Key key) throws IOException {
Record record = parseRecord();
if (!valid) {
throw new AerospikeException.ScanTerminated();
}
callback.scanCallback(key, record);
}
use of com.aerospike.client.Record in project aerospike-client-java by aerospike.
the class QueryPredExp method runQuery1.
private void runQuery1(AerospikeClient client, Parameters params, String binName) throws Exception {
int begin = 10;
int end = 40;
console.info("Query Predicate: (bin2 > 126 && bin2 <= 140) or (bin2 = 360)");
Statement stmt = new Statement();
stmt.setNamespace(params.namespace);
stmt.setSetName(params.set);
// Filter applied on query itself. Filter can only reference an indexed bin.
stmt.setFilter(Filter.range(binName, begin, end));
// Predicates are applied on query results on server side.
// Predicates can reference any bin.
stmt.setPredExp(PredExp.integerBin("bin2"), PredExp.integerValue(126), PredExp.integerGreater(), PredExp.integerBin("bin2"), PredExp.integerValue(140), PredExp.integerLessEq(), PredExp.and(2), PredExp.integerBin("bin2"), PredExp.integerValue(360), PredExp.integerEqual(), PredExp.or(2));
RecordSet rs = client.query(null, stmt);
try {
while (rs.next()) {
Record record = rs.getRecord();
console.info("Record: " + record.toString());
}
} finally {
rs.close();
}
}
use of com.aerospike.client.Record in project XRTB by benmfaul.
the class RedissonClient method hgetAll.
/**
* Mimic a REDIS hgetAll operation.
* @param id String. They key to get.
* @return Map. The map stored at 'key'
* @throws Exception on aerospike/cache2k errors.
*/
public Map hgetAll(String id) {
if (ae == null) {
return (Map) cache.peek(id);
}
Key key = new Key("test", "cache", id);
Record record = null;
record = ae.getClient().get(null, key);
if (record == null) {
return null;
}
Map map = (Map) record.bins.get("value");
return map;
}
use of com.aerospike.client.Record in project XRTB by benmfaul.
the class RedissonClient method getMap.
/**
* Return the User object (as a map) from the database.
* @param name String. the name of the user.
* @return ConcurrentHashMap. The map representation of the user.
* @throws Exception on cache2k/aerorpike errors.
*/
public ConcurrentHashMap getMap(String name) throws Exception {
if (ae == null) {
return (ConcurrentHashMap) cacheDb.peek(name);
}
Key key = new Key("test", "database", "rtb4free");
Record record = null;
record = ae.getClient().get(null, key);
if (record == null) {
return new ConcurrentHashMap();
}
String content = (String) record.bins.get("map");
return mapper.readValue(content, ConcurrentHashMap.class);
}
use of com.aerospike.client.Record in project XRTB by benmfaul.
the class Membership method query.
/**
* Does the key exist in the member
* @param key Object. The key we are looking for.
* @return Boolean. Returns the object if the object exists in the membership, otherwise returns null.
*/
@Override
public Object query(Object tkey) {
if (client == null) {
if (tree.contains(tkey))
return tkey;
} else {
Record record = client.get(null, key);
Set<String> receivedList = (Set<String>) record.getValue(name);
return receivedList.contains(tkey);
}
return null;
}
Aggregations