Search in sources :

Example 56 with Record

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

the class TestAppend method prepend.

@Test
public void prepend() {
    Key key = new Key(args.namespace, args.set, "prependkey");
    String binName = args.getBinName("prependbin");
    // Delete record if it already exists.
    client.delete(null, key);
    Bin bin = new Bin(binName, "World");
    client.prepend(null, key, bin);
    bin = new Bin(binName, "Hello ");
    client.prepend(null, key, bin);
    Record record = client.get(null, key, bin.name);
    assertBinEqual(key, record, bin.name, "Hello World");
}
Also used : Bin(com.aerospike.client.Bin) Record(com.aerospike.client.Record) Key(com.aerospike.client.Key) Test(org.junit.Test)

Example 57 with Record

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

the class TestDeleteBin method deleteBin.

@Test
public void deleteBin() {
    Key key = new Key(args.namespace, args.set, "delbinkey");
    String binName1 = args.getBinName("bin1");
    String binName2 = args.getBinName("bin2");
    Bin bin1 = new Bin(binName1, "value1");
    Bin bin2 = new Bin(binName2, "value2");
    client.put(null, key, bin1, bin2);
    // Set bin value to null to drop bin.
    bin1 = Bin.asNull(binName1);
    client.put(null, key, bin1);
    Record record = client.get(null, key, bin1.name, bin2.name, "bin3");
    assertRecordFound(key, record);
    if (record.getValue("bin1") != null) {
        fail("bin1 still exists.");
    }
    Object v2 = record.getValue("bin2");
    assertNotNull(v2);
    assertEquals("value2", v2);
}
Also used : Bin(com.aerospike.client.Bin) Record(com.aerospike.client.Record) Key(com.aerospike.client.Key) Test(org.junit.Test)

Example 58 with Record

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

the class TestBitExp method and.

private void and(Key key) {
    byte[] bytes = new byte[] { (byte) 0x01 };
    policy.filterExp = Exp.build(Exp.ne(BitExp.get(Exp.val(0), Exp.val(8), BitExp.and(BitPolicy.Default, Exp.val(16), Exp.val(8), Exp.val(bytes), Exp.blobBin(binA))), BitExp.get(Exp.val(0), 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.and(BitPolicy.Default, Exp.val(16), Exp.val(8), Exp.val(bytes), Exp.blobBin(binA))), BitExp.get(Exp.val(0), Exp.val(8), Exp.blobBin(binA))));
    r = client.get(policy, key);
    assertRecordFound(key, r);
}
Also used : Record(com.aerospike.client.Record)

Example 59 with Record

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

the class TestBitExp method insert.

private void insert(Key key) {
    byte[] bytes = new byte[] { (byte) 0xff };
    int expected = 0xff;
    policy.filterExp = Exp.build(Exp.ne(BitExp.getInt(Exp.val(8), Exp.val(8), false, BitExp.insert(BitPolicy.Default, Exp.val(1), Exp.val(bytes), 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(8), Exp.val(8), false, BitExp.insert(BitPolicy.Default, Exp.val(1), Exp.val(bytes), Exp.blobBin(binA))), Exp.val(expected)));
    r = client.get(policy, key);
    assertRecordFound(key, r);
}
Also used : Record(com.aerospike.client.Record)

Example 60 with Record

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

the class TestBitExp method lshift.

private void lshift(Key key) {
    policy.filterExp = Exp.build(Exp.ne(BitExp.get(Exp.val(0), Exp.val(6), BitExp.lshift(BitPolicy.Default, Exp.val(0), Exp.val(8), Exp.val(2), Exp.blobBin(binA))), BitExp.get(Exp.val(2), Exp.val(6), 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(6), BitExp.lshift(BitPolicy.Default, Exp.val(0), Exp.val(8), Exp.val(2), Exp.blobBin(binA))), BitExp.get(Exp.val(2), Exp.val(6), Exp.blobBin(binA))));
    r = client.get(policy, key);
    assertRecordFound(key, r);
}
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