Main Page
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
src
include
citrusleaf
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 {
29
CL_WRITE_ASYNC
,
30
CL_WRITE_ONESHOT
,
31
CL_WRITE_RETRY
,
32
CL_WRITE_ASSURED
33
}
cl_write_policy
;
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
;
50
int
timeout_ms
;
51
uint32_t
record_ttl
;
// seconds, from now, when the record would be auto-removed from the DBcd
52
cl_write_policy
w_pol
;
53
}
cl_write_parameters
;
54
55
/******************************************************************************
56
* INLINE FUNCTIONS
57
******************************************************************************/
58
59
static
inline
void
cl_write_parameters_set_default
(
cl_write_parameters
*cl_w_p) {
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
79
static
inline
void
cl_write_parameters_set_generation_gt
(
cl_write_parameters
*cl_w_p, uint32_t
generation
) {
80
cl_w_p->
generation
=
generation
;
81
cl_w_p->
use_generation_gt
=
true
;
82
}
83
84
static
inline
void
cl_write_parameters_set_generation_dup
(
cl_write_parameters
*cl_w_p, uint32_t
generation
) {
85
cl_w_p->
generation
=
generation
;
86
cl_w_p->
use_generation_dup
=
true
;
87
}
cl_write_parameters::use_generation_gt
bool use_generation_gt
Definition:
cl_write.h:47
cl_write_parameters::use_generation_dup
bool use_generation_dup
Definition:
cl_write.h:48
cl_write_parameters::unique_bin
bool unique_bin
Definition:
cl_write.h:41
cl_write_parameters::bin_replace_only
bool bin_replace_only
Definition:
cl_write.h:45
generation
uint32_t generation
Definition:
src/include/citrusleaf/cf_proto.h:61
CL_WRITE_ONESHOT
Definition:
cl_write.h:30
cl_write_parameters::record_ttl
uint32_t record_ttl
Definition:
cl_write.h:51
cl_write_parameters_set_generation_dup
static void cl_write_parameters_set_generation_dup(cl_write_parameters *cl_w_p, uint32_t generation)
Definition:
cl_write.h:84
cl_write_parameters_set_generation
static void cl_write_parameters_set_generation(cl_write_parameters *cl_w_p, uint32_t generation)
Definition:
cl_write.h:74
cl_write_parameters::replace_only
bool replace_only
Definition:
cl_write.h:44
cl_write_parameters
Definition:
cl_write.h:39
cl_write_parameters::use_generation
bool use_generation
Definition:
cl_write.h:46
CL_WRITE_ASYNC
Definition:
cl_write.h:29
cl_write_policy
cl_write_policy
Definition:
cl_write.h:28
cl_write_parameters_set_generation_gt
static void cl_write_parameters_set_generation_gt(cl_write_parameters *cl_w_p, uint32_t generation)
Definition:
cl_write.h:79
cl_write_parameters::update_only
bool update_only
Definition:
cl_write.h:42
CL_WRITE_RETRY
Definition:
cl_write.h:31
cl_write_parameters::timeout_ms
int timeout_ms
Definition:
cl_write.h:50
cl_write_parameters::generation
uint32_t generation
Definition:
cl_write.h:49
CL_WRITE_ASSURED
Definition:
cl_write.h:32
cl_write_parameters::w_pol
cl_write_policy w_pol
Definition:
cl_write.h:52
cl_write_parameters::unique
bool unique
Definition:
cl_write.h:40
cl_write_parameters_set_default
static void cl_write_parameters_set_default(cl_write_parameters *cl_w_p)
Definition:
cl_write.h:59
cl_write_parameters::create_or_replace
bool create_or_replace
Definition:
cl_write.h:43