Package com.aerospike.client.operation
Class BitOperation
java.lang.Object
com.aerospike.client.operation.BitOperation
Bit operations. Create bit operations used by client operate command.
Offset orientation is left-to-right. Negative offsets are supported.
If the offset is negative, the offset starts backwards from end of the bitmap.
If an offset is out of bounds, a parameter error will be returned.
Bit operations on bitmap items nested in lists/maps are not currently supported by the server.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Operation
add
(BitPolicy policy, String binName, int bitOffset, int bitSize, long value, boolean signed, BitOverflowAction action) Create bit "add" operation.static Operation
Create bit "and" operation.static Operation
Create bit "count" operation.static Operation
Create bit "get" operation.static Operation
Create bit "get integer" operation.static Operation
Create byte "insert" operation.static Operation
Create bit "left scan" operation.static Operation
Create bit "left shift" operation.static Operation
Create bit "not" operation.static Operation
Create bit "or" operation.static Operation
Create byte "remove" operation.static Operation
Create byte "resize" operation.static Operation
Create bit "right scan" operation.static Operation
Create bit "right shift" operation.static Operation
Create bit "set" operation.static Operation
Create bit "setInt" operation.static Operation
subtract
(BitPolicy policy, String binName, int bitOffset, int bitSize, long value, boolean signed, BitOverflowAction action) Create bit "subtract" operation.static Operation
Create bit "exclusive or" operation.
-
Constructor Details
-
BitOperation
public BitOperation()
-
-
Method Details
-
resize
Create byte "resize" operation. Server resizes byte[] to byteSize according to resizeFlags (SeeBitResizeFlags
). Server does not return a value. Example:- bin = [0b00000001, 0b01000010]
- byteSize = 4
- resizeFlags = 0
- bin result = [0b00000001, 0b01000010, 0b00000000, 0b00000000]
-
insert
Create byte "insert" operation. Server inserts value bytes into byte[] bin at byteOffset. Server does not return a value. Example:- bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
- byteOffset = 1
- value = [0b11111111, 0b11000111]
- bin result = [0b00000001, 0b11111111, 0b11000111, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
-
remove
Create byte "remove" operation. Server removes bytes from byte[] bin at byteOffset for byteSize. Server does not return a value. Example:- bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
- byteOffset = 2
- byteSize = 3
- bin result = [0b00000001, 0b01000010]
-
set
public static Operation set(BitPolicy policy, String binName, int bitOffset, int bitSize, byte[] value) Create bit "set" operation. Server sets value on byte[] bin at bitOffset for bitSize. Server does not return a value. Example:- bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
- bitOffset = 13
- bitSize = 3
- value = [0b11100000]
- bin result = [0b00000001, 0b01000111, 0b00000011, 0b00000100, 0b00000101]
-
or
public static Operation or(BitPolicy policy, String binName, int bitOffset, int bitSize, byte[] value) Create bit "or" operation. Server performs bitwise "or" on value and byte[] bin at bitOffset for bitSize. Server does not return a value. Example:- bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
- bitOffset = 17
- bitSize = 6
- value = [0b10101000]
- bin result = [0b00000001, 0b01000010, 0b01010111, 0b00000100, 0b00000101]
-
xor
public static Operation xor(BitPolicy policy, String binName, int bitOffset, int bitSize, byte[] value) Create bit "exclusive or" operation. Server performs bitwise "xor" on value and byte[] bin at bitOffset for bitSize. Server does not return a value. Example:- bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
- bitOffset = 17
- bitSize = 6
- value = [0b10101100]
- bin result = [0b00000001, 0b01000010, 0b01010101, 0b00000100, 0b00000101]
-
and
public static Operation and(BitPolicy policy, String binName, int bitOffset, int bitSize, byte[] value) Create bit "and" operation. Server performs bitwise "and" on value and byte[] bin at bitOffset for bitSize. Server does not return a value. Example:- bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
- bitOffset = 23
- bitSize = 9
- value = [0b00111100, 0b10000000]
- bin result = [0b00000001, 0b01000010, 0b00000010, 0b00000000, 0b00000101]
-
not
Create bit "not" operation. Server negates byte[] bin starting at bitOffset for bitSize. Server does not return a value. Example:- bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
- bitOffset = 25
- bitSize = 6
- bin result = [0b00000001, 0b01000010, 0b00000011, 0b01111010, 0b00000101]
-
lshift
public static Operation lshift(BitPolicy policy, String binName, int bitOffset, int bitSize, int shift) Create bit "left shift" operation. Server shifts left byte[] bin starting at bitOffset for bitSize. Server does not return a value. Example:- bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
- bitOffset = 32
- bitSize = 8
- shift = 3
- bin result = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00101000]
-
rshift
public static Operation rshift(BitPolicy policy, String binName, int bitOffset, int bitSize, int shift) Create bit "right shift" operation. Server shifts right byte[] bin starting at bitOffset for bitSize. Server does not return a value. Example:- bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
- bitOffset = 0
- bitSize = 9
- shift = 1
- bin result = [0b00000000, 0b11000010, 0b00000011, 0b00000100, 0b00000101]
-
add
public static Operation add(BitPolicy policy, String binName, int bitOffset, int bitSize, long value, boolean signed, BitOverflowAction action) Create bit "add" operation. Server adds value to byte[] bin starting at bitOffset for bitSize. BitSize must be <= 64. Signed indicates if bits should be treated as a signed number. If add overflows/underflows,BitOverflowAction
is used. Server does not return a value. Example:- bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
- bitOffset = 24
- bitSize = 16
- value = 128
- signed = false
- bin result = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b10000101]
-
subtract
public static Operation subtract(BitPolicy policy, String binName, int bitOffset, int bitSize, long value, boolean signed, BitOverflowAction action) Create bit "subtract" operation. Server subtracts value from byte[] bin starting at bitOffset for bitSize. BitSize must be <= 64. Signed indicates if bits should be treated as a signed number. If add overflows/underflows,BitOverflowAction
is used. Server does not return a value. Example:- bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
- bitOffset = 24
- bitSize = 16
- value = 128
- signed = false
- bin result = [0b00000001, 0b01000010, 0b00000011, 0b0000011, 0b10000101]
-
setInt
public static Operation setInt(BitPolicy policy, String binName, int bitOffset, int bitSize, long value) Create bit "setInt" operation. Server sets value to byte[] bin starting at bitOffset for bitSize. Size must be <= 64. Server does not return a value. Example:- bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
- bitOffset = 1
- bitSize = 8
- value = 127
- bin result = [0b00111111, 0b11000010, 0b00000011, 0b0000100, 0b00000101]
-
get
Create bit "get" operation. Server returns bits from byte[] bin starting at bitOffset for bitSize. Example:- bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
- bitOffset = 9
- bitSize = 5
- returns [0b10000000]
-
count
Create bit "count" operation. Server returns integer count of set bits from byte[] bin starting at bitOffset for bitSize. Example:- bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
- bitOffset = 20
- bitSize = 4
- returns 2
-
lscan
Create bit "left scan" operation. Server returns integer bit offset of the first specified value bit in byte[] bin starting at bitOffset for bitSize. Example:- bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
- bitOffset = 24
- bitSize = 8
- value = true
- returns 5
-
rscan
Create bit "right scan" operation. Server returns integer bit offset of the last specified value bit in byte[] bin starting at bitOffset for bitSize. Example:- bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
- bitOffset = 32
- bitSize = 8
- value = true
- returns 7
-
getInt
Create bit "get integer" operation. Server returns integer from byte[] bin starting at bitOffset for bitSize. Signed indicates if bits should be treated as a signed number. Example:- bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
- bitOffset = 8
- bitSize = 16
- signed = false
- returns 16899
-