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:     H5EAprivate.h
17  *              Jun 17 2008
18  *              Quincey Koziol <koziol@hdfgroup.org>
19  *
20  * Purpose:     Private header for library accessible extensible
21  *              array routines.
22  *
23  *-------------------------------------------------------------------------
24  */
25 
26 #ifndef _H5EAprivate_H
27 #define _H5EAprivate_H
28 
29 /* Include package's public header */
30 #ifdef NOT_YET
31 #include "H5EApublic.h"
32 #endif /* NOT_YET */
33 
34 /* Private headers needed by this file */
35 #include "H5ACprivate.h"        /* Metadata cache               */
36 #include "H5Fprivate.h"         /* File access                  */
37 
38 
39 /**************************/
40 /* Library Private Macros */
41 /**************************/
42 
43 
44 /****************************/
45 /* Library Private Typedefs */
46 /****************************/
47 
48 /* Extensible array class IDs */
49 typedef enum H5EA_cls_id_t {
50     H5EA_CLS_CHUNK_ID = 0,      /* Extensible array is for indexing dataset chunks w/o filters */
51     H5EA_CLS_FILT_CHUNK_ID,     /* Extensible array is for indexing dataset chunks w/filters */
52 
53     /* Start real class IDs at 0 -QAK */
54     /* (keep these last) */
55     H5EA_CLS_TEST_ID,           /* Extensible array is for testing (do not use for actual data) */
56     H5EA_NUM_CLS_ID             /* Number of Extensible Array class IDs (must be last) */
57 } H5EA_cls_id_t;
58 
59 /*
60  * Each type of element that can be stored in an extesible array has a
61  * variable of this type that contains class variables and methods.
62  */
63 typedef struct H5EA_class_t {
64     H5EA_cls_id_t id;           /* ID of Extensible Array class, as found in file */
65     const char *name;           /* Name of class (for debugging) */
66     size_t nat_elmt_size;       /* Size of native (memory) element */
67 
68     /* Extensible array client callback methods */
69     void *(*crt_context)(void *udata);          /* Create context for other callbacks */
70     herr_t (*dst_context)(void *ctx);           /* Destroy context */
71     herr_t (*fill)(void *nat_blk, size_t nelmts);    /* Fill array of elements with encoded form of "missing element" value */
72     herr_t (*encode)(void *raw, const void *elmt, size_t nelmts, void *ctx);   /* Encode elements from native form to disk storage form */
73     herr_t (*decode)(const void *raw, void *elmt, size_t nelmts, void *ctx);   /* Decode elements from disk storage form to native form */
74     herr_t (*debug)(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt); /* Print an element for debugging */
75     void *(*crt_dbg_ctx)(H5F_t *f, haddr_t obj_addr); /* Create debugging context */
76     herr_t (*dst_dbg_ctx)(void *dbg_ctx);       /* Destroy debugging context */
77 } H5EA_class_t;
78 
79 /* Extensible array creation parameters */
80 typedef struct H5EA_create_t {
81     const H5EA_class_t *cls;            /* Class of extensible array to create */
82     uint8_t raw_elmt_size;              /* Element size in file (in bytes) */
83     uint8_t max_nelmts_bits;            /* Log2(Max. # of elements in array) - i.e. # of bits needed to store max. # of elements */
84     uint8_t idx_blk_elmts;              /* # of elements to store in index block */
85     uint8_t data_blk_min_elmts;         /* Min. # of elements per data block */
86     uint8_t sup_blk_min_data_ptrs;      /* Min. # of data block pointers for a super block */
87     uint8_t max_dblk_page_nelmts_bits;       /* Log2(Max. # of elements in data block page) - i.e. # of bits needed to store max. # of elements in data block page */
88 } H5EA_create_t;
89 
90 /* Extensible array metadata statistics info */
91 /* (If these are ever exposed to applications, don't let the application see
92  *      which fields are computed vs. which fields are stored. -QAK)
93  */
94 typedef struct H5EA_stat_t {
95     /* Non-stored (i.e. computed) fields */
96     struct {
97         hsize_t hdr_size;           /* Size of header */
98         hsize_t nindex_blks;        /* # of index blocks (should be 0 or 1) */
99         hsize_t index_blk_size;     /* Size of index blocks allocated */
100     } computed;
101 
102     /* Stored fields */
103     struct {
104         hsize_t nsuper_blks;        /* # of super blocks */
105         hsize_t super_blk_size;     /* Size of super blocks allocated */
106         hsize_t ndata_blks;         /* # of data blocks */
107         hsize_t data_blk_size;      /* Size of data blocks allocated */
108         hsize_t max_idx_set;        /* Highest element index stored (+1 - i.e. if element 0 has been set, this value with be '1', if no elements have been stored, this value will be '0') */
109         hsize_t nelmts;             /* # of elements "realized" */
110     } stored;
111 } H5EA_stat_t;
112 
113 /* Extensible array info (forward decl - defined in H5EApkg.h) */
114 typedef struct H5EA_t H5EA_t;
115 
116 /* Define the operator callback function pointer for H5EA_iterate() */
117 typedef int (*H5EA_operator_t)(hsize_t idx, const void *_elmt, void *_udata);
118 
119 
120 /*****************************/
121 /* Library-private Variables */
122 /*****************************/
123 
124 /* The Extensible Array class for dataset chunks w/o filters*/
125 H5_DLLVAR const H5EA_class_t H5EA_CLS_CHUNK[1];
126 
127 /* The Extensible Array class for dataset chunks w/ filters*/
128 H5_DLLVAR const H5EA_class_t H5EA_CLS_FILT_CHUNK[1];
129 
130 
131 /***************************************/
132 /* Library-private Function Prototypes */
133 /***************************************/
134 
135 /* General routines */
136 H5_DLL H5EA_t *H5EA_create(H5F_t *f, const H5EA_create_t *cparam,
137     void *ctx_udata);
138 H5_DLL H5EA_t *H5EA_open(H5F_t *f, haddr_t ea_addr, void *ctx_udata);
139 H5_DLL herr_t H5EA_get_nelmts(const H5EA_t *ea, hsize_t *nelmts);
140 H5_DLL herr_t H5EA_get_addr(const H5EA_t *ea, haddr_t *addr);
141 H5_DLL herr_t H5EA_set(const H5EA_t *ea, hsize_t idx, const void *elmt);
142 H5_DLL herr_t H5EA_get(const H5EA_t *ea, hsize_t idx, void *elmt);
143 H5_DLL herr_t H5EA_depend(H5EA_t *ea, H5AC_proxy_entry_t *parent);
144 H5_DLL herr_t H5EA_iterate(H5EA_t *fa, H5EA_operator_t op, void *udata);
145 H5_DLL herr_t H5EA_close(H5EA_t *ea);
146 H5_DLL herr_t H5EA_delete(H5F_t *f, haddr_t ea_addr, void *ctx_udata);
147 H5_DLL herr_t H5EA_patch_file(H5EA_t *fa, H5F_t *f);
148 
149 /* Statistics routines */
150 H5_DLL herr_t H5EA_get_stats(const H5EA_t *ea, H5EA_stat_t *stats);
151 
152 /* Debugging routines */
153 #ifdef H5EA_DEBUGGING
154 #endif /* H5EA_DEBUGGING */
155 
156 #endif /* _H5EAprivate_H */
157 
158