iinq.h File Reference

Description

This code contains definitions for iinq functions.

Author
IonDB Project
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1.Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2.Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3.Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file iinq.h.

Include dependency graph for iinq.h:
This graph shows which files directly or indirectly include this file:

Classes

struct  ion_iinq_result_t
 
struct  ion_iinq_query_processor_t
 
struct  iinq_cleanup
 
struct  iinq_source
 

Macros

#define IINQ_NEW_PROCESSOR_FUNC(name)   void name(ion_iinq_result_t *result, void* state)
 
#define IINQ_QUERY_PROCESSOR(execute, state)   ((ion_iinq_query_processor_t){ execute, state })
 
#define CREATE_DICTIONARY(schema_name, key_type, key_size, value_size)   iinq_create_source(#schema_name ".inq", key_type, key_size, value_size)
 
#define INSERT(schema_name, key, value)   iinq_insert(#schema_name ".inq", key, value)
 
#define UPDATE(schema_name, key, value)   iinq_insert(#schema_name ".inq", key, value)
 
#define DELETE_FROM(schema_name, key)   iinq_delete(#schema_name ".inq", key)
 
#define DROP(schema_name)   iinq_drop(#schema_name ".inq")
 
#define SELECT_ALL
 
#define _FROM_SOURCE_SINGLE(source)
 
#define _FROM_CHECK_CURSOR_SINGLE(source)   (cs_cursor_active == (source.cursor_status = source.cursor->next(source.cursor, &source.ion_record)) || cs_cursor_initialized == source.cursor_status)
 
#define _FROM_ADVANCE_CURSORS
 
#define _FROM_SOURCE_1(_1)   _FROM_SOURCE_SINGLE(_1)
 
#define _FROM_SOURCE_2(_1, _2)   _FROM_SOURCE_1(_1) _FROM_SOURCE_1(_2)
 
#define _FROM_SOURCE_3(_1, _2, _3)   _FROM_SOURCE_2(_1, _2) _FROM_SOURCE_1(_3)
 
#define _FROM_SOURCE_4(_1, _2, _3, _4)   _FROM_SOURCE_3(_1, _2, _3) _FROM_SOURCE_1(_4)
 
#define _FROM_SOURCE_5(_1, _2, _3, _4, _5)   _FROM_SOURCE_4(_1, _2, _3, _4) _FROM_SOURCE_1(_5)
 
#define _FROM_SOURCE_6(_1, _2, _3, _4, _5, _6)   _FROM_SOURCE_5(_1, _2, _3, _4, _5) _FROM_SOURCE_1(_6)
 
#define _FROM_SOURCE_7(_1, _2, _3, _4, _5, _6, _7)   _FROM_SOURCE_6(_1, _2, _3, _4, _5, _6) _FROM_SOURCE_1(_7)
 
#define _FROM_SOURCE_8(_1, _2, _3, _4, _5, _6, _7, _8)   _FROM_SOURCE_7(_1, _2, _3, _4, _5, _6, _7) _FROM_SOURCE_1(_8)
 
#define _FROM_SOURCE_GET_OVERRIDE(_1, _2, _3, _4, _5, _6, _7, _8, MACRO, ...)   MACRO
 
#define _FROM_SOURCES(...)   _FROM_SOURCE_GET_OVERRIDE(__VA_ARGS__, _FROM_SOURCE_8, _FROM_SOURCE_7, _FROM_SOURCE_6, _FROM_SOURCE_5, _FROM_SOURCE_4, _FROM_SOURCE_3, _FROM_SOURCE_2, _FROM_SOURCE_1, THEBLACKWHOLE)(__VA_ARGS__)
 
#define _FROM_CHECK_CURSOR(sources)   _FROM_CHECK_CURSOR_SINGLE(sources)
 
#define FROM(...)
 
#define WHERE(condition)   (condition)
 
#define QUERY(select, from, where, groupby, having, orderby, limit, when, p)
 

Typedefs

typedef unsigned int ion_iinq_result_size_t
 
typedef void(* ion_iinq_query_processor_func_t) (ion_iinq_result_t *, void *)
 Function pointer type for processing not data modifying IINQ queries. More...
 
typedef struct iinq_source ion_iinq_source_t
 
typedef struct iinq_cleanup ion_iinq_cleanup_t
 

Functions

ion_err_t iinq_create_source (char *schema_file_name, ion_key_type_t key_type, ion_key_size_t key_size, ion_value_size_t value_size)
 
ion_err_t iinq_open_source (char *schema_file_name, ion_dictionary_t *dictionary, ion_dictionary_handler_t *handler)
 
ion_status_t iinq_insert (char *schema_file_name, ion_key_t key, ion_value_t value)
 
ion_status_t iinq_update (char *schema_file_name, ion_key_t key, ion_value_t value)
 
ion_status_t iinq_delete (char *schema_file_name, ion_key_t key)
 
ion_err_t iinq_drop (char *schema_file_name)
 

Macro Definition Documentation

#define _FROM_ADVANCE_CURSORS
Value:
if (NULL == ref_cursor) { \
break; \
} \
last_cursor = ref_cursor; \
/* Keep going backwards through sources until we find one we can advance. If we re-initialize any cursors, reset ref_cursor to last. */ \
while (NULL != ref_cursor && (cs_cursor_active != (ref_cursor->reference->cursor_status = ref_cursor->reference->cursor->next(ref_cursor->reference->cursor, &ref_cursor->reference->ion_record)) && cs_cursor_initialized != ref_cursor->reference->cursor_status)) { \
ref_cursor->reference->cursor->destroy(&ref_cursor->reference->cursor); \
dictionary_find(&ref_cursor->reference->dictionary, &ref_cursor->reference->predicate, &ref_cursor->reference->cursor); \
if ((cs_cursor_active != (ref_cursor->reference->cursor_status = ref_cursor->reference->cursor->next(ref_cursor->reference->cursor, &ref_cursor->reference->ion_record)) && cs_cursor_initialized != ref_cursor->reference->cursor_status)) { \
goto IINQ_QUERY_CLEANUP; \
} \
ref_cursor = ref_cursor->last; \
} \
if (NULL == ref_cursor) { \
break; \
} \
else if (last_cursor != ref_cursor) { \
ref_cursor = last; \
}
ion_err_t dictionary_find(ion_dictionary_t *dictionary, ion_predicate_t *predicate, ion_dict_cursor_t **cursor)
Uses the given predicate and cursor to search the dictionary.
Definition: dictionary.c:562

Definition at line 191 of file iinq.h.

#define _FROM_CHECK_CURSOR (   sources)    _FROM_CHECK_CURSOR_SINGLE(sources)

Definition at line 233 of file iinq.h.

#define _FROM_CHECK_CURSOR_SINGLE (   source)    (cs_cursor_active == (source.cursor_status = source.cursor->next(source.cursor, &source.ion_record)) || cs_cursor_initialized == source.cursor_status)

Definition at line 188 of file iinq.h.

#define _FROM_SOURCE_1 (   _1)    _FROM_SOURCE_SINGLE(_1)

Definition at line 213 of file iinq.h.

#define _FROM_SOURCE_2 (   _1,
  _2 
)    _FROM_SOURCE_1(_1) _FROM_SOURCE_1(_2)

Definition at line 214 of file iinq.h.

#define _FROM_SOURCE_3 (   _1,
  _2,
  _3 
)    _FROM_SOURCE_2(_1, _2) _FROM_SOURCE_1(_3)

Definition at line 215 of file iinq.h.

#define _FROM_SOURCE_4 (   _1,
  _2,
  _3,
  _4 
)    _FROM_SOURCE_3(_1, _2, _3) _FROM_SOURCE_1(_4)

Definition at line 216 of file iinq.h.

#define _FROM_SOURCE_5 (   _1,
  _2,
  _3,
  _4,
  _5 
)    _FROM_SOURCE_4(_1, _2, _3, _4) _FROM_SOURCE_1(_5)

Definition at line 217 of file iinq.h.

#define _FROM_SOURCE_6 (   _1,
  _2,
  _3,
  _4,
  _5,
  _6 
)    _FROM_SOURCE_5(_1, _2, _3, _4, _5) _FROM_SOURCE_1(_6)

Definition at line 218 of file iinq.h.

#define _FROM_SOURCE_7 (   _1,
  _2,
  _3,
  _4,
  _5,
  _6,
  _7 
)    _FROM_SOURCE_6(_1, _2, _3, _4, _5, _6) _FROM_SOURCE_1(_7)

Definition at line 219 of file iinq.h.

#define _FROM_SOURCE_8 (   _1,
  _2,
  _3,
  _4,
  _5,
  _6,
  _7,
  _8 
)    _FROM_SOURCE_7(_1, _2, _3, _4, _5, _6, _7) _FROM_SOURCE_1(_8)

Definition at line 220 of file iinq.h.

#define _FROM_SOURCE_GET_OVERRIDE (   _1,
  _2,
  _3,
  _4,
  _5,
  _6,
  _7,
  _8,
  MACRO,
  ... 
)    MACRO

Definition at line 224 of file iinq.h.

#define _FROM_SOURCE_SINGLE (   source)
Value:
source.cleanup.next = NULL; \
source.cleanup.last = last; \
source.cleanup.reference = &source; \
if (NULL == first) { \
first = &source.cleanup; \
} \
if (NULL != last) { \
last->next = &source.cleanup; \
} \
last = &source.cleanup; \
source.cleanup.next = NULL; \
source.dictionary.handler = &source.handler; \
error = iinq_open_source(#source ".inq", &(source.dictionary), &(source.handler)); \
if (err_ok != error) { \
break; \
} \
source.key = alloca(source.dictionary.instance->record.key_size); \
source.value = alloca(source.dictionary.instance->record.value_size); \
source.ion_record.key = source.key; \
source.ion_record.value = source.value; \
result.num_bytes += source.dictionary.instance->record.key_size; \
result.num_bytes += source.dictionary.instance->record.value_size; \
if (err_ok != error) { \
break; \
} \
dictionary_find(&source.dictionary, &source.predicate, &source.cursor);
ion_record_info_t record
ion_err_t iinq_open_source(char *schema_file_name, ion_dictionary_t *dictionary, ion_dictionary_handler_t *handler)
Definition: iinq.c:106
ion_dict_cursor_t * cursor
Definition: iinq.h:84
ion_dictionary_parent_t * instance
ion_value_t value
Definition: iinq.h:87
ion_iinq_source_t * reference
Definition: iinq.h:75
ion_predicate_t predicate
Definition: iinq.h:83
struct iinq_cleanup * next
Definition: iinq.h:76
ion_key_size_t key_size
Definition: kv_system.h:307
ion_iinq_cleanup_t cleanup
Definition: iinq.h:89
#define error(rc)
Definition: bpp_tree.c:151
ion_key_t key
Definition: iinq.h:86
ion_err_t dictionary_find(ion_dictionary_t *dictionary, ion_predicate_t *predicate, ion_dict_cursor_t **cursor)
Uses the given predicate and cursor to search the dictionary.
Definition: dictionary.c:562
ion_dictionary_t dictionary
Definition: iinq.h:82
ion_value_size_t value_size
Definition: kv_system.h:309
ion_err_t dictionary_build_predicate(ion_predicate_t *predicate, ion_predicate_type_t type,...)
Builds a predicate based on the type given.
Definition: dictionary.c:512
ion_dictionary_handler_t handler
Definition: iinq.h:81
struct iinq_cleanup * last
Definition: iinq.h:77

Definition at line 158 of file iinq.h.

#define _FROM_SOURCES (   ...)    _FROM_SOURCE_GET_OVERRIDE(__VA_ARGS__, _FROM_SOURCE_8, _FROM_SOURCE_7, _FROM_SOURCE_6, _FROM_SOURCE_5, _FROM_SOURCE_4, _FROM_SOURCE_3, _FROM_SOURCE_2, _FROM_SOURCE_1, THEBLACKWHOLE)(__VA_ARGS__)

Definition at line 231 of file iinq.h.

#define CREATE_DICTIONARY (   schema_name,
  key_type,
  key_size,
  value_size 
)    iinq_create_source(#schema_name ".inq", key_type, key_size, value_size)

Definition at line 132 of file iinq.h.

#define DELETE_FROM (   schema_name,
  key 
)    iinq_delete(#schema_name ".inq", key)

Definition at line 141 of file iinq.h.

#define DROP (   schema_name)    iinq_drop(#schema_name ".inq")

Definition at line 144 of file iinq.h.

#define FROM (   ...)
Value:
ion_iinq_cleanup_t *ref_cursor; \
ion_iinq_cleanup_t *last_cursor; \
first = NULL; \
last = NULL; \
ref_cursor = NULL; \
last_cursor = NULL; \
_FROM_SOURCES(__VA_ARGS__) \
result.data = alloca(result.num_bytes); \
ref_cursor = first; \
/* Initialize all cursors except the last one. */ \
while (ref_cursor != last) { \
if (NULL == ref_cursor || (cs_cursor_active != (ref_cursor->reference->cursor_status = ref_cursor->reference->cursor->next(ref_cursor->reference->cursor, &ref_cursor->reference->ion_record)) && cs_cursor_initialized != ref_cursor->reference->cursor_status)) { \
break; \
} \
ref_cursor = ref_cursor->next; \
} \
ref_cursor = last; \
while (1) { \
#define _FROM_SOURCES(...)
Definition: iinq.h:231
struct iinq_cleanup ion_iinq_cleanup_t
struct iinq_cleanup * next
Definition: iinq.h:76
#define _FROM_ADVANCE_CURSORS
Definition: iinq.h:191

Definition at line 236 of file iinq.h.

#define IINQ_NEW_PROCESSOR_FUNC (   name)    void name(ion_iinq_result_t *result, void* state)

Definition at line 62 of file iinq.h.

#define IINQ_QUERY_PROCESSOR (   execute,
  state 
)    ((ion_iinq_query_processor_t){ execute, state })

Definition at line 70 of file iinq.h.

#define INSERT (   schema_name,
  key,
  value 
)    iinq_insert(#schema_name ".inq", key, value)

Definition at line 135 of file iinq.h.

#define QUERY (   select,
  from,
  where,
  groupby,
  having,
  orderby,
  limit,
  when,
  p 
)
Value:
do { \
ion_iinq_result_t result; \
result.num_bytes = 0; \
from/* This includes a loop declaration with some other stuff. */ \
if (!where) { \
continue; \
} \
select \
(p)->execute(&result, (p)->state); \
} \
IINQ_QUERY_CLEANUP: \
while (NULL != first) { \
first->reference->cursor->destroy(&first->reference->cursor); \
ion_close_dictionary(&first->reference->dictionary); \
first = first->next; \
}\
} while (0);
char ion_err_t
The error type used to store error codes.
Definition: kv_system.h:226
ion_err_t ion_close_dictionary(ion_dictionary_t *dictionary)
Closes a given dictionary.
#define error(rc)
Definition: bpp_tree.c:151
#define p(b)
Definition: bpp_tree.c:86

Definition at line 264 of file iinq.h.

#define SELECT_ALL
Value:
ion_iinq_result_size_t result_loc = 0; \
ion_iinq_cleanup_t *copyer = first; \
while (NULL != copyer) { \
memcpy(result.data+(result_loc), copyer->reference->key, copyer->reference->dictionary.instance->record.key_size); \
result_loc += copyer->reference->dictionary.instance->record.key_size; \
memcpy(result.data+(result_loc), copyer->reference->value, copyer->reference->dictionary.instance->record.value_size); \
result_loc += copyer->reference->dictionary.instance->record.value_size; \
copyer = copyer->next; \
}
struct iinq_cleanup ion_iinq_cleanup_t
unsigned int ion_iinq_result_size_t
Definition: iinq.h:49

Definition at line 147 of file iinq.h.

#define UPDATE (   schema_name,
  key,
  value 
)    iinq_insert(#schema_name ".inq", key, value)

Definition at line 138 of file iinq.h.

#define WHERE (   condition)    (condition)

Definition at line 262 of file iinq.h.

Typedef Documentation

typedef void(* ion_iinq_query_processor_func_t) (ion_iinq_result_t *, void *)

Function pointer type for processing not data modifying IINQ queries.

Definition at line 60 of file iinq.h.

typedef unsigned int ion_iinq_result_size_t

Definition at line 49 of file iinq.h.

Definition at line 72 of file iinq.h.

Function Documentation

ion_err_t iinq_create_source ( char *  schema_file_name,
ion_key_type_t  key_type,
ion_key_size_t  key_size,
ion_value_size_t  value_size 
)

Definition at line 42 of file iinq.c.

47  {
49  FILE *schema_file;
52 
53  dictionary.handler = &handler;
54 
55  error = ion_init_master_table();
56 
57  if (err_ok != error) {
58  return error;
59  }
60 
61  /* Load the handler. */
62  bpptree_init(&handler);
63 
64  /* If the file exists, fail. */
65  if (NULL != (schema_file = fopen(schema_file_name, "rb"))) {
66  if (0 != fclose(schema_file)) {
67  return err_file_close_error;
68  }
69 
71  }
72  /* Otherwise, we are creating the dictionary for the first time. */
73  else if (NULL != (schema_file = fopen(schema_file_name, "w+b"))) {
74  if (0 != fseek(schema_file, 0, SEEK_SET)) {
75  return err_file_bad_seek;
76  }
77 
78  error = ion_master_table_create_dictionary(&handler, &dictionary, key_type, key_size, value_size, -1);
79 
80  if (err_ok != error) {
81  return error;
82  }
83 
84  if (1 != fwrite(&dictionary.instance->id, sizeof(dictionary.instance->id), 1, schema_file)) {
85  return err_file_read_error;
86  }
87 
88  if (0 != fclose(schema_file)) {
89  return err_file_close_error;
90  }
91 
92  ion_close_dictionary(&dictionary);
93 
94  error = err_ok;
95  }
96  else {
97  error = err_file_open_error;
98  }
99 
101 
102  return error;
103 }
ion_err_t ion_master_table_create_dictionary(ion_dictionary_handler_t *handler, ion_dictionary_t *dictionary, ion_key_type_t key_type, ion_key_size_t key_size, ion_value_size_t value_size, ion_dictionary_size_t dictionary_size)
Creates a dictionary through use of the master table.
ion_dictionary_handler_t * handler
ion_dictionary_parent_t * instance
char ion_err_t
The error type used to store error codes.
Definition: kv_system.h:226
A dictionary contains information regarding an instance of the storage element and the associated han...
ion_dictionary_id_t id
ion_err_t ion_close_dictionary(ion_dictionary_t *dictionary)
Closes a given dictionary.
ion_err_t ion_init_master_table(void)
Opens the master table.
void bpptree_init(ion_dictionary_handler_t *handler)
Registers a specific handler for a dictionary instance.
ion_err_t ion_close_master_table(void)
Closes the master table.
#define error(rc)
Definition: bpp_tree.c:151
A dictionary_handler is responsible for dealing with the specific interface for an underlying diction...

Here is the call graph for this function:

ion_status_t iinq_delete ( char *  schema_file_name,
ion_key_t  key 
)

Definition at line 216 of file iinq.c.

219  {
223  ion_dictionary_handler_t handler;
224 
225  dictionary.handler = &handler;
226 
227  error = iinq_open_source(schema_file_name, &dictionary, &handler);
228 
229  if (err_ok != error) {
230  status = ION_STATUS_ERROR(error);
231  goto RETURN;
232  }
233 
234  status = dictionary_delete(&dictionary, key);
235  error = ion_close_dictionary(&dictionary);
236 
237  if ((err_ok == status.error) && (err_ok != error)) {
238  status.error = error;
239  }
240 
241 RETURN: return status;
242 }
#define ION_STATUS_ERROR(error)
Definition: kv_system.h:110
ion_dictionary_handler_t * handler
#define key(k)
Definition: bpp_tree.c:75
ion_err_t error
Definition: kv_system.h:291
ion_status_t dictionary_delete(ion_dictionary_t *dictionary, ion_key_t key)
Delete a value given a key.
Definition: dictionary.c:199
char ion_err_t
The error type used to store error codes.
Definition: kv_system.h:226
A dictionary contains information regarding an instance of the storage element and the associated han...
ion_err_t ion_close_dictionary(ion_dictionary_t *dictionary)
Closes a given dictionary.
#define error(rc)
Definition: bpp_tree.c:151
ion_err_t iinq_open_source(char *schema_file_name, ion_dictionary_t *dictionary, ion_dictionary_handler_t *handler)
Definition: iinq.c:106
#define ION_STATUS_INITIALIZE
Definition: kv_system.h:107
A dictionary_handler is responsible for dealing with the specific interface for an underlying diction...
A status object that describes the result of a dictionary operation.
Definition: kv_system.h:290

Here is the call graph for this function:

ion_err_t iinq_drop ( char *  schema_file_name)

Definition at line 245 of file iinq.c.

247  {
250  ion_dictionary_handler_t handler;
251 
252  dictionary.handler = &handler;
253 
254  error = iinq_open_source(schema_file_name, &dictionary, &handler);
255 
256  if (err_ok != error) {
257  return error;
258  }
259 
260  error = dictionary_delete_dictionary(&dictionary);
261 
262  fremove(schema_file_name);
263 
264  return error;
265 }
ion_dictionary_handler_t * handler
#define fremove(x)
Definition: kv_system.h:56
char ion_err_t
The error type used to store error codes.
Definition: kv_system.h:226
A dictionary contains information regarding an instance of the storage element and the associated han...
ion_err_t dictionary_delete_dictionary(ion_dictionary_t *dictionary)
Destroys dictionary.
Definition: dictionary.c:178
#define error(rc)
Definition: bpp_tree.c:151
ion_err_t iinq_open_source(char *schema_file_name, ion_dictionary_t *dictionary, ion_dictionary_handler_t *handler)
Definition: iinq.c:106
A dictionary_handler is responsible for dealing with the specific interface for an underlying diction...

Here is the call graph for this function:

ion_status_t iinq_insert ( char *  schema_file_name,
ion_key_t  key,
ion_value_t  value 
)

Definition at line 156 of file iinq.c.

160  {
164  ion_dictionary_handler_t handler;
165 
166  dictionary.handler = &handler;
167 
168  error = iinq_open_source(schema_file_name, &dictionary, &handler);
169 
170  if (err_ok != error) {
171  status = ION_STATUS_ERROR(error);
172  goto RETURN;
173  }
174 
175  status = dictionary_insert(&dictionary, key, value);
176  error = ion_close_dictionary(&dictionary);
177 
178  if ((err_ok == status.error) && (err_ok != error)) {
179  status.error = error;
180  }
181 
182 RETURN: return status;
183 }
#define ION_STATUS_ERROR(error)
Definition: kv_system.h:110
ion_dictionary_handler_t * handler
#define key(k)
Definition: bpp_tree.c:75
ion_err_t error
Definition: kv_system.h:291
ion_status_t dictionary_insert(ion_dictionary_t *dictionary, ion_key_t key, ion_value_t value)
Insert a value into a dictionary.
Definition: dictionary.c:151
char ion_err_t
The error type used to store error codes.
Definition: kv_system.h:226
A dictionary contains information regarding an instance of the storage element and the associated han...
ion_err_t ion_close_dictionary(ion_dictionary_t *dictionary)
Closes a given dictionary.
#define error(rc)
Definition: bpp_tree.c:151
ion_err_t iinq_open_source(char *schema_file_name, ion_dictionary_t *dictionary, ion_dictionary_handler_t *handler)
Definition: iinq.c:106
#define ION_STATUS_INITIALIZE
Definition: kv_system.h:107
A dictionary_handler is responsible for dealing with the specific interface for an underlying diction...
A status object that describes the result of a dictionary operation.
Definition: kv_system.h:290

Here is the call graph for this function:

ion_err_t iinq_open_source ( char *  schema_file_name,
ion_dictionary_t dictionary,
ion_dictionary_handler_t handler 
)

Definition at line 106 of file iinq.c.

110  {
112  FILE *schema_file;
114 
115  error = ion_init_master_table();
116 
117  if (err_ok != error) {
118  return error;
119  }
120 
121  /* Load the handler. */
122  bpptree_init(handler);
123 
124  /* If the schema file already exists. */
125  if (NULL != (schema_file = fopen(schema_file_name, "rb"))) {
126  if (0 != fseek(schema_file, 0, SEEK_SET)) {
127  return err_file_bad_seek;
128  }
129 
130  if (1 != fread(&id, sizeof(id), 1, schema_file)) {
131  return err_file_read_error;
132  }
133 
134  error = ion_open_dictionary(handler, dictionary, id);
135 
136  if (err_ok != error) {
137  return error;
138  }
139 
140  if (0 != fclose(schema_file)) {
141  return err_file_close_error;
142  }
143 
144  error = err_ok;
145  }
146  else {
147  error = err_file_open_error;
148  }
149 
151 
152  return error;
153 }
unsigned int ion_dictionary_id_t
A type used to identify dictionaries, specifically in the master table.
char ion_err_t
The error type used to store error codes.
Definition: kv_system.h:226
ion_err_t ion_init_master_table(void)
Opens the master table.
void bpptree_init(ion_dictionary_handler_t *handler)
Registers a specific handler for a dictionary instance.
ion_err_t ion_open_dictionary(ion_dictionary_handler_t *handler, ion_dictionary_t *dictionary, ion_dictionary_id_t id)
Finds the target dictionary and opens it.
ion_err_t ion_close_master_table(void)
Closes the master table.
#define error(rc)
Definition: bpp_tree.c:151

Here is the call graph for this function:

Here is the caller graph for this function:

ion_status_t iinq_update ( char *  schema_file_name,
ion_key_t  key,
ion_value_t  value 
)

Definition at line 186 of file iinq.c.

190  {
194  ion_dictionary_handler_t handler;
195 
196  dictionary.handler = &handler;
197 
198  error = iinq_open_source(schema_file_name, &dictionary, &handler);
199 
200  if (err_ok != error) {
201  status = ION_STATUS_ERROR(error);
202  goto RETURN;
203  }
204 
205  status = dictionary_update(&dictionary, key, value);
206  error = ion_close_dictionary(&dictionary);
207 
208  if ((err_ok == status.error) && (err_ok != error)) {
209  status.error = error;
210  }
211 
212 RETURN: return status;
213 }
#define ION_STATUS_ERROR(error)
Definition: kv_system.h:110
ion_dictionary_handler_t * handler
#define key(k)
Definition: bpp_tree.c:75
ion_status_t dictionary_update(ion_dictionary_t *dictionary, ion_key_t key, ion_value_t value)
Update all records with a given key.
Definition: dictionary.c:169
ion_err_t error
Definition: kv_system.h:291
char ion_err_t
The error type used to store error codes.
Definition: kv_system.h:226
A dictionary contains information regarding an instance of the storage element and the associated han...
ion_err_t ion_close_dictionary(ion_dictionary_t *dictionary)
Closes a given dictionary.
#define error(rc)
Definition: bpp_tree.c:151
ion_err_t iinq_open_source(char *schema_file_name, ion_dictionary_t *dictionary, ion_dictionary_handler_t *handler)
Definition: iinq.c:106
#define ION_STATUS_INITIALIZE
Definition: kv_system.h:107
A dictionary_handler is responsible for dealing with the specific interface for an underlying diction...
A status object that describes the result of a dictionary operation.
Definition: kv_system.h:290

Here is the call graph for this function: