How to do bitwise operation on UDF

I want to use bitwise operation like xor on the UDF, is there any way of doing that?

Lua UDF can use standard luajit bitops library

Checkout API Functions for more ops

Example File: bittest.lua

local bit = require(“bit”) function xorbitandstore (rec, binname, a, b) local c = bit.bxor(a,b) rec[binname] = c; if aerospike:exists(rec) then aerospike:update(rec) else aerospike:create(rec) end return c end

aql> register module ‘bittest.lua’ OK, 1 module added.

aql> execute bittest.xorbitandstore(‘mybin’, 3,5) on test.demo where PK=‘1’ ±---------------+ | xorbitandstore | ±---------------+ | 6 | ±---------------+ 1 row in set (0.000 secs)

aql> select * from test.demo where PK=‘1’ ±------+ | mybin | ±------+ | 6 | ±------+ 1 row in set (0.000 secs)

1 Like