summaryrefslogtreecommitdiffstats
path: root/src/H5Oprivate.h
blob: dcddfa2adb6874619f1afa5a9079ce5b846bc7a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
/* * * * * * * * * * * * * * * * * * * * * * *fs * * * * * * * * * * * * * * * *
 * Copyright by the Board of Trustees of the University of Illinois.         *
 * All rights reserved.                                                      *
 *                                                                           *
 * This file is part of HDF5.  The full HDF5 copyright notice, including     *
 * terms governing use, modification, and redistribution, is contained in    *
 * the files COPYING and Copyright.html.  COPYING can be found at the root   *
 * of the source code distribution tree; Copyright.html can be found at the  *
 * root level of an installed copy of the electronic HDF5 document set and   *
 * is linked from the top-level documents page.  It can also be found at     *
 * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html.  If you do not have     *
 * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/*-------------------------------------------------------------------------
 *
 * Created:		H5Oprivate.h
 *			Aug  5 1997
 *			Robb Matzke <matzke@llnl.gov>
 *
 * Purpose:		Object header private include file.
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
#ifndef _H5Oprivate_H
#define _H5Oprivate_H

/* Include the public header file for this API */
#include "H5Opublic.h"          /* Object header functions              */

/* Public headers needed by this file */
#include "H5Dpublic.h"          /* Dataset functions                    */
#include "H5Lpublic.h"		/* Link functions                       */
#include "H5Spublic.h"		/* Dataspace functions			*/

/* Private headers needed by this file */
#include "H5Fprivate.h"		/* File access				*/
#include "H5SLprivate.h"	/* Skip lists				*/
#include "H5Tprivate.h"		/* Datatype functions			*/
#include "H5Zprivate.h"         /* I/O pipeline filters			*/

/* Forward references of package typedefs */
typedef struct H5O_msg_class_t H5O_msg_class_t;
typedef struct H5O_t H5O_t;

/* JAMES: should these be in H5SM_private?  or renamed? */
/* JAMES: causes errors encoding/decoding if this is wrong.  Can't be constant. */
#define H5SM_FHEAP_ID_LEN 6

/* JAMES: not great? */
typedef uint64_t H5SM_fheap_id_t;


/* JAMES for debugging */
#define PRINT_BUF(buf, size)                \
    if(1) { size_t x;               \
        for(x=0; x<size; ++x) {     \
            printf("%d ", *(((uint8_t *) buf) + x)); \
        } printf("\n"); }


/* Object header macros */
#define H5O_MESG_MAX_SIZE	65536	/*max obj header message size	     */
#define H5O_NEW_MESG	(-1)		/*new message			     */
#define H5O_ALL		(-1)		/* Operate on all messages of type   */
#define H5O_FIRST	(-2)		/* Operate on first message of type  */

/* Flags needed when encoding messages */
#define H5O_MSG_FLAG_CONSTANT	0x01u
#define H5O_MSG_FLAG_SHARED	0x02u
#define H5O_MSG_FLAG_SOHM	0x04u
#define H5O_MSG_FLAG_DONTSOHM	0x08u
#define H5O_MSG_FLAG_BITS	(H5O_MSG_FLAG_CONSTANT|H5O_MSG_FLAG_SHARED|H5O_MSG_FLAG_SOHM|H5O_MSG_FLAG_DONTSOHM)

/* Flags for updating messages */
#define H5O_UPDATE_TIME         0x01u
#define H5O_UPDATE_DATA_ONLY    0x02u

/* Hash value constants */
/* JAMES: undefined hash value may not be great */
#define H5O_HASH_SIZE 32
#define H5O_HASH_UNDEF ((uint32_t)FAIL)

/* ========= Object Creation properties ============ */
#define H5O_CRT_ATTR_MAX_COMPACT_NAME	"max compact attr"      /* Max. # of attributes to store compactly */
#define H5O_CRT_ATTR_MIN_DENSE_NAME	"min dense attr"	/* Min. # of attributes to store densely */

/* ========= Object Copy properties ============ */
#define H5O_CPY_OPTION_NAME 		"copy object"           /* Copy options */

/* The object location information for an object */
typedef struct H5O_loc_t {
    H5F_t       *file;          /* File that object header is located within */
    haddr_t     addr;           /* File address of object header */
    hbool_t     holding_file;   /* True if this object header has incremented
                                 * its file's count of open objects. */
} H5O_loc_t;

/* Settings/flags for copying an object */
typedef struct H5O_copy_t {
    hbool_t copy_shallow;               /* Flag to perform shallow hierarchy copy */
    hbool_t expand_soft_link;           /* Flag to expand soft links */
    hbool_t expand_ext_link;            /* Flag to expand external links */
    hbool_t expand_ref;                 /* Flag to expand object references */
    hbool_t copy_without_attr;          /* Flag to not copy attributes */
    hbool_t preserve_null;              /* Flag to not delete NULL messages */
    int curr_depth;                     /* Current depth in hierarchy copied */
    int max_depth;                      /* Maximum depth in hierarchy to copy */
    H5SL_t *map_list;                   /* Skip list to hold address mappings */
} H5O_copy_t;

/* Header message IDs */
#define H5O_NULL_ID	0x0000          /* Null Message.  */
#define H5O_SDSPACE_ID	0x0001          /* Simple Dataspace Message.  */
#define H5O_LINFO_ID    0x0002          /* Link Info Message. */
#define H5O_DTYPE_ID	0x0003          /* Datatype Message.  */
#define H5O_FILL_ID     0x0004          /* Fill Value Message. (Old)  */
#define H5O_FILL_NEW_ID 0x0005          /* Fill Value Message. (New)  */
#define H5O_LINK_ID     0x0006          /* Link Message. */
#define H5O_EFL_ID	0x0007          /* External File List Message  */
#define H5O_LAYOUT_ID	0x0008          /* Data Storage Layout Message.  */
#define H5O_BOGUS_ID	0x0009          /* "Bogus" Message.  */
#define H5O_GINFO_ID	0x000a          /* Group Info Message.  */
#define H5O_PLINE_ID	0x000b          /* Filter pipeline message.  */
#define H5O_ATTR_ID	0x000c          /* Attribute Message.  */
#define H5O_NAME_ID	0x000d          /* Object name message.  */
#define H5O_MTIME_ID	0x000e          /* Modification time message. (Old)  */
#define H5O_SHARED_ID	0x000f          /* Shared object message.  */
#define H5O_CONT_ID	0x0010          /* Object header continuation message.  */
#define H5O_STAB_ID	0x0011          /* Symbol table message.  */
#define H5O_MTIME_NEW_ID 0x0012         /* Modification time message. (New)  */


/* Shared object message flags.
 * Shared objects can be committed, in which case the shared message contains
 * the location of the object header that holds the message, or shared in the
 * heap, in which case the shared message holds their heap ID.
 */
#define H5O_NOT_SHARED 0
#define H5O_SHARED_IN_HEAP_FLAG 0x01
#define H5O_COMMITTED_FLAG 0x02

/*
 * Shared object message.
 * This needs to go first because other messages can be shared and
 * include a H5O_shared_t struct
 */
typedef struct H5O_shared_t {
    unsigned flags;             /* flags describing how message is shared */
    union {
        H5O_loc_t	oloc;		/*object location info		     */
        H5SM_fheap_id_t heap_id;        /* ID within the SOHM heap           */
    } u;
    /* JAMES: add hash value? */
} H5O_shared_t;


/*
 * Link Info Message.
 * (Contains dynamic information about links in a group)
 * (Data structure in memory)
 * (if the fields in this struct are changed, remember to change the default
 *      link info structure in src/H5Gprivate.h - QAK)
 */
typedef struct H5O_linfo_t {
    /* (creation order info) */
    hbool_t     index_corder;           /* Are creation order values indexed on links? */
    int64_t     min_corder;             /* Current min. creation order value for group */
    int64_t     max_corder;             /* Current max. creation order value for group */
    haddr_t     corder_bt2_addr;        /* Address of v2 B-tree for indexing creation order values of links */

    /* (storage management info) */
    hsize_t     nlinks;                 /* Number of links in the group      */
    haddr_t     link_fheap_addr;        /* Address of fractal heap for storing "dense" links */
    haddr_t     name_bt2_addr;          /* Address of v2 B-tree for indexing names of links */
} H5O_linfo_t;

/*
 * Fill Value Message. (Old)
 * (Data structure in memory)
 */
typedef struct H5O_fill_t {
    H5T_t               *type;          /*type. Null implies same as dataset */
    size_t              size;           /*number of bytes in the fill value  */
    void                *buf;           /*the fill value                     */
} H5O_fill_t;

/*
 * New Fill Value Message.  The new fill value message is fill value plus
 * space allocation time, fill value writing time, whether fill
 * value is defined, and the location of the message if it's shared
 */

typedef struct H5O_fill_new_t {
    H5T_t		*type;		/*type. Null implies same as dataset */
    ssize_t		size;		/*number of bytes in the fill value  */
    void		*buf;		/*the fill value		     */
    H5D_alloc_time_t	alloc_time;	/* time to allocate space	     */
    H5D_fill_time_t	fill_time;	/* time to write fill value	     */
    hbool_t		fill_defined;   /* whether fill value is defined     */
    H5O_shared_t        sh_loc;         /*location of shared message         */
} H5O_fill_new_t;

/*
 * Link message.
 * (Data structure in memory)
 */
typedef struct H5O_link_hard_t {
    haddr_t	addr;			/* Object header address */
} H5O_link_hard_t;

typedef struct H5O_link_soft_t {
    char	*name;			/* Destination name */
} H5O_link_soft_t;

typedef struct H5O_link_ud_t {
    void	*udata;			/* Opaque data supplied by the user */
    size_t       size;                  /* Size of udata */
} H5O_link_ud_t;

typedef struct H5O_link_t {
    H5L_type_t  type;                   /* Type of link */
    hbool_t     corder_valid;           /* Creation order for link is valid (not stored) */
    int64_t     corder;                 /* Creation order for link (stored if it's valid) */
    H5T_cset_t  cset;                   /* Character set of link name	*/
    char	*name;			/* Link name */
    union {
        H5O_link_hard_t hard;           /* Information for hard links */
        H5O_link_soft_t soft;           /* Information for soft links */
        H5O_link_ud_t ud;               /* Information for user-defined links */
    } u;
} H5O_link_t;

/*
 * External File List Message
 * (Data structure in memory)
 */
#define H5O_EFL_ALLOC		16	/*number of slots to alloc at once   */
#define H5O_EFL_UNLIMITED	H5F_UNLIMITED /*max possible file size	     */

typedef struct H5O_efl_entry_t {
    size_t	name_offset;		/*offset of name within heap	     */
    char	*name;			/*malloc'd name			     */
    off_t	offset;			/*offset of data within file	     */
    hsize_t	size;			/*size allocated within file	     */
} H5O_efl_entry_t;

typedef struct H5O_efl_t {
    haddr_t	heap_addr;		/*address of name heap		     */
    size_t	nalloc;			/*number of slots allocated	     */
    size_t	nused;			/*number of slots used		     */
    H5O_efl_entry_t *slot;		/*array of external file entries     */
} H5O_efl_t;

/*
 * Data Layout Message.
 * (Data structure in memory)
 */
#define H5O_LAYOUT_NDIMS	(H5S_MAX_RANK+1)

typedef struct H5O_layout_contig_t {
    haddr_t	addr;			/* File address of data              */
    hsize_t     size;                   /* Size of data in bytes             */
} H5O_layout_contig_t;

typedef struct H5O_layout_chunk_t {
    haddr_t	addr;			/* File address of B-tree            */
    unsigned	ndims;			/* Num dimensions in chunk           */
    size_t	dim[H5O_LAYOUT_NDIMS];	/* Size of chunk in elements         */
    size_t      size;                   /* Size of chunk in bytes            */
    H5RC_t     *btree_shared;           /* Ref-counted info for B-tree nodes */
} H5O_layout_chunk_t;

typedef struct H5O_layout_compact_t {
    hbool_t     dirty;                  /* Dirty flag for compact dataset    */
    size_t      size;                   /* Size of buffer in bytes           */
    void        *buf;                   /* Buffer for compact dataset        */
} H5O_layout_compact_t;

typedef struct H5O_layout_t {
    H5D_layout_t type;			/* Type of layout                    */
    unsigned version;                   /* Version of message                */
    union {
        H5O_layout_contig_t contig;     /* Information for contiguous layout */
        H5O_layout_chunk_t chunk;       /* Information for chunked layout    */
        H5O_layout_compact_t compact;   /* Information for compact layout    */
    } u;
} H5O_layout_t;

/* Enable reading/writing "bogus" messages */
/* #define H5O_ENABLE_BOGUS */

#ifdef H5O_ENABLE_BOGUS
/*
 * "Bogus" Message.
 * (Data structure in memory)
 */
#define H5O_BOGUS_VALUE         0xdeadbeef
typedef struct H5O_bogus_t {
    unsigned u;                         /* Hold the bogus info */
} H5O_bogus_t;
#endif /* H5O_ENABLE_BOGUS */

/*
 * Group info message.
 * (Contains constant information about a group)
 * (Data structure in memory)
 * (if the fields in this struct are changed, remember to change the default
 *      group info structure in src/H5Gprivate.h - QAK)
 */
typedef struct H5O_ginfo_t {
    /* "Old" format group info (not stored) */
    uint32_t    lheap_size_hint;        /* Local heap size hint              */

    /* "New" format group info (stored) */
    /* (creation order info) */
    hbool_t     track_corder;           /* Are creation order values tracked on links? */

    /* (storage management info) */
    uint16_t	max_compact;		/* Maximum # of compact links        */
    uint16_t	min_dense;		/* Minimum # of "dense" links        */

    /* (initial object header size info) */
    uint16_t	est_num_entries;	/* Estimated # of entries in group   */
    uint16_t	est_name_len;		/* Estimated length of entry name    */
} H5O_ginfo_t;

/*
 * Filter pipeline message.
 * (Data structure in memory)
 */
typedef struct H5O_pline_t {
    size_t	nalloc;			/*num elements in `filter' array     */
    size_t	nused;			/*num filters defined		     */
    H5Z_filter_info_t *filter;		/*array of filters		     */
    H5O_shared_t        sh_loc;         /*location of shared message         */
} H5O_pline_t;

/*
 * Object name message.
 * (Data structure in memory)
 */

typedef struct H5O_name_t {
    char	*s;			/*ptr to malloc'd memory	     */
} H5O_name_t;

/*
 * Object header continuation message.
 * (Data structure in memory)
 */

typedef struct H5O_cont_t {
    haddr_t	addr;			/*address of continuation block	     */
    size_t	size;			/*size of continuation block	     */

    /* the following field(s) do not appear on disk */
    unsigned	chunkno;		/*chunk this mesg refers to	     */
} H5O_cont_t;

/*
 * Symbol table message.
 * (Data structure in memory)
 */
typedef struct H5O_stab_t {
    haddr_t	btree_addr;		/*address of B-tree		     */
    haddr_t	heap_addr;		/*address of name heap		     */
} H5O_stab_t;

/* Typedef for iteration operations */
typedef herr_t (*H5O_operator_t)(const void *mesg/*in*/, unsigned idx,
    void *operator_data/*in,out*/);

/* Forward declarations for prototype arguments */
struct H5P_genplist_t;
struct H5SL_t;
struct H5O_t;

/* General message operators */
H5_DLL herr_t H5O_init(void);
H5_DLL herr_t H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint,
    hid_t ocpl_id, H5O_loc_t *loc/*out*/);
H5_DLL herr_t H5O_open(const H5O_loc_t *loc);
H5_DLL herr_t H5O_close(H5O_loc_t *loc);
H5_DLL int H5O_link(const H5O_loc_t *loc, int adjust, hid_t dxpl_id);
H5_DLL int H5O_count(H5O_loc_t *loc, unsigned type_id, hid_t dxpl_id);
H5_DLL htri_t H5O_exists(H5O_loc_t *loc, unsigned type_id, int sequence,
    hid_t dxpl_id);
H5_DLL htri_t H5O_exists_oh(struct H5O_t *oh, unsigned type_id, int sequence);
H5_DLL void *H5O_read(const H5O_loc_t *loc, unsigned type_id, int sequence,
    void *mesg, hid_t dxpl_id);
H5_DLL int H5O_modify(H5O_loc_t *loc, unsigned type_id,
    int overwrite, unsigned flags, unsigned update_flags, void *mesg, hid_t dxpl_id);
H5_DLL struct H5O_t *H5O_protect(H5O_loc_t *loc, hid_t dxpl_id);
H5_DLL herr_t H5O_unprotect(H5O_loc_t *loc, struct H5O_t *oh, hid_t dxpl_id,
    unsigned oh_flags);
H5_DLL int H5O_append(H5F_t *f, hid_t dxpl_id, struct H5O_t *oh, unsigned type_id,
    unsigned flags, void *mesg, unsigned * oh_flags_ptr);
H5_DLL herr_t H5O_touch(H5O_loc_t *loc, hbool_t force, hid_t dxpl_id);
H5_DLL herr_t H5O_touch_oh(H5F_t *f, hid_t dxpl_id, struct H5O_t *oh,
    hbool_t force, unsigned *oh_flags_ptr);
#ifdef H5O_ENABLE_BOGUS
H5_DLL herr_t H5O_bogus(H5O_loc_t *loc, hid_t dxpl_id);
H5_DLL herr_t H5O_bogus_oh(H5F_t *f, hid_t dxpl_id, struct H5O_t *oh,
    unsigned * oh_flags_ptr);
#endif /* H5O_ENABLE_BOGUS */
H5_DLL herr_t H5O_remove(H5O_loc_t *loc, unsigned type_id, int sequence,
    hbool_t adj_link, hid_t dxpl_id);
H5_DLL herr_t H5O_remove_op(const H5O_loc_t *loc, unsigned type_id, int sequence,
    H5O_operator_t op, void *op_data, hbool_t adj_link, hid_t dxpl_id);
H5_DLL herr_t H5O_reset(unsigned type_id, void *native);
H5_DLL void *H5O_free(unsigned type_id, void *mesg);
H5_DLL herr_t H5O_encode(H5F_t *f, unsigned char *buf, const void *obj, unsigned type_id);
H5_DLL void* H5O_decode(H5F_t *f, hid_t dxpl_id, const unsigned char *buf,
    unsigned type_id);
H5_DLL void *H5O_copy(unsigned type_id, const void *mesg, void *dst);
H5_DLL size_t H5O_raw_size(unsigned type_id, const H5F_t *f, const void *mesg);
H5_DLL size_t H5O_mesg_size(unsigned type_id, const H5F_t *f, const void *mesg,
    size_t extra_raw);
H5_DLL herr_t H5O_get_share(unsigned type_id, H5F_t *f, const void *mesg, H5O_shared_t *share);
H5_DLL herr_t H5O_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr);
H5_DLL htri_t H5O_is_shared(unsigned type_id, const void *mesg);
H5_DLL herr_t H5O_set_share(H5F_t *f, H5O_shared_t *share, unsigned type_id,
    void *mesg);
H5_DLL herr_t H5O_reset_share(H5F_t *f, unsigned type_id, void *mesg);
H5_DLL herr_t H5O_get_info(H5O_loc_t *oloc, H5O_info_t *oinfo, hid_t dxpl_id);
H5_DLL herr_t H5O_iterate(const H5O_loc_t *loc, unsigned type_id, H5O_operator_t op,
    void *op_data, hid_t dxpl_id);
H5_DLL herr_t H5O_obj_type(const H5O_loc_t *loc, H5O_type_t *obj_type, hid_t dxpl_id);
H5_DLL uint32_t H5O_mesg_hash(unsigned type_id, H5F_t *f, const void *mesg);
H5_DLL herr_t H5O_get_create_plist(const H5O_loc_t *loc, hid_t dxpl_id, struct H5P_genplist_t *oc_plist);

/* Object copying routines */
H5_DLL herr_t H5O_copy_header_map(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
    hid_t dxpl_id, H5O_copy_t *cpy_info, hbool_t inc_depth);
H5_DLL herr_t H5O_copy_expand_ref(H5F_t *file_src, void *_src_ref, hid_t dxpl_id,
    H5F_t *file_dst, void *_dst_ref, size_t ref_count, H5R_type_t ref_type,
    H5O_copy_t *cpy_info);

/* Debugging routines */
H5_DLL herr_t H5O_debug_id(unsigned type_id, H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream, int indent, int fwidth);
H5_DLL herr_t H5O_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent,
			 int fwidth);

/*
 * These functions operate on object locations
 */
H5_DLL herr_t H5O_loc_reset(H5O_loc_t *loc);
H5_DLL herr_t H5O_loc_copy(H5O_loc_t *dst, const H5O_loc_t *src, H5_copy_depth_t depth);
H5_DLL herr_t H5O_loc_hold_file(H5O_loc_t *loc);
H5_DLL herr_t H5O_loc_free(H5O_loc_t *loc);

/* Layout operators */
H5_DLL size_t H5O_layout_meta_size(const H5F_t *f, const void *_mesg);

/* EFL operators */
H5_DLL hsize_t H5O_efl_total_size(H5O_efl_t *efl);

/* Fill value operators */
H5_DLL herr_t H5O_fill_convert(void *_fill, H5T_t *type, hid_t dxpl_id);

/* Link operators */
H5_DLL herr_t H5O_link_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link);

#endif /* _H5Oprivate_H */