SIONlib  1.7.7
Scalable I/O library for parallel access to task-local files
sion_keyvalue_keymngr.h
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 #ifndef SION_SION_KEYVALUE_KEYMNGR_H
15 #define SION_SION_KEYVALUE_KEYMNGR_H
16 
17 #include <stdint.h>
18 
19 #include "sion_const.h"
20 #include "sion_common.h"
21 /* for key-type */
22 #include "sion_keyvalue_table.h"
23 
24 /* keyvalue_keymngr: handles memory based tables storing blocks for each key */
25 
27 
28 _sion_keyvalue_keymngr* _sion_keyvalue_keymngr_init(int size);
29 int _sion_keyvalue_keymngr_destroy(_sion_keyvalue_keymngr** keymngr);
30 
31 _sion_keyvalue_keymngr* _sion_keyvalue_keymngr_dup(_sion_keyvalue_keymngr* keymngr_orig, int dup_mode, sion_table_key_t sel_key);
32 
33 /* add info (offset and len) about a new block for a key */
34 int _sion_keyvalue_keymngr_add_block(_sion_keyvalue_keymngr* keymngr, sion_table_key_t key, size_t offset, size_t len);
35 
36 /* update internal data of a key by advancing current_pos of that key by bytes_read
37  if a block is fully read, the meta data is no longer needed and the block will be destroyed */
38 int _sion_keyvalue_keymngr_update_read_pos(_sion_keyvalue_keymngr* keymngr, sion_table_key_t key, size_t bytes_read, sion_int64 current_pos);
39 
40 /* searches for info about a key, if available (SION_SUCCESS) current_pos and
41  bytes_left are returned, otherwise SION_NOT_SUCCESS */
42 int _sion_keyvalue_keymngr_lookup(_sion_keyvalue_keymngr* keymngr, sion_table_key_t key, size_t *current_pos, size_t *bytes_left);
43 
44 /* searches for info about a key at position (entrynum,posinentry), if
45  available (SION_SUCCESS) current_pos and bytes_left are returned, otherwise
46  SION_NOT_SUCCESS. In addition, on success the current_block/pos of that
47  key is set to this position */
48 int _sion_keyvalue_keymngr_lookup_and_set_pos(_sion_keyvalue_keymngr* keymngr, sion_table_key_t key, int entrynum, sion_int64 posinentry,
49  size_t *current_pos, size_t *bytes_left);
50 
51 /* sets next position from where next meta data could be read */
52 int _sion_keyvalue_keymngr_set_next_scan_pos(_sion_keyvalue_keymngr* keymngr, size_t pos);
53 
54 /* gets next position from where next meta data could be read */
55 int _sion_keyvalue_keymngr_get_next_scan_pos(_sion_keyvalue_keymngr* keymngr, size_t *pos);
56 
57 /* get/setter for flag scan_done: all data about keys is stored in keymngr */
58 int _sion_keyvalue_keymngr_set_scan_done(_sion_keyvalue_keymngr* keymngr);
59 int _sion_keyvalue_keymngr_is_scan_done(_sion_keyvalue_keymngr* keymngr);
60 
61 
62 
63 /* iterator to run over all blocks of all keys in write order */
64 int _sion_keyvalue_keymngr_iterator_reset(_sion_keyvalue_keymngr* keymngr);
65 /* current_pos is set to a value if current read position is in this block, otherwise -1 */
66 int _sion_keyvalue_keymngr_iterator_next(_sion_keyvalue_keymngr* keymngr, sion_table_key_t *key, size_t *current_pos, size_t *offset, size_t *len);
67 
68 /* iterator to get key list */
69 int _sion_keyvalue_keymngr_key_list_iterator_reset(_sion_keyvalue_keymngr* keymngr);
70 int _sion_keyvalue_keymngr_key_list_iterator_next(_sion_keyvalue_keymngr* keymngr, sion_table_key_t *key);
71 
72 int _sion_keyvalue_keymngr_key_get_stat(_sion_keyvalue_keymngr* keymngr, sion_table_key_t key, sion_key_stat_t *keystat);
73 
74 int _sion_keyvalue_keymngr_key_get_sizeof(_sion_keyvalue_keymngr* keymngr);
75 
76 #endif