Main Page
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
aerospike
aerospike_index.h
Go to the documentation of this file.
1
/*
2
* Copyright 2008-2014 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
/**
20
* @defgroup index_operations Index Operations
21
* @ingroup client_operations
22
*
23
* The Index API provides the ability to create and remove secondary indexes.
24
*
25
* Aerospike currently supports indexing of strings and integers.
26
*
27
* ## String Indexes
28
*
29
* A string index allows for equality lookups. An equality lookup means that
30
* if you query for an indexed bin with value "abc", then only the records
31
* containing bins with "abc" will be returned.
32
*
33
* To create a string index, see aerospike_index_string_create().
34
*
35
* ## Integer Indexes
36
*
37
* An integer index allows for either equality or range lookups. An equality
38
* lookup means that if you query for an indexed bin with value 123, then only
39
* the records containing bins with the value 123 will be returned. A range
40
* lookup means that you can query bins within a range. So, if your range is
41
* (1...100), then all records containing the a value in that range will
42
* be returned.
43
*
44
* To create a integer index, see aerospike_index_integer_create().
45
*
46
*/
47
48
#include <
aerospike/aerospike.h
>
49
#include <
aerospike/as_bin.h
>
50
#include <
aerospike/as_error.h
>
51
#include <
aerospike/as_key.h
>
52
#include <
aerospike/as_policy.h
>
53
#include <
aerospike/as_status.h
>
54
55
/******************************************************************************
56
* FUNCTIONS
57
*****************************************************************************/
58
59
/**
60
* Create a new secondary index on an integer bin.
61
*
62
* ~~~~~~~~~~{.c}
63
* if ( aerospike_index_integer_create(&as, &err, NULL, "test", "demo", "bin1", "idx_test_demo_bin1") != AEROSPIKE_OK ) {
64
* fprintf(stderr, "error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
65
* }
66
* ~~~~~~~~~~
67
*
68
* @param as The aerospike instance to use for this operation.
69
* @param err The as_error to be populated if an error occurs.
70
* @param policy The policy to use for this operation. If NULL, then the default policy will be used.
71
* @param ns The namespace to be indexed.
72
* @param set The set to be indexed.
73
* @param bin The bin to be indexed.
74
* @param name The name of the index.
75
*
76
* @return AEROSPIKE_OK if successful or index already exists. Otherwise an error.
77
*
78
* @ingroup index_operations
79
*/
80
as_status
aerospike_index_integer_create
(
81
aerospike
* as,
as_error
* err,
const
as_policy_info
* policy,
82
const
as_namespace
ns
,
const
as_set
set,
const
as_bin_name
bin,
const
char
* name);
83
84
/**
85
* Create a new secondary index on a string bin.
86
*
87
* ~~~~~~~~~~{.c}
88
* if ( aerospike_index_string_create(&as, &err, NULL, "test", "demo", "bin1", "idx_test_demo_bin1") != AEROSPIKE_OK ) {
89
* fprintf(stderr, "error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
90
* }
91
* ~~~~~~~~~~
92
*
93
* @param as The aerospike instance to use for this operation.
94
* @param err The as_error to be populated if an error occurs.
95
* @param policy The policy to use for this operation. If NULL, then the default policy will be used.
96
* @param ns The namespace to be indexed.
97
* @param set The set to be indexed.
98
* @param bin The bin to be indexed.
99
* @param name The name of the index.
100
*
101
* @return AEROSPIKE_OK if successful or index already exists. Otherwise an error.
102
*
103
* @ingroup index_operations
104
*/
105
as_status
aerospike_index_string_create
(
106
aerospike
* as,
as_error
* err,
const
as_policy_info
* policy,
107
const
as_namespace
ns
,
const
as_set
set,
const
as_bin_name
bin,
const
char
* name);
108
109
/**
110
* Removes (drops) a secondary index.
111
*
112
* ~~~~~~~~~~{.c}
113
* if ( aerospike_index_remove(&as, &err, NULL, "test", idx_test_demo_bin1") != AEROSPIKE_OK ) {
114
* fprintf(stderr, "error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
115
* }
116
* ~~~~~~~~~~
117
*
118
* @param as The aerospike instance to use for this operation.
119
* @param err The as_error to be populated if an error occurs.
120
* @param policy The policy to use for this operation. If NULL, then the default policy will be used.
121
* @param ns The namespace containing the index to be removed.
122
* @param name The name of the index to be removed.
123
*
124
* @return AEROSPIKE_OK if successful or index does not exist. Otherwise an error.
125
*
126
* @ingroup index_operations
127
*/
128
as_status
aerospike_index_remove
(
129
aerospike
* as,
as_error
* err,
const
as_policy_info
* policy,
130
const
as_namespace
ns
,
const
char
* name);
131
132
133
/**
134
* @}
135
*/