Search in sources :

Example 61 with Record

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

the class TestBitExp method set.

private void set(Key key) {
    byte[] bytes = new byte[] { (byte) 0x80 };
    policy.filterExp = Exp.build(Exp.ne(BitExp.get(Exp.val(24), Exp.val(8), BitExp.set(BitPolicy.Default, Exp.val(31), Exp.val(1), Exp.val(bytes), Exp.blobBin(binA))), BitExp.get(Exp.val(32), Exp.val(8), Exp.blobBin(binA))));
    Record r = client.get(policy, key);
    assertEquals(null, r);
    policy.filterExp = Exp.build(Exp.eq(BitExp.get(Exp.val(24), Exp.val(8), BitExp.set(BitPolicy.Default, Exp.val(31), Exp.val(1), Exp.val(bytes), Exp.blobBin(binA))), BitExp.get(Exp.val(32), Exp.val(8), Exp.blobBin(binA))));
    r = client.get(policy, key);
    assertRecordFound(key, r);
}
Also used : Record(com.aerospike.client.Record)

Example 62 with Record

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

the class TestBitExp method xor.

private void xor(Key key) {
    byte[] bytes = new byte[] { (byte) 0x02 };
    policy.filterExp = Exp.build(Exp.ne(BitExp.get(Exp.val(0), Exp.val(8), BitExp.xor(BitPolicy.Default, Exp.val(0), Exp.val(8), Exp.val(bytes), Exp.blobBin(binA))), BitExp.get(Exp.val(16), Exp.val(8), Exp.blobBin(binA))));
    Record r = client.get(policy, key);
    assertEquals(null, r);
    policy.filterExp = Exp.build(Exp.eq(BitExp.get(Exp.val(0), Exp.val(8), BitExp.xor(BitPolicy.Default, Exp.val(0), Exp.val(8), Exp.val(bytes), Exp.blobBin(binA))), BitExp.get(Exp.val(16), Exp.val(8), Exp.blobBin(binA))));
    r = client.get(policy, key);
    assertRecordFound(key, r);
}
Also used : Record(com.aerospike.client.Record)

Example 63 with Record

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

the class TestBitExp method remove.

private void remove(Key key) {
    int expected = 0x42;
    policy.filterExp = Exp.build(Exp.ne(BitExp.getInt(Exp.val(0), Exp.val(8), false, BitExp.remove(BitPolicy.Default, Exp.val(0), Exp.val(1), Exp.blobBin(binA))), Exp.val(expected)));
    Record r = client.get(policy, key);
    assertEquals(null, r);
    policy.filterExp = Exp.build(Exp.eq(BitExp.getInt(Exp.val(0), Exp.val(8), false, BitExp.remove(BitPolicy.Default, Exp.val(0), Exp.val(1), Exp.blobBin(binA))), Exp.val(expected)));
    r = client.get(policy, key);
    assertRecordFound(key, r);
}
Also used : Record(com.aerospike.client.Record)

Example 64 with Record

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

the class TestBitExp method resize.

private void resize(Key key) {
    Exp size = Exp.val(6);
    policy.filterExp = Exp.build(Exp.ne(BitExp.resize(BitPolicy.Default, size, 0, Exp.blobBin(binA)), BitExp.resize(BitPolicy.Default, size, 0, Exp.blobBin(binA))));
    Record r = client.get(policy, key);
    assertEquals(null, r);
    policy.filterExp = Exp.build(Exp.eq(BitExp.resize(BitPolicy.Default, size, 0, Exp.blobBin(binA)), BitExp.resize(BitPolicy.Default, size, 0, Exp.blobBin(binA))));
    r = client.get(policy, key);
    assertRecordFound(key, r);
}
Also used : Record(com.aerospike.client.Record) Exp(com.aerospike.client.exp.Exp) BitExp(com.aerospike.client.exp.BitExp)

Example 65 with Record

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

the class TestOperateHll method operateGetUnion.

@Test
public void operateGetUnion() {
    int nIndexBits = 14;
    long expectedUnionCount = 0;
    ArrayList<List<Value>> vals = new ArrayList<List<Value>>();
    List<HLLValue> hlls = new ArrayList<HLLValue>();
    for (int i = 0; i < keys.length; i++) {
        ArrayList<Value> subVals = new ArrayList<Value>();
        for (int j = 0; j < nEntries / 3; j++) {
            subVals.add(new StringValue("key" + i + " " + j));
        }
        Record record = assertSuccess("init other keys", keys[i], Operation.delete(), HLLOperation.add(HLLPolicy.Default, binName, subVals, nIndexBits), Operation.get(binName));
        List<?> resultList = record.getList(binName);
        hlls.add((HLLValue) resultList.get(1));
        expectedUnionCount += subVals.size();
        vals.add(subVals);
    }
    // Keep record around win binName is removed.
    assertSuccess("other bin", key, Operation.delete(), HLLOperation.init(HLLPolicy.Default, binName + "other", nIndexBits), HLLOperation.add(HLLPolicy.Default, binName, vals.get(0), nIndexBits));
    Record record = assertSuccess("union and unionCount", key, HLLOperation.getUnion(binName, hlls), HLLOperation.getUnionCount(binName, hlls));
    List<?> resultList = record.getList(binName);
    long unionCount = (Long) resultList.get(1);
    assertHLLCount("verify union count", nIndexBits, unionCount, expectedUnionCount);
    HLLValue unionHll = (HLLValue) resultList.get(0);
    record = assertSuccess("", key, Operation.put(new Bin(binName, unionHll)), HLLOperation.getCount(binName));
    resultList = record.getList(binName);
    long unionCount2 = (Long) resultList.get(1);
    assertEquals("unions equal", unionCount, unionCount2);
}
Also used : HLLValue(com.aerospike.client.Value.HLLValue) Bin(com.aerospike.client.Bin) ArrayList(java.util.ArrayList) HLLValue(com.aerospike.client.Value.HLLValue) StringValue(com.aerospike.client.Value.StringValue) Value(com.aerospike.client.Value) ArrayList(java.util.ArrayList) List(java.util.List) Record(com.aerospike.client.Record) StringValue(com.aerospike.client.Value.StringValue) Test(org.junit.Test)

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