Add new records in context of UDF



I am looking for a way to insert/create new records in AeroSpike DB in context of a UDF. Requirement is to register a UDF with background scan which will delete some of the old records and correspondingly create new ones with different primary key. New records will have same data as old one but will be stored with different primary key in AeroSpike.

“create” method mentioned in some of the available UDF documents, expect “rec” as input parameter. What I am looking for is to create a totally new record and populate it’s bins with given input record.



A UDF can only handle 1 key at a time properly… It would be best to handle this from client code.


Thanks for the reply. Is it possible to update the primary key of the record itself in UDF (replace the old key with new PK ) and then use the “update” method for persistence. This way we are dealing with single record (return by scan) rather than the approach I mentioned earlier, creating a new record and deleting the old one.


No, you cannot change the PK within a UDF while it is operating on a record. I think you want to handle the entire thing from application code for this. Maybe if you tell us more about your use case we can come up with an alternative?


We are trying to maintain snapshot hierarchy in Aerospike DB. Each snapshot has a special ID and blocks of individual snapshots are being stored into Aerospike with their corresponding special IDs (part of record’s PK). Once a snapshot is deleted, it’s blocks need to be merged into next snapshot in the chain and we are trying to offload this to Aerospike server using UDF (rather than involving client to read data and rewriting it with new snapshot ID).