H5B2private.h

00001 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00002  * Copyright by The HDF Group.                                               *
00003  * Copyright by the Board of Trustees of the University of Illinois.         *
00004  * All rights reserved.                                                      *
00005  *                                                                           *
00006  * This file is part of HDF5.  The full HDF5 copyright notice, including     *
00007  * terms governing use, modification, and redistribution, is contained in    *
00008  * the files COPYING and Copyright.html.  COPYING can be found at the root   *
00009  * of the source code distribution tree; Copyright.html can be found at the  *
00010  * root level of an installed copy of the electronic HDF5 document set and   *
00011  * is linked from the top-level documents page.  It can also be found at     *
00012  * http://hdfgroup.org/HDF5/doc/Copyright.html.  If you do not have          *
00013  * access to either file, you may request a copy from help@hdfgroup.org.     *
00014  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00015 
00016 /*-------------------------------------------------------------------------
00017  *
00018  * Created:             H5B2private.h
00019  *                      Jan 31 2005
00020  *                      Quincey Koziol <koziol@ncsa.uiuc.edu>
00021  *
00022  * Purpose:             Private header for library accessible B-tree routines.
00023  *
00024  *-------------------------------------------------------------------------
00025  */
00026 
00027 #ifndef _H5B2private_H
00028 #define _H5B2private_H
00029 
00030 /* Include package's public header */
00031 #include "H5B2public.h"
00032 
00033 /* Private headers needed by this file */
00034 #include "H5Fprivate.h"         /* File access                          */
00035 
00036 /**************************/
00037 /* Library Private Macros */
00038 /**************************/
00039 
00040 
00041 /****************************/
00042 /* Library Private Typedefs */
00043 /****************************/
00044 
00045 /* B-tree IDs for various internal things. */
00046 typedef enum H5B2_subid_t {
00047     H5B2_TEST_ID         = 0,   /* B-tree is for testing (do not use for actual data) */
00048     H5B2_FHEAP_HUGE_INDIR_ID,   /* B-tree is for fractal heap indirectly accessed, non-filtered 'huge' objects */
00049     H5B2_FHEAP_HUGE_FILT_INDIR_ID, /* B-tree is for fractal heap indirectly accessed, filtered 'huge' objects */
00050     H5B2_FHEAP_HUGE_DIR_ID,     /* B-tree is for fractal heap directly accessed, non-filtered 'huge' objects */
00051     H5B2_FHEAP_HUGE_FILT_DIR_ID, /* B-tree is for fractal heap directly accessed, filtered 'huge' objects */
00052     H5B2_GRP_DENSE_NAME_ID,     /* B-tree is for indexing 'name' field for "dense" link storage in groups */
00053     H5B2_GRP_DENSE_CORDER_ID,   /* B-tree is for indexing 'creation order' field for "dense" link storage in groups */
00054     H5B2_SOHM_INDEX_ID,         /* B-tree is an index for shared object header messages */
00055     H5B2_ATTR_DENSE_NAME_ID,    /* B-tree is for indexing 'name' field for "dense" attribute storage on objects */
00056     H5B2_ATTR_DENSE_CORDER_ID,  /* B-tree is for indexing 'creation order' field for "dense" attribute storage on objects */
00057     H5B2_NUM_BTREE_ID           /* Number of B-tree IDs (must be last)  */
00058 } H5B2_subid_t;
00059 
00060 /* Define the operator callback function pointer for H5B2_iterate() */
00061 typedef int (*H5B2_operator_t)(const void *record, void *op_data);
00062 
00063 /* Define the 'found' callback function pointer for H5B2_find(), H5B2_neighbor() & H5B2_index() */
00064 typedef herr_t (*H5B2_found_t)(const void *record, void *op_data);
00065 
00066 /* Define the 'modify' callback function pointer for H5B2_modify() */
00067 typedef herr_t (*H5B2_modify_t)(void *record, void *op_data, hbool_t *changed);
00068 
00069 /* Define the 'remove' callback function pointer for H5B2_remove() & H5B2_delete() */
00070 typedef herr_t (*H5B2_remove_t)(const void *record, void *op_data);
00071 
00072 /* Comparisons for H5B2_neighbor() call */
00073 typedef enum H5B2_compare_t {
00074     H5B2_COMPARE_LESS,            /* Records with keys less than query value */
00075     H5B2_COMPARE_GREATER          /* Records with keys greater than query value */
00076 } H5B2_compare_t;
00077 
00078 /*
00079  * Each class of object that can be pointed to by a B-tree has a
00080  * variable of this type that contains class variables and methods.
00081  */
00082 typedef struct H5B2_class_t H5B2_class_t;
00083 struct H5B2_class_t {
00084     H5B2_subid_t id;            /* ID of B-tree class, as found in file */
00085     const char *name;           /* Name of B-tree class, for debugging */
00086     size_t nrec_size;           /* Size of native (memory) record */
00087 
00088     /* Extensible array client callback methods */
00089     void *(*crt_context)(void *udata);          /* Create context for other client callbacks */
00090     herr_t (*dst_context)(void *ctx);           /* Destroy client callback context */
00091     herr_t (*store)(void *nrecord, const void *udata);              /*  Store application record in native record table */
00092     herr_t (*compare)(const void *rec1, const void *rec2);          /*  Compare two native records */
00093     herr_t (*encode)(uint8_t *raw, const void *record, void *ctx);  /*  Encode record from native form to disk storage form */
00094     herr_t (*decode)(const uint8_t *raw, void *record, void *ctx);  /*  Decode record from disk storage form to native form */
00095     herr_t (*debug)(FILE *stream, const H5F_t *f, hid_t dxpl_id,    /* Print a record for debugging */
00096         int indent, int fwidth, const void *record, const void *udata);
00097     void *(*crt_dbg_ctx)(H5F_t *f, hid_t dxpl_id, haddr_t obj_addr); /* Create debugging context */
00098     herr_t (*dst_dbg_ctx)(void *dbg_ctx);       /* Destroy debugging context */
00099 };
00100 
00101 /* v2 B-tree creation parameters */
00102 typedef struct H5B2_create_t {
00103     const H5B2_class_t *cls;            /* v2 B-tree client class */
00104     uint32_t node_size;                 /* Size of each node (in bytes) */
00105     uint32_t rrec_size;                 /* Size of raw record (in bytes) */
00106     uint8_t split_percent;              /* % full to split nodes */
00107     uint8_t merge_percent;              /* % full to merge nodes */
00108 } H5B2_create_t;
00109 
00110 /* v2 B-tree metadata statistics info */
00111 typedef struct H5B2_stat_t {
00112     unsigned depth;             /* Depth of B-tree */
00113     hsize_t nrecords;          /* Number of records */
00114 } H5B2_stat_t;
00115 
00116 /* v2 B-tree info (forward decl - defined in H5B2pkg.h) */
00117 typedef struct H5B2_t H5B2_t;
00118 
00119 
00120 /*****************************/
00121 /* Library-private Variables */
00122 /*****************************/
00123 
00124 
00125 /***************************************/
00126 /* Library-private Function Prototypes */
00127 /***************************************/
00128 H5_DLL H5B2_t *H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam,
00129     void *ctx_udata);
00130 H5_DLL H5B2_t *H5B2_open(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *ctx_udata);
00131 H5_DLL herr_t H5B2_get_addr(const H5B2_t *bt2, haddr_t *addr/*out*/);
00132 H5_DLL herr_t H5B2_insert(H5B2_t *bt2, hid_t dxpl_id, void *udata);
00133 H5_DLL herr_t H5B2_iterate(H5B2_t *bt2, hid_t dxpl_id, H5B2_operator_t op,
00134     void *op_data);
00135 H5_DLL htri_t H5B2_find(H5B2_t *bt2, hid_t dxpl_id, void *udata,
00136     H5B2_found_t op, void *op_data);
00137 H5_DLL herr_t H5B2_index(H5B2_t *bt2, hid_t dxpl_id, H5_iter_order_t order,
00138     hsize_t idx, H5B2_found_t op, void *op_data);
00139 H5_DLL herr_t H5B2_neighbor(H5B2_t *bt2, hid_t dxpl_id, H5B2_compare_t range,
00140     void *udata, H5B2_found_t op, void *op_data);
00141 H5_DLL herr_t H5B2_modify(H5B2_t *bt2, hid_t dxpl_id, void *udata,
00142     H5B2_modify_t op, void *op_data);
00143 H5_DLL herr_t H5B2_remove(H5B2_t *b2, hid_t dxpl_id, void *udata,
00144     H5B2_remove_t op, void *op_data);
00145 H5_DLL herr_t H5B2_remove_by_idx(H5B2_t *bt2, hid_t dxpl_id,
00146     H5_iter_order_t order, hsize_t idx, H5B2_remove_t op, void *op_data);
00147 H5_DLL herr_t H5B2_get_nrec(const H5B2_t *bt2, hsize_t *nrec);
00148 H5_DLL herr_t H5B2_size(H5B2_t *bt2, hid_t dxpl_id,
00149     hsize_t *btree_size);
00150 H5_DLL herr_t H5B2_close(H5B2_t *bt2, hid_t dxpl_id);
00151 H5_DLL herr_t H5B2_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr,
00152     void *ctx_udata, H5B2_remove_t op, void *op_data);
00153 
00154 /* Statistics routines */
00155 H5_DLL herr_t H5B2_stat_info(H5B2_t *bt2, H5B2_stat_t *info);
00156 
00157 #endif /* _H5B2private_H */
00158