use of com.aerospike.client.operation.BitPolicy in project aerospike-client-java by aerospike.
the class TestOperateBit method operateBitAddEx.
@Test
public void operateBitAddEx() {
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[] 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.add(policy, binName, offset, set_sz, 1, false, BitOverflowAction.WRAP));
}
}
}
use of com.aerospike.client.operation.BitPolicy in project aerospike-client-java by aerospike.
the class TestOperateBit method operateBitSet.
@Test
public void operateBitSet() {
BitPolicy putMode = new BitPolicy();
byte[] bit0 = new byte[] { (byte) 0x80 };
byte[] bits1 = new byte[] { 0x11, 0x22, 0x33 };
assertBitModifyOperations(new byte[] { 0x01, 0x12, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x41 }, new byte[] { 0x41, 0x13, 0x11, 0x22, 0x33, 0x11, 0x22, 0x33, 0x08, 0x08, (byte) 0x91, 0x1B, 0X01, 0x12, 0x23, 0x11, 0x22, 0x11, (byte) 0xc1 }, BitOperation.set(putMode, binName, 1, 1, bit0), BitOperation.set(putMode, binName, 15, 1, bit0), // Y Y Y
BitOperation.set(putMode, binName, 16, 24, bits1), // N Y N
BitOperation.set(putMode, binName, 40, 22, bits1), // N N N
BitOperation.set(putMode, binName, 73, 21, bits1), // Y N N
BitOperation.set(putMode, binName, 100, 20, bits1), // N Y N
BitOperation.set(putMode, binName, 120, 17, bits1), BitOperation.set(putMode, binName, 144, 1, bit0));
}
use of com.aerospike.client.operation.BitPolicy in project aerospike-client-java by aerospike.
the class TestOperateBit method operateBitRShiftEx.
@Test
public void operateBitRShiftEx() {
BitPolicy policy = new BitPolicy();
BitPolicy partial_policy = new BitPolicy(BitWriteFlags.PARTIAL);
int bin_sz = 15;
int bin_bit_sz = bin_sz * 8;
for (int set_sz = 1; set_sz <= 4; set_sz++) {
byte[] set_data = new byte[(set_sz + 7) / 8];
for (int offset = 0; offset <= (bin_bit_sz - set_sz); offset++) {
int limit = set_sz < 16 ? set_sz + 1 : 16;
for (int n_bits = 0; n_bits <= limit; n_bits++) {
assertBitModifyRegion(bin_sz, offset, set_sz, set_data, BitOperation.set(policy, binName, offset, set_sz, set_data), BitOperation.rshift(policy, binName, offset, set_sz, n_bits));
}
for (int n_bits = 63; n_bits <= set_sz; n_bits++) {
assertBitModifyRegion(bin_sz, offset, set_sz, set_data, BitOperation.set(policy, binName, offset, set_sz, set_data), BitOperation.rshift(policy, binName, offset, set_sz, n_bits));
}
}
// Test Partial
int n_bits = 1;
for (int offset = bin_bit_sz - set_sz + 1; offset < bin_bit_sz; offset++) {
int actual_set_sz = bin_bit_sz - offset;
byte[] actual_set_data = new byte[(actual_set_sz + 7) / 8];
assertBitModifyRegion(bin_sz, offset, actual_set_sz, actual_set_data, BitOperation.set(partial_policy, binName, offset, set_sz, set_data), BitOperation.rshift(partial_policy, binName, offset, set_sz, n_bits));
}
}
}
use of com.aerospike.client.operation.BitPolicy in project aerospike-client-java by aerospike.
the class TestOperateBit method operateBitNotEx.
@Test
public void operateBitNotEx() {
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.not(policy, binName, offset, set_sz));
}
}
}
use of com.aerospike.client.operation.BitPolicy in project aerospike-client-java by aerospike.
the class TestOperateBit method operateBitSetEx.
@Test
public void operateBitSetEx() {
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.set(policy, binName, offset, set_sz, set_data));
}
}
}