All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Functions
UDF Operations (3.0 only)

Description

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

Management capabilities include:

+ Collaboration diagram for UDF Operations (3.0 only):

Functions

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_status aerospike_udf_list (aerospike *as, as_error *err, const as_policy_info *policy, as_udf_files *files)
 
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_status aerospike_udf_put_wait (aerospike *as, as_error *err, const as_policy_info *policy, const char *filename, uint32_t interval_ms)
 
as_status aerospike_udf_remove (aerospike *as, as_error *err, const as_policy_info *policy, const char *filename)
 

Function Documentation

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)
}
}
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.
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);
}
}
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.
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.

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);
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 successful. Otherwise an error occurred.
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);
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.
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.

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);
}
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 successful. Otherwise an error occurred.