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://www.hdfgroup.org/licenses. * 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: H5B2private.h 17 * Jan 31 2005 18 * Quincey Koziol 19 * 20 * Purpose: Private header for library accessible B-tree routines. 21 * 22 *------------------------------------------------------------------------- 23 */ 24 25 #ifndef H5B2private_H 26 #define H5B2private_H 27 28 /* Private headers needed by this file */ 29 #include "H5ACprivate.h" /* Metadata cache */ 30 #include "H5Fprivate.h" /* File access */ 31 32 /**************************/ 33 /* Library Private Macros */ 34 /**************************/ 35 36 /****************************/ 37 /* Library Private Typedefs */ 38 /****************************/ 39 40 /* B-tree IDs for various internal things. */ 41 typedef enum H5B2_subid_t { 42 H5B2_TEST_ID = 0, /* B-tree is for testing (do not use for actual data) */ 43 H5B2_FHEAP_HUGE_INDIR_ID, /* B-tree is for fractal heap indirectly accessed, non-filtered 'huge' objects 44 */ 45 H5B2_FHEAP_HUGE_FILT_INDIR_ID, /* B-tree is for fractal heap indirectly accessed, filtered 'huge' objects 46 */ 47 H5B2_FHEAP_HUGE_DIR_ID, /* B-tree is for fractal heap directly accessed, non-filtered 'huge' objects */ 48 H5B2_FHEAP_HUGE_FILT_DIR_ID, /* B-tree is for fractal heap directly accessed, filtered 'huge' objects */ 49 H5B2_GRP_DENSE_NAME_ID, /* B-tree is for indexing 'name' field for "dense" link storage in groups */ 50 H5B2_GRP_DENSE_CORDER_ID, /* B-tree is for indexing 'creation order' field for "dense" link storage in 51 groups */ 52 H5B2_SOHM_INDEX_ID, /* B-tree is an index for shared object header messages */ 53 H5B2_ATTR_DENSE_NAME_ID, /* B-tree is for indexing 'name' field for "dense" attribute storage on objects 54 */ 55 H5B2_ATTR_DENSE_CORDER_ID, /* B-tree is for indexing 'creation order' field for "dense" attribute storage 56 on objects */ 57 H5B2_CDSET_ID, /* B-tree is for non-filtered chunked dataset storage w/ >1 unlim dims */ 58 H5B2_CDSET_FILT_ID, /* B-tree is for filtered chunked dataset storage w/ >1 unlim dims */ 59 H5B2_TEST2_ID, /* Another B-tree is for testing (do not use for actual data) */ 60 H5B2_NUM_BTREE_ID /* Number of B-tree IDs (must be last) */ 61 } H5B2_subid_t; 62 63 /* Define the operator callback function pointer for H5B2_iterate() */ 64 typedef int (*H5B2_operator_t)(const void *record, void *op_data); 65 66 /* Define the 'found' callback function pointer for H5B2_find(), H5B2_neighbor() & H5B2_index() */ 67 typedef herr_t (*H5B2_found_t)(const void *record, void *op_data); 68 69 /* Define the 'modify' callback function pointer for H5B2_modify() */ 70 typedef herr_t (*H5B2_modify_t)(void *record, void *op_data, hbool_t *changed); 71 72 /* Define the 'remove' callback function pointer for H5B2_remove() & H5B2_delete() */ 73 typedef herr_t (*H5B2_remove_t)(const void *record, void *op_data); 74 75 /* Comparisons for H5B2_neighbor() call */ 76 typedef enum H5B2_compare_t { 77 H5B2_COMPARE_LESS, /* Records with keys less than query value */ 78 H5B2_COMPARE_GREATER /* Records with keys greater than query value */ 79 } H5B2_compare_t; 80 81 /* 82 * Each class of object that can be pointed to by a B-tree has a 83 * variable of this type that contains class variables and methods. 84 */ 85 typedef struct H5B2_class_t H5B2_class_t; 86 struct H5B2_class_t { 87 H5B2_subid_t id; /* ID of B-tree class, as found in file */ 88 const char * name; /* Name of B-tree class, for debugging */ 89 size_t nrec_size; /* Size of native (memory) record */ 90 91 /* Extensible array client callback methods */ 92 void *(*crt_context)(void *udata); /* Create context for other client callbacks */ 93 herr_t (*dst_context)(void *ctx); /* Destroy client callback context */ 94 herr_t (*store)(void *nrecord, const void *udata); /* Store application record in native record table */ 95 herr_t (*compare)(const void *rec1, const void *rec2, int *result); /* Compare two native records */ 96 herr_t (*encode)(uint8_t *raw, const void *record, 97 void *ctx); /* Encode record from native form to disk storage form */ 98 herr_t (*decode)(const uint8_t *raw, void *record, 99 void *ctx); /* Decode record from disk storage form to native form */ 100 herr_t (*debug)(FILE *stream, int indent, int fwidth, /* Print a record for debugging */ 101 const void *record, const void *ctx); 102 }; 103 104 /* v2 B-tree creation parameters */ 105 typedef struct H5B2_create_t { 106 const H5B2_class_t *cls; /* v2 B-tree client class */ 107 uint32_t node_size; /* Size of each node (in bytes) */ 108 uint32_t rrec_size; /* Size of raw record (in bytes) */ 109 uint8_t split_percent; /* % full to split nodes */ 110 uint8_t merge_percent; /* % full to merge nodes */ 111 } H5B2_create_t; 112 113 /* v2 B-tree metadata statistics info */ 114 typedef struct H5B2_stat_t { 115 unsigned depth; /* Depth of B-tree */ 116 hsize_t nrecords; /* Number of records */ 117 } H5B2_stat_t; 118 119 /* v2 B-tree info (forward decl - defined in H5B2pkg.h) */ 120 typedef struct H5B2_t H5B2_t; 121 122 /*****************************/ 123 /* Library-private Variables */ 124 /*****************************/ 125 126 /***************************************/ 127 /* Library-private Function Prototypes */ 128 /***************************************/ 129 H5_DLL H5B2_t *H5B2_create(H5F_t *f, const H5B2_create_t *cparam, void *ctx_udata); 130 H5_DLL H5B2_t *H5B2_open(H5F_t *f, haddr_t addr, void *ctx_udata); 131 H5_DLL herr_t H5B2_get_addr(const H5B2_t *bt2, haddr_t *addr /*out*/); 132 H5_DLL herr_t H5B2_insert(H5B2_t *bt2, void *udata); 133 H5_DLL herr_t H5B2_iterate(H5B2_t *bt2, H5B2_operator_t op, void *op_data); 134 H5_DLL htri_t H5B2_find(H5B2_t *bt2, void *udata, H5B2_found_t op, void *op_data); 135 H5_DLL herr_t H5B2_index(H5B2_t *bt2, H5_iter_order_t order, hsize_t idx, H5B2_found_t op, void *op_data); 136 H5_DLL herr_t H5B2_neighbor(H5B2_t *bt2, H5B2_compare_t range, void *udata, H5B2_found_t op, void *op_data); 137 H5_DLL herr_t H5B2_modify(H5B2_t *bt2, void *udata, H5B2_modify_t op, void *op_data); 138 H5_DLL herr_t H5B2_update(H5B2_t *bt2, void *udata, H5B2_modify_t op, void *op_data); 139 H5_DLL herr_t H5B2_remove(H5B2_t *b2, void *udata, H5B2_remove_t op, void *op_data); 140 H5_DLL herr_t H5B2_remove_by_idx(H5B2_t *bt2, H5_iter_order_t order, hsize_t idx, H5B2_remove_t op, 141 void *op_data); 142 H5_DLL herr_t H5B2_get_nrec(const H5B2_t *bt2, hsize_t *nrec); 143 H5_DLL herr_t H5B2_size(H5B2_t *bt2, hsize_t *btree_size); 144 H5_DLL herr_t H5B2_close(H5B2_t *bt2); 145 H5_DLL herr_t H5B2_delete(H5F_t *f, haddr_t addr, void *ctx_udata, H5B2_remove_t op, void *op_data); 146 H5_DLL herr_t H5B2_depend(H5B2_t *bt2, H5AC_proxy_entry_t *parent); 147 H5_DLL herr_t H5B2_patch_file(H5B2_t *fa, H5F_t *f); 148 149 /* Statistics routines */ 150 H5_DLL herr_t H5B2_stat_info(H5B2_t *bt2, H5B2_stat_t *info); 151 152 #endif /* H5B2private_H */ 153