All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
src/include/citrusleaf/as_scan.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 #pragma once
23 
24 #include <citrusleaf/cl_types.h>
25 #include <citrusleaf/cl_cluster.h>
26 #include <citrusleaf/cl_scan.h>
27 
28 #include <aerospike/as_list.h>
29 #include <stdbool.h>
30 
31 /******************************************************************************
32  * TYPES
33  ******************************************************************************/
34 
35 typedef uint8_t cl_scan_pct;
36 
37 typedef enum cl_scan_udf_execution_type_s {
38  CL_SCAN_UDF_NONE, // Scan w/o udfs -- noop
39  CL_SCAN_UDF_CLIENT_RECORD, // Job per record
40  CL_SCAN_UDF_BACKGROUND, // Background job no response
42 
43 typedef struct cl_scan_udf_s {
45  char * filename;
46  char * function;
48 } cl_scan_udf;
49 
50 typedef struct cl_scan_parameters {
51  bool fail_on_cluster_change; // honored by server: terminate scan if cluster in fluctuating state
52  cl_scan_priority priority; // honored by server: priority of scan
53  cl_scan_pct pct; // honored by server: % of data to be scanned
54  bool concurrent; // honored by client: if all the nodes should be scanned in parallel or not
56 
57 typedef struct cl_scan_s {
58  char * ns;
59  char * setname;
62  void * res_streamq;
63  uint64_t job_id;
64 } cl_scan;
65 
66 typedef struct cl_scan_response_record_t {
67  char * ns;
68  cf_digest keyd;
69  char * set;
70  uint32_t generation;
71  uint32_t record_ttl;
73  int n_bins;
74  bool ismalloc;
76 
77 
78 typedef bool (* cl_scan_cb) (const as_val * val, void * udata);
79 
80 /******************************************************************************
81  * FUNCTIONS
82  ******************************************************************************/
83 
84 /**
85  * Allocates and initializes a new cl_scan
86  */
87 cl_scan * cl_scan_new(const char *ns, const char *setname, uint64_t *job_id);
88 
89 /**
90  * Initializes an cl_scan
91  */
92 cl_scan * cl_scan_init(cl_scan *scan , const char *ns, const char *setname, uint64_t *job_id);
93 cl_rv cl_scan_udf_init(cl_scan_udf * udf, udf_execution_type type, const char * filename, const char * function, as_list * arglist);
95 
96 /**
97  * Destroy and free an cl_scan
98  */
99 void cl_scan_destroy(cl_scan * scan);
100 
101 /**
102  * Initializing udfs
103  */
104 int cl_scan_foreach (cl_scan *scan, const char *filename, const char *function, as_list *arglist);
105 
106 /**
107  * Return vector of cl_rv for each node
108  */
109 cl_rv citrusleaf_udf_scan_node (cl_cluster *asc, cl_scan *scan, char *node_name, int( *callback)(as_val *, void *), void * udata);
110 cf_vector * citrusleaf_udf_scan_all_nodes (cl_cluster *asc, cl_scan *scan, int( *callback)(as_val *, void *), void * udata);
111 cf_vector * citrusleaf_udf_scan_background (cl_cluster *asc, cl_scan *scan);
112 cl_rv citrusleaf_udf_scan_node_background (cl_cluster *asc, cl_scan *scan, char *node_name);
113 
114 /*
115  * Init and destroy for client scan environment. Should be called for once per cluster
116  * instance before performing citrusleaf scan
117  */
118 int cl_cluster_scan_init(cl_cluster* asc);
119 void cl_cluster_scan_shutdown(cl_cluster* asc);