All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Typedefs | 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):

Typedefs

typedef int(* aerospike_udf_foreach_callback )(const as_udf_file *, void *)
 
typedef int(* aerospike_udf_foreach_callback )(const as_udf_file *, void *)
 

Functions

as_status aerospike_udf_foreach (aerospike *as, as_error *err, const as_policy_info *policy, aerospike_udf_foreach_callback callback, void *udata)
 
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_remove (aerospike *as, as_error *err, const as_policy_info *policy, const char *filename)
 

Typedef Documentation

typedef int(* aerospike_udf_foreach_callback)(const as_udf_file *, void *)

Callback for the aerospike_udf_foreach() function.

Definition at line 55 of file src/include/aerospike/aerospike_udf.h.

typedef int(* aerospike_udf_foreach_callback)(const as_udf_file *, void *)

Callback for the aerospike_udf_foreach() function.

Definition at line 55 of file target/Darwin-i386/include/aerospike/aerospike_udf.h.

Function Documentation

as_status aerospike_udf_foreach ( aerospike as,
as_error err,
const as_policy_info policy,
aerospike_udf_foreach_callback  callback,
void *  udata 
)

Call the callback function for each the UDF file in the cluster.

bool callback(cont as_udf_file * file, void * udata) {
printf(" - %s (%d) [%s]\n", file->name, file->type, file->hash);
return true;
}
printf("files[%d]:\n", list.size);
if ( aerospike_udf_foreach(&as, &err, NULL, callback, NULL) != 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.
callbackThe function to call for each udf file returned.
udataUser-data to be sent to the callback.
Returns
AEROSPIKE_OK if successful. Otherwise an error occurred.
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_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.