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