Search in sources :

Example 16 with BitPolicy

use of com.aerospike.client.operation.BitPolicy in project aerospike-client-java by aerospike.

the class TestOperateBit method operateBitAnd.

@Test
public void operateBitAnd() {
    byte[] bits1 = new byte[] { 0x11, 0x22, 0x33 };
    BitPolicy putMode = new BitPolicy();
    assertBitModifyOperations(new byte[] { (byte) 0x80, 0x40, 0x01, 0x00, 0x00, 0x01, 0x02, 0x03 }, new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03 }, BitOperation.and(putMode, binName, 0, 5, bits1), BitOperation.and(putMode, binName, 9, 7, bits1), BitOperation.and(putMode, binName, 23, 6, bits1), BitOperation.and(putMode, binName, 32, 8, bits1), BitOperation.and(putMode, binName, 40, 24, bits1));
}
Also used : BitPolicy(com.aerospike.client.operation.BitPolicy) Test(org.junit.Test)

Example 17 with BitPolicy

use of com.aerospike.client.operation.BitPolicy in project aerospike-client-java by aerospike.

the class TestOperateBit method operateBitNot.

@Test
public void operateBitNot() {
    BitPolicy putMode = new BitPolicy();
    assertBitModifyOperations(new byte[] { (byte) 0x80, 0x40, 0x01, 0x00, 0x00, 0x01, 0x02, 0x03 }, new byte[] { 0x78, 0x3F, 0x00, (byte) 0xF8, (byte) 0xFF, (byte) 0xFE, (byte) 0xFD, (byte) 0xFC }, BitOperation.not(putMode, binName, 0, 5), BitOperation.not(putMode, binName, 9, 7), BitOperation.not(putMode, binName, 23, 6), BitOperation.not(putMode, binName, 32, 8), BitOperation.not(putMode, binName, 40, 24));
}
Also used : BitPolicy(com.aerospike.client.operation.BitPolicy) Test(org.junit.Test)

Example 18 with BitPolicy

use of com.aerospike.client.operation.BitPolicy in project aerospike-client-java by aerospike.

the class TestOperateBit method operateBitSubEx.

@Test
public void operateBitSubEx() {
    BitPolicy policy = new BitPolicy();
    int bin_sz = 15;
    int bin_bit_sz = bin_sz * 8;
    for (int set_sz = 1; set_sz <= 64; set_sz++) {
        byte[] expected = new byte[(set_sz + 7) / 8];
        long value = 0xFFFFffffFFFFffffl >> (64 - set_sz);
        for (int offset = 0; offset <= (bin_bit_sz - set_sz); offset++) {
            assertBitModifyRegion(bin_sz, offset, set_sz, expected, BitOperation.subtract(policy, binName, offset, set_sz, value, false, BitOverflowAction.WRAP));
        }
    }
}
Also used : BitPolicy(com.aerospike.client.operation.BitPolicy) Test(org.junit.Test)

Example 19 with BitPolicy

use of com.aerospike.client.operation.BitPolicy in project aerospike-client-java by aerospike.

the class TestOperateBit method operateBitAndEx.

@Test
public void operateBitAndEx() {
    BitPolicy policy = new BitPolicy();
    int bin_sz = 15;
    int bin_bit_sz = bin_sz * 8;
    for (int set_sz = 1; set_sz <= 80; set_sz++) {
        byte[] set_data = new byte[(set_sz + 7) / 8];
        for (int offset = 0; offset <= (bin_bit_sz - set_sz); offset++) {
            assertBitModifyRegion(bin_sz, offset, set_sz, set_data, BitOperation.and(policy, binName, offset, set_sz, set_data));
        }
    }
}
Also used : BitPolicy(com.aerospike.client.operation.BitPolicy) Test(org.junit.Test)

Example 20 with BitPolicy

use of com.aerospike.client.operation.BitPolicy in project aerospike-client-java by aerospike.

the class TestOperateBit method operateBitRShift.

@Test
public void operateBitRShift() {
    BitPolicy putMode = new BitPolicy();
    assertBitModifyOperations(new byte[] { (byte) 0x80, 0x40, 0x01, 0x00, (byte) 0xFF, 0x01, 0x01, 0x18, (byte) 0x80 }, new byte[] { 0x40, 0x01, 0x00, (byte) 0x80, (byte) 0xF8, (byte) 0xE0, 0x21, 0x14, (byte) 0x80 }, BitOperation.rshift(putMode, binName, 0, 8, 1), BitOperation.rshift(putMode, binName, 9, 7, 6), BitOperation.rshift(putMode, binName, 23, 2, 1), BitOperation.rshift(putMode, binName, 37, 18, 3), BitOperation.rshift(putMode, binName, 60, 2, 1), BitOperation.rshift(putMode, binName, 68, 4, 7));
}
Also used : BitPolicy(com.aerospike.client.operation.BitPolicy) Test(org.junit.Test)

Aggregations

BitPolicy (com.aerospike.client.operation.BitPolicy)21 Test (org.junit.Test)21 Bin (com.aerospike.client.Bin)3 Record (com.aerospike.client.Record)1