Loading...
Searching...
No Matches
Functions
UDF Operations

Description

The UDF API provides the ability to manage UDFs in the cluster.

Management capabilities include:

+ Collaboration diagram for UDF Operations:

Functions

AS_EXTERN as_status aerospike_udf_get (aerospike *as, as_error *err, const as_policy_info *policy, const char *filename, as_udf_type type, as_udf_file *file)
 
AS_EXTERN as_status aerospike_udf_list (aerospike *as, as_error *err, const as_policy_info *policy, as_udf_files *files)
 
AS_EXTERN as_status aerospike_udf_put (aerospike *as, as_error *err, const as_policy_info *policy, const char *filename, as_udf_type type, as_bytes *content)
 
AS_EXTERN as_status aerospike_udf_put_wait (aerospike *as, as_error *err, const as_policy_info *policy, const char *filename, uint32_t interval_ms)
 
AS_EXTERN as_status aerospike_udf_remove (aerospike *as, as_error *err, const as_policy_info *policy, const char *filename)
 
AS_EXTERN as_status aerospike_udf_remove_wait (aerospike *as, as_error *err, const as_policy_info *policy, const char *filename, uint32_t interval_ms)
 

Function Documentation

◆ aerospike_udf_get()

AS_EXTERN as_status aerospike_udf_get ( aerospike * as,
as_error * err,
const as_policy_info * policy,
const char * filename,
as_udf_type type,
as_udf_file * file )

Get specified UDF file from the cluster.

if (aerospike_udf_get(&as, &err, NULL, "my.lua", AS_UDF_TYPE_LUA, &file) != AEROSPIKE_OK) {
fprintf(stderr, "error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
}
else {
printf("%s type=%d hash=%s size=%d:\n", file.name, file.type. file.hash, file.content.size);
if (file.type == AS_UDF_TYPE_UDF) {
printf("%s", file.content.bytes)
}
}
@ AEROSPIKE_OK
Definition as_status.h:128
AS_EXTERN as_udf_file * as_udf_file_init(as_udf_file *file)
@ AS_UDF_TYPE_LUA
Definition as_udf.h:120
AS_EXTERN void as_udf_file_destroy(as_udf_file *file)
AS_EXTERN as_status aerospike_udf_get(aerospike *as, as_error *err, const as_policy_info *policy, const char *filename, as_udf_type type, as_udf_file *file)
char name[AS_UDF_FILE_NAME_SIZE]
Definition as_udf.h:132
uint8_t hash[AS_UDF_FILE_HASH_SIZE+1]
Definition as_udf.h:170
as_udf_type type
Definition as_udf.h:165
struct as_udf_file::@8 content
uint8_t * bytes
Definition as_udf.h:142
uint32_t size
Definition as_udf.h:152
Parameters
asThe aerospike instance to use for this operation.
errThe as_error to be populated if an error occurs.
policyThe policy to use for this operation. If NULL, then the default policy will be used.
filenameThe name of the UDF file.
typeThe type of UDF file.
fileThe file from the cluster.
Returns
AEROSPIKE_OK if successful. Otherwise an error occurred.

◆ aerospike_udf_list()

AS_EXTERN as_status aerospike_udf_list ( aerospike * as,
as_error * err,
const as_policy_info * policy,
as_udf_files * files )

List the UDF files in the cluster.

as_udf_files_init(&files, 0);
if (aerospike_udf_list(&as, &err, NULL, &files) != AEROSPIKE_OK) {
fprintf(stderr, "error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
}
else {
printf("files[%d]:\n", files.size);
for(int i = 0; i < files.size; i++) {
as_udf_file * file = &files.entries[i];
printf(" - %s (%d) [%s]\n", file->name, file->type, file->hash);
}
}
AS_EXTERN as_udf_files * as_udf_files_init(as_udf_files *files, uint32_t capacity)
AS_EXTERN void as_udf_files_destroy(as_udf_files *files)
AS_EXTERN as_status aerospike_udf_list(aerospike *as, as_error *err, const as_policy_info *policy, as_udf_files *files)
uint32_t size
Definition as_udf.h:198
as_udf_file * entries
Definition as_udf.h:188
Parameters
asThe aerospike instance to use for this operation.
errThe as_error to be populated if an error occurs.
policyThe policy to use for this operation. If NULL, then the default policy will be used.
filesThe list to populate with the results from the request.
Returns
AEROSPIKE_OK if successful. Otherwise an error occurred.

◆ aerospike_udf_put()

AS_EXTERN as_status aerospike_udf_put ( aerospike * as,
as_error * err,
const as_policy_info * policy,
const char * filename,
as_udf_type type,
as_bytes * content )

Put a UDF file into the cluster. This function will return before the put is completed on all nodes. Use aerospike_udf_put_wait() when need to wait for completion.

as_bytes content;
as_bytes_init(&content);
...
if (aerospike_udf_put(&as, &err, NULL, "my.lua", AS_UDF_TYPE_LUA, &content) != AEROSPIKE_OK) {
fprintf(stderr, "error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
}
as_bytes_destroy(&content);
AS_EXTERN as_bytes * as_bytes_init(as_bytes *bytes, uint32_t capacity)
static void as_bytes_destroy(as_bytes *bytes)
Definition as_bytes.h:401
AS_EXTERN as_status aerospike_udf_put(aerospike *as, as_error *err, const as_policy_info *policy, const char *filename, as_udf_type type, as_bytes *content)
Parameters
asThe aerospike instance to use for this operation.
errThe as_error to be populated if an error occurs.
policyThe policy to use for this operation. If NULL, then the default policy will be used.
filenameThe name of the UDF file.
typeThe type of UDF file.
contentThe file of the UDF file.
Returns
AEROSPIKE_OK if UDF put was started. Otherwise an error occurred.

◆ aerospike_udf_put_wait()

AS_EXTERN as_status aerospike_udf_put_wait ( aerospike * as,
as_error * err,
const as_policy_info * policy,
const char * filename,
uint32_t interval_ms )

Wait for asynchronous udf put to complete using given polling interval.

as_bytes content;
as_bytes_init(&content);
if (aerospike_udf_put(&as, &err, NULL, "my.lua", AS_UDF_TYPE_LUA, &content) == AEROSPIKE_OK ) {
aerospike_udf_put_wait(&as, &err, NULL, "my.lua", 0);
}
as_bytes_destroy(&content);
AS_EXTERN as_status aerospike_udf_put_wait(aerospike *as, as_error *err, const as_policy_info *policy, const char *filename, uint32_t interval_ms)
Parameters
asThe aerospike instance to use for this operation.
errThe as_error to be populated if an error occurs.
policyThe policy to use for this operation. If NULL, then the default policy will be used.
filenameThe name of the UDF file.
interval_msThe polling interval in milliseconds. If zero, 1000 ms is used.
Returns
AEROSPIKE_OK if successful. Otherwise an error occurred.

◆ aerospike_udf_remove()

AS_EXTERN as_status aerospike_udf_remove ( aerospike * as,
as_error * err,
const as_policy_info * policy,
const char * filename )

Remove a UDF file from the cluster. This function will return before the remove is completed on all nodes. Use aerospike_udf_remove_wait() when need to wait for completion.

if (aerospike_udf_remove(&as, &err, NULL, "my.lua") != AEROSPIKE_OK) {
fprintf(stderr, "error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
}
AS_EXTERN as_status aerospike_udf_remove(aerospike *as, as_error *err, const as_policy_info *policy, const char *filename)
Parameters
asThe aerospike instance to use for this operation.
errThe as_error to be populated if an error occurs.
policyThe policy to use for this operation. If NULL, then the default policy will be used.
filenameThe name of the UDF file.
Returns
AEROSPIKE_OK if remove was started. Otherwise an error occurred.

◆ aerospike_udf_remove_wait()

AS_EXTERN as_status aerospike_udf_remove_wait ( aerospike * as,
as_error * err,
const as_policy_info * policy,
const char * filename,
uint32_t interval_ms )

Wait for asynchronous udf remove to complete using given polling interval.

*
if (aerospike_udf_remove(&as, &err, NULL, "my.lua") == AEROSPIKE_OK) {
aerospike_udf_remove_wait(&as, &err, NULL, "my.lua", 0);
}
AS_EXTERN as_status aerospike_udf_remove_wait(aerospike *as, as_error *err, const as_policy_info *policy, const char *filename, uint32_t interval_ms)
Parameters
asThe aerospike instance to use for this operation.
errThe as_error to be populated if an error occurs.
policyThe policy to use for this operation. If NULL, then the default policy will be used.
filenameThe name of the UDF file.
interval_msThe polling interval in milliseconds. If zero, 1000 ms is used.
Returns
AEROSPIKE_OK if successful. Otherwise an error occurred.