All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
example_utils.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright 2008-2013 by Aerospike.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to
6  * deal in the Software without restriction, including without limitation the
7  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8  * sell copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20  * IN THE SOFTWARE.
21  ******************************************************************************/
22 
23 #pragma once
24 
25 
26 //==========================================================
27 // Includes
28 //
29 
30 #include <stdbool.h>
31 #include <stdio.h>
32 
33 #include <aerospike/aerospike.h>
34 #include <aerospike/as_key.h>
35 #include <aerospike/as_operations.h>
36 #include <aerospike/as_record.h>
37 
38 
39 //==========================================================
40 // Example Logging Macros
41 //
42 
43 #define LOG(_fmt, _args...) { printf(_fmt "\n", ## _args); fflush(stdout); }
44 
45 #ifdef SHOW_DETAIL
46 #define DETAIL(_fmt, _args...) { printf(_fmt "\n", ## _args); fflush(stdout); }
47 #else
48 #define DETAIL(_fmt, _args...)
49 #endif
50 
51 
52 //==========================================================
53 // Example Namespace and Set
54 //
55 
56 #define MAX_NAMESPACE_SIZE 32 // based on current server limit
57 #define MAX_SET_SIZE 64 // based on current server limit
58 
59 extern char g_namespace[MAX_NAMESPACE_SIZE];
60 extern char g_set[MAX_SET_SIZE];
61 
62 
63 //==========================================================
64 // Example Test Key (for basic single-key examples)
65 //
66 
67 extern as_key g_key;
68 
69 
70 //==========================================================
71 // Example Test Key Count (for multiple-key examples)
72 //
73 
74 extern uint32_t g_n_keys;
75 
76 
77 //==========================================================
78 // Example Command Line Options
79 //
80 
81 #define EXAMPLE_BASIC_OPTS "h:p:n:s:k:"
82 #define EXAMPLE_MULTI_KEY_OPTS "h:p:n:s:K:"
83 
84 // Must be called first!
85 bool example_get_opts(int argc, char* argv[], const char* which_opts);
86 
87 
88 //==========================================================
89 // Example Utilities
90 //
91 
94  const char* lua_user_path);
95 void example_cleanup(aerospike* p_as);
100 bool example_register_udf(aerospike* p_as, const char* filename);
101 bool example_remove_udf(aerospike* p_as, const char* filename);
102 bool example_create_integer_index(aerospike* p_as, const char* bin,
103  const char* index);
104 void example_remove_index(aerospike* p_as, const char* index);
105 void example_dump_record(const as_record* p_rec);
106 void example_dump_operations(const as_operations* p_ops);
void example_dump_operations(const as_operations *p_ops)
char g_set[MAX_SET_SIZE]
uint32_t g_n_keys
char g_namespace[MAX_NAMESPACE_SIZE]
#define MAX_NAMESPACE_SIZE
Definition: example_utils.h:56
void example_remove_index(aerospike *p_as, const char *index)
void example_dump_record(const as_record *p_rec)
bool example_read_test_records(aerospike *p_as)
bool example_read_test_record(aerospike *p_as)
bool example_get_opts(int argc, char *argv[], const char *which_opts)
bool example_remove_udf(aerospike *p_as, const char *filename)
void example_connect_to_aerospike_with_udf_config(aerospike *p_as, const char *lua_user_path)
bool example_create_integer_index(aerospike *p_as, const char *bin, const char *index)
as_key g_key
void example_remove_test_record(aerospike *p_as)
#define MAX_SET_SIZE
Definition: example_utils.h:57
void example_connect_to_aerospike(aerospike *p_as)
bool example_register_udf(aerospike *p_as, const char *filename)
void example_remove_test_records(aerospike *p_as)
void example_cleanup(aerospike *p_as)