SIONlib  1.7.7
Scalable I/O library for parallel access to task-local files
sion_keyvalue.c
Go to the documentation of this file.
1 /****************************************************************************
2 ** SIONLIB http://www.fz-juelich.de/jsc/sionlib **
3 *****************************************************************************
4 ** Copyright (c) 2008-2019 **
5 ** Forschungszentrum Juelich, Juelich Supercomputing Centre **
6 ** **
7 ** See the file COPYRIGHT in the package base directory for details **
8 ****************************************************************************/
9 
14 #define _XOPEN_SOURCE 700
15 
16 #include <stdlib.h>
17 #include <stdio.h>
18 #include <string.h>
19 #include <time.h>
20 #include <assert.h>
21 
22 #include <sys/types.h>
23 #include <sys/stat.h>
24 #include <fcntl.h>
25 #include <unistd.h>
26 
27 
28 #include "sion.h"
29 #include "sion_debug.h"
30 #include "sion_error_handler.h"
31 #include "sion_filedesc.h"
32 #include "sion_tools.h"
33 #include "sion_fd.h"
34 #include "sion_file.h"
35 #include "sion_metadata.h"
36 #include "sion_internal.h"
37 #include "sion_internal_seek.h"
38 #include "sion_printts.h"
39 #include "sion_keyvalue.h"
40 #include "sion_keyvalue_inline.h"
41 
42 #define DFUNCTION "_sion_keyval_check_env"
43 int _sion_keyval_check_env(_sion_filedesc *sion_filedesc, sion_int64 file_mode_flags) {
44  const char *t;
45  int rc=1;
46  sion_int32 keyvalmode_env;
47  sion_int32 keyvalmode_parm;
48 
49  DPRINTFP((2, DFUNCTION, -1, "keyval mode is initially set to %s\n", sion_keyval_type_to_str((int) sion_filedesc->keyvalmode)));
50 
51  /* check env-var */
52  keyvalmode_env=SION_KEYVAL_NOTSET;
53  t = _sion_getenv("SION_KEYVALUE_MODE");
54  if(t) {
55  if (strstr(t, "inline")) keyvalmode_env=SION_KEYVAL_INLINE;
56  if (strstr(t, "meta")) keyvalmode_env=SION_KEYVAL_META;
57  if (strstr(t, "hash")) keyvalmode_env=SION_KEYVAL_HASH;
58  if (strstr(t, "none")) keyvalmode_env=SION_KEYVAL_NONE;
59  if (strstr(t, "unknown")) keyvalmode_env=SION_KEYVAL_UNKNOWN;
60  }
61  DPRINTFP((2, DFUNCTION, -1, "keyval mode from env is=%s\n", sion_keyval_type_to_str((int) keyvalmode_env)));
62 
63  /* check file mode from open call */
64  keyvalmode_parm=SION_KEYVAL_NOTSET;
65  if(file_mode_flags&_SION_FMODE_KEYVAL_INLINE) keyvalmode_parm=SION_KEYVAL_INLINE;
66  if(file_mode_flags&_SION_FMODE_KEYVAL_META) keyvalmode_parm=SION_KEYVAL_META;
67  if(file_mode_flags&_SION_FMODE_KEYVAL_HASH) keyvalmode_parm=SION_KEYVAL_HASH;
68  if(file_mode_flags&_SION_FMODE_KEYVAL_NONE) keyvalmode_parm=SION_KEYVAL_NONE;
69  if(file_mode_flags&_SION_FMODE_KEYVAL_UNKNOWN) keyvalmode_parm=SION_KEYVAL_UNKNOWN;
70  DPRINTFP((2, DFUNCTION, -1, "keyval mode from parameter is=%s\n", sion_keyval_type_to_str((int) keyvalmode_parm)));
71 
72  if(file_mode_flags&_SION_FMODE_READ) {
73  DPRINTFP((2, DFUNCTION, -1, "file is opened for reading\n"));
74  /* keyvalmode is already read from meta-data of file */
75  /* open parameter and environment have to be identical */
76 
77  if(keyvalmode_parm==SION_KEYVAL_UNKNOWN) {
78  /* user will query mode later */
79  DPRINTFP((2, DFUNCTION, -1, "file read: parameter is 'unknown' keyvalmode will taken from file ...\n"));
80 
81  } else {
82  /* check for consistency */
83  if((keyvalmode_parm!=SION_KEYVAL_NOTSET) && (keyvalmode_parm!=sion_filedesc->keyvalmode)) {
84  DPRINTFP((2, DFUNCTION, -1, "file read: keyvalmode of file is different to requested keyvalmode from parameter, aborting ...\n"));
85  return(_sion_errorprint(0,_SION_ERROR_RETURN,"file read: keyvalmode of file is different to requested keyvalmode from parameter, aborting ...\n"));
86  }
87  if((keyvalmode_env!=SION_KEYVAL_NOTSET) && (keyvalmode_env!=sion_filedesc->keyvalmode)) {
88  DPRINTFP((2, DFUNCTION, -1, "file read: keyvalmode of file is different to requested keyvalmode from environment, aborting ...\n"));
89  return(_sion_errorprint(0,_SION_ERROR_RETURN,"file read: keyvalmode of file is different to requested keyvalmode from env-var, aborting ...\n"));
90  }
91  }
92 
93  } else {
94 
95  DPRINTFP((2, DFUNCTION, -1, "file is opened for writing\n"));
96  /* order: first env, then parameter */
97  sion_filedesc->keyvalmode=SION_KEYVAL_NONE;
98  if(keyvalmode_env!=SION_KEYVAL_NOTSET) sion_filedesc->keyvalmode=keyvalmode_env;
99  if(keyvalmode_parm!=SION_KEYVAL_NOTSET) sion_filedesc->keyvalmode=keyvalmode_parm;
100  }
101 
102 
103  DPRINTFP((2, DFUNCTION, -1, "keyval mode is=%s\n", sion_keyval_type_to_str((int) sion_filedesc->keyvalmode)));
104  return (rc);
105 }
106 #undef DFUNCTION
107 
108 /* dup internal data structures from first to second sion_filedesc */
109 #define DFUNCTION "_sion_keyval_dup_dataptr"
110 int _sion_keyval_dup_dataptr(_sion_filedesc *sion_filedesc, _sion_filedesc *new_filedesc) {
111  int rc=0;
112  DPRINTFP((2, DFUNCTION, -1, "enter\n"));
113 
114  if(sion_filedesc->keyvalmode==SION_KEYVAL_INLINE) {
115  rc=_sion_keyval_dup_dataptr_inline(sion_filedesc,new_filedesc);
116  } else {
117  return(_sion_errorprint(0,_SION_ERROR_RETURN,"trying to call sion_keyval_dup_dataptr in inknown keyval mode , aborting ...\n"));
118  }
119 
120  DPRINTFP((2, DFUNCTION, -1, "leave\n"));
121  return (rc);
122 }
123 #undef DFUNCTION
124 
125 
126 
127 #define DFUNCTION "sion_fwrite_key"
143 size_t sion_fwrite_key(const void *data, uint64_t key, size_t size, size_t nitems, int sid) {
144  size_t rc=0, frc;
145  size_t len;
146  _sion_filedesc *sion_filedesc;
147 
148  /* */ DPRINTFTS(-1, "enter sion_fwrite_key");
149  DPRINTFP((2, DFUNCTION, -1, "enter\n"));
150 
151  if ((sid<0) || (_sion_vcdtype(sid) != SION_FILEDESCRIPTOR)
152  || !(sion_filedesc = _sion_vcdtovcon(sid))) {
153  return(_sion_errorprint(0,_SION_ERROR_RETURN,"invalid sion_filedesc, aborting %d ...\n", sid));
154  }
155  if(sion_filedesc->rank<0) { /* empty file */
156  return(SION_NOT_SUCCESS);
157  }
158  DPRINTFP((2, DFUNCTION, -1, "fwrite_key: key=%d size=%d, nitems=%d\n",(int) key,(int) size, (int) nitems));
159 
160  len=size*nitems;
161 
162  /* store key and length */
163  frc=_sion_store_and_write_key_and_len(sion_filedesc,key,len);
164  if(frc != SION_SUCCESS) {
165  return(_sion_errorprint_on_rank(-1,_SION_ERROR_RETURN,sion_filedesc->rank,
166  "could not write meta data to file (frc=%d sid=%d) ...", (int) frc, sid));
167  }
168 
169  /* store data */
170  frc=_sion_write_value(sion_filedesc,data,key,len);
171  if(frc != len) {
172  return(_sion_errorprint_on_rank(-1,_SION_ERROR_RETURN,sion_filedesc->rank,
173  "could not write data (%d bytes) to file (frc=%d sid=%d) ...", (int) len, (int) frc, sid));
174  }
175 
176  rc=(size_t) len / size;
177 
178  DPRINTFP((2, DFUNCTION, -1, "leave\n"));
179  /* */ DPRINTFTS(-1, "leave sion_fwrite_key");
180  return (rc);
181 }
182 #undef DFUNCTION
183 
184 
185 
186 #define DFUNCTION "sion_fread_key"
202 size_t sion_fread_key(void *data, uint64_t key, size_t size, size_t nitems, int sid) {
203  size_t rc=0, frc;
204  size_t len, datalen=0;
205  _sion_filedesc *sion_filedesc;
206 
207  /* */ DPRINTFTS(-1, "enter sion_fread_key");
208  DPRINTFP((8, DFUNCTION, -1, "enter\n"));
209 
210  if ((sid<0) || (_sion_vcdtype(sid) != SION_FILEDESCRIPTOR)
211  || !(sion_filedesc = _sion_vcdtovcon(sid))) {
212  return(_sion_errorprint(0,_SION_ERROR_RETURN,"invalid sion_filedesc, aborting %d ...\n", sid));
213  }
214  if(sion_filedesc->rank<0) { /* empty file */
215  return(SION_NOT_SUCCESS);
216  }
217  DPRINTFP((32, DFUNCTION, -1, "fread_key: sid=%d key=%ld size=%d, nitems=%d\n",(int) sid, (long) key,(int) size, (int) nitems));
218 
219  len=size*nitems;
220 
221  /* find key and length */
222  if (_sion_find_and_read_key_and_len(sion_filedesc,key,len,&datalen) !=
223  SION_SUCCESS) {
224  DPRINTFP((8, DFUNCTION, -1, "_sion_find_and_read_key_and_len return NOT SUCCESS\n"));
225  return(SION_NOT_SUCCESS);
226  }
227 
228  /* read as much elements of size <size> as posible */
229  len = ( (int) datalen/size ) * size;
230 
231  /* read data */
232  frc=_sion_read_value(sion_filedesc,data,key,len);
233  if(frc != len) {
234  return(SION_NOT_SUCCESS);
235  }
236 
237  rc=(size_t) len / size;
238 
239  DPRINTFP((8, DFUNCTION, -1, "leave rc=%d\n",(int) rc));
240  /* */ DPRINTFTS(-1, "leave sion_fread_key");
241  return (rc);
242 }
243 #undef DFUNCTION
244 
245 #define DFUNCTION "sion_key_full_scan"
254 int sion_key_full_scan(int sid) {
255  size_t rc=SION_NOT_SUCCESS;
256  _sion_filedesc *sion_filedesc;
257 
258  /* */ DPRINTFTS(-1, "enter sion_key_full_scan");
259  DPRINTFP((2, DFUNCTION, -1, "enter\n"));
260 
261  if ((sid<0) || (_sion_vcdtype(sid) != SION_FILEDESCRIPTOR)
262  || !(sion_filedesc = _sion_vcdtovcon(sid))) {
263  return(_sion_errorprint(0,_SION_ERROR_RETURN,"invalid sion_filedesc, aborting %d ...\n", sid));
264  }
265  if(sion_filedesc->rank<0) { /* empty file */
266  return(SION_NOT_SUCCESS);
267  }
268  if(sion_filedesc->keyvalmode==SION_KEYVAL_INLINE) {
269  rc=_sion_key_full_scan_inline(sion_filedesc);
270  } else {
271  return(_sion_errorprint(0,_SION_ERROR_RETURN,"trying to perform full scan of file which is not opened in that mode, aborting ...\n"));
272  }
273 
274  DPRINTFP((2, DFUNCTION, -1, "leave\n"));
275  /* */ DPRINTFTS(-1, "leave sion_key_full_scan");
276  return (rc);
277 }
278 #undef DFUNCTION
279 
280 
281 #define DFUNCTION "sion_fread_key_iterator_reset"
291  size_t rc=SION_NOT_SUCCESS;
292  _sion_filedesc *sion_filedesc;
293 
294  DPRINTFP((2, DFUNCTION, -1, "enter\n"));
295 
296  if ((sid<0) || (_sion_vcdtype(sid) != SION_FILEDESCRIPTOR)
297  || !(sion_filedesc = _sion_vcdtovcon(sid))) {
298  return(_sion_errorprint(0,_SION_ERROR_RETURN,"invalid sion_filedesc, aborting %d ...\n", sid));
299  }
300  if(sion_filedesc->rank<0) { /* empty file */
301  return(SION_NOT_SUCCESS);
302  }
303 
304  if(sion_filedesc->keyvalmode==SION_KEYVAL_INLINE) {
305  rc=_sion_iterator_reset_inline(sion_filedesc);
306  } else {
307  return(_sion_errorprint(0,_SION_ERROR_RETURN,"trying to reset iterator in keyval mode from file which is not opened in that mode, aborting ...\n"));
308  }
309 
310  DPRINTFP((2, DFUNCTION, -1, "leave\n"));
311  return (rc);
312 }
313 #undef DFUNCTION
314 
315 #define DFUNCTION "sion_fread_key_iterator_next"
326 int sion_fread_key_iterator_next(int sid, uint64_t *keyptr, size_t *sizeptr) {
327  size_t rc=SION_NOT_SUCCESS;
328  _sion_filedesc *sion_filedesc;
329 
330  DPRINTFP((2, DFUNCTION, -1, "enter\n"));
331 
332  if ((sid<0) || (_sion_vcdtype(sid) != SION_FILEDESCRIPTOR)
333  || !(sion_filedesc = _sion_vcdtovcon(sid))) {
334  return(_sion_errorprint(0,_SION_ERROR_RETURN,"invalid sion_filedesc, aborting %d ...\n", sid));
335  }
336  if(sion_filedesc->rank<0) { /* empty file */
337  return(SION_NOT_SUCCESS);
338  }
339  if(sion_filedesc->keyvalmode==SION_KEYVAL_INLINE) {
340  rc=_sion_iterator_next_inline(sion_filedesc, keyptr, sizeptr);
341  DPRINTFP((2, DFUNCTION, -1, "sion_fread_key_iterator_next: key=%d size=%d\n",(int) *keyptr,(int) *sizeptr));
342  } else {
343  return(_sion_errorprint(0,_SION_ERROR_RETURN,"trying to forward iterator in keyval mode from file which is not opened in that mode, aborting ...\n"));
344  }
345 
346  DPRINTFP((2, DFUNCTION, -1, "leave\n"));
347  return (rc);
348 }
349 #undef DFUNCTION
350 
351 
352 #define DFUNCTION "sion_seek_key"
365 int sion_seek_key(int sid, uint64_t key, int entrynum, sion_int64 posinentry) {
366  size_t rc=SION_NOT_SUCCESS;
367  _sion_filedesc *sion_filedesc;
368 
369  /* */ DPRINTFTS(-1, "enter sion_seek_key");
370  DPRINTFP((2, DFUNCTION, -1, "enter\n"));
371 
372  if ((sid<0) || (_sion_vcdtype(sid) != SION_FILEDESCRIPTOR)
373  || !(sion_filedesc = _sion_vcdtovcon(sid))) {
374  return(_sion_errorprint(0,_SION_ERROR_RETURN,"invalid sion_filedesc, aborting %d ...\n", sid));
375  }
376  if(sion_filedesc->rank<0) { /* empty file */
377  return(SION_NOT_SUCCESS);
378  }
379 
380  if( (posinentry==SION_CURRENT_POS) && (entrynum!=SION_CURRENT_BLOCK) ) {
381  return(_sion_errorprint(0,_SION_ERROR_RETURN,"Error: SION_CURRENT_POS set in sion_search_key, but blovk is not SION_CURRENT_BLOCK, aborting ...\n"));
382  }
383 
384  if(sion_filedesc->keyvalmode==SION_KEYVAL_INLINE) {
385  DPRINTFP((2, DFUNCTION, -1, "sion_seek_key: key=%d entrynum=%d posinentry=%d\n",(int) key,(int) entrynum, (int) posinentry));
386  rc=_sion_seek_key_inline(sion_filedesc, key, entrynum, posinentry);
387  } else {
388  return(_sion_errorprint(0,_SION_ERROR_RETURN,"trying to search within key in keyval mode from file which is not opened in that mode, aborting ...\n"));
389  }
390 
391  DPRINTFP((2, DFUNCTION, -1, "leave rc=%d\n",rc));
392  /* */ DPRINTFTS(-1, "leave sion_seek_key");
393  return (rc);
394 }
395 #undef DFUNCTION
396 
397 #define DFUNCTION "sion_get_keyval_mode"
406 int sion_get_keyval_mode(int sid) {
407  size_t rc=SION_KEYVAL_UNKNOWN;
408 
409  _sion_filedesc *sion_filedesc;
410 
411  /* */ DPRINTFTS(-1, "enter sion_get_keyval_mode");
412  DPRINTFP((2, DFUNCTION, -1, "enter\n"));
413 
414  if ((sid<0) || (_sion_vcdtype(sid) != SION_FILEDESCRIPTOR)
415  || !(sion_filedesc = _sion_vcdtovcon(sid))) {
416  return(_sion_errorprint(SION_KEYVAL_UNKNOWN,_SION_ERROR_RETURN,"invalid sion_filedesc, aborting %d ...\n", sid));
417  }
418 
419  rc=sion_filedesc->keyvalmode;
420 
421  DPRINTFP((2, DFUNCTION, -1, "leave\n"));
422  /* */ DPRINTFTS(-1, "leave sion_get_keyval_mode");
423  return (rc);
424 }
425 #undef DFUNCTION
426 
427 
428 #define DFUNCTION "sion_keyval_type_to_str"
429 #define STR_PRT(X) case X: return # X
438 char* sion_keyval_type_to_str (int type) {
439  switch (type) {
440  STR_PRT(SION_KEYVAL_NONE);
441  STR_PRT(SION_KEYVAL_INLINE);
442  STR_PRT(SION_KEYVAL_META);
443  STR_PRT(SION_KEYVAL_HASH);
444  STR_PRT(SION_KEYVAL_UNKNOWN);
445  }
446  return "unknown";
447 }
448 #undef DFUNCTION
449 
450 
451 
452 #define DFUNCTION "sion_key_list_iterator_reset"
462  size_t rc=SION_NOT_SUCCESS;
463  _sion_filedesc *sion_filedesc;
464 
465  DPRINTFP((2, DFUNCTION, -1, "enter\n"));
466 
467  if ((sid<0) || (_sion_vcdtype(sid) != SION_FILEDESCRIPTOR)
468  || !(sion_filedesc = _sion_vcdtovcon(sid))) {
469  return(_sion_errorprint(0,_SION_ERROR_RETURN,"invalid sion_filedesc, aborting %d ...\n", sid));
470  }
471  if(sion_filedesc->rank<0) { /* empty file */
472  return(SION_NOT_SUCCESS);
473  }
474 
475  if(sion_filedesc->keyvalmode==SION_KEYVAL_INLINE) {
476  rc=_sion_key_list_iterator_reset_inline(sion_filedesc);
477  } else {
478  return(_sion_errorprint(0,_SION_ERROR_RETURN,"trying to reset iterator in keyval mode from file which is not opened in that mode, aborting ...\n"));
479  }
480 
481  DPRINTFP((2, DFUNCTION, -1, "leave\n"));
482  return (rc);
483 }
484 #undef DFUNCTION
485 
486 #define DFUNCTION "sion_key_list_iterator_next"
496 int sion_key_list_iterator_next(int sid, uint64_t *keyptr) {
497  size_t rc=SION_NOT_SUCCESS;
498  _sion_filedesc *sion_filedesc;
499 
500  DPRINTFP((2, DFUNCTION, -1, "enter\n"));
501 
502  if ((sid<0) || (_sion_vcdtype(sid) != SION_FILEDESCRIPTOR)
503  || !(sion_filedesc = _sion_vcdtovcon(sid))) {
504  return(_sion_errorprint(0,_SION_ERROR_RETURN,"invalid sion_filedesc, aborting %d ...\n", sid));
505  }
506  if(sion_filedesc->rank<0) { /* empty file */
507  return(SION_NOT_SUCCESS);
508  }
509  if(sion_filedesc->keyvalmode==SION_KEYVAL_INLINE) {
510  rc=_sion_key_list_iterator_next_inline(sion_filedesc, keyptr);
511  DPRINTFP((2, DFUNCTION, -1, "sion_fread_key_iterator_next: key=%d\n",(int) *keyptr));
512  } else {
513  return(_sion_errorprint(0,_SION_ERROR_RETURN,"trying to forward iterator in keyval mode from file which is not opened in that mode, aborting ...\n"));
514  }
515 
516  DPRINTFP((2, DFUNCTION, -1, "leave\n"));
517  return (rc);
518 }
519 #undef DFUNCTION
520 
521 #define DFUNCTION "sion_key_get_stat"
532 int sion_key_get_stat(int sid, uint64_t key, sion_key_stat_t *keystatptr) {
533  size_t rc=SION_NOT_SUCCESS;
534  _sion_filedesc *sion_filedesc;
535 
536  DPRINTFP((2, DFUNCTION, -1, "enter\n"));
537 
538  if ((sid<0) || (_sion_vcdtype(sid) != SION_FILEDESCRIPTOR)
539  || !(sion_filedesc = _sion_vcdtovcon(sid))) {
540  return(_sion_errorprint(0,_SION_ERROR_RETURN,"invalid sion_filedesc, aborting %d ...\n", sid));
541  }
542  if(sion_filedesc->rank<0) { /* empty file */
543  return(SION_NOT_SUCCESS);
544  }
545  if(sion_filedesc->keyvalmode==SION_KEYVAL_INLINE) {
546  rc=_sion_key_get_stat_inline(sion_filedesc, key, keystatptr);
547  DPRINTFP((2, DFUNCTION, -1, "_sion_key_get_stat_inline: key=%d rc=%d\n",(int) key, rc));
548  } else {
549  return(_sion_errorprint(0,_SION_ERROR_RETURN,"trying to get stat of key from file which is not opened in that mode, aborting ...\n"));
550  }
551 
552  DPRINTFP((2, DFUNCTION, -1, "leave\n"));
553  return (rc);
554 }
555 #undef DFUNCTION
556 
557 
558 /* internal wrapper function */
559 
560 
561 #define DFUNCTION "_sion_store_and_write_key_and_len"
562 int _sion_store_and_write_key_and_len(_sion_filedesc *sion_filedesc, uint64_t key, size_t len) {
563  int rc=0;
564  DPRINTFP((2, DFUNCTION, -1, "enter\n"));
565 
566  if(sion_filedesc->keyvalmode==SION_KEYVAL_INLINE) {
567  rc=_sion_store_and_write_key_and_len_inline(sion_filedesc,key,len);
568  } else {
569  return(_sion_errorprint(0,_SION_ERROR_RETURN,"trying to write in keyval mode from file which is not opened in that mode, aborting ...\n"));
570  }
571 
572  DPRINTFP((2, DFUNCTION, -1, "leave\n"));
573  return (rc);
574 }
575 #undef DFUNCTION
576 
577 #define DFUNCTION "_sion_write_value"
578 int _sion_write_value(_sion_filedesc *sion_filedesc, const void *data, uint64_t key, size_t len) {
579  int rc=0;
580  DPRINTFP((2, DFUNCTION, -1, "enter\n"));
581 
582  if(sion_filedesc->keyvalmode==SION_KEYVAL_INLINE) {
583  rc=_sion_write_value_inline(sion_filedesc,data,key,len);
584  } else {
585  return(_sion_errorprint(0,_SION_ERROR_RETURN,"trying to read in keyval mode from file which is not opened in that mode, aborting ...\n"));
586  }
587 
588  DPRINTFP((2, DFUNCTION, -1, "leave\n"));
589  return (rc);
590 }
591 #undef DFUNCTION
592 
593 #define DFUNCTION "_sion_find_and_read_key_and_len"
594 int _sion_find_and_read_key_and_len(_sion_filedesc *sion_filedesc, uint64_t key, size_t len, size_t *datalen) {
595  int rc = SION_NOT_SUCCESS;
596  DPRINTFP((2, DFUNCTION, -1, "enter\n"));
597 
598  if(sion_filedesc->keyvalmode==SION_KEYVAL_INLINE) {
599  rc=_sion_find_and_read_key_and_len_inline(sion_filedesc, key, len, datalen);
600  } else {
601  return(_sion_errorprint(0,_SION_ERROR_RETURN,"trying to read in keyval mode from file which is not opened in that mode, aborting ...\n"));
602  }
603 
604  DPRINTFP((2, DFUNCTION, -1, "leave\n"));
605  return (rc);
606 }
607 #undef DFUNCTION
608 
609 #define DFUNCTION "_sion_read_value"
610 int _sion_read_value(_sion_filedesc *sion_filedesc, void *data, uint64_t key, size_t len) {
611  int rc=0;
612  DPRINTFP((2, DFUNCTION, -1, "enter\n"));
613 
614  if(sion_filedesc->keyvalmode==SION_KEYVAL_INLINE) {
615  rc=_sion_read_value_inline(sion_filedesc,data,key,len);
616  } else {
617  return(_sion_errorprint(0,_SION_ERROR_RETURN,"trying to read in keyval mode from file which is not opened in that mode, aborting ...\n"));
618  }
619 
620  DPRINTFP((2, DFUNCTION, -1, "leave\n"));
621  return (rc);
622 }
623 #undef DFUNCTION
624 
625 
char * sion_keyval_type_to_str(int type)
Returns key value mode as string.
size_t sion_fwrite_key(const void *data, uint64_t key, size_t size, size_t nitems, int sid)
Writes data for key.
int sion_seek_key(int sid, uint64_t key, int entrynum, sion_int64 posinentry)
Seek to position in key.
int sion_get_keyval_mode(int sid)
Return selected mode for key value.
int sion_key_list_iterator_reset(int sid)
Resets key iterator.
int sion_key_full_scan(int sid)
Performs a full scan of all meta data in current file.
size_t sion_fread_key(void *data, uint64_t key, size_t size, size_t nitems, int sid)
Read data for key.
int sion_fread_key_iterator_reset(int sid)
Resets key iterator.
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_INLINE
Definition: sion_const.h:81
#define SION_KEYVAL_HASH
Definition: sion_const.h:83
#define SION_KEYVAL_UNKNOWN
Definition: sion_const.h:84
#define SION_KEYVAL_NOTSET
Definition: sion_const.h:85
#define SION_CURRENT_BLOCK
Definition: sion_const.h:69
#define SION_CURRENT_POS
Definition: sion_const.h:70
#define SION_KEYVAL_META
Definition: sion_const.h:82
#define SION_KEYVAL_NONE
Definition: sion_const.h:80
void * _sion_vcdtovcon(int sid)
Definition: sion_fd.c:53
int _sion_vcdtype(int sid)
Definition: sion_fd.c:58
#define SION_FILEDESCRIPTOR
Definition: sion_fd.h:17
char * _sion_getenv(const char *name)
Sion Time Stamp Header.
Sion File Descriptor Structure.
Definition: sion_filedesc.h:79