Bit expressions
For the complete documentation index see: llms.txt
All documentation pages available in markdown.
Bit expressions read and modify blob (bytes) values inside an expression tree: reading bit ranges, counting and scanning bits, resizing or patching bytes, and applying bitwise math without round-tripping the whole blob to the client. For the data type itself and its Operate API, see Blob (bytes).
Read expressions (bit_get, bit_count, bit_lscan, …) evaluate to an integer, a blob, or a string. That makes them projection: they shape what a command returns for each record, in operate, in a batch, and in a query. Wrap one in comparison or logic to get the Boolean a record filter needs.
Modify expressions (bit_set, bit_add, bit_insert, …) evaluate to a new blob and leave the record untouched. Storing that value takes a write operation expression; see Operations and expressions for how the two APIs differ.
A blob operand is a bin, read with bin_blob, or any expression that evaluates to a blob. Reading stored data can evaluate to unknown; see Unknown results.
The examples use a blob bin device_flags holding [0x01, 0x42, 0x03, 0x04, 0x05]; bit_b64_encode uses the Blob reference’s flags, [0x01, 0x42, 0xB0, 0x04, 0x05].
The Developer SDK’s AEL text syntax exposes the same bit/blob functions as path methods, for example $.header.bitGetInt(offset: 0, size: 16). See BLOB (bit) path functions.
Composing expressions
An expression evaluates to a value, and that value is what the next expression operates on — see Expressions compose.
Every bit operation takes its bin operand that way: not only a named blob bin, but the result of any expression evaluating to a blob. bit_set shows the pattern — its example reads the result of a bit_set back with bit_get, so the read sees the patched blob while the record keeps the original.
Each operation’s Example shows the code in nine tabs: Aerospike Expression Language (AEL) text on the Java SDK and Python SDK tabs, and the Exp builder on the other seven. See the AEL reference for AEL grammar.
Modify
bit_add(policy, bit_offset, bit_size, value, signed, action, bin)Returns the blob with value added to the bit_size-bit big-endian integer starting at bit_offset, read as signed or unsigned according to signed. The rest of the blob is unchanged, and its length does not change.
| Name | Type | Description |
|---|---|---|
policy | Bit policy | Write policy for the transform. Supplied by your client as a blob or bitwise policy object. |
bit_offset | integer | Offset in bits from the start of the blob to the first bit of the region being added to. |
bit_size | integer | Width of the region in bits, up to 64. This is the width of the integer the addition is performed on, not the width of |
value | integer | Integer to add. It is converted to a |
signed | boolean literal | Whether the region is read as a signed or an unsigned integer. This does not change the arithmetic; it decides where the limits sit, and so which results count as overflow. In an 8-bit region, adding 1 to |
action | Overflow action | What happens when the addition crosses the region’s limit: fail, which is the default; saturate at the limit; or wrap around past it. Which values count as crossing depends on |
bin | blob | Blob bin to operate on, or any expression that evaluates to a blob. |
blob Filter where adding 1 to the unsigned 8-bit field at bit offset 16 (overflow FAIL) matches reading the next byte at offset 24.
String exp = "$.device_flags.bitAdd(offset: 16, size: 8, value: 1)" + ".bitGet(offset: 16, size: 8)" + " == $.device_flags.bitGet(offset: 24, size: 8)";exp = ("$.device_flags.bitAdd(offset: 16, size: 8, value: 1)" ".bitGet(offset: 16, size: 8)" " == $.device_flags.bitGet(offset: 24, size: 8)")use aerospike::expressions::bitwise as bit_exp;use aerospike::expressions::{blob_bin, eq, int_val};use aerospike::operations::bitwise::{BitPolicy, BitwiseOverflowActions};
let exp = eq( bit_exp::get( int_val(16), int_val(8), bit_exp::add( &BitPolicy::default(), int_val(16), int_val(8), int_val(1), false, BitwiseOverflowActions::Fail, blob_bin("device_flags".into()))), bit_exp::get(int_val(24), int_val(8), blob_bin("device_flags".into())));Expression exp = Exp.Build( Exp.EQ( BitExp.Get( Exp.Val(16), Exp.Val(8), BitExp.Add( BitPolicy.Default, Exp.Val(16), Exp.Val(8), Exp.Val(1), false, BitOverflowAction.FAIL, Exp.BlobBin("device_flags"))), BitExp.Get(Exp.Val(24), Exp.Val(8), Exp.BlobBin("device_flags"))));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"bin := as.ExpBlobBin("device_flags")exp := as.ExpEq( as.ExpBitGet( as.ExpIntVal(16), as.ExpIntVal(8), as.ExpBitAdd( as.DefaultBitPolicy(), as.ExpIntVal(16), as.ExpIntVal(8), as.ExpIntVal(1), false, as.BitOverflowActionFail, bin, ), ), as.ExpBitGet(as.ExpIntVal(24), as.ExpIntVal(8), bin),)const exp = Aerospike.expconst bits = Aerospike.bitwiseconst bin = exp.binBlob('device_flags')
const filterExp = exp.eq( exp.bit.get( exp.bit.add(bin, bits.overflow.FAIL, exp.int(1), exp.int(8), exp.int(16)), exp.int(8), exp.int(16), ), exp.bit.get(bin, exp.int(8), exp.int(24)),)as_exp_build(predexp, as_exp_cmp_eq( as_exp_bit_get( as_exp_int(16), as_exp_int(8), as_exp_bit_add( NULL, as_exp_int(16), as_exp_int(8), as_exp_int(1), AS_BIT_OVERFLOW_FAIL, as_exp_bin_blob("device_flags"))), as_exp_bit_get(as_exp_int(24), as_exp_int(8), as_exp_bin_blob("device_flags"))));import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;import com.aerospike.client.operation.BitOverflowAction;import com.aerospike.client.operation.BitPolicy;
Expression exp = Exp.build( Exp.eq( BitExp.get( Exp.val(16), Exp.val(8), BitExp.add( BitPolicy.Default, Exp.val(16), Exp.val(8), Exp.val(1), false, BitOverflowAction.FAIL, Exp.blobBin("device_flags"))), BitExp.get(Exp.val(24), Exp.val(8), Exp.blobBin("device_flags"))));import aerospikefrom aerospike_helpers.expressions import BlobBin, Eqfrom aerospike_helpers.expressions.bitwise import BitAdd, BitGet
b = BlobBin("device_flags")exp = Eq(BitGet(16, 8, BitAdd(None, 16, 8, 1, aerospike.BIT_OVERFLOW_FAIL, b)), BitGet(24, 8, b)).compile()bit_and(policy, bit_offset, bit_size, value, bin)Returns the blob with the bit_size bits at bit_offset replaced by their bitwise AND with value. The rest of the blob is unchanged, and its length does not change.
| Name | Type | Description |
|---|---|---|
policy | Bit policy | Write policy for the transform. Supplied by your client as a blob or bitwise policy object. |
bit_offset | integer | Offset in bits from the start of the blob to the first bit of the region. |
bit_size | integer | Width of the region in bits. |
value | blob | Blob supplying the bits to AND with. Must be at least |
bin | blob | Blob bin to operate on, or any expression that evaluates to a blob. |
blob Filter where AND-ing bits 16–23 (0x03) with 0x01 leaves 0x01.
String exp = "$.device_flags.bitAnd(offset: 16, size: 8, value: x'01')" + ".bitGet(offset: 16, size: 8) == x'01'";exp = ("$.device_flags.bitAnd(offset: 16, size: 8, value: x'01')" ".bitGet(offset: 16, size: 8) == x'01'")use aerospike::expressions::bitwise as bit_exp;use aerospike::expressions::{blob_bin, blob_val, eq, int_val};use aerospike::operations::bitwise::{BitPolicy};
let exp = eq( bit_exp::get( int_val(16), int_val(8), bit_exp::and( &BitPolicy::default(), int_val(16), int_val(8), blob_val(vec![0x01]), blob_bin("device_flags".into()))), blob_val(vec![0x01]));Expression exp = Exp.Build( Exp.EQ( BitExp.Get( Exp.Val(16), Exp.Val(8), BitExp.And( BitPolicy.Default, Exp.Val(16), Exp.Val(8), Exp.Val(new byte[] {0x01}), Exp.BlobBin("device_flags"))), Exp.Val(new byte[] {0x01})));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"bin := as.ExpBlobBin("device_flags")exp := as.ExpEq( as.ExpBitGet( as.ExpIntVal(16), as.ExpIntVal(8), as.ExpBitAnd(as.DefaultBitPolicy(), as.ExpIntVal(16), as.ExpIntVal(8), as.ExpBlobVal([]byte{0x01}), bin), ), as.ExpBlobVal([]byte{0x01}),)const exp = Aerospike.expconst bin = exp.binBlob('device_flags')
const filterExp = exp.eq( exp.bit.get(exp.bit.and(bin, exp.bytes(Buffer.from([0x01])), exp.int(8), exp.int(16)), exp.int(8), exp.int(16)), exp.bytes(Buffer.from([0x01])),)uint8_t v[] = {0x01};as_exp_build(predexp, as_exp_cmp_eq( as_exp_bit_get( as_exp_int(16), as_exp_int(8), as_exp_bit_and( NULL, as_exp_int(16), as_exp_int(8), as_exp_bytes(v, sizeof(v)), as_exp_bin_blob("device_flags"))), as_exp_bytes(v, sizeof(v))));import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;import com.aerospike.client.operation.BitPolicy;
Expression exp = Exp.build( Exp.eq( BitExp.get( Exp.val(16), Exp.val(8), BitExp.and( BitPolicy.Default, Exp.val(16), Exp.val(8), Exp.val(new byte[] {0x01}), Exp.blobBin("device_flags"))), Exp.val(new byte[] {0x01})));from aerospike_helpers.expressions import BlobBin, Eqfrom aerospike_helpers.expressions.bitwise import BitAnd, BitGet
b = BlobBin("device_flags")exp = Eq(BitGet(16, 8, BitAnd(None, 16, 8, bytearray([0x01]), b)), bytearray([0x01])).compile()bit_insert(policy, byte_offset, blob, bin)Returns the blob with blob inserted at byte_offset, growing it by the length of blob.
| Name | Type | Description |
|---|---|---|
policy | Bit policy | Write policy for the transform. Supplied by your client as a blob or bitwise policy object. |
byte_offset | integer | Offset in bytes from the start of the blob at which to insert. |
blob | blob | Bytes to insert. |
bin | blob | Blob bin to operate on, or any expression that evaluates to a blob. |
blob Filter where inserting 0xFF at byte offset 1 makes the unsigned 8-bit integer at bit offset 8 equal 0xFF.
String exp = "$.device_flags.bitInsert(byteOffset: 1, value: x'ff')" + ".bitGetInt(offset: 8, size: 8) == 0xff";exp = ("$.device_flags.bitInsert(byteOffset: 1, value: x'ff')" ".bitGetInt(offset: 8, size: 8) == 0xff")use aerospike::expressions::bitwise as bit_exp;use aerospike::expressions::{blob_bin, blob_val, eq, int_val};use aerospike::operations::bitwise::{BitPolicy};
let exp = eq( bit_exp::get_int( int_val(8), int_val(8), false, bit_exp::insert( &BitPolicy::default(), int_val(1), blob_val(vec![0xff]), blob_bin("device_flags".into()))), int_val(0xff));Expression exp = Exp.Build( Exp.EQ( BitExp.GetInt( Exp.Val(8), Exp.Val(8), false, BitExp.Insert(BitPolicy.Default, Exp.Val(1), Exp.Val(new byte[] {0xFF}), Exp.BlobBin("device_flags"))), Exp.Val(0xFF)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpEq( as.ExpBitGetInt( as.ExpIntVal(8), as.ExpIntVal(8), false, as.ExpBitInsert(as.DefaultBitPolicy(), as.ExpIntVal(1), as.ExpBlobVal([]byte{0xff}), as.ExpBlobBin("device_flags")), ), as.ExpIntVal(0xff),)const exp = Aerospike.exp
const filterExp = exp.eq( exp.bit.getInt( exp.bit.insert(exp.binBlob('device_flags'), exp.bytes(Buffer.from([0xff])), exp.int(1)), false, exp.int(8), exp.int(8), ), exp.int(0xff),)uint8_t ins[] = {0xff};as_exp_build(predexp, as_exp_cmp_eq( as_exp_bit_get_int( as_exp_int(8), as_exp_int(8), false, as_exp_bit_insert( NULL, as_exp_int(1), as_exp_bytes(ins, sizeof(ins)), as_exp_bin_blob("device_flags"))), as_exp_int(0xff)));import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;import com.aerospike.client.operation.BitPolicy;
Expression exp = Exp.build( Exp.eq( BitExp.getInt( Exp.val(8), Exp.val(8), false, BitExp.insert( BitPolicy.Default, Exp.val(1), Exp.val(new byte[] {(byte) 0xff}), Exp.blobBin("device_flags"))), Exp.val(0xff)));from aerospike_helpers.expressions import BlobBin, Eqfrom aerospike_helpers.expressions.bitwise import BitGetInt, BitInsert
exp = Eq( BitGetInt(8, 8, False, BitInsert(None, 1, bytearray([0xFF]), BlobBin("device_flags"))), 0xFF,).compile()bit_lshift(policy, bit_offset, bit_size, shift, bin)Returns the blob with the bit_size bits at bit_offset shifted left by shift, filling from the right with zeros. Bits shifted out of the region are discarded. The rest of the blob is unchanged, and its length does not change.
| Name | Type | Description |
|---|---|---|
policy | Bit policy | Write policy for the transform. Supplied by your client as a blob or bitwise policy object. |
bit_offset | integer | Offset in bits from the start of the blob to the first bit of the region. |
bit_size | integer | Width of the region in bits. |
shift | integer | Number of bit positions to shift by. |
bin | blob | Blob bin to operate on, or any expression that evaluates to a blob. |
blob Filter where shifting the first byte left by two bits preserves the following six bits relative to the unmodified blob.
String exp = "$.device_flags.bitLshift(offset: 0, size: 8, shift: 2)" + ".bitGet(offset: 0, size: 6)" + " == $.device_flags.bitGet(offset: 2, size: 6)";exp = ("$.device_flags.bitLshift(offset: 0, size: 8, shift: 2)" ".bitGet(offset: 0, size: 6)" " == $.device_flags.bitGet(offset: 2, size: 6)")use aerospike::expressions::bitwise as bit_exp;use aerospike::expressions::{blob_bin, eq, int_val};use aerospike::operations::bitwise::{BitPolicy};
let exp = eq( bit_exp::get( int_val(0), int_val(6), bit_exp::lshift( &BitPolicy::default(), int_val(0), int_val(8), int_val(2), blob_bin("device_flags".into()))), bit_exp::get(int_val(2), int_val(6), blob_bin("device_flags".into())));Expression exp = 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("device_flags"))), BitExp.Get(Exp.Val(2), Exp.Val(6), Exp.BlobBin("device_flags"))));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"bin := as.ExpBlobBin("device_flags")exp := as.ExpEq( as.ExpBitGet( as.ExpIntVal(0), as.ExpIntVal(6), as.ExpBitLShift(as.DefaultBitPolicy(), as.ExpIntVal(0), as.ExpIntVal(8), as.ExpIntVal(2), bin), ), as.ExpBitGet(as.ExpIntVal(2), as.ExpIntVal(6), bin),)const exp = Aerospike.expconst bin = exp.binBlob('device_flags')
const filterExp = exp.eq( exp.bit.get(exp.bit.lShift(bin, exp.int(2), exp.int(8), exp.int(0)), exp.int(6), exp.int(0)), exp.bit.get(bin, exp.int(6), exp.int(2)),)as_exp_build(predexp, as_exp_cmp_eq( as_exp_bit_get( as_exp_int(0), as_exp_int(6), as_exp_bit_lshift( NULL, as_exp_int(0), as_exp_int(8), as_exp_int(2), as_exp_bin_blob("device_flags"))), as_exp_bit_get(as_exp_int(2), as_exp_int(6), as_exp_bin_blob("device_flags"))));import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;import com.aerospike.client.operation.BitPolicy;
Expression exp = 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("device_flags"))), BitExp.get(Exp.val(2), Exp.val(6), Exp.blobBin("device_flags"))));from aerospike_helpers.expressions import BlobBin, Eqfrom aerospike_helpers.expressions.bitwise import BitGet, BitLeftShift
b = BlobBin("device_flags")exp = Eq(BitGet(0, 6, BitLeftShift(None, 0, 8, 2, b)), BitGet(2, 6, b)).compile()bit_not(policy, bit_offset, bit_size, bin)Returns the blob with the bit_size bits at bit_offset replaced by their bitwise complement. The rest of the blob is unchanged, and its length does not change.
| Name | Type | Description |
|---|---|---|
policy | Bit policy | Write policy for the transform. Supplied by your client as a blob or bitwise policy object. |
bit_offset | integer | Offset in bits from the start of the blob to the first bit of the region. |
bit_size | integer | Width of the region in bits. |
bin | blob | Blob bin to operate on, or any expression that evaluates to a blob. |
blob Filter where NOT-ing one bit at offset 6 makes the first byte match bits 16–23 of the original blob (0x03).
String exp = "$.device_flags.bitNot(offset: 6, size: 1)" + ".bitGet(offset: 0, size: 8)" + " == $.device_flags.bitGet(offset: 16, size: 8)";exp = ("$.device_flags.bitNot(offset: 6, size: 1)" ".bitGet(offset: 0, size: 8)" " == $.device_flags.bitGet(offset: 16, size: 8)")use aerospike::expressions::bitwise as bit_exp;use aerospike::expressions::{blob_bin, eq, int_val};use aerospike::operations::bitwise::{BitPolicy};
let exp = eq( bit_exp::get( int_val(0), int_val(8), bit_exp::not( &BitPolicy::default(), int_val(6), int_val(1), blob_bin("device_flags".into()))), bit_exp::get(int_val(16), int_val(8), blob_bin("device_flags".into())));Expression exp = Exp.Build( Exp.EQ( BitExp.Get( Exp.Val(0), Exp.Val(8), BitExp.Not(BitPolicy.Default, Exp.Val(6), Exp.Val(1), Exp.BlobBin("device_flags"))), BitExp.Get(Exp.Val(16), Exp.Val(8), Exp.BlobBin("device_flags"))));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"bin := as.ExpBlobBin("device_flags")exp := as.ExpEq( as.ExpBitGet( as.ExpIntVal(0), as.ExpIntVal(8), as.ExpBitNot(as.DefaultBitPolicy(), as.ExpIntVal(6), as.ExpIntVal(1), bin), ), as.ExpBitGet(as.ExpIntVal(16), as.ExpIntVal(8), bin),)const exp = Aerospike.expconst bin = exp.binBlob('device_flags')
const filterExp = exp.eq( exp.bit.get(exp.bit.not(bin, exp.int(1), exp.int(6)), exp.int(8), exp.int(0)), exp.bit.get(bin, exp.int(8), exp.int(16)),)as_exp_build(predexp, as_exp_cmp_eq( as_exp_bit_get( as_exp_int(0), as_exp_int(8), as_exp_bit_not(NULL, as_exp_int(6), as_exp_int(1), as_exp_bin_blob("device_flags"))), as_exp_bit_get(as_exp_int(16), as_exp_int(8), as_exp_bin_blob("device_flags"))));import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;import com.aerospike.client.operation.BitPolicy;
Expression exp = Exp.build( Exp.eq( BitExp.get( Exp.val(0), Exp.val(8), BitExp.not(BitPolicy.Default, Exp.val(6), Exp.val(1), Exp.blobBin("device_flags"))), BitExp.get(Exp.val(16), Exp.val(8), Exp.blobBin("device_flags"))));from aerospike_helpers.expressions import BlobBin, Eqfrom aerospike_helpers.expressions.bitwise import BitGet, BitNot
b = BlobBin("device_flags")exp = Eq(BitGet(0, 8, BitNot(None, 6, 1, b)), BitGet(16, 8, b)).compile()bit_or(policy, bit_offset, bit_size, value, bin)Returns the blob with the bit_size bits at bit_offset replaced by their bitwise OR with value. The rest of the blob is unchanged, and its length does not change.
| Name | Type | Description |
|---|---|---|
policy | Bit policy | Write policy for the transform. Supplied by your client as a blob or bitwise policy object. |
bit_offset | integer | Offset in bits from the start of the blob to the first bit of the region. |
bit_size | integer | Width of the region in bits. |
value | blob | Blob supplying the bits to OR with. Must be at least |
bin | blob | Blob bin to operate on, or any expression that evaluates to a blob. |
blob Filter where OR-ing 0x01 into bits 24–31 makes the 8-bit slice at offset 24 match the slice at offset 32.
String exp = "$.device_flags.bitOr(offset: 24, size: 8, value: x'01')" + ".bitGet(offset: 24, size: 8)" + " == $.device_flags.bitGet(offset: 32, size: 8)";exp = ("$.device_flags.bitOr(offset: 24, size: 8, value: x'01')" ".bitGet(offset: 24, size: 8)" " == $.device_flags.bitGet(offset: 32, size: 8)")use aerospike::expressions::bitwise as bit_exp;use aerospike::expressions::{blob_bin, blob_val, eq, int_val};use aerospike::operations::bitwise::{BitPolicy};
let exp = eq( bit_exp::get( int_val(24), int_val(8), bit_exp::or( &BitPolicy::default(), int_val(24), int_val(8), blob_val(vec![0x01]), blob_bin("device_flags".into()))), bit_exp::get(int_val(32), int_val(8), blob_bin("device_flags".into())));Expression exp = Exp.Build( Exp.EQ( BitExp.Get( Exp.Val(24), Exp.Val(8), BitExp.Or( BitPolicy.Default, Exp.Val(24), Exp.Val(8), Exp.Val(new byte[] {0x01}), Exp.BlobBin("device_flags"))), BitExp.Get(Exp.Val(32), Exp.Val(8), Exp.BlobBin("device_flags"))));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"bin := as.ExpBlobBin("device_flags")exp := as.ExpEq( as.ExpBitGet( as.ExpIntVal(24), as.ExpIntVal(8), as.ExpBitOr(as.DefaultBitPolicy(), as.ExpIntVal(24), as.ExpIntVal(8), as.ExpBlobVal([]byte{0x01}), bin), ), as.ExpBitGet(as.ExpIntVal(32), as.ExpIntVal(8), bin),)const exp = Aerospike.expconst bin = exp.binBlob('device_flags')
const filterExp = exp.eq( exp.bit.get(exp.bit.or(bin, exp.bytes(Buffer.from([0x01])), exp.int(8), exp.int(24)), exp.int(8), exp.int(24)), exp.bit.get(bin, exp.int(8), exp.int(32)),)uint8_t v[] = {0x01};as_exp_build(predexp, as_exp_cmp_eq( as_exp_bit_get( as_exp_int(24), as_exp_int(8), as_exp_bit_or( NULL, as_exp_int(24), as_exp_int(8), as_exp_bytes(v, sizeof(v)), as_exp_bin_blob("device_flags"))), as_exp_bit_get(as_exp_int(32), as_exp_int(8), as_exp_bin_blob("device_flags"))));import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;import com.aerospike.client.operation.BitPolicy;
Expression exp = Exp.build( Exp.eq( BitExp.get( Exp.val(24), Exp.val(8), BitExp.or( BitPolicy.Default, Exp.val(24), Exp.val(8), Exp.val(new byte[] {0x01}), Exp.blobBin("device_flags"))), BitExp.get(Exp.val(32), Exp.val(8), Exp.blobBin("device_flags"))));from aerospike_helpers.expressions import BlobBin, Eqfrom aerospike_helpers.expressions.bitwise import BitGet, BitOr
b = BlobBin("device_flags")exp = Eq(BitGet(24, 8, BitOr(None, 24, 8, bytearray([0x01]), b)), BitGet(32, 8, b)).compile()bit_remove(policy, byte_offset, byte_size, bin)Returns the blob with byte_size bytes removed starting at byte_offset, shrinking it by that many bytes.
| Name | Type | Description |
|---|---|---|
policy | Bit policy | Write policy for the transform. Supplied by your client as a blob or bitwise policy object. |
byte_offset | integer | Offset in bytes from the start of the blob at which to start removing. |
byte_size | integer | Number of bytes to remove. |
bin | blob | Blob bin to operate on, or any expression that evaluates to a blob. |
blob Filter where removing the first byte leaves 0x42 as the unsigned 8-bit value at bit offset 0.
String exp = "$.device_flags.bitRemove(byteOffset: 0, byteSize: 1)" + ".bitGetInt(offset: 0, size: 8) == 0x42";exp = ("$.device_flags.bitRemove(byteOffset: 0, byteSize: 1)" ".bitGetInt(offset: 0, size: 8) == 0x42")use aerospike::expressions::bitwise as bit_exp;use aerospike::expressions::{blob_bin, eq, int_val};use aerospike::operations::bitwise::{BitPolicy};
let exp = eq( bit_exp::get_int( int_val(0), int_val(8), false, bit_exp::remove( &BitPolicy::default(), int_val(0), int_val(1), blob_bin("device_flags".into()))), int_val(0x42));Expression exp = Exp.Build( Exp.EQ( BitExp.GetInt( Exp.Val(0), Exp.Val(8), false, BitExp.Remove(BitPolicy.Default, Exp.Val(0), Exp.Val(1), Exp.BlobBin("device_flags"))), Exp.Val(0x42)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpEq( as.ExpBitGetInt( as.ExpIntVal(0), as.ExpIntVal(8), false, as.ExpBitRemove(as.DefaultBitPolicy(), as.ExpIntVal(0), as.ExpIntVal(1), as.ExpBlobBin("device_flags")), ), as.ExpIntVal(0x42),)const exp = Aerospike.exp
const filterExp = exp.eq( exp.bit.getInt( exp.bit.remove(exp.binBlob('device_flags'), exp.int(1), exp.int(0)), false, exp.int(8), exp.int(0), ), exp.int(0x42),)as_exp_build(predexp, as_exp_cmp_eq( as_exp_bit_get_int( as_exp_int(0), as_exp_int(8), 0, as_exp_bit_remove(NULL, as_exp_int(0), as_exp_int(1), as_exp_bin_blob("device_flags"))), as_exp_int(0x42)));import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;import com.aerospike.client.operation.BitPolicy;
Expression exp = Exp.build( Exp.eq( BitExp.getInt( Exp.val(0), Exp.val(8), false, BitExp.remove(BitPolicy.Default, Exp.val(0), Exp.val(1), Exp.blobBin("device_flags"))), Exp.val(0x42)));from aerospike_helpers.expressions import BlobBin, Eqfrom aerospike_helpers.expressions.bitwise import BitGetInt, BitRemove
exp = Eq(BitGetInt(0, 8, False, BitRemove(None, 0, 1, BlobBin("device_flags"))), 0x42).compile()bit_resize(policy, byte_size, resize_flags, bin)Returns the blob resized to byte_size bytes. Growing pads with zero bytes at the end and shrinking drops bytes from the end; resize_flags can work at the front instead, or forbid growing or shrinking.
| Name | Type | Description |
|---|---|---|
policy | Bit policy | Write policy for the transform. Supplied by your client as a blob or bitwise policy object. |
byte_size | integer | New size of the blob in bytes. |
resize_flags | Resize flags | Where bytes are added or dropped, and whether both directions are allowed: by default at the end, with |
bin | blob | Blob bin to operate on, or any expression that evaluates to a blob. |
blob Filter where the first byte after resizing device_flags to six bytes (default resize flags) is still 0x01 — modify expressions evaluate on a temporary blob value.
String exp = "$.device_flags.bitResize(byteSize: 6)" + ".bitGet(offset: 0, size: 8) == x'01'";exp = ("$.device_flags.bitResize(byteSize: 6)" ".bitGet(offset: 0, size: 8) == x'01'")use aerospike::expressions::bitwise as bit_exp;use aerospike::expressions::{blob_bin, blob_val, eq, int_val};use aerospike::operations::bitwise::{BitPolicy, BitwiseResizeFlags};
let exp = eq( bit_exp::get( int_val(0), int_val(8), bit_exp::resize( &BitPolicy::default(), int_val(6), BitwiseResizeFlags::Default, blob_bin("device_flags".into()))), blob_val(vec![0x01]));Expression exp = Exp.Build( Exp.EQ( BitExp.Get( Exp.Val(0), Exp.Val(8), BitExp.Resize(BitPolicy.Default, Exp.Val(6), 0, Exp.BlobBin("device_flags"))), Exp.Val(new byte[] {0x01})));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpEq( as.ExpBitGet( as.ExpIntVal(0), as.ExpIntVal(8), as.ExpBitResize(as.DefaultBitPolicy(), as.ExpIntVal(6), as.BitResizeFlagsDefault, as.ExpBlobBin("device_flags")), ), as.ExpBlobVal([]byte{0x01}),)const exp = Aerospike.expconst bits = Aerospike.bitwise
const filterExp = exp.eq( exp.bit.get( exp.bit.reSize(exp.binBlob('device_flags'), bits.resizeFlags.DEFAULT, exp.int(6)), exp.int(8), exp.int(0), ), exp.bytes(Buffer.from([0x01])),)uint8_t want[] = {0x01};as_exp_build(predexp, as_exp_cmp_eq( as_exp_bit_get( as_exp_int(0), as_exp_int(8), as_exp_bit_resize(NULL, as_exp_int(6), 0, as_exp_bin_blob("device_flags"))), as_exp_bytes(want, sizeof(want))));import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;import com.aerospike.client.operation.BitPolicy;
Expression exp = Exp.build( Exp.eq( BitExp.get( Exp.val(0), Exp.val(8), BitExp.resize(BitPolicy.Default, Exp.val(6), 0, Exp.blobBin("device_flags"))), Exp.val(new byte[] {0x01})));from aerospike_helpers.expressions import BlobBin, Eqfrom aerospike_helpers.expressions.bitwise import BitGet, BitResize
exp = Eq(BitGet(0, 8, BitResize(None, 6, 0, BlobBin("device_flags"))), bytearray([0x01])).compile()bit_rshift(policy, bit_offset, bit_size, shift, bin)Returns the blob with the bit_size bits at bit_offset shifted right by shift, filling from the left with zeros. Bits shifted out of the region are discarded. The rest of the blob is unchanged, and its length does not change.
| Name | Type | Description |
|---|---|---|
policy | Bit policy | Write policy for the transform. Supplied by your client as a blob or bitwise policy object. |
bit_offset | integer | Offset in bits from the start of the blob to the first bit of the region. |
bit_size | integer | Width of the region in bits. |
shift | integer | Number of bit positions to shift by. |
bin | blob | Blob bin to operate on, or any expression that evaluates to a blob. |
blob Filter where shifting bits 24–31 right by two leaves the following six bits unchanged relative to the original blob.
String exp = "$.device_flags.bitRshift(offset: 24, size: 8, shift: 2)" + ".bitGet(offset: 26, size: 6)" + " == $.device_flags.bitGet(offset: 24, size: 6)";exp = ("$.device_flags.bitRshift(offset: 24, size: 8, shift: 2)" ".bitGet(offset: 26, size: 6)" " == $.device_flags.bitGet(offset: 24, size: 6)")use aerospike::expressions::bitwise as bit_exp;use aerospike::expressions::{blob_bin, eq, int_val};use aerospike::operations::bitwise::{BitPolicy};
let exp = eq( bit_exp::get( int_val(26), int_val(6), bit_exp::rshift( &BitPolicy::default(), int_val(24), int_val(8), int_val(2), blob_bin("device_flags".into()))), bit_exp::get(int_val(24), int_val(6), blob_bin("device_flags".into())));Expression exp = Exp.Build( Exp.EQ( BitExp.Get( Exp.Val(26), Exp.Val(6), BitExp.Rshift( BitPolicy.Default, Exp.Val(24), Exp.Val(8), Exp.Val(2), Exp.BlobBin("device_flags"))), BitExp.Get(Exp.Val(24), Exp.Val(6), Exp.BlobBin("device_flags"))));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"bin := as.ExpBlobBin("device_flags")exp := as.ExpEq( as.ExpBitGet( as.ExpIntVal(26), as.ExpIntVal(6), as.ExpBitRShift(as.DefaultBitPolicy(), as.ExpIntVal(24), as.ExpIntVal(8), as.ExpIntVal(2), bin), ), as.ExpBitGet(as.ExpIntVal(24), as.ExpIntVal(6), bin),)const exp = Aerospike.expconst bin = exp.binBlob('device_flags')
const filterExp = exp.eq( exp.bit.get(exp.bit.rShift(bin, exp.int(2), exp.int(8), exp.int(24)), exp.int(6), exp.int(26)), exp.bit.get(bin, exp.int(6), exp.int(24)),)as_exp_build(predexp, as_exp_cmp_eq( as_exp_bit_get( as_exp_int(26), as_exp_int(6), as_exp_bit_rshift( NULL, as_exp_int(24), as_exp_int(8), as_exp_int(2), as_exp_bin_blob("device_flags"))), as_exp_bit_get(as_exp_int(24), as_exp_int(6), as_exp_bin_blob("device_flags"))));import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;import com.aerospike.client.operation.BitPolicy;
Expression exp = Exp.build( Exp.eq( BitExp.get( Exp.val(26), Exp.val(6), BitExp.rshift( BitPolicy.Default, Exp.val(24), Exp.val(8), Exp.val(2), Exp.blobBin("device_flags"))), BitExp.get(Exp.val(24), Exp.val(6), Exp.blobBin("device_flags"))));from aerospike_helpers.expressions import BlobBin, Eqfrom aerospike_helpers.expressions.bitwise import BitGet, BitRightShift
b = BlobBin("device_flags")exp = Eq(BitGet(26, 6, BitRightShift(None, 24, 8, 2, b)), BitGet(24, 6, b)).compile()bit_set(policy, bit_offset, bit_size, value, bin)Returns the blob with the bit_size bits at bit_offset replaced by the leading bit_size bits of value. value must supply at least that many bits. The rest of the blob is unchanged, and its length does not change.
| Name | Type | Description |
|---|---|---|
policy | Bit policy | Write policy for the transform. Supplied by your client as a blob or bitwise policy object. |
bit_offset | integer | Offset in bits from the start of the blob to the first bit of the region. |
bit_size | integer | Width of the region in bits. |
value | blob | Blob supplying the replacement bits, taken from its leading bits. Must be at least |
bin | blob | Blob bin to operate on, or any expression that evaluates to a blob. |
blob Filter where setting one bit at offset 31 makes the 8-bit slice at offset 24 match the original slice at offset 32.
String exp = "$.device_flags.bitSet(offset: 31, size: 1, value: x'80')" + ".bitGet(offset: 24, size: 8)" + " == $.device_flags.bitGet(offset: 32, size: 8)";exp = ("$.device_flags.bitSet(offset: 31, size: 1, value: x'80')" ".bitGet(offset: 24, size: 8)" " == $.device_flags.bitGet(offset: 32, size: 8)")use aerospike::expressions::bitwise as bit_exp;use aerospike::expressions::{blob_bin, blob_val, eq, int_val};use aerospike::operations::bitwise::{BitPolicy};
let exp = eq( bit_exp::get( int_val(24), int_val(8), bit_exp::set( &BitPolicy::default(), int_val(31), int_val(1), blob_val(vec![0x80]), blob_bin("device_flags".into()))), bit_exp::get(int_val(32), int_val(8), blob_bin("device_flags".into())));Expression exp = Exp.Build( Exp.EQ( BitExp.Get( Exp.Val(24), Exp.Val(8), BitExp.Set( BitPolicy.Default, Exp.Val(31), Exp.Val(1), Exp.Val(new byte[] {0x80}), Exp.BlobBin("device_flags"))), BitExp.Get(Exp.Val(32), Exp.Val(8), Exp.BlobBin("device_flags"))));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"bin := as.ExpBlobBin("device_flags")exp := as.ExpEq( as.ExpBitGet( as.ExpIntVal(24), as.ExpIntVal(8), as.ExpBitSet(as.DefaultBitPolicy(), as.ExpIntVal(31), as.ExpIntVal(1), as.ExpBlobVal([]byte{0x80}), bin), ), as.ExpBitGet(as.ExpIntVal(32), as.ExpIntVal(8), bin),)const exp = Aerospike.expconst bin = exp.binBlob('device_flags')
const filterExp = exp.eq( exp.bit.get(exp.bit.set(bin, exp.bytes(Buffer.from([0x80])), exp.int(1), exp.int(31)), exp.int(8), exp.int(24)), exp.bit.get(bin, exp.int(8), exp.int(32)),)uint8_t v[] = {0x80};as_exp_build(predexp, as_exp_cmp_eq( as_exp_bit_get( as_exp_int(24), as_exp_int(8), as_exp_bit_set( NULL, as_exp_int(31), as_exp_int(1), as_exp_bytes(v, sizeof(v)), as_exp_bin_blob("device_flags"))), as_exp_bit_get(as_exp_int(32), as_exp_int(8), as_exp_bin_blob("device_flags"))));import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;import com.aerospike.client.operation.BitPolicy;
Expression exp = Exp.build( Exp.eq( BitExp.get( Exp.val(24), Exp.val(8), BitExp.set( BitPolicy.Default, Exp.val(31), Exp.val(1), Exp.val(new byte[] {(byte) 0x80}), Exp.blobBin("device_flags"))), BitExp.get(Exp.val(32), Exp.val(8), Exp.blobBin("device_flags"))));from aerospike_helpers.expressions import BlobBin, Eqfrom aerospike_helpers.expressions.bitwise import BitGet, BitSet
b = BlobBin("device_flags")exp = Eq( BitGet(24, 8, BitSet(None, 31, 1, bytearray([0x80]), b)), BitGet(32, 8, b),).compile()bit_set_int(policy, bit_offset, bit_size, value, bin)Returns the blob with the bit_size bits at bit_offset replaced by value, written as a big-endian integer of that width. The rest of the blob is unchanged, and its length does not change.
| Name | Type | Description |
|---|---|---|
policy | Bit policy | Write policy for the transform. Supplied by your client as a blob or bitwise policy object. |
bit_offset | integer | Offset in bits from the start of the blob to the first bit of the region. |
bit_size | integer | Width of the region in bits. |
value | integer | Integer to write into the region. |
bin | blob | Blob bin to operate on, or any expression that evaluates to a blob. |
blob Filter where writing integer 0x42 into bits 24–31 makes that 8-bit slice match the original second byte of device_flags.
String exp = "$.device_flags.bitSetInt(offset: 24, size: 8, value: 0x42)" + ".bitGet(offset: 24, size: 8)" + " == $.device_flags.bitGet(offset: 8, size: 8)";exp = ("$.device_flags.bitSetInt(offset: 24, size: 8, value: 0x42)" ".bitGet(offset: 24, size: 8)" " == $.device_flags.bitGet(offset: 8, size: 8)")use aerospike::expressions::bitwise as bit_exp;use aerospike::expressions::{blob_bin, eq, int_val};use aerospike::operations::bitwise::{BitPolicy};
let exp = eq( bit_exp::get( int_val(24), int_val(8), bit_exp::set_int( &BitPolicy::default(), int_val(24), int_val(8), int_val(0x42), blob_bin("device_flags".into()))), bit_exp::get(int_val(8), int_val(8), blob_bin("device_flags".into())));Expression exp = Exp.Build( Exp.EQ( BitExp.Get( Exp.Val(24), Exp.Val(8), BitExp.SetInt( BitPolicy.Default, Exp.Val(24), Exp.Val(8), Exp.Val(0x42), Exp.BlobBin("device_flags"))), BitExp.Get(Exp.Val(8), Exp.Val(8), Exp.BlobBin("device_flags"))));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"bin := as.ExpBlobBin("device_flags")exp := as.ExpEq( as.ExpBitGet( as.ExpIntVal(24), as.ExpIntVal(8), as.ExpBitSetInt(as.DefaultBitPolicy(), as.ExpIntVal(24), as.ExpIntVal(8), as.ExpIntVal(0x42), bin), ), as.ExpBitGet(as.ExpIntVal(8), as.ExpIntVal(8), bin),)const exp = Aerospike.expconst bin = exp.binBlob('device_flags')
const filterExp = exp.eq( exp.bit.get(exp.bit.setInt(bin, exp.int(0x42), exp.int(8), exp.int(24)), exp.int(8), exp.int(24)), exp.bit.get(bin, exp.int(8), exp.int(8)),)as_exp_build(predexp, as_exp_cmp_eq( as_exp_bit_get( as_exp_int(24), as_exp_int(8), as_exp_bit_set_int( NULL, as_exp_int(24), as_exp_int(8), as_exp_int(0x42), as_exp_bin_blob("device_flags"))), as_exp_bit_get(as_exp_int(8), as_exp_int(8), as_exp_bin_blob("device_flags"))));import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;import com.aerospike.client.operation.BitPolicy;
Expression exp = Exp.build( Exp.eq( BitExp.get( Exp.val(24), Exp.val(8), BitExp.setInt( BitPolicy.Default, Exp.val(24), Exp.val(8), Exp.val(0x42), Exp.blobBin("device_flags"))), BitExp.get(Exp.val(8), Exp.val(8), Exp.blobBin("device_flags"))));from aerospike_helpers.expressions import BlobBin, Eqfrom aerospike_helpers.expressions.bitwise import BitGet, BitSetInt
b = BlobBin("device_flags")exp = Eq(BitGet(24, 8, BitSetInt(None, 24, 8, 0x42, b)), BitGet(8, 8, b)).compile()bit_subtract(policy, bit_offset, bit_size, value, signed, action, bin)Returns the blob with value subtracted from the bit_size-bit big-endian integer starting at bit_offset, read as signed or unsigned according to signed. The rest of the blob is unchanged, and its length does not change.
| Name | Type | Description |
|---|---|---|
policy | Bit policy | Write policy for the transform. Supplied by your client as a blob or bitwise policy object. |
bit_offset | integer | Offset in bits from the start of the blob to the first bit of the region. |
bit_size | integer | Width of the region in bits. |
value | integer | Integer to subtract. It is converted to a |
signed | boolean literal | Whether the region is read as a signed or an unsigned integer. This does not change the arithmetic; it decides where the limits sit, and so which results count as overflow. In an 8-bit region, adding 1 to |
action | Overflow action | What happens when the subtraction crosses the region’s limit: fail, which is the default; saturate at the limit; or wrap around past it. Which values count as crossing depends on |
bin | blob | Blob bin to operate on, or any expression that evaluates to a blob. |
blob Filter where subtracting 1 from the unsigned 8-bit field at bit offset 24 (overflow FAIL) matches the field at offset 16.
String exp = "$.device_flags.bitSubtract(offset: 24, size: 8, value: 1)" + ".bitGet(offset: 24, size: 8)" + " == $.device_flags.bitGet(offset: 16, size: 8)";exp = ("$.device_flags.bitSubtract(offset: 24, size: 8, value: 1)" ".bitGet(offset: 24, size: 8)" " == $.device_flags.bitGet(offset: 16, size: 8)")use aerospike::expressions::bitwise as bit_exp;use aerospike::expressions::{blob_bin, eq, int_val};use aerospike::operations::bitwise::{BitPolicy, BitwiseOverflowActions};
let exp = eq( bit_exp::get( int_val(24), int_val(8), bit_exp::subtract( &BitPolicy::default(), int_val(24), int_val(8), int_val(1), false, BitwiseOverflowActions::Fail, blob_bin("device_flags".into()))), bit_exp::get(int_val(16), int_val(8), blob_bin("device_flags".into())));Expression exp = Exp.Build( Exp.EQ( BitExp.Get( Exp.Val(24), Exp.Val(8), BitExp.Subtract( BitPolicy.Default, Exp.Val(24), Exp.Val(8), Exp.Val(1), false, BitOverflowAction.FAIL, Exp.BlobBin("device_flags"))), BitExp.Get(Exp.Val(16), Exp.Val(8), Exp.BlobBin("device_flags"))));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"bin := as.ExpBlobBin("device_flags")exp := as.ExpEq( as.ExpBitGet( as.ExpIntVal(24), as.ExpIntVal(8), as.ExpBitSubtract( as.DefaultBitPolicy(), as.ExpIntVal(24), as.ExpIntVal(8), as.ExpIntVal(1), false, as.BitOverflowActionFail, bin, ), ), as.ExpBitGet(as.ExpIntVal(16), as.ExpIntVal(8), bin),)const exp = Aerospike.expconst bits = Aerospike.bitwiseconst bin = exp.binBlob('device_flags')
const filterExp = exp.eq( exp.bit.get( exp.bit.subtract(bin, bits.overflow.FAIL, exp.int(1), exp.int(8), exp.int(24)), exp.int(8), exp.int(24), ), exp.bit.get(bin, exp.int(8), exp.int(16)),)as_exp_build(predexp, as_exp_cmp_eq( as_exp_bit_get( as_exp_int(24), as_exp_int(8), as_exp_bit_subtract( NULL, as_exp_int(24), as_exp_int(8), as_exp_int(1), AS_BIT_OVERFLOW_FAIL, as_exp_bin_blob("device_flags"))), as_exp_bit_get(as_exp_int(16), as_exp_int(8), as_exp_bin_blob("device_flags"))));import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;import com.aerospike.client.operation.BitOverflowAction;import com.aerospike.client.operation.BitPolicy;
Expression exp = Exp.build( Exp.eq( BitExp.get( Exp.val(24), Exp.val(8), BitExp.subtract( BitPolicy.Default, Exp.val(24), Exp.val(8), Exp.val(1), false, BitOverflowAction.FAIL, Exp.blobBin("device_flags"))), BitExp.get(Exp.val(16), Exp.val(8), Exp.blobBin("device_flags"))));import aerospikefrom aerospike_helpers.expressions import BlobBin, Eqfrom aerospike_helpers.expressions.bitwise import BitGet, BitSubtract
b = BlobBin("device_flags")exp = Eq(BitGet(24, 8, BitSubtract(None, 24, 8, 1, aerospike.BIT_OVERFLOW_FAIL, b)), BitGet(16, 8, b)).compile()bit_xor(policy, bit_offset, bit_size, value, bin)Returns the blob with the bit_size bits at bit_offset replaced by their bitwise XOR with value. The rest of the blob is unchanged, and its length does not change.
| Name | Type | Description |
|---|---|---|
policy | Bit policy | Write policy for the transform. Supplied by your client as a blob or bitwise policy object. |
bit_offset | integer | Offset in bits from the start of the blob to the first bit of the region. |
bit_size | integer | Width of the region in bits. |
value | blob | Blob supplying the bits to XOR with. Must be at least |
bin | blob | Blob bin to operate on, or any expression that evaluates to a blob. |
blob Filter where XOR-ing the first byte with 0x02 yields the same 8-bit slice as bits 16–23 of the original device_flags.
String exp = "$.device_flags.bitXor(offset: 0, size: 8, value: x'02')" + ".bitGet(offset: 0, size: 8)" + " == $.device_flags.bitGet(offset: 16, size: 8)";exp = ("$.device_flags.bitXor(offset: 0, size: 8, value: x'02')" ".bitGet(offset: 0, size: 8)" " == $.device_flags.bitGet(offset: 16, size: 8)")use aerospike::expressions::bitwise as bit_exp;use aerospike::expressions::{blob_bin, blob_val, eq, int_val};use aerospike::operations::bitwise::{BitPolicy};
let exp = eq( bit_exp::get( int_val(0), int_val(8), bit_exp::xor( &BitPolicy::default(), int_val(0), int_val(8), blob_val(vec![0x02]), blob_bin("device_flags".into()))), bit_exp::get(int_val(16), int_val(8), blob_bin("device_flags".into())));Expression exp = Exp.Build( Exp.EQ( BitExp.Get( Exp.Val(0), Exp.Val(8), BitExp.Xor( BitPolicy.Default, Exp.Val(0), Exp.Val(8), Exp.Val(new byte[] {0x02}), Exp.BlobBin("device_flags"))), BitExp.Get(Exp.Val(16), Exp.Val(8), Exp.BlobBin("device_flags"))));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"bin := as.ExpBlobBin("device_flags")exp := as.ExpEq( as.ExpBitGet( as.ExpIntVal(0), as.ExpIntVal(8), as.ExpBitXor(as.DefaultBitPolicy(), as.ExpIntVal(0), as.ExpIntVal(8), as.ExpBlobVal([]byte{0x02}), bin), ), as.ExpBitGet(as.ExpIntVal(16), as.ExpIntVal(8), bin),)const exp = Aerospike.expconst bin = exp.binBlob('device_flags')
const filterExp = exp.eq( exp.bit.get(exp.bit.xor(bin, exp.bytes(Buffer.from([0x02])), exp.int(8), exp.int(0)), exp.int(8), exp.int(0)), exp.bit.get(bin, exp.int(8), exp.int(16)),)uint8_t v[] = {0x02};as_exp_build(predexp, as_exp_cmp_eq( as_exp_bit_get( as_exp_int(0), as_exp_int(8), as_exp_bit_xor( NULL, as_exp_int(0), as_exp_int(8), as_exp_bytes(v, sizeof(v)), as_exp_bin_blob("device_flags"))), as_exp_bit_get(as_exp_int(16), as_exp_int(8), as_exp_bin_blob("device_flags"))));import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;import com.aerospike.client.operation.BitPolicy;
Expression exp = Exp.build( Exp.eq( BitExp.get( Exp.val(0), Exp.val(8), BitExp.xor( BitPolicy.Default, Exp.val(0), Exp.val(8), Exp.val(new byte[] {0x02}), Exp.blobBin("device_flags"))), BitExp.get(Exp.val(16), Exp.val(8), Exp.blobBin("device_flags"))));from aerospike_helpers.expressions import BlobBin, Eqfrom aerospike_helpers.expressions.bitwise import BitGet, BitXor
b = BlobBin("device_flags")exp = Eq(BitGet(0, 8, BitXor(None, 0, 8, bytearray([0x02]), b)), BitGet(16, 8, b)).compile()Read
bit_b64_encode(byte_offset, byte_size, invert_size, bin)Returns the byte_size bytes starting at byte_offset, base64 encoded as a string. With invert_size, byte_size counts back from the end of the blob instead, so the span runs from byte_offset to that many bytes before the end.
| Name | Type | Description |
|---|---|---|
byte_offset | integer | Offset in bytes from the start of the blob. |
byte_size | integer | Number of bytes to encode. When |
invert_size | boolean literal | When true, |
bin | blob | Blob bin to operate on, or any expression that evaluates to a blob. |
string Filter where the base64 text of the whole flags bin equals AUKwBAU= (the 5-byte [0x01, 0x42, 0xB0, 0x04, 0x05] pattern used throughout the Blob reference).
String exp = "$.flags.b64Encode() == 'AUKwBAU='";exp = "$.flags.b64Encode() == 'AUKwBAU='"use aerospike::expressions::bitwise as bit_exp;use aerospike::expressions::{blob_bin, eq, string_val};
let exp = eq( bit_exp::b64_encode(blob_bin("flags".into())), string_val("AUKwBAU=".into()));Expression exp = Exp.Build( Exp.EQ( BitExp.B64Encode(Exp.BlobBin("flags")), Exp.Val("AUKwBAU=")));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpEq( as.ExpBitB64Encode(as.ExpBlobBin("flags")), as.ExpStringVal("AUKwBAU="),)const exp = Aerospike.exp
const filterExp = exp.eq( exp.bit.b64Encode(exp.binBlob('flags')), exp.str('AUKwBAU='),)as_exp_build(predexp, as_exp_cmp_eq( as_exp_bit_b64_encode(as_exp_bin_blob("flags")), as_exp_str("AUKwBAU=")));import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;
Expression exp = Exp.build( Exp.eq( BitExp.b64Encode(Exp.blobBin("flags")), Exp.val("AUKwBAU=")));from aerospike_helpers.expressions import BlobBin, Eqfrom aerospike_helpers.expressions.bitwise import BitB64Encode
exp = Eq(BitB64Encode(0, None, False, BlobBin("flags")), "AUKwBAU=").compile()bit_count(bit_offset, bit_size, bin)Returns the number of bits set to 1 in the bit_size bits starting at bit_offset.
| Name | Type | Description |
|---|---|---|
bit_offset | integer | Offset in bits from the start of the blob to the first bit of the region. |
bit_size | integer | Width of the region in bits. |
bin | blob | Blob bin to operate on, or any expression that evaluates to a blob. |
integer Filter where the second byte of device_flags (bits 8–15) has more than one bit set (0x42).
String exp = "$.device_flags.bitCount(offset: 8, size: 8) > 1";exp = "$.device_flags.bitCount(offset: 8, size: 8) > 1"use aerospike::expressions::bitwise as bit_exp;use aerospike::expressions::{blob_bin, gt, int_val};
let exp = gt( bit_exp::count(int_val(8), int_val(8), blob_bin("device_flags".into())), int_val(1));Expression exp = Exp.Build( Exp.GT(BitExp.Count(Exp.Val(8), Exp.Val(8), Exp.BlobBin("device_flags")), Exp.Val(1)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpGreater( as.ExpBitCount(as.ExpIntVal(8), as.ExpIntVal(8), as.ExpBlobBin("device_flags")), as.ExpIntVal(1),)const exp = Aerospike.exp
const filterExp = exp.gt( exp.bit.count(exp.binBlob('device_flags'), exp.int(8), exp.int(8)), exp.int(1),)as_exp_build(predexp, as_exp_cmp_gt( as_exp_bit_count(as_exp_int(8), as_exp_int(8), as_exp_bin_blob("device_flags")), as_exp_int(1)));import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;
Expression exp = Exp.build( Exp.gt(BitExp.count(Exp.val(8), Exp.val(8), Exp.blobBin("device_flags")), Exp.val(1)));from aerospike_helpers.expressions import BlobBin, GTfrom aerospike_helpers.expressions.bitwise import BitCount
exp = GT(BitCount(8, 8, BlobBin("device_flags")), 1).compile()bit_get(bit_offset, bit_size, bin)Returns the bit_size bits starting at bit_offset, as a blob.
| Name | Type | Description |
|---|---|---|
bit_offset | integer | Offset in bits from the start of the blob to the first bit of the region. |
bit_size | integer | Width of the region in bits. |
bin | blob | Blob bin to operate on, or any expression that evaluates to a blob. |
blob Filter where bits 16–23 of blob bin device_flags read as one byte equal 0x03.
String exp = "$.device_flags.bitGet(offset: 16, size: 8) == x'03'";exp = "$.device_flags.bitGet(offset: 16, size: 8) == x'03'"use aerospike::expressions::bitwise as bit_exp;use aerospike::expressions::{blob_bin, blob_val, eq, int_val};
let exp = eq( bit_exp::get(int_val(16), int_val(8), blob_bin("device_flags".into())), blob_val(vec![0x03]));Expression exp = Exp.Build( Exp.EQ( BitExp.Get(Exp.Val(16), Exp.Val(8), Exp.BlobBin("device_flags")), Exp.Val(new byte[] {0x03})));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpEq( as.ExpBitGet(as.ExpIntVal(16), as.ExpIntVal(8), as.ExpBlobBin("device_flags")), as.ExpBlobVal([]byte{0x03}),)const exp = Aerospike.exp
const filterExp = exp.eq( exp.bit.get(exp.binBlob('device_flags'), exp.int(8), exp.int(16)), exp.bytes(Buffer.from([0x03])),)uint8_t want[] = {0x03};as_exp_build(predexp, as_exp_cmp_eq( as_exp_bit_get(as_exp_int(16), as_exp_int(8), as_exp_bin_blob("device_flags")), as_exp_bytes(want, sizeof(want))));import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;
Expression exp = Exp.build( Exp.eq( BitExp.get(Exp.val(16), Exp.val(8), Exp.blobBin("device_flags")), Exp.val(new byte[] {0x03})));from aerospike_helpers.expressions import BlobBin, Eqfrom aerospike_helpers.expressions.bitwise import BitGet
exp = Eq(BitGet(16, 8, BlobBin("device_flags")), bytearray([0x03])).compile()bit_get_int(bit_offset, bit_size, signed, bin)Returns the bit_size bits starting at bit_offset as an integer, read as signed when signed is true and as unsigned when it is false.
| Name | Type | Description |
|---|---|---|
bit_offset | integer | Offset in bits from the start of the blob to the first bit of the region. |
bit_size | integer | Width of the region in bits. |
signed | boolean literal | Whether to read the region as a signed integer. |
bin | blob | Blob bin to operate on, or any expression that evaluates to a blob. |
integer Filter where the signed 8-bit integer at bit offset 32 in device_flags equals 5 (fifth byte 0x05).
String exp = "$.device_flags.bitGetInt(offset: 32, size: 8, signed: true) == 5";exp = "$.device_flags.bitGetInt(offset: 32, size: 8, signed: true) == 5"use aerospike::expressions::bitwise as bit_exp;use aerospike::expressions::{blob_bin, eq, int_val};
let exp = eq( bit_exp::get_int(int_val(32), int_val(8), true, blob_bin("device_flags".into())), int_val(5));Expression exp = Exp.Build( Exp.EQ( BitExp.GetInt(Exp.Val(32), Exp.Val(8), true, Exp.BlobBin("device_flags")), Exp.Val(5)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpEq( as.ExpBitGetInt(as.ExpIntVal(32), as.ExpIntVal(8), true, as.ExpBlobBin("device_flags")), as.ExpIntVal(5),)const exp = Aerospike.exp
const filterExp = exp.eq( exp.bit.getInt(exp.binBlob('device_flags'), true, exp.int(8), exp.int(32)), exp.int(5),)as_exp_build(predexp, as_exp_cmp_eq( as_exp_bit_get_int(as_exp_int(32), as_exp_int(8), true, as_exp_bin_blob("device_flags")), as_exp_int(5)));import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;
Expression exp = Exp.build( Exp.eq( BitExp.getInt(Exp.val(32), Exp.val(8), true, Exp.blobBin("device_flags")), Exp.val(5)));from aerospike_helpers.expressions import BlobBin, Eqfrom aerospike_helpers.expressions.bitwise import BitGetInt
exp = Eq(BitGetInt(32, 8, True, BlobBin("device_flags")), 5).compile()bit_lscan(bit_offset, bit_size, value, bin)Returns the position of the first bit equal to value, scanning the bit_size bits at bit_offset from left to right. The position is relative to bit_offset, so 0 is the bit at bit_offset itself. Returns -1 when no bit matches.
| Name | Type | Description |
|---|---|---|
bit_offset | integer | Offset in bits from the start of the blob to the first bit of the region. |
bit_size | integer | Width of the region in bits. |
value | boolean | Bit value to look for: true finds a bit set to 1, false finds a bit set to 0. |
bin | blob | Blob bin to operate on, or any expression that evaluates to a blob. |
integer Filter where a left scan for a set bit in the fifth byte of device_flags (bits 32–39) returns index 5.
String exp = "$.device_flags.bitLscan(offset: 32, size: 8, value: true) == 5";exp = "$.device_flags.bitLscan(offset: 32, size: 8, value: true) == 5"use aerospike::expressions::bitwise as bit_exp;use aerospike::expressions::{blob_bin, bool_val, eq, int_val};
let exp = eq( bit_exp::lscan( int_val(32), int_val(8), bool_val(true), blob_bin("device_flags".into())), int_val(5));Expression exp = Exp.Build( Exp.EQ( BitExp.Lscan(Exp.Val(32), Exp.Val(8), Exp.Val(true), Exp.BlobBin("device_flags")), Exp.Val(5)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpEq( as.ExpBitLScan(as.ExpIntVal(32), as.ExpIntVal(8), as.ExpBoolVal(true), as.ExpBlobBin("device_flags")), as.ExpIntVal(5),)const exp = Aerospike.exp
const filterExp = exp.eq( exp.bit.lScan(exp.binBlob('device_flags'), exp.bool(true), exp.int(8), exp.int(32)), exp.int(5),)as_exp_build(predexp, as_exp_cmp_eq( as_exp_bit_lscan( as_exp_int(32), as_exp_int(8), as_exp_bool(true), as_exp_bin_blob("device_flags")), as_exp_int(5)));import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;
Expression exp = Exp.build( Exp.eq( BitExp.lscan(Exp.val(32), Exp.val(8), Exp.val(true), Exp.blobBin("device_flags")), Exp.val(5)));from aerospike_helpers.expressions import BlobBin, Eqfrom aerospike_helpers.expressions.bitwise import BitLeftScan
exp = Eq(BitLeftScan(32, 8, True, BlobBin("device_flags")), 5).compile()bit_rscan(bit_offset, bit_size, value, bin)Returns the position of the last bit equal to value, scanning the bit_size bits at bit_offset from right to left. The position is relative to bit_offset. Returns -1 when no bit matches.
| Name | Type | Description |
|---|---|---|
bit_offset | integer | Offset in bits from the start of the blob to the first bit of the region. |
bit_size | integer | Width of the region in bits. |
value | boolean | Bit value to look for: true finds a bit set to 1, false finds a bit set to 0. |
bin | blob | Blob bin to operate on, or any expression that evaluates to a blob. |
integer Filter where a right scan for a set bit in the fifth byte of device_flags returns index 7.
String exp = "$.device_flags.bitRscan(offset: 32, size: 8, value: true) == 7";exp = "$.device_flags.bitRscan(offset: 32, size: 8, value: true) == 7"use aerospike::expressions::bitwise as bit_exp;use aerospike::expressions::{blob_bin, bool_val, eq, int_val};
let exp = eq( bit_exp::rscan( int_val(32), int_val(8), bool_val(true), blob_bin("device_flags".into())), int_val(7));Expression exp = Exp.Build( Exp.EQ( BitExp.Rscan(Exp.Val(32), Exp.Val(8), Exp.Val(true), Exp.BlobBin("device_flags")), Exp.Val(7)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpEq( as.ExpBitRScan(as.ExpIntVal(32), as.ExpIntVal(8), as.ExpBoolVal(true), as.ExpBlobBin("device_flags")), as.ExpIntVal(7),)const exp = Aerospike.exp
const filterExp = exp.eq( exp.bit.rScan(exp.binBlob('device_flags'), exp.bool(true), exp.int(8), exp.int(32)), exp.int(7),)as_exp_build(predexp, as_exp_cmp_eq( as_exp_bit_rscan( as_exp_int(32), as_exp_int(8), as_exp_bool(true), as_exp_bin_blob("device_flags")), as_exp_int(7)));import com.aerospike.client.exp.BitExp;import com.aerospike.client.exp.Expression;import com.aerospike.client.exp.Exp;
Expression exp = Exp.build( Exp.eq( BitExp.rscan(Exp.val(32), Exp.val(8), Exp.val(true), Exp.blobBin("device_flags")), Exp.val(7)));from aerospike_helpers.expressions import BlobBin, Eqfrom aerospike_helpers.expressions.bitwise import BitRightScan
exp = Eq(BitRightScan(32, 8, True, BlobBin("device_flags")), 7).compile()