How to do bitwise operation on UDF


#1

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


Wrong value returned by record UDF
#2

Lua UDF can use standard luajit bitops library

Checkout http://bitop.luajit.org/api.html 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)