Search in sources :

Example 6 with Record

use of com.aerospike.client.Record in project XRTB by benmfaul.

the class AeroRange method main.

public static void main(String[] args) throws Exception {
    AerospikeClient client = new AerospikeClient(args[0], 3000);
    String skey = "accountingsystem";
    Key key = new Key("test", "cache", skey);
    while (true) {
        Record record = null;
        record = client.get(null, key);
        String value = (String) record.bins.get("value");
        System.out.println(value);
        Thread.sleep(1000);
    }
}
Also used : AerospikeClient(com.aerospike.client.AerospikeClient) Record(com.aerospike.client.Record) Key(com.aerospike.client.Key)

Example 7 with Record

use of com.aerospike.client.Record in project XRTB by benmfaul.

the class CookieList method main.

public static void main(String[] args) throws Exception {
    int i = 0;
    String aero = "localhost:3000";
    String setName = null;
    String mapName = null;
    String op = null;
    String name = null;
    String file = null;
    boolean range = false;
    AerospikeClient client = new AerospikeClient("localhost", 3000);
    Key key = new Key("test", "database", "rtb4free");
    ArrayList<String> list = new ArrayList<String>();
    TreeSet set = new TreeSet();
    for (i = 0; i < 100000; i++) {
        list.add(Integer.toString(i));
        set.add(Integer.toString(i));
    }
    Bin bin1 = new Bin("c1x-cookies", set);
    client.put(null, key, bin1);
    System.out.println("Done!");
    Record record = client.get(null, key);
    long time = System.currentTimeMillis();
    Set<String> receivedList = (Set<String>) record.getValue("c1x-cookies");
    receivedList.contains("99999");
    System.out.println(System.currentTimeMillis() - time);
    System.out.println("Received List = " + receivedList.size());
}
Also used : AerospikeClient(com.aerospike.client.AerospikeClient) Set(java.util.Set) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) Bin(com.aerospike.client.Bin) ArrayList(java.util.ArrayList) TreeSet(java.util.TreeSet) Record(com.aerospike.client.Record) Key(com.aerospike.client.Key)

Example 8 with Record

use of com.aerospike.client.Record in project gora by apache.

the class AerospikeStore method get.

/**
 * {@inheritDoc}
 *
 * @param key    the key of the object
 * @param fields the fields required in the object. Pass null, to retrieve all fields
 * @return the Object corresponding to the key or null if it cannot be found
 */
@Override
public T get(K key, String[] fields) throws GoraException {
    try {
        Key recordKey = getAerospikeKey(key);
        fields = getFieldsToQuery(fields);
        Record record = aerospikeClient.get(aerospikeParameters.getAerospikeMapping().getReadPolicy(), recordKey, fields);
        if (record == null) {
            return null;
        }
        return createPersistentInstance(record, fields);
    } catch (GoraException e) {
        throw e;
    } catch (Exception e) {
        throw new GoraException(e);
    }
}
Also used : GoraException(org.apache.gora.util.GoraException) Record(com.aerospike.client.Record) AerospikeResultRecord(org.apache.gora.aerospike.query.AerospikeResultRecord) Key(com.aerospike.client.Key) AerospikeException(com.aerospike.client.AerospikeException) GoraException(org.apache.gora.util.GoraException) IOException(java.io.IOException)

Example 9 with Record

use of com.aerospike.client.Record in project aerospike-client-java by aerospike.

the class ScanPartitionCommand method parseRow.

@Override
protected void parseRow(Key key) {
    if ((info3 & Command.INFO3_PARTITION_DONE) != 0) {
        // specified partition will need to be requested on the scan retry.
        if (resultCode == 0) {
            tracker.partitionDone(nodePartitions, generation);
        }
        return;
    }
    if (resultCode != 0) {
        throw new AerospikeException(resultCode);
    }
    Record record = parseRecord();
    if (!valid) {
        throw new AerospikeException.ScanTerminated();
    }
    callback.scanCallback(key, record);
    tracker.setDigest(nodePartitions, key);
}
Also used : AerospikeException(com.aerospike.client.AerospikeException) Record(com.aerospike.client.Record)

Example 10 with Record

use of com.aerospike.client.Record in project aerospike-client-java by aerospike.

the class RWTaskSync method get.

@Override
protected void get(Key key) {
    Record record;
    if (counters.read.latency != null) {
        long begin = System.nanoTime();
        record = client.get(args.readPolicy, key);
        long elapsed = System.nanoTime() - begin;
        counters.read.latency.add(elapsed);
    } else {
        record = client.get(args.readPolicy, key);
    }
    processRead(key, record);
}
Also used : 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