All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cl_write.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 /******************************************************************************
25  * CONSTANTS
26  ******************************************************************************/
27 
28 typedef enum cl_write_policy_e {
34 
35 /**
36  * write info structure
37  * There's a lot of info that can go into a write ---
38  */
39 typedef struct cl_write_parameters_s {
40  bool unique; // write unique - means success if didn't exist before
41  bool unique_bin; // write unique bin - means success if the bin didn't exist before
42  bool update_only; // means success only if the record did exist before
43  bool create_or_replace; // completely overwrite existing record if any, otherwise create
44  bool replace_only; // completely overwrite existing record, do not create new record
45  bool bin_replace_only; // replace existing bin, do not create new bin
46  bool use_generation; // generation must be exact for write to succeed
47  bool use_generation_gt; // generation must be less - good for backup & restore
48  bool use_generation_dup; // on generation collision, create a duplicate
49  uint32_t generation;
51  uint32_t record_ttl; // seconds, from now, when the record would be auto-removed from the DBcd
54 
55 /******************************************************************************
56  * INLINE FUNCTIONS
57  ******************************************************************************/
58 
60  cl_w_p->unique = false;
61  cl_w_p->unique_bin = false;
62  cl_w_p->update_only = false;
63  cl_w_p->create_or_replace = false;
64  cl_w_p->replace_only = false;
65  cl_w_p->bin_replace_only = false;
66  cl_w_p->use_generation = false;
67  cl_w_p->use_generation_gt = false;
68  cl_w_p->use_generation_dup = false;
69  cl_w_p->timeout_ms = 0;
70  cl_w_p->record_ttl = 0;
71  cl_w_p->w_pol = CL_WRITE_RETRY;
72 }
73 
74 static inline void cl_write_parameters_set_generation( cl_write_parameters *cl_w_p, uint32_t generation) {
75  cl_w_p->generation = generation;
76  cl_w_p->use_generation = true;
77 }
78 
80  cl_w_p->generation = generation;
81  cl_w_p->use_generation_gt = true;
82 }
83 
85  cl_w_p->generation = generation;
86  cl_w_p->use_generation_dup = true;
87 }