All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
as_partition.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2008-2014 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 <aerospike/as_node.h>
25 #include <citrusleaf/cf_digest.h>
26 
27 /******************************************************************************
28  * MACROS
29  *****************************************************************************/
30 
31 /**
32  * Maximum namespace size including null byte. Effective maximum length is 31.
33  */
34 #define AS_MAX_NAMESPACE_SIZE 32
35 
36 /******************************************************************************
37  * TYPES
38  *****************************************************************************/
39 
40 /**
41  * @private
42  * Map of namespace data partitions to nodes.
43  */
44 typedef struct as_partition_s {
45  /**
46  * @private
47  * Master node for this partition.
48  */
50 
51  /**
52  * @private
53  * Prole node for this partition.
54  * TODO - not ideal for replication factor > 2.
55  */
57 } as_partition;
58 
59 /**
60  * @private
61  * Map of namespace to data partitions.
62  */
63 typedef struct as_partition_table_s {
64  /**
65  * @private
66  * Namespace
67  */
69 
70  /**
71  * @private
72  * Fixed length of partition array.
73  */
74  uint32_t size;
75 
76  /**
77  * @private
78  * Array of partitions for a given namespace.
79  */
80  as_partition partitions[];
82 
83 /**
84  * @private
85  * Reference counted array of partition table pointers.
86  */
87 typedef struct as_partition_tables_s {
88  /**
89  * @private
90  * Reference count of partition table array.
91  */
92  uint32_t ref_count;
93 
94  /**
95  * @private
96  * Length of partition table array.
97  */
98  uint32_t size;
99 
100  /**
101  * @private
102  * Partition table array.
103  */
106 
107 /******************************************************************************
108  * FUNCTIONS
109  ******************************************************************************/
110 
111 /**
112  * @private
113  * Create reference counted structure containing partition tables.
114  */
116 as_partition_tables_create(uint32_t capacity);
117 
118 /**
119  * @private
120  * Destroy and release memory for partition table.
121  */
122 void
124 
125 /**
126  * @private
127  * Get partition table given namespace.
128  */
130 as_partition_tables_get(as_partition_tables* tables, const char* ns);
131 
132 /**
133  * @private
134  * Is node referenced in any partition table.
135  */
136 bool