H5Bprivate.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:             H5Bprivate.h
00019  *                      Jul 10 1997
00020  *                      Robb Matzke <matzke@llnl.gov>
00021  *
00022  * Purpose:             Private non-prototype header.
00023  *
00024  * Modifications:
00025  *
00026  *-------------------------------------------------------------------------
00027  */
00028 
00029 #ifndef _H5Bprivate_H
00030 #define _H5Bprivate_H
00031 
00032 #include "H5Bpublic.h"          /*API prototypes                             */
00033 
00034 /* Private headers needed by this file */
00035 #include "H5private.h"          /* Generic Functions                    */
00036 #include "H5ACprivate.h"        /* Metadata cache                       */
00037 #include "H5Fprivate.h"         /* File access                          */
00038 #include "H5FLprivate.h"        /* Free Lists                           */
00039 #include "H5RCprivate.h"        /* Reference counted object functions   */
00040 
00041 /**************************/
00042 /* Library Private Macros */
00043 /**************************/
00044 
00045 /*
00046  * Feature: Define this constant if you want to check B-tree consistency
00047  *          after each B-tree operation.  Note that this slows down the
00048  *          library considerably! Debugging the B-tree depends on assert()
00049  *          being enabled.
00050  */
00051 #ifdef NDEBUG
00052 #  undef H5B_DEBUG
00053 #endif
00054 
00055 
00056 /****************************/
00057 /* Library Private Typedefs */
00058 /****************************/
00059 
00060 /* B-tree IDs for various internal things. */
00061 /* Note - if more of these are added, any 'K' values (for internal or leaf
00062  * nodes) they use will need to be stored in the file somewhere. -QAK
00063  */
00064 typedef enum H5B_subid_t {
00065     H5B_SNODE_ID         = 0,   /*B-tree is for symbol table nodes           */
00066     H5B_CHUNK_ID         = 1,   /*B-tree is for chunked dataset storage      */
00067     H5B_NUM_BTREE_ID            /* Number of B-tree key IDs (must be last)   */
00068 } H5B_subid_t;
00069 
00070 /* Define return values from B-tree insertion callbacks */
00071 typedef enum H5B_ins_t {
00072     H5B_INS_ERROR        = -1,  /*error return value                         */
00073     H5B_INS_NOOP         = 0,   /*insert made no changes                     */
00074     H5B_INS_LEFT         = 1,   /*insert new node to left of cur node        */
00075     H5B_INS_RIGHT        = 2,   /*insert new node to right of cur node       */
00076     H5B_INS_CHANGE       = 3,   /*change child address for cur node          */
00077     H5B_INS_FIRST        = 4,   /*insert first node in (sub)tree             */
00078     H5B_INS_REMOVE       = 5    /*remove current node                        */
00079 } H5B_ins_t;
00080 
00081 /* Define the operator callback function pointer for H5B_iterate() */
00082 typedef int (*H5B_operator_t)(H5F_t *f, hid_t dxpl_id, const void *_lt_key, haddr_t addr,
00083                                         const void *_rt_key, void *_udata);
00084 
00085 /* Typedef for B-tree in memory (defined in H5Bpkg.h) */
00086 typedef struct H5B_t H5B_t;
00087 
00088 /* Each B-tree has certain information that can be shared across all
00089  * the instances of nodes in that B-tree.
00090  */
00091 typedef struct H5B_shared_t {
00092     const struct H5B_class_t    *type;  /* Type of tree                      */
00093     unsigned            two_k;          /* 2*"K" value for tree's nodes      */
00094     size_t              sizeof_rkey;    /* Size of raw (disk) key            */
00095     size_t              sizeof_rnode;   /* Size of raw (disk) node           */
00096     size_t              sizeof_keys;    /* Size of native (memory) key node  */
00097     uint8_t             *page;          /* Disk page */
00098     size_t              *nkey;          /* Offsets of each native key in native key buffer */
00099 } H5B_shared_t;
00100 
00101 /*
00102  * Each class of object that can be pointed to by a B-link tree has a
00103  * variable of this type that contains class variables and methods.  Each
00104  * tree has a K (1/2 rank) value on a per-file basis.  The file_create_parms
00105  * has an array of K values indexed by the `id' class field below.  The
00106  * array is initialized with the HDF5_BTREE_K_DEFAULT macro.
00107  */
00108 
00109 typedef struct H5B_class_t {
00110     H5B_subid_t id;                                     /*id as found in file*/
00111     size_t      sizeof_nkey;                    /*size of native (memory) key*/
00112     H5RC_t *    (*get_shared)(const H5F_t*, const void*);    /*shared info for node */
00113     herr_t      (*new_node)(H5F_t*, hid_t, H5B_ins_t, void*, void*, void*, haddr_t*);
00114     int         (*cmp2)(H5F_t*, hid_t, void*, void*, void*);        /*compare 2 keys */
00115     int         (*cmp3)(H5F_t*, hid_t, void*, void*, void*);        /*compare 3 keys */
00116     htri_t      (*found)(H5F_t*, hid_t, haddr_t, const void*, void*);
00117 
00118     /* insert new data */
00119     H5B_ins_t   (*insert)(H5F_t*, hid_t, haddr_t, void*, hbool_t*, void*, void*,
00120                           void*, hbool_t*, haddr_t*);
00121 
00122     /* min insert uses min leaf, not new(), similarily for max insert */
00123     hbool_t     follow_min;
00124     hbool_t     follow_max;
00125 
00126     /* remove existing data */
00127     H5B_ins_t   (*remove)(H5F_t*, hid_t, haddr_t, void*, hbool_t*, void*, void*,
00128                           hbool_t*);
00129 
00130     /* encode, decode, debug key values */
00131     herr_t      (*decode)(const H5F_t*, const struct H5B_t*, const uint8_t*, void*);
00132     herr_t      (*encode)(const H5F_t*, const struct H5B_t*, uint8_t*, void*);
00133     herr_t      (*debug_key)(FILE*, H5F_t*, hid_t, int, int, const void*, const void*);
00134 } H5B_class_t;
00135 
00136 /* Information about B-tree */
00137 typedef struct H5B_info_t {
00138     hsize_t     size;           /* Size of B-tree nodes */
00139     hsize_t     num_nodes;      /* Number of B-tree nodes */
00140 } H5B_info_t;
00141 
00142 
00143 
00144 /*****************************/
00145 /* Library-private Variables */
00146 /*****************************/
00147 
00148 
00149 /***************************************/
00150 /* Library-private Function Prototypes */
00151 /***************************************/
00152 H5_DLL herr_t H5B_create(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type,
00153     void *udata, haddr_t *addr_p/*out*/);
00154 H5_DLL herr_t H5B_find(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type,
00155     haddr_t addr, void *udata);
00156 H5_DLL herr_t H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type,
00157     haddr_t addr, void *udata);
00158 H5_DLL herr_t H5B_iterate(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type,
00159     haddr_t addr, H5B_operator_t op, void *udata);
00160 H5_DLL herr_t H5B_get_info(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type,
00161     haddr_t addr, H5B_info_t *bt_info, H5B_operator_t op, void *udata);
00162 H5_DLL herr_t H5B_remove(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type,
00163     haddr_t addr, void *udata);
00164 H5_DLL herr_t H5B_delete(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type,
00165     haddr_t addr, void *udata);
00166 H5_DLL H5B_shared_t *H5B_shared_new(const H5F_t *f, const H5B_class_t *type,
00167     size_t sizeof_rkey);
00168 H5_DLL herr_t H5B_shared_free(void *_shared);
00169 H5_DLL herr_t H5B_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream,
00170     int indent, int fwidth, const H5B_class_t *type, void *udata);
00171 H5_DLL htri_t H5B_valid(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type,
00172     haddr_t addr);
00173 #endif /* _H5Bprivate_H */
00174