Main Page
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
aerospike
as_partition.h
Go to the documentation of this file.
1
/*
2
* Copyright 2008-2016 Aerospike, Inc.
3
*
4
* Portions may be licensed to Aerospike, Inc. under one or more contributor
5
* license agreements.
6
*
7
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
8
* use this file except in compliance with the License. You may obtain a copy of
9
* the License at http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
* License for the specific language governing permissions and limitations under
15
* the License.
16
*/
17
#pragma once
18
19
#include <
aerospike/as_node.h
>
20
21
#ifdef __cplusplus
22
extern
"C"
{
23
#endif
24
25
/******************************************************************************
26
* MACROS
27
*****************************************************************************/
28
29
/**
30
* Maximum namespace size including null byte. Effective maximum length is 31.
31
*/
32
#define AS_MAX_NAMESPACE_SIZE 32
33
34
/******************************************************************************
35
* TYPES
36
*****************************************************************************/
37
38
/**
39
* @private
40
* Map of namespace data partitions to nodes.
41
*/
42
typedef
struct
as_partition_s {
43
/**
44
* @private
45
* Master node for this partition.
46
*/
47
as_node
*
master
;
48
49
/**
50
* @private
51
* Prole node for this partition.
52
* TODO - not ideal for replication factor > 2.
53
*/
54
as_node
*
prole
;
55
}
as_partition
;
56
57
/**
58
* @private
59
* Map of namespace to data partitions.
60
*/
61
typedef
struct
as_partition_table_s {
62
/**
63
* @private
64
* Namespace
65
*/
66
char
ns[
AS_MAX_NAMESPACE_SIZE
];
67
68
/**
69
* @private
70
* Fixed length of partition array.
71
*/
72
uint32_t
size
;
73
74
/**
75
* @private
76
* Array of partitions for a given namespace.
77
*/
78
as_partition
partitions[];
79
}
as_partition_table
;
80
81
/**
82
* @private
83
* Reference counted array of partition table pointers.
84
*/
85
typedef
struct
as_partition_tables_s {
86
/**
87
* @private
88
* Reference count of partition table array.
89
*/
90
uint32_t
ref_count
;
91
92
/**
93
* @private
94
* Length of partition table array.
95
*/
96
uint32_t
size
;
97
98
/**
99
* @private
100
* Partition table array.
101
*/
102
as_partition_table
* array[];
103
}
as_partition_tables
;
104
105
/******************************************************************************
106
* FUNCTIONS
107
******************************************************************************/
108
109
/**
110
* @private
111
* Create reference counted structure containing partition tables.
112
*/
113
as_partition_tables
*
114
as_partition_tables_create
(uint32_t capacity);
115
116
/**
117
* @private
118
* Destroy and release memory for partition table.
119
*/
120
void
121
as_partition_table_destroy
(
as_partition_table
* table);
122
123
/**
124
* @private
125
* Get partition table given namespace.
126
*/
127
as_partition_table
*
128
as_partition_tables_get
(
as_partition_tables
* tables,
const
char
*
ns
);
129
130
/**
131
* @private
132
* Is node referenced in any partition table.
133
*/
134
bool
135
as_partition_tables_find_node
(
as_partition_tables
* tables,
as_node
* node);
136
137
/**
138
* @private
139
* Return partition ID given digest.
140
*/
141
static
inline
uint32_t
142
as_partition_getid
(
const
uint8_t* digest, uint32_t n_partitions)
143
{
144
return
(*(uint16_t*)digest) & (n_partitions - 1);
145
}
146
147
#ifdef __cplusplus
148
}
// end extern "C"
149
#endif