Search in sources :

Example 1 with Record

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);
}
Also used : Record(com.aerospike.client.Record)

Example 2 with 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();
    }
}
Also used : Statement(com.aerospike.client.query.Statement) Record(com.aerospike.client.Record) RecordSet(com.aerospike.client.query.RecordSet)

Example 3 with Record

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;
}
Also used : Record(com.aerospike.client.Record) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Map(java.util.Map) Key(com.aerospike.client.Key)

Example 4 with Record

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);
}
Also used : Record(com.aerospike.client.Record) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Key(com.aerospike.client.Key)

Example 5 with Record

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;
}
Also used : ConcurrentHashSet(org.eclipse.jetty.util.ConcurrentHashSet) Set(java.util.Set) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) Record(com.aerospike.client.Record)

Aggregations

Record (com.aerospike.client.Record)259 Key (com.aerospike.client.Key)140 Test (org.junit.Test)139 ArrayList (java.util.ArrayList)75 Bin (com.aerospike.client.Bin)70 AerospikeException (com.aerospike.client.AerospikeException)62 Value (com.aerospike.client.Value)54 WritePolicy (com.aerospike.client.policy.WritePolicy)47 List (java.util.List)41 HashMap (java.util.HashMap)36 ThrowingRunnable (org.junit.function.ThrowingRunnable)32 BatchPolicy (com.aerospike.client.policy.BatchPolicy)29 Policy (com.aerospike.client.policy.Policy)29 Statement (com.aerospike.client.query.Statement)23 RecordSet (com.aerospike.client.query.RecordSet)22 Expression (com.aerospike.client.exp.Expression)18 Map (java.util.Map)15 HLLValue (com.aerospike.client.Value.HLLValue)14 Collections.singletonList (java.util.Collections.singletonList)9 MapPolicy (com.aerospike.client.cdt.MapPolicy)7