summaryrefslogtreecommitdiffstats
path: root/src/H5HFpkg.h
blob: 57671c0364a740197d61df76dc12b6985491e59e (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
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * 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. *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/*
 * Programmer:	Quincey Koziol <koziol@ncsa.uiuc.edu>
 *		Friday, February 24, 2006
 *
 * Purpose:	This file contains declarations which are visible only within
 *		the H5HF package.  Source files outside the H5HF package should
 *		include H5HFprivate.h instead.
 */
#ifndef H5HF_PACKAGE
#error "Do not include this file outside the H5HF package!"
#endif

#ifndef _H5HFpkg_H
#define _H5HFpkg_H

/* Get package's private header */
#include "H5HFprivate.h"

/* Other private headers needed by this file */
#include "H5ACprivate.h"	/* Metadata cache			*/
#include "H5FLprivate.h"	/* Free Lists                           */
#include "H5RCprivate.h"	/* Reference counted object functions	*/

/**************************/
/* Package Private Macros */
/**************************/

/* Size of signature information (on disk) */
#define H5HF_SIZEOF_MAGIC               4

/* Fractal heap signatures */
#define H5HF_HDR_MAGIC                  "FRHP"          /* Header */

/* Size of the fractal heap header on disk */
#define H5HF_HEADER_SIZE(f)     (                                             \
    /* General metadata fields */                                             \
    4   /* Signature */                                                       \
    + 1 /* Version */                                                         \
    + 1 /* Metadata flags */                                                  \
    + 4 /* Metadata checksum */                                               \
                                                                              \
    /* Fractal heap header specific fields */                                 \
    + 1 /* Address mapping */                                                 \
    + 4 /* Min. size of standalone object */                                  \
    + 4 /* Length of fixed-size objects */                                    \
    )

/****************************/
/* Package Private Typedefs */
/****************************/

/* Doubling-table info */
typedef struct H5HF_dtable_param_t {
    /* Immutable, pre-set information for table */
    unsigned    width;          /* Number of columns in the table (must be power of 2) */
    hsize_t     start_block_size; /* Starting block size for table (must be power of 2) */
    hsize_t     max_direct_size; /* Maximum size of a direct block (must be power of 2) */
    hsize_t     max_index;      /* Maximum ID/offset for table (must be power of 2) */
    unsigned    start_root_rows;        /* Starting number of rows for root indirect block */
                                /* 0 indicates to create the full indirect block for the root,
                                 * right from the start.  Doesn't have to be power of 2
                                 */

    /* Derived information that varies during lifetime of table */
    haddr_t     table_addr;     /* Address of first block for table */
                                /* Undefined if no space allocated for table */
    unsigned    curr_root_rows; /* Current number of rows in the root indirect block */
                                /* 0 indicates that the TABLE_ADDR field points
                                 * to direct block (of START_BLOCK_SIZE) instead
                                 * of indirect root block.
                                 */
} H5HF_dtable_param_t;

/* Each fractal heap has certain information that can be shared across all
 * the instances of blocks in that fractal heap.
 */
typedef struct H5HF_shared_t {
    /* Shared internal information */
    hsize_t     next_man_block; /* Offset of next direct managed block */
    hsize_t     next_std_block; /* Offset of next direct standalone block */
    hsize_t     total_man_free; /* Total amount of free space in managed blocks */
    hsize_t     total_std_free; /* Total # of free standalone ID entries */

    /* Doubling table information */
    /* (Partially set by user, partially derived/updated internally) */
    H5HF_dtable_param_t man_dtable_info;        /* Doubling-table info for managed objects */
    H5HF_dtable_param_t std_dtable_info;        /* Doubling-table info for standalone objects */

    /* Information set by user */
    H5HF_addrmap_t addrmap;     /* Type of address mapping */
    uint32_t standalone_size;   /* Size of object to store standalone */
    uint32_t fixed_len_size;    /* Size of objects (only for heaps w/fixed-length objects) */

    /* Information derived from user parameters */
    hbool_t     fixed_len_obj;  /* Are objects in the heap fixed length? */
    hbool_t     ref_count_obj;  /* Are objects in the heap ref. counted? */
    hbool_t     have_io_filter; /* Does the heap have I/O filters for the direct blocks? */
    hbool_t     write_once;     /* Is heap being written in "write once" mode? */
} H5HF_shared_t;

/* The fractal heap information */
typedef struct H5HF_t {
    /* Information for H5AC cache functions, _must_ be first field in structure */
    H5AC_info_t cache_info;

    /* Internal fractal heap information */
    H5RC_t	*shared;	/* Ref-counted shared info	              */
} H5HF_t;


/*****************************/
/* Package Private Variables */
/*****************************/

/* H5HF header inherits cache-like properties from H5AC */
H5_DLLVAR const H5AC_class_t H5AC_FHEAP_HDR[1];

/* Declare a free list to manage the H5HF_t struct */
H5FL_EXTERN(H5HF_t);


/******************************/
/* Package Private Prototypes */
/******************************/

/* Routines for managing shared fractal heap info */
H5_DLL herr_t H5HF_shared_init(H5HF_t *fh, H5HF_create_t *cparam);

/* Routines for allocating space */
herr_t H5HF_man_alloc_end(H5HF_shared_t *shared, size_t size, const void *obj,
    void *id/*out*/);

/* Metadata cache callbacks */
H5_DLL herr_t H5HF_cache_hdr_dest(H5F_t *f, H5HF_t *b);

/* Debugging routines for dumping file structures */
H5_DLL herr_t H5HF_hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr,
    FILE *stream, int indent, int fwidth);

/* Testing routines */
#ifdef H5HF_TESTING
H5_DLL herr_t H5HF_get_cparam_test(H5F_t *f, hid_t dxpl_id, haddr_t fh_addr,
    H5HF_create_t *cparam);
#endif /* H5HF_TESTING */

#endif /* _H5HFpkg_H */