SIONlib  2.0.0-rc.1
Scalable I/O library for parallel access to task-local files
sion_keyvalue.c
1 /****************************************************************************
2 ** SIONLIB http://www.fz-juelich.de/jsc/sionlib **
3 *****************************************************************************
4 ** Copyright (c) 2008-2018 **
5 ** Forschungszentrum Juelich, Juelich Supercomputing Centre **
6 ** **
7 ** See the file COPYRIGHT in the package base directory for details **
8 ****************************************************************************/
9 
10 #define _XOPEN_SOURCE 700
11 
12 #include <stdint.h>
13 #include <string.h>
14 
15 #include "sion_const.h"
16 #include "sion_debug.h"
17 #include "sion_error_handler.h"
18 #include "sion_fd.h"
19 #include "sion_filedesc.h"
20 #include "sion_internal.h"
21 #include "sion_keyvalue.h"
22 #include "sion_keyvalue_inline.h"
23 
24 #define DFUNCTION "_sion_keyval_check_env"
25 int _sion_keyval_check_env(_sion_filedesc *sion_filedesc, int64_t file_mode_flags)
26 {
27  const char *t;
28  int rc = 1;
29  int32_t keyvalmode_env;
30  int32_t keyvalmode_parm;
31 
32  DPRINTFP((2, DFUNCTION, -1, "keyval mode is initially set to %s\n", sion_keyval_type_to_str((int)sion_filedesc->keyvalmode)));
33 
34  /* check env-var */
35  keyvalmode_env = SION_KEYVAL_NOTSET;
36  t = _sion_getenv("SION_KEYVALUE_MODE");
37  if (t) {
38  if (strstr(t, "inline")) {
39  keyvalmode_env = SION_KEYVAL_INLINE;
40  }
41  if (strstr(t, "meta")) {
42  keyvalmode_env = SION_KEYVAL_META;
43  }
44  if (strstr(t, "hash")) {
45  keyvalmode_env = SION_KEYVAL_HASH;
46  }
47  if (strstr(t, "none")) {
48  keyvalmode_env = SION_KEYVAL_NONE;
49  }
50  if (strstr(t, "unknown")) {
51  keyvalmode_env = SION_KEYVAL_UNKNOWN;
52  }
53  }
54  DPRINTFP((2, DFUNCTION, -1, "keyval mode from env is=%s\n", sion_keyval_type_to_str((int)keyvalmode_env)));
55 
56  /* check file mode from open call */
57  keyvalmode_parm = SION_KEYVAL_NOTSET;
58  if (file_mode_flags & _SION_FMODE_KEYVAL_INLINE) {
59  keyvalmode_parm = SION_KEYVAL_INLINE;
60  }
61  if (file_mode_flags & _SION_FMODE_KEYVAL_META) {
62  keyvalmode_parm = SION_KEYVAL_META;
63  }
64  if (file_mode_flags & _SION_FMODE_KEYVAL_HASH) {
65  keyvalmode_parm = SION_KEYVAL_HASH;
66  }
67  if (file_mode_flags & _SION_FMODE_KEYVAL_NONE) {
68  keyvalmode_parm = SION_KEYVAL_NONE;
69  }
70  if (file_mode_flags & _SION_FMODE_KEYVAL_UNKNOWN) {
71  keyvalmode_parm = SION_KEYVAL_UNKNOWN;
72  }
73  DPRINTFP((2, DFUNCTION, -1, "keyval mode from parameter is=%s\n", sion_keyval_type_to_str((int)keyvalmode_parm)));
74 
75  if (file_mode_flags & _SION_FMODE_READ) {
76  DPRINTFP((2, DFUNCTION, -1, "file is opened for reading\n"));
77  /* keyvalmode is already read from meta-data of file */
78  /* open parameter and environment have to be identical */
79 
80  if (keyvalmode_parm == SION_KEYVAL_UNKNOWN) {
81  /* user will query mode later */
82  DPRINTFP((2, DFUNCTION, -1, "file read: parameter is 'unknown' keyvalmode will taken from file ...\n"));
83 
84  } else {
85  /* check for consistency */
86  if ((keyvalmode_parm != SION_KEYVAL_NOTSET) && (keyvalmode_parm != sion_filedesc->keyvalmode)) {
87  DPRINTFP((
88  2, DFUNCTION, -1, "file read: keyvalmode of file is different to requested keyvalmode from parameter, aborting ...\n"));
89  return _sion_errorprint(0, _SION_ERROR_RETURN,
90  "file read: keyvalmode of file is different to requested keyvalmode from parameter, aborting ...\n");
91  }
92  if ((keyvalmode_env != SION_KEYVAL_NOTSET) && (keyvalmode_env != sion_filedesc->keyvalmode)) {
93  DPRINTFP((2, DFUNCTION, -1,
94  "file read: keyvalmode of file is different to requested keyvalmode from environment, aborting ...\n"));
95  return _sion_errorprint(0, _SION_ERROR_RETURN,
96  "file read: keyvalmode of file is different to requested keyvalmode from env-var, aborting ...\n");
97  }
98  }
99 
100  } else {
101  DPRINTFP((2, DFUNCTION, -1, "file is opened for writing\n"));
102  /* order: first env, then parameter */
103  sion_filedesc->keyvalmode = SION_KEYVAL_NONE;
104  if (keyvalmode_env != SION_KEYVAL_NOTSET) {
105  sion_filedesc->keyvalmode = keyvalmode_env;
106  }
107  if (keyvalmode_parm != SION_KEYVAL_NOTSET) {
108  sion_filedesc->keyvalmode = keyvalmode_parm;
109  }
110  }
111 
112  DPRINTFP((2, DFUNCTION, -1, "keyval mode is=%s\n", sion_keyval_type_to_str((int)sion_filedesc->keyvalmode)));
113  return rc;
114 }
115 #undef DFUNCTION
116 
117 /* dup internal data structures from first to second sion_filedesc */
118 #define DFUNCTION "_sion_keyval_dup_dataptr"
119 int _sion_keyval_dup_dataptr(_sion_filedesc *sion_filedesc, _sion_filedesc *new_filedesc)
120 {
121  int rc = 0;
122  DPRINTFP((2, DFUNCTION, -1, "enter\n"));
123 
124  if (sion_filedesc->keyvalmode == SION_KEYVAL_INLINE) {
125  rc = _sion_keyval_dup_dataptr_inline(sion_filedesc, new_filedesc);
126  } else {
127  return _sion_errorprint(
128  0, _SION_ERROR_RETURN, "trying to call sion_keyval_dup_dataptr in inknown keyval mode , aborting ...\n");
129  }
130 
131  DPRINTFP((2, DFUNCTION, -1, "leave\n"));
132  return rc;
133 }
134 #undef DFUNCTION
135 
136 #define DFUNCTION "sion_fwrite_key"
137 size_t sion_fwrite_key(const void *data, uint64_t key, size_t size, size_t nitems, int sid)
138 {
139  size_t rc = 0, frc;
140  size_t len;
141  _sion_filedesc *sion_filedesc;
142 
143  DPRINTFTS(-1, "enter sion_fwrite_key");
144  DPRINTFP((2, DFUNCTION, -1, "enter\n"));
145 
146  if ((sid < 0) || (_sion_vcdtype(sid) != SION_FILEDESCRIPTOR) || !(sion_filedesc = _sion_vcdtovcon(sid))) {
147  return _sion_errorprint(0, _SION_ERROR_RETURN, "invalid sion_filedesc, aborting %d ...\n", sid);
148  }
149  if (sion_filedesc->rank < 0) { /* empty file */
150  return SION_NOT_SUCCESS;
151  }
152  DPRINTFP((2, DFUNCTION, -1, "fwrite_key: key=%d size=%d, nitems=%d\n", (int)key, (int)size, (int)nitems));
153 
154  len = size * nitems;
155 
156  /* store key and length */
157  frc = _sion_store_and_write_key_and_len(sion_filedesc, key, len);
158  if (frc != SION_SUCCESS) {
159  return _sion_errorprint_on_rank(
160  -1, _SION_ERROR_RETURN, sion_filedesc->rank, "could not write meta data to file (frc=%d sid=%d) ...", (int)frc, sid);
161  }
162 
163  /* store data */
164  frc = _sion_write_value(sion_filedesc, data, key, len);
165  if (frc != len) {
166  return _sion_errorprint_on_rank(-1, _SION_ERROR_RETURN, sion_filedesc->rank,
167  "could not write data (%d bytes) to file (frc=%d sid=%d) ...", (int)len, (int)frc, sid);
168  }
169 
170  rc = (size_t)len / size;
171 
172  DPRINTFP((2, DFUNCTION, -1, "leave\n"));
173  DPRINTFTS(-1, "leave sion_fwrite_key");
174  return rc;
175 }
176 #undef DFUNCTION
177 
178 #define DFUNCTION "sion_fread_key"
179 size_t sion_fread_key(void *data, uint64_t key, size_t size, size_t nitems, int sid)
180 {
181  size_t rc = 0, frc;
182  size_t len, datalen = 0;
183  _sion_filedesc *sion_filedesc;
184 
185  DPRINTFTS(-1, "enter sion_fread_key");
186  DPRINTFP((8, DFUNCTION, -1, "enter\n"));
187 
188  if ((sid < 0) || (_sion_vcdtype(sid) != SION_FILEDESCRIPTOR) || !(sion_filedesc = _sion_vcdtovcon(sid))) {
189  return _sion_errorprint(0, _SION_ERROR_RETURN, "invalid sion_filedesc, aborting %d ...\n", sid);
190  }
191  if (sion_filedesc->rank < 0) { /* empty file */
192  return SION_NOT_SUCCESS;
193  }
194  DPRINTFP((32, DFUNCTION, -1, "fread_key: sid=%d key=%ld size=%d, nitems=%d\n", (int)sid, (long)key, (int)size, (int)nitems));
195 
196  len = size * nitems;
197 
198  /* find key and length */
199  if (_sion_find_and_read_key_and_len(sion_filedesc, key, len, &datalen) != SION_SUCCESS) {
200  DPRINTFP((8, DFUNCTION, -1, "_sion_find_and_read_key_and_len return NOT SUCCESS\n"));
201  return SION_NOT_SUCCESS;
202  }
203 
204  /* read as much elements of size <size> as posible */
205  len = ((int)datalen / size) * size;
206 
207  /* read data */
208  frc = _sion_read_value(sion_filedesc, data, key, len);
209  if (frc != len) {
210  return SION_NOT_SUCCESS;
211  }
212 
213  rc = (size_t)len / size;
214 
215  DPRINTFP((8, DFUNCTION, -1, "leave rc=%d\n", (int)rc));
216  DPRINTFTS(-1, "leave sion_fread_key");
217  return rc;
218 }
219 #undef DFUNCTION
220 
221 #define DFUNCTION "sion_key_full_scan"
222 int sion_key_full_scan(int sid)
223 {
224  size_t rc = SION_NOT_SUCCESS;
225  _sion_filedesc *sion_filedesc;
226 
227  DPRINTFTS(-1, "enter sion_key_full_scan");
228  DPRINTFP((2, DFUNCTION, -1, "enter\n"));
229 
230  if ((sid < 0) || (_sion_vcdtype(sid) != SION_FILEDESCRIPTOR) || !(sion_filedesc = _sion_vcdtovcon(sid))) {
231  return _sion_errorprint(0, _SION_ERROR_RETURN, "invalid sion_filedesc, aborting %d ...\n", sid);
232  }
233  if (sion_filedesc->rank < 0) { /* empty file */
234  return SION_NOT_SUCCESS;
235  }
236  if (sion_filedesc->keyvalmode == SION_KEYVAL_INLINE) {
237  rc = _sion_key_full_scan_inline(sion_filedesc);
238  } else {
239  return _sion_errorprint(
240  0, _SION_ERROR_RETURN, "trying to perform full scan of file which is not opened in that mode, aborting ...\n");
241  }
242 
243  DPRINTFP((2, DFUNCTION, -1, "leave\n"));
244  DPRINTFTS(-1, "leave sion_key_full_scan");
245  return rc;
246 }
247 #undef DFUNCTION
248 
249 #define DFUNCTION "sion_fread_key_iterator_reset"
251 {
252  size_t rc = SION_NOT_SUCCESS;
253  _sion_filedesc *sion_filedesc;
254 
255  DPRINTFP((2, DFUNCTION, -1, "enter\n"));
256 
257  if ((sid < 0) || (_sion_vcdtype(sid) != SION_FILEDESCRIPTOR) || !(sion_filedesc = _sion_vcdtovcon(sid))) {
258  return _sion_errorprint(0, _SION_ERROR_RETURN, "invalid sion_filedesc, aborting %d ...\n", sid);
259  }
260  if (sion_filedesc->rank < 0) { /* empty file */
261  return SION_NOT_SUCCESS;
262  }
263 
264  if (sion_filedesc->keyvalmode == SION_KEYVAL_INLINE) {
265  rc = _sion_iterator_reset_inline(sion_filedesc);
266  } else {
267  return _sion_errorprint(0, _SION_ERROR_RETURN,
268  "trying to reset iterator in keyval mode from file which is not opened in that mode, aborting ...\n");
269  }
270 
271  DPRINTFP((2, DFUNCTION, -1, "leave\n"));
272  return rc;
273 }
274 #undef DFUNCTION
275 
276 #define DFUNCTION "sion_fread_key_iterator_next"
277 int sion_fread_key_iterator_next(int sid, uint64_t *keyptr, size_t *sizeptr)
278 {
279  size_t rc = SION_NOT_SUCCESS;
280  _sion_filedesc *sion_filedesc;
281 
282  DPRINTFP((2, DFUNCTION, -1, "enter\n"));
283 
284  if ((sid < 0) || (_sion_vcdtype(sid) != SION_FILEDESCRIPTOR) || !(sion_filedesc = _sion_vcdtovcon(sid))) {
285  return _sion_errorprint(0, _SION_ERROR_RETURN, "invalid sion_filedesc, aborting %d ...\n", sid);
286  }
287  if (sion_filedesc->rank < 0) { /* empty file */
288  return SION_NOT_SUCCESS;
289  }
290  if (sion_filedesc->keyvalmode == SION_KEYVAL_INLINE) {
291  rc = _sion_iterator_next_inline(sion_filedesc, keyptr, sizeptr);
292  DPRINTFP((2, DFUNCTION, -1, "sion_fread_key_iterator_next: key=%d size=%d\n", (int)*keyptr, (int)*sizeptr));
293  } else {
294  return _sion_errorprint(0, _SION_ERROR_RETURN,
295  "trying to forward iterator in keyval mode from file which is not opened in that mode, aborting ...\n");
296  }
297 
298  DPRINTFP((2, DFUNCTION, -1, "leave\n"));
299  return rc;
300 }
301 #undef DFUNCTION
302 
303 #define DFUNCTION "sion_seek_key"
304 int sion_seek_key(int sid, uint64_t key, int entrynum, int64_t posinentry)
305 {
306  size_t rc = SION_NOT_SUCCESS;
307  _sion_filedesc *sion_filedesc;
308 
309  DPRINTFTS(-1, "enter sion_seek_key");
310  DPRINTFP((2, DFUNCTION, -1, "enter\n"));
311 
312  if ((sid < 0) || (_sion_vcdtype(sid) != SION_FILEDESCRIPTOR) || !(sion_filedesc = _sion_vcdtovcon(sid))) {
313  return _sion_errorprint(0, _SION_ERROR_RETURN, "invalid sion_filedesc, aborting %d ...\n", sid);
314  }
315  if (sion_filedesc->rank < 0) { /* empty file */
316  return SION_NOT_SUCCESS;
317  }
318 
319  if ((posinentry == SION_CURRENT_POS) && (entrynum != SION_CURRENT_BLOCK)) {
320  return _sion_errorprint(0, _SION_ERROR_RETURN,
321  "Error: SION_CURRENT_POS set in sion_search_key, but blovk is not SION_CURRENT_BLOCK, aborting ...\n");
322  }
323 
324  if (sion_filedesc->keyvalmode == SION_KEYVAL_INLINE) {
325  DPRINTFP((2, DFUNCTION, -1, "sion_seek_key: key=%d entrynum=%d posinentry=%d\n", (int)key, (int)entrynum, (int)posinentry));
326  rc = _sion_seek_key_inline(sion_filedesc, key, entrynum, posinentry);
327  } else {
328  return _sion_errorprint(0, _SION_ERROR_RETURN,
329  "trying to search within key in keyval mode from file which is not opened in that mode, aborting ...\n");
330  }
331 
332  DPRINTFP((2, DFUNCTION, -1, "leave rc=%d\n", rc));
333  DPRINTFTS(-1, "leave sion_seek_key");
334  return rc;
335 }
336 #undef DFUNCTION
337 
338 #define DFUNCTION "sion_get_keyval_mode"
340 {
341  size_t rc = SION_KEYVAL_UNKNOWN;
342 
343  _sion_filedesc *sion_filedesc;
344 
345  DPRINTFTS(-1, "enter sion_get_keyval_mode");
346  DPRINTFP((2, DFUNCTION, -1, "enter\n"));
347 
348  if ((sid < 0) || (_sion_vcdtype(sid) != SION_FILEDESCRIPTOR) || !(sion_filedesc = _sion_vcdtovcon(sid))) {
349  return _sion_errorprint(SION_KEYVAL_UNKNOWN, _SION_ERROR_RETURN, "invalid sion_filedesc, aborting %d ...\n", sid);
350  }
351 
352  rc = sion_filedesc->keyvalmode;
353 
354  DPRINTFP((2, DFUNCTION, -1, "leave\n"));
355  DPRINTFTS(-1, "leave sion_get_keyval_mode");
356  return rc;
357 }
358 #undef DFUNCTION
359 
360 #define DFUNCTION "sion_keyval_type_to_str"
361 #define STR_PRT(X) \
362  case X: \
363  return #X
364 char *sion_keyval_type_to_str(int type)
365 {
366  switch (type) {
367  STR_PRT(SION_KEYVAL_NONE);
368  STR_PRT(SION_KEYVAL_INLINE);
369  STR_PRT(SION_KEYVAL_META);
370  STR_PRT(SION_KEYVAL_HASH);
371  STR_PRT(SION_KEYVAL_UNKNOWN);
372  }
373  return "unknown";
374 }
375 #undef DFUNCTION
376 
377 #define DFUNCTION "sion_key_list_iterator_reset"
379 {
380  size_t rc = SION_NOT_SUCCESS;
381  _sion_filedesc *sion_filedesc;
382 
383  DPRINTFP((2, DFUNCTION, -1, "enter\n"));
384 
385  if ((sid < 0) || (_sion_vcdtype(sid) != SION_FILEDESCRIPTOR) || !(sion_filedesc = _sion_vcdtovcon(sid))) {
386  return _sion_errorprint(0, _SION_ERROR_RETURN, "invalid sion_filedesc, aborting %d ...\n", sid);
387  }
388  if (sion_filedesc->rank < 0) { /* empty file */
389  return SION_NOT_SUCCESS;
390  }
391 
392  if (sion_filedesc->keyvalmode == SION_KEYVAL_INLINE) {
393  rc = _sion_key_list_iterator_reset_inline(sion_filedesc);
394  } else {
395  return _sion_errorprint(0, _SION_ERROR_RETURN,
396  "trying to reset iterator in keyval mode from file which is not opened in that mode, aborting ...\n");
397  }
398 
399  DPRINTFP((2, DFUNCTION, -1, "leave\n"));
400  return rc;
401 }
402 #undef DFUNCTION
403 
404 #define DFUNCTION "sion_key_list_iterator_next"
405 int sion_key_list_iterator_next(int sid, uint64_t *keyptr)
406 {
407  size_t rc = SION_NOT_SUCCESS;
408  _sion_filedesc *sion_filedesc;
409 
410  DPRINTFP((2, DFUNCTION, -1, "enter\n"));
411 
412  if ((sid < 0) || (_sion_vcdtype(sid) != SION_FILEDESCRIPTOR) || !(sion_filedesc = _sion_vcdtovcon(sid))) {
413  return _sion_errorprint(0, _SION_ERROR_RETURN, "invalid sion_filedesc, aborting %d ...\n", sid);
414  }
415  if (sion_filedesc->rank < 0) { /* empty file */
416  return SION_NOT_SUCCESS;
417  }
418  if (sion_filedesc->keyvalmode == SION_KEYVAL_INLINE) {
419  rc = _sion_key_list_iterator_next_inline(sion_filedesc, keyptr);
420  DPRINTFP((2, DFUNCTION, -1, "sion_fread_key_iterator_next: key=%d\n", (int)*keyptr));
421  } else {
422  return _sion_errorprint(0, _SION_ERROR_RETURN,
423  "trying to forward iterator in keyval mode from file which is not opened in that mode, aborting ...\n");
424  }
425 
426  DPRINTFP((2, DFUNCTION, -1, "leave\n"));
427  return rc;
428 }
429 #undef DFUNCTION
430 
431 #define DFUNCTION "sion_key_get_stat"
432 int sion_key_get_stat(int sid, uint64_t key, sion_key_stat_t *keystatptr)
433 {
434  size_t rc = SION_NOT_SUCCESS;
435  _sion_filedesc *sion_filedesc;
436 
437  DPRINTFP((2, DFUNCTION, -1, "enter\n"));
438 
439  if ((sid < 0) || (_sion_vcdtype(sid) != SION_FILEDESCRIPTOR) || !(sion_filedesc = _sion_vcdtovcon(sid))) {
440  return _sion_errorprint(0, _SION_ERROR_RETURN, "invalid sion_filedesc, aborting %d ...\n", sid);
441  }
442  if (sion_filedesc->rank < 0) { /* empty file */
443  return SION_NOT_SUCCESS;
444  }
445  if (sion_filedesc->keyvalmode == SION_KEYVAL_INLINE) {
446  rc = _sion_key_get_stat_inline(sion_filedesc, key, keystatptr);
447  DPRINTFP((2, DFUNCTION, -1, "_sion_key_get_stat_inline: key=%d rc=%d\n", (int)key, rc));
448  } else {
449  return _sion_errorprint(
450  0, _SION_ERROR_RETURN, "trying to get stat of key from file which is not opened in that mode, aborting ...\n");
451  }
452 
453  DPRINTFP((2, DFUNCTION, -1, "leave\n"));
454  return rc;
455 }
456 #undef DFUNCTION
457 
458 /* internal wrapper function */
459 
460 #define DFUNCTION "_sion_store_and_write_key_and_len"
461 int _sion_store_and_write_key_and_len(_sion_filedesc *sion_filedesc, uint64_t key, size_t len)
462 {
463  int rc = 0;
464  DPRINTFP((2, DFUNCTION, -1, "enter\n"));
465 
466  if (sion_filedesc->keyvalmode == SION_KEYVAL_INLINE) {
467  rc = _sion_store_and_write_key_and_len_inline(sion_filedesc, key, len);
468  } else {
469  return _sion_errorprint(
470  0, _SION_ERROR_RETURN, "trying to write in keyval mode from file which is not opened in that mode, aborting ...\n");
471  }
472 
473  DPRINTFP((2, DFUNCTION, -1, "leave\n"));
474  return rc;
475 }
476 #undef DFUNCTION
477 
478 #define DFUNCTION "_sion_write_value"
479 int _sion_write_value(_sion_filedesc *sion_filedesc, const void *data, uint64_t key, size_t len)
480 {
481  int rc = 0;
482  DPRINTFP((2, DFUNCTION, -1, "enter\n"));
483 
484  if (sion_filedesc->keyvalmode == SION_KEYVAL_INLINE) {
485  rc = _sion_write_value_inline(sion_filedesc, data, key, len);
486  } else {
487  return _sion_errorprint(
488  0, _SION_ERROR_RETURN, "trying to read in keyval mode from file which is not opened in that mode, aborting ...\n");
489  }
490 
491  DPRINTFP((2, DFUNCTION, -1, "leave\n"));
492  return rc;
493 }
494 #undef DFUNCTION
495 
496 #define DFUNCTION "_sion_find_and_read_key_and_len"
497 int _sion_find_and_read_key_and_len(_sion_filedesc *sion_filedesc, uint64_t key, size_t len, size_t *datalen)
498 {
499  int rc = SION_NOT_SUCCESS;
500  DPRINTFP((2, DFUNCTION, -1, "enter\n"));
501 
502  if (sion_filedesc->keyvalmode == SION_KEYVAL_INLINE) {
503  rc = _sion_find_and_read_key_and_len_inline(sion_filedesc, key, len, datalen);
504  } else {
505  return _sion_errorprint(
506  0, _SION_ERROR_RETURN, "trying to read in keyval mode from file which is not opened in that mode, aborting ...\n");
507  }
508 
509  DPRINTFP((2, DFUNCTION, -1, "leave\n"));
510  return rc;
511 }
512 #undef DFUNCTION
513 
514 #define DFUNCTION "_sion_read_value"
515 int _sion_read_value(_sion_filedesc *sion_filedesc, void *data, uint64_t key, size_t len)
516 {
517  int rc = 0;
518  DPRINTFP((2, DFUNCTION, -1, "enter\n"));
519 
520  if (sion_filedesc->keyvalmode == SION_KEYVAL_INLINE) {
521  rc = _sion_read_value_inline(sion_filedesc, data, key, len);
522  } else {
523  return _sion_errorprint(
524  0, _SION_ERROR_RETURN, "trying to read in keyval mode from file which is not opened in that mode, aborting ...\n");
525  }
526 
527  DPRINTFP((2, DFUNCTION, -1, "leave\n"));
528  return rc;
529 }
530 #undef DFUNCTION
int sion_key_full_scan(int sid)
Performs a full scan of all meta data in current file.
int sion_key_list_iterator_next(int sid, uint64_t *keyptr)
Forward to next key.
int sion_key_get_stat(int sid, uint64_t key, sion_key_stat_t *keystatptr)
get statistics about key
int sion_fread_key_iterator_next(int sid, uint64_t *keyptr, size_t *sizeptr)
Forward to next key.
#define SION_KEYVAL_UNKNOWN
type UNKNOWN
Definition: sion_const.h:100
#define SION_KEYVAL_NOTSET
no Key-Value Pairs in Chunks
Definition: sion_const.h:102
char * sion_keyval_type_to_str(int type)
Returns key value mode as string.
#define SION_CURRENT_BLOCK
Alias for the current block.
Definition: sion_const.h:74
#define SION_KEYVAL_NONE
no Key-Value Pairs in Chunks
Definition: sion_const.h:92
int sion_key_list_iterator_reset(int sid)
Resets key iterator.
int sion_seek_key(int sid, uint64_t key, int entrynum, int64_t posinentry)
Seek to position in key.
#define SION_KEYVAL_HASH
use hash data structure to store key-value
Definition: sion_const.h:98
#define SION_KEYVAL_META
use meta data block to store keys/len
Definition: sion_const.h:96
int sion_fread_key_iterator_reset(int sid)
Resets key iterator.
#define SION_KEYVAL_INLINE
use inline records to store key-value
Definition: sion_const.h:94
size_t sion_fwrite_key(const void *data, uint64_t key, size_t size, size_t nitems, int sid)
Writes data for key.
size_t sion_fread_key(void *data, uint64_t key, size_t size, size_t nitems, int sid)
Read data for key.
int sion_get_keyval_mode(int sid)
Return selected mode for key value.
#define SION_CURRENT_POS
Alias for the current position in the current block.
Definition: sion_const.h:76