HDF5  1.12.0
H5Bprivate.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * Copyright by The HDF Group. *
3  * Copyright by the Board of Trustees of the University of Illinois. *
4  * All rights reserved. *
5  * *
6  * This file is part of HDF5. The full HDF5 copyright notice, including *
7  * terms governing use, modification, and redistribution, is contained in *
8  * the COPYING file, which can be found at the root of the source code *
9  * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
10  * If you do not have access to either file, you may request a copy from *
11  * help@hdfgroup.org. *
12  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
13 
14 /*-------------------------------------------------------------------------
15  *
16  * Created: H5Bprivate.h
17  * Jul 10 1997
18  * Robb Matzke <matzke@llnl.gov>
19  *
20  * Purpose: Private non-prototype header.
21  *
22  * Modifications:
23  *
24  *-------------------------------------------------------------------------
25  */
26 
27 #ifndef _H5Bprivate_H
28 #define _H5Bprivate_H
29 
30 
31 /* Private headers needed by this file */
32 #include "H5private.h" /* Generic Functions */
33 #include "H5Fprivate.h" /* File access */
34 #include "H5UCprivate.h" /* Reference counted object functions */
35 
36 /**************************/
37 /* Library Private Macros */
38 /**************************/
39 
40 /*
41  * Feature: Define this constant if you want to check B-tree consistency
42  * after each B-tree operation. Note that this slows down the
43  * library considerably! Debugging the B-tree depends on assert()
44  * being enabled.
45  */
46 #ifdef NDEBUG
47 # undef H5B_DEBUG
48 #endif
49 
50 
51 /****************************/
52 /* Library Private Typedefs */
53 /****************************/
54 
55 /* B-tree IDs for various internal things. */
56 /* Note - if more of these are added, any 'K' values (for internal or leaf
57  * nodes) they use will need to be stored in the file somewhere. -QAK
58  */
59 typedef enum H5B_subid_t {
60  H5B_SNODE_ID = 0, /*B-tree is for symbol table nodes */
61  H5B_CHUNK_ID = 1, /*B-tree is for chunked dataset storage */
62  H5B_NUM_BTREE_ID /* Number of B-tree key IDs (must be last) */
64 
65 /* Define return values from B-tree insertion callbacks */
66 typedef enum H5B_ins_t {
67  H5B_INS_ERROR = -1, /*error return value */
68  H5B_INS_NOOP = 0, /*insert made no changes */
69  H5B_INS_LEFT = 1, /*insert new node to left of cur node */
70  H5B_INS_RIGHT = 2, /*insert new node to right of cur node */
71  H5B_INS_CHANGE = 3, /*change child address for cur node */
72  H5B_INS_FIRST = 4, /*insert first node in (sub)tree */
73  H5B_INS_REMOVE = 5 /*remove current node */
75 
76 /* Enum for specifying the direction of the critical key in relation to the
77  * child */
78 typedef enum H5B_dir_t {
79  H5B_LEFT = 0, /* Critical key is to the left */
80  H5B_RIGHT = 1 /* Critical key is to the right */
82 
83 /* Define the operator callback function pointer for H5B_iterate() */
84 typedef int (*H5B_operator_t)(H5F_t *f, const void *_lt_key, haddr_t addr,
85  const void *_rt_key, void *_udata);
86 
87 /* Each B-tree has certain information that can be shared across all
88  * the instances of nodes in that B-tree.
89  */
90 typedef struct H5B_shared_t {
91  const struct H5B_class_t *type; /* Type of tree */
92  unsigned two_k; /* 2*"K" value for tree's nodes */
93  size_t sizeof_rkey; /* Size of raw (disk) key */
94  size_t sizeof_rnode; /* Size of raw (disk) node */
95  size_t sizeof_keys; /* Size of native (memory) key node */
96  size_t sizeof_addr; /* Size of file address (in bytes) */
97  size_t sizeof_len; /* Size of file lengths (in bytes) */
98  uint8_t *page; /* Disk page */
99  size_t *nkey; /* Offsets of each native key in native key buffer */
100  void *udata; /* 'Local' info for a B-tree */
102 
103 /*
104  * Each class of object that can be pointed to by a B-link tree has a
105  * variable of this type that contains class variables and methods. Each
106  * tree has a K (1/2 rank) value on a per-file basis. The file_create_parms
107  * has an array of K values indexed by the `id' class field below. The
108  * array is initialized with the HDF5_BTREE_K_DEFAULT macro.
109  */
110 
111 typedef struct H5B_class_t {
112  H5B_subid_t id; /*id as found in file*/
113  size_t sizeof_nkey; /*size of native (memory) key*/
114  H5UC_t * (*get_shared)(const H5F_t*, const void*); /*shared info for node */
115  herr_t (*new_node)(H5F_t*, H5B_ins_t, void*, void*, void*, haddr_t*);
116  int (*cmp2)(void*, void*, void*); /*compare 2 keys */
117  int (*cmp3)(void*, void*, void*); /*compare 3 keys */
118  htri_t (*found)(H5F_t*, haddr_t, const void*, void*);
119 
120  /* insert new data */
121  H5B_ins_t (*insert)(H5F_t*, haddr_t, void*, hbool_t*, void*, void*,
122  void*, hbool_t*, haddr_t*);
123 
124  /* min insert uses min leaf, not new(), similarly for max insert */
127 
128  /* The direction of the key that is intrinsically associated with each node */
130 
131  /* remove existing data */
132  H5B_ins_t (*remove)(H5F_t*, haddr_t, void*, hbool_t*, void*, void*, hbool_t*);
133 
134  /* encode, decode, debug key values */
135  herr_t (*decode)(const H5B_shared_t*, const uint8_t*, void*);
136  herr_t (*encode)(const H5B_shared_t*, uint8_t*, const void*);
137  herr_t (*debug_key)(FILE*, int, int, const void*, const void*);
139 
140 /* Information about B-tree */
141 typedef struct H5B_info_t {
142  hsize_t size; /* Size of B-tree nodes */
143  hsize_t num_nodes; /* Number of B-tree nodes */
145 
146 
147 
148 /*****************************/
149 /* Library-private Variables */
150 /*****************************/
151 
152 
153 /***************************************/
154 /* Library-private Function Prototypes */
155 /***************************************/
156 H5_DLL herr_t H5B_create(H5F_t *f, const H5B_class_t *type, void *udata,
157  haddr_t *addr_p/*out*/);
158 H5_DLL herr_t H5B_find(H5F_t *f, const H5B_class_t *type, haddr_t addr,
159  void *udata);
160 H5_DLL herr_t H5B_insert(H5F_t *f, const H5B_class_t *type, haddr_t addr,
161  void *udata);
162 H5_DLL herr_t H5B_iterate(H5F_t *f, const H5B_class_t *type, haddr_t addr,
163  H5B_operator_t op, void *udata);
164 H5_DLL herr_t H5B_get_info(H5F_t *f, const H5B_class_t *type, haddr_t addr,
165  H5B_info_t *bt_info, H5B_operator_t op, void *udata);
166 H5_DLL herr_t H5B_remove(H5F_t *f, const H5B_class_t *type, haddr_t addr,
167  void *udata);
168 H5_DLL herr_t H5B_delete(H5F_t *f, const H5B_class_t *type, haddr_t addr,
169  void *udata);
170 H5_DLL H5B_shared_t *H5B_shared_new(const H5F_t *f, const H5B_class_t *type,
171  size_t sizeof_rkey);
172 H5_DLL herr_t H5B_shared_free(void *_shared);
173 H5_DLL herr_t H5B_debug(H5F_t *f, haddr_t addr, FILE * stream,
174  int indent, int fwidth, const H5B_class_t *type, void *udata);
175 H5_DLL htri_t H5B_valid(H5F_t *f, const H5B_class_t *type, haddr_t addr);
176 #endif /* _H5Bprivate_H */
177 
H5B_shared_t::two_k
unsigned two_k
Definition: H5Bprivate.h:92
H5B_shared_t::page
uint8_t * page
Definition: H5Bprivate.h:98
H5B_INS_REMOVE
@ H5B_INS_REMOVE
Definition: H5Bprivate.h:73
H5B_INS_FIRST
@ H5B_INS_FIRST
Definition: H5Bprivate.h:72
f
hdr f
Definition: H5EA.c:755
H5B_class_t::remove
H5B_ins_t(* remove)(H5F_t *, haddr_t, void *, hbool_t *, void *, void *, hbool_t *)
Definition: H5Bprivate.h:132
H5B_remove
H5_DLL herr_t H5B_remove(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata)
Definition: H5B.c:1568
H5B_subid_t
H5B_subid_t
Definition: H5Bprivate.h:59
H5B_class_t::critical_key
H5B_dir_t critical_key
Definition: H5Bprivate.h:129
haddr_t
CATCH haddr_t
Definition: H5EAdblock.c:162
indent
*s *s indent
Definition: H5HLdbg.c:111
H5B_CHUNK_ID
@ H5B_CHUNK_ID
Definition: H5Bprivate.h:61
H5B_find
H5_DLL herr_t H5B_find(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata)
Definition: H5B.c:300
H5B_shared_t
Definition: H5Bprivate.h:90
H5B_RIGHT
@ H5B_RIGHT
Definition: H5Bprivate.h:80
H5B_shared_t::sizeof_addr
size_t sizeof_addr
Definition: H5Bprivate.h:96
H5B_shared_t
struct H5B_shared_t H5B_shared_t
H5B_INS_NOOP
@ H5B_INS_NOOP
Definition: H5Bprivate.h:68
H5B_class_t::id
H5B_subid_t id
Definition: H5Bprivate.h:112
H5UCprivate.h
H5B_class_t::sizeof_nkey
size_t sizeof_nkey
Definition: H5Bprivate.h:113
H5B_class_t::new_node
herr_t(* new_node)(H5F_t *, H5B_ins_t, void *, void *, void *, haddr_t *)
Definition: H5Bprivate.h:115
uint8_t
unsigned char uint8_t
Definition: H5private.h:429
H5B_insert
H5_DLL herr_t H5B_insert(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata)
Definition: H5B.c:551
H5B_class_t
Definition: H5Bprivate.h:111
H5B_SNODE_ID
@ H5B_SNODE_ID
Definition: H5Bprivate.h:60
htri_t
int htri_t
Definition: H5public.h:160
H5B_class_t::cmp3
int(* cmp3)(void *, void *, void *)
Definition: H5Bprivate.h:117
H5B_class_t::insert
H5B_ins_t(* insert)(H5F_t *, haddr_t, void *, hbool_t *, void *, void *, void *, hbool_t *, haddr_t *)
Definition: H5Bprivate.h:121
H5B_class_t::follow_max
hbool_t follow_max
Definition: H5Bprivate.h:126
H5B_class_t::follow_min
hbool_t follow_min
Definition: H5Bprivate.h:125
H5B_operator_t
int(* H5B_operator_t)(H5F_t *f, const void *_lt_key, haddr_t addr, const void *_rt_key, void *_udata)
Definition: H5Bprivate.h:84
H5B_shared_t::type
const struct H5B_class_t * type
Definition: H5Bprivate.h:91
H5B_info_t::size
hsize_t size
Definition: H5Bprivate.h:142
H5UC_t
Definition: H5UCprivate.h:43
FILE
Invalid arguments to routine Resource unavailable Internal File accessibility Low level I O Function entry exit Object atom Object cache Links B Tree node Symbol table Heap Object header Datatype Dataspace Dataset Data storage Property lists Attribute Data filters External file list References Virtual File Layer Virtual Object Layer Ternary Search Trees Reference Counted Strings Error API Skip Lists Free Space Manager Shared Object Header Messages Extensible Array Fixed Array Plugin for dynamically loaded library Page Buffering API Context Map No error Argument errors Resource errors File accessibility errors FILE
Definition: H5err.txt:88
H5B_shared_new
H5_DLL H5B_shared_t * H5B_shared_new(const H5F_t *f, const H5B_class_t *type, size_t sizeof_rkey)
Definition: H5B.c:1688
H5B_shared_t::nkey
size_t * nkey
Definition: H5Bprivate.h:99
H5B_get_info
H5_DLL herr_t H5B_get_info(H5F_t *f, const H5B_class_t *type, haddr_t addr, H5B_info_t *bt_info, H5B_operator_t op, void *udata)
Definition: H5B.c:1967
int
CATCH int
Definition: H5EA.c:1002
H5Fprivate.h
H5B_ins_t
H5B_ins_t
Definition: H5Bprivate.h:66
fwidth
*s *s fwidth
Definition: H5HLdbg.c:111
H5B_shared_t::sizeof_keys
size_t sizeof_keys
Definition: H5Bprivate.h:95
H5B_INS_CHANGE
@ H5B_INS_CHANGE
Definition: H5Bprivate.h:71
H5B_shared_free
H5_DLL herr_t H5B_shared_free(void *_shared)
Definition: H5B.c:1760
H5B_class_t::decode
herr_t(* decode)(const H5B_shared_t *, const uint8_t *, void *)
Definition: H5Bprivate.h:135
H5B_info_t::num_nodes
hsize_t num_nodes
Definition: H5Bprivate.h:143
H5B_INS_RIGHT
@ H5B_INS_RIGHT
Definition: H5Bprivate.h:70
H5_DLL
#define H5_DLL
Definition: H5api_adpt.h:234
H5B_LEFT
@ H5B_LEFT
Definition: H5Bprivate.h:79
H5B_shared_t::udata
void * udata
Definition: H5Bprivate.h:100
H5B_info_t
Definition: H5Bprivate.h:141
H5B_iterate
H5_DLL herr_t H5B_iterate(H5F_t *f, const H5B_class_t *type, haddr_t addr, H5B_operator_t op, void *udata)
Definition: H5B.c:1194
H5B_debug
H5_DLL herr_t H5B_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, const H5B_class_t *type, void *udata)
Definition: H5Bdbg.c:56
H5B_class_t
struct H5B_class_t H5B_class_t
H5B_delete
H5_DLL herr_t H5B_delete(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata)
Definition: H5B.c:1612
H5B_INS_LEFT
@ H5B_INS_LEFT
Definition: H5Bprivate.h:69
H5F_t
Definition: H5Fpkg.h:374
H5B_valid
H5_DLL htri_t H5B_valid(H5F_t *f, const H5B_class_t *type, haddr_t addr)
Definition: H5B.c:2019
H5B_class_t::debug_key
herr_t(* debug_key)(FILE *, int, int, const void *, const void *)
Definition: H5Bprivate.h:137
H5B_shared_t::sizeof_rnode
size_t sizeof_rnode
Definition: H5Bprivate.h:94
H5B_shared_t::sizeof_rkey
size_t sizeof_rkey
Definition: H5Bprivate.h:93
herr_t
int herr_t
Definition: H5public.h:128
hbool_t
bool hbool_t
Definition: H5public.h:159
H5B_NUM_BTREE_ID
@ H5B_NUM_BTREE_ID
Definition: H5Bprivate.h:62
H5B_INS_ERROR
@ H5B_INS_ERROR
Definition: H5Bprivate.h:67
H5B_class_t::cmp2
int(* cmp2)(void *, void *, void *)
Definition: H5Bprivate.h:116
H5B_dir_t
H5B_dir_t
Definition: H5Bprivate.h:78
hsize_t
hsize_t
Definition: H5overflow.txt:44
H5B_info_t
struct H5B_info_t H5B_info_t
H5B_shared_t::sizeof_len
size_t sizeof_len
Definition: H5Bprivate.h:97
H5B_create
H5_DLL herr_t H5B_create(H5F_t *f, const H5B_class_t *type, void *udata, haddr_t *addr_p)
Definition: H5B.c:215
H5private.h
H5B_class_t::encode
herr_t(* encode)(const H5B_shared_t *, uint8_t *, const void *)
Definition: H5Bprivate.h:136
H5B_class_t::found
htri_t(* found)(H5F_t *, haddr_t, const void *, void *)
Definition: H5Bprivate.h:118