Main Page
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
aerospike
aerospike_udf.h
Go to the documentation of this file.
1
/*
2
* Copyright 2008-2014 Aerospike, Inc.
3
*
4
* Portions may be licensed to Aerospike, Inc. under one or more contributor
5
* license agreements.
6
*
7
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
8
* use this file except in compliance with the License. You may obtain a copy of
9
* the License at http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
* License for the specific language governing permissions and limitations under
15
* the License.
16
*/
17
#pragma once
18
19
/**
20
* @defgroup udf_operations UDF Operations (3.0 only)
21
* @ingroup client_operations
22
*
23
* The UDF API provides the ability to manage UDFs in the cluster.
24
*
25
* Management capabilities include:
26
* - aerospike_udf_list() - List the UDF modules in the cluster.
27
* - aerospike_udf_get() - Download a UDF module.
28
* - aerospike_udf_put() - Upload a UDF module.
29
* - aerospike_udf_remove() - Remove a UDF module.
30
*
31
*/
32
33
#include <
aerospike/aerospike.h
>
34
#include <
aerospike/as_error.h
>
35
#include <
aerospike/as_policy.h
>
36
#include <
aerospike/as_status.h
>
37
#include <
aerospike/as_udf.h
>
38
39
/******************************************************************************
40
* FUNCTIONS
41
*****************************************************************************/
42
43
/**
44
* List the UDF files in the cluster.
45
*
46
* ~~~~~~~~~~{.c}
47
* as_udf_files files;
48
* as_udf_files_init(&files, 0);
49
*
50
* if ( aerospike_udf_list(&as, &err, NULL, &files) != AEROSPIKE_OK ) {
51
* fprintf(stderr, "error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
52
* }
53
* else {
54
* printf("files[%d]:\n", files.size);
55
* for( int i = 0; i < files.size; i++ ) {
56
* as_udf_file * file = &files.entries[i];
57
* printf(" - %s (%d) [%s]\n", file->name, file->type, file->hash);
58
* }
59
* }
60
*
61
* as_udf_files_destroy(&files);
62
* ~~~~~~~~~~
63
*
64
*
65
* @param as The aerospike instance to use for this operation.
66
* @param err The as_error to be populated if an error occurs.
67
* @param policy The policy to use for this operation. If NULL, then the default policy will be used.
68
* @param files The list to populate with the results from the request.
69
*
70
* @return AEROSPIKE_OK if successful. Otherwise an error occurred.
71
*
72
* @ingroup udf_operations
73
*/
74
as_status
aerospike_udf_list
(
75
aerospike
* as,
as_error
* err,
const
as_policy_info
* policy,
76
as_udf_files
* files
77
);
78
79
80
/**
81
* Get specified UDF file from the cluster.
82
*
83
* ~~~~~~~~~~{.c}
84
* as_udf_file file;
85
* as_udf_file_init(&file);
86
*
87
* if ( aerospike_udf_get(&as, &err, NULL, "my.lua", AS_UDF_TYPE_LUA, &file) != AEROSPIKE_OK ) {
88
* fprintf(stderr, "error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
89
* }
90
* else {
91
* printf("%s type=%d hash=%s size=%d:\n", file.name, file.type. file.hash, file.content.size);
92
* if ( file.type == AS_UDF_TYPE_UDF ) {
93
* printf("%s", file.content.bytes)
94
* }
95
* }
96
*
97
* as_udf_file_destroy(&file);
98
* ~~~~~~~~~~
99
*
100
*
101
* @param as The aerospike instance to use for this operation.
102
* @param err The as_error to be populated if an error occurs.
103
* @param policy The policy to use for this operation. If NULL, then the default policy will be used.
104
* @param filename The name of the UDF file.
105
* @param type The type of UDF file.
106
* @param file The file from the cluster.
107
*
108
* @return AEROSPIKE_OK if successful. Otherwise an error occurred.
109
*
110
* @ingroup udf_operations
111
*/
112
as_status
aerospike_udf_get
(
113
aerospike
* as,
as_error
* err,
const
as_policy_info
* policy,
114
const
char
* filename,
as_udf_type
type,
as_udf_file
* file
115
);
116
117
/**
118
* Put a UDF file into the cluster.
119
*
120
* ~~~~~~~~~~{.c}
121
* as_bytes content;
122
* as_bytes_init(&content);
123
* ...
124
*
125
* if ( aerospike_udf_put(&as, &err, NULL, "my.lua", AS_UDF_TYPE_LUA, &content) != AEROSPIKE_OK ) {
126
* fprintf(stderr, "error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
127
* }
128
*
129
* as_bytes_destroy(&content);
130
* ~~~~~~~~~~
131
*
132
*
133
* @param as The aerospike instance to use for this operation.
134
* @param err The as_error to be populated if an error occurs.
135
* @param policy The policy to use for this operation. If NULL, then the default policy will be used.
136
* @param filename The name of the UDF file.
137
* @param type The type of UDF file.
138
* @param content The file of the UDF file.
139
*
140
* @return AEROSPIKE_OK if successful. Otherwise an error occurred.
141
*
142
* @ingroup udf_operations
143
*/
144
as_status
aerospike_udf_put
(
145
aerospike
* as,
as_error
* err,
const
as_policy_info
* policy,
146
const
char
* filename,
as_udf_type
type,
as_bytes
* content
147
);
148
149
/**
150
* Remove a UDF file from the cluster.
151
*
152
* ~~~~~~~~~~{.c}
153
* if ( aerospike_udf_remove(&as, &err, NULL, "my.lua") != AEROSPIKE_OK ) {
154
* fprintf(stderr, "error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
155
* }
156
* ~~~~~~~~~~
157
*
158
* @param as The aerospike instance to use for this operation.
159
* @param err The as_error to be populated if an error occurs.
160
* @param policy The policy to use for this operation. If NULL, then the default policy will be used.
161
* @param filename The name of the UDF file.
162
*
163
* @return AEROSPIKE_OK if successful. Otherwise an error occurred.
164
*
165
* @ingroup udf_operations
166
*/
167
as_status
aerospike_udf_remove
(
168
aerospike
* as,
as_error
* err,
const
as_policy_info
* policy,
169
const
char
* filename
170
);