Package com.aerospike.client.exp
Class BitExp
java.lang.Object
com.aerospike.client.exp.BitExp
Bit expression generator. See
Exp
.
The bin expression argument in these methods can be a reference to a bin or the result of another expression. Expressions that modify bin values are only used for temporary expression evaluation and are not permanently applied to the bin. Bit modify expressions return the blob bin's value.
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.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Exp
add
(BitPolicy policy, Exp bitOffset, Exp bitSize, Exp value, boolean signed, BitOverflowAction action, Exp bin) Create expression that adds value to byte[] bin starting at bitOffset for bitSize and returns byte[].static Exp
Create expression that performs bitwise "and" on value and byte[] bin at bitOffset for bitSize and returns byte[].static Exp
Create expression that returns integer count of set bits from byte[] bin starting at bitOffset for bitSize.static Exp
Create expression that returns bits from byte[] bin starting at bitOffset for bitSize.static Exp
Create expression that returns integer from byte[] bin starting at bitOffset for bitSize.static Exp
Create expression that inserts value bytes into byte[] bin at byteOffset and returns byte[].static Exp
Create expression that returns integer bit offset of the first specified value bit in byte[] bin starting at bitOffset for bitSize.static Exp
Create expression that shifts left byte[] bin starting at bitOffset for bitSize and returns byte[].static Exp
Create expression that negates byte[] bin starting at bitOffset for bitSize and returns byte[].static Exp
Create expression that performs bitwise "or" on value and byte[] bin at bitOffset for bitSize and returns byte[].static Exp
Create expression that removes bytes from byte[] bin at byteOffset for byteSize and returns byte[].static Exp
Create expression that resizes byte[] to byteSize according to resizeFlags (SeeBitResizeFlags
) and returns byte[].static Exp
Create expression that returns integer bit offset of the last specified value bit in byte[] bin starting at bitOffset for bitSize.static Exp
Create expression that shifts right byte[] bin starting at bitOffset for bitSize and returns byte[].static Exp
Create expression that sets value on byte[] bin at bitOffset for bitSize and returns byte[].static Exp
Create expression that sets value to byte[] bin starting at bitOffset for bitSize and returns byte[].static Exp
subtract
(BitPolicy policy, Exp bitOffset, Exp bitSize, Exp value, boolean signed, BitOverflowAction action, Exp bin) Create expression that subtracts value from byte[] bin starting at bitOffset for bitSize and returns byte[].static Exp
Create expression that performs bitwise "xor" on value and byte[] bin at bitOffset for bitSize and returns byte[].
-
Constructor Details
-
BitExp
public BitExp()
-
-
Method Details
-
resize
Create expression that resizes byte[] to byteSize according to resizeFlags (SeeBitResizeFlags
) and returns byte[].- bin = [0b00000001, 0b01000010]
- byteSize = 4
- resizeFlags = 0
- returns [0b00000001, 0b01000010, 0b00000000, 0b00000000]
// Resize bin "a" and compare bit count Exp.eq( BitExp.count(Exp.val(0), Exp.val(3), BitExp.resize(BitPolicy.Default, Exp.val(4), 0, Exp.blobBin("a"))), Exp.val(2))
-
insert
Create expression that inserts value bytes into byte[] bin at byteOffset and returns byte[].- bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
- byteOffset = 1
- value = [0b11111111, 0b11000111]
- bin result = [0b00000001, 0b11111111, 0b11000111, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
// Insert bytes into bin "a" and compare bit count Exp.eq( BitExp.count(Exp.val(0), Exp.val(3), BitExp.insert(BitPolicy.Default, Exp.val(1), Exp.val(bytes), Exp.blobBin("a"))), Exp.val(2))
-
remove
Create expression that removes bytes from byte[] bin at byteOffset for byteSize and returns byte[].- bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
- byteOffset = 2
- byteSize = 3
- bin result = [0b00000001, 0b01000010]
// Remove bytes from bin "a" and compare bit count Exp.eq( BitExp.count(Exp.val(0), Exp.val(3), BitExp.remove(BitPolicy.Default, Exp.val(2), Exp.val(3), Exp.blobBin("a"))), Exp.val(2))
-
set
Create expression that sets value on byte[] bin at bitOffset for bitSize and returns byte[].- bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
- bitOffset = 13
- bitSize = 3
- value = [0b11100000]
- bin result = [0b00000001, 0b01000111, 0b00000011, 0b00000100, 0b00000101]
// Set bytes in bin "a" and compare bit count Exp.eq( BitExp.count(Exp.val(0), Exp.val(3), BitExp.set(BitPolicy.Default, Exp.val(13), Exp.val(3), Exp.val(bytes), Exp.blobBin("a"))), Exp.val(2))
-
or
Create expression that performs bitwise "or" on value and byte[] bin at bitOffset for bitSize and returns byte[].- bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
- bitOffset = 17
- bitSize = 6
- value = [0b10101000]
- bin result = [0b00000001, 0b01000010, 0b01010111, 0b00000100, 0b00000101]
-
xor
Create expression that performs bitwise "xor" on value and byte[] bin at bitOffset for bitSize and returns byte[].- bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
- bitOffset = 17
- bitSize = 6
- value = [0b10101100]
- bin result = [0b00000001, 0b01000010, 0b01010101, 0b00000100, 0b00000101]
-
and
Create expression that performs bitwise "and" on value and byte[] bin at bitOffset for bitSize and returns byte[].- bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
- bitOffset = 23
- bitSize = 9
- value = [0b00111100, 0b10000000]
- bin result = [0b00000001, 0b01000010, 0b00000010, 0b00000000, 0b00000101]
-
not
Create expression that negates byte[] bin starting at bitOffset for bitSize and returns byte[].- bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
- bitOffset = 25
- bitSize = 6
- bin result = [0b00000001, 0b01000010, 0b00000011, 0b01111010, 0b00000101]
-
lshift
Create expression that shifts left byte[] bin starting at bitOffset for bitSize and returns byte[].- bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
- bitOffset = 32
- bitSize = 8
- shift = 3
- bin result = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00101000]
-
rshift
Create expression that shifts right byte[] bin starting at bitOffset for bitSize and returns byte[].- bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
- bitOffset = 0
- bitSize = 9
- shift = 1
- bin result = [0b00000000, 0b11000010, 0b00000011, 0b00000100, 0b00000101]
-
add
public static Exp add(BitPolicy policy, Exp bitOffset, Exp bitSize, Exp value, boolean signed, BitOverflowAction action, Exp bin) Create expression that adds value to byte[] bin starting at bitOffset for bitSize and returns byte[]. BitSize must be <= 64. Signed indicates if bits should be treated as a signed number. If add overflows/underflows,BitOverflowAction
is used.- bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
- bitOffset = 24
- bitSize = 16
- value = 128
- signed = false
- bin result = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b10000101]
-
subtract
public static Exp subtract(BitPolicy policy, Exp bitOffset, Exp bitSize, Exp value, boolean signed, BitOverflowAction action, Exp bin) Create expression that subtracts value from byte[] bin starting at bitOffset for bitSize and returns byte[]. BitSize must be <= 64. Signed indicates if bits should be treated as a signed number. If add overflows/underflows,BitOverflowAction
is used.- bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
- bitOffset = 24
- bitSize = 16
- value = 128
- signed = false
- bin result = [0b00000001, 0b01000010, 0b00000011, 0b0000011, 0b10000101]
-
setInt
Create expression that sets value to byte[] bin starting at bitOffset for bitSize and returns byte[]. BitSize must be <= 64.- bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
- bitOffset = 1
- bitSize = 8
- value = 127
- bin result = [0b00111111, 0b11000010, 0b00000011, 0b0000100, 0b00000101]
-
get
Create expression that returns bits from byte[] bin starting at bitOffset for bitSize.- bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
- bitOffset = 9
- bitSize = 5
- returns [0b10000000]
// Bin "a" bits = [0b10000000] Exp.eq( BitExp.get(Exp.val(9), Exp.val(5), Exp.blobBin("a")), Exp.val(new byte[] {(byte)0b10000000}))
-
count
Create expression that returns integer count of set bits from byte[] bin starting at bitOffset for bitSize.- bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
- bitOffset = 20
- bitSize = 4
- returns 2
// Bin "a" bit count <= 2 Exp.le(BitExp.count(Exp.val(0), Exp.val(5), Exp.blobBin("a")), Exp.val(2))
-
lscan
Create expression that returns integer bit offset of the first specified value bit in byte[] bin starting at bitOffset for bitSize.- bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
- bitOffset = 24
- bitSize = 8
- value = true
- returns 5
// lscan(a) == 5 Exp.eq(BitExp.lscan(Exp.val(24), Exp.val(8), Exp.val(true), Exp.blobBin("a")), Exp.val(5))
- Parameters:
bitOffset
- offset int expressionbitSize
- size int expressionvalue
- boolean expressionbin
- bin or blob value expression
-
rscan
Create expression that 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
// rscan(a) == 7 Exp.eq(BitExp.rscan(Exp.val(32), Exp.val(8), Exp.val(true), Exp.blobBin("a")), Exp.val(7))
- Parameters:
bitOffset
- offset int expressionbitSize
- size int expressionvalue
- boolean expressionbin
- bin or blob value expression
-
getInt
Create expression that returns integer from byte[] bin starting at bitOffset for bitSize. Signed indicates if bits should be treated as a signed number.- bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
- bitOffset = 8
- bitSize = 16
- signed = false
- returns 16899
// getInt(a) == 16899 Exp.eq(BitExp.getInt(Exp.val(8), Exp.val(16), false, Exp.blobBin("a")), Exp.val(16899))
-