2003-02-25 04:13:07 +08:00
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
2007-02-07 22:56:24 +08:00
|
|
|
* Copyright by The HDF Group. *
|
2003-02-25 04:13:07 +08:00
|
|
|
* 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 *
|
2007-02-07 22:56:24 +08:00
|
|
|
* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
|
|
|
|
* access to either file, you may request a copy from help@hdfgroup.org. *
|
2003-02-25 04:13:07 +08:00
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
1997-07-31 05:17:56 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1998-09-22 23:27:26 +08:00
|
|
|
* Created: H5Bprivate.h
|
|
|
|
* Jul 10 1997
|
|
|
|
* Robb Matzke <matzke@llnl.gov>
|
1997-07-31 05:17:56 +08:00
|
|
|
*
|
1998-09-22 23:27:26 +08:00
|
|
|
* Purpose: Private non-prototype header.
|
1997-07-31 05:17:56 +08:00
|
|
|
*
|
1998-01-23 00:41:32 +08:00
|
|
|
* Modifications:
|
1997-07-31 05:17:56 +08:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2003-02-25 04:13:07 +08:00
|
|
|
|
1997-07-31 05:17:56 +08:00
|
|
|
#ifndef _H5Bprivate_H
|
|
|
|
#define _H5Bprivate_H
|
1998-01-23 00:41:32 +08:00
|
|
|
|
2001-04-06 01:29:14 +08:00
|
|
|
#include "H5Bpublic.h" /*API prototypes */
|
1997-07-31 05:17:56 +08:00
|
|
|
|
1997-08-16 00:51:34 +08:00
|
|
|
/* Private headers needed by this file */
|
2003-05-16 03:22:33 +08:00
|
|
|
#include "H5private.h" /* Generic Functions */
|
|
|
|
#include "H5ACprivate.h" /* Metadata cache */
|
|
|
|
#include "H5Fprivate.h" /* File access */
|
2005-11-07 11:13:53 +08:00
|
|
|
#include "H5FLprivate.h" /* Free Lists */
|
2004-07-10 10:28:06 +08:00
|
|
|
#include "H5RCprivate.h" /* Reference counted object functions */
|
1997-07-31 05:17:56 +08:00
|
|
|
|
2005-11-07 11:13:53 +08:00
|
|
|
/**************************/
|
|
|
|
/* Library Private Macros */
|
|
|
|
/**************************/
|
|
|
|
|
1997-11-14 22:42:14 +08:00
|
|
|
/*
|
|
|
|
* Feature: Define this constant if you want to check B-tree consistency
|
1998-09-22 23:27:26 +08:00
|
|
|
* after each B-tree operation. Note that this slows down the
|
|
|
|
* library considerably! Debugging the B-tree depends on assert()
|
|
|
|
* being enabled.
|
1997-11-14 22:42:14 +08:00
|
|
|
*/
|
|
|
|
#ifdef NDEBUG
|
|
|
|
# undef H5B_DEBUG
|
|
|
|
#endif
|
1998-09-22 23:27:26 +08:00
|
|
|
#define H5B_MAGIC "TREE" /*tree node magic number */
|
|
|
|
#define H5B_SIZEOF_MAGIC 4 /*size of magic number */
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2005-11-07 11:13:53 +08:00
|
|
|
/****************************/
|
|
|
|
/* Library Private Typedefs */
|
|
|
|
/****************************/
|
|
|
|
|
|
|
|
/* Define return values from B-tree insertion callbacks */
|
1997-10-21 07:14:35 +08:00
|
|
|
typedef enum H5B_ins_t {
|
1998-09-22 23:27:26 +08:00
|
|
|
H5B_INS_ERROR = -1, /*error return value */
|
|
|
|
H5B_INS_NOOP = 0, /*insert made no changes */
|
|
|
|
H5B_INS_LEFT = 1, /*insert new node to left of cur node */
|
|
|
|
H5B_INS_RIGHT = 2, /*insert new node to right of cur node */
|
|
|
|
H5B_INS_CHANGE = 3, /*change child address for cur node */
|
|
|
|
H5B_INS_FIRST = 4, /*insert first node in (sub)tree */
|
|
|
|
H5B_INS_REMOVE = 5 /*remove current node */
|
1997-10-21 07:14:35 +08:00
|
|
|
} H5B_ins_t;
|
1997-08-05 00:19:57 +08:00
|
|
|
|
2002-04-24 00:01:43 +08:00
|
|
|
/* Define the operator callback function pointer for H5B_iterate() */
|
2004-12-29 22:26:20 +08:00
|
|
|
typedef int (*H5B_operator_t)(H5F_t *f, hid_t dxpl_id, const void *_lt_key, haddr_t addr,
|
|
|
|
const void *_rt_key, void *_udata);
|
2002-04-24 00:01:43 +08:00
|
|
|
|
2003-05-16 03:22:33 +08:00
|
|
|
/* Typedef for B-tree in memory (defined in H5Bpkg.h) */
|
|
|
|
typedef struct H5B_t H5B_t;
|
|
|
|
|
2004-07-10 10:28:06 +08:00
|
|
|
/* Each B-tree has certain information that can be shared across all
|
|
|
|
* the instances of nodes in that B-tree.
|
|
|
|
*/
|
|
|
|
typedef struct H5B_shared_t {
|
|
|
|
const struct H5B_class_t *type; /* Type of tree */
|
2004-07-14 01:44:01 +08:00
|
|
|
unsigned two_k; /* 2*"K" value for tree's nodes */
|
2004-07-10 10:28:06 +08:00
|
|
|
size_t sizeof_rkey; /* Size of raw (disk) key */
|
|
|
|
size_t sizeof_rnode; /* Size of raw (disk) node */
|
|
|
|
size_t sizeof_keys; /* Size of native (memory) key node */
|
|
|
|
uint8_t *page; /* Disk page */
|
|
|
|
size_t *nkey; /* Offsets of each native key in native key buffer */
|
|
|
|
} H5B_shared_t;
|
|
|
|
|
1997-07-31 05:17:56 +08:00
|
|
|
/*
|
|
|
|
* Each class of object that can be pointed to by a B-link tree has a
|
1997-08-13 23:36:47 +08:00
|
|
|
* variable of this type that contains class variables and methods. Each
|
|
|
|
* tree has a K (1/2 rank) value on a per-file basis. The file_create_parms
|
|
|
|
* has an array of K values indexed by the `id' class field below. The
|
|
|
|
* array is initialized with the HDF5_BTREE_K_DEFAULT macro.
|
1997-07-31 05:17:56 +08:00
|
|
|
*/
|
1998-01-23 00:41:32 +08:00
|
|
|
|
1997-07-31 05:17:56 +08:00
|
|
|
typedef struct H5B_class_t {
|
1998-09-22 23:27:26 +08:00
|
|
|
H5B_subid_t id; /*id as found in file*/
|
|
|
|
size_t sizeof_nkey; /*size of native (memory) key*/
|
2004-12-29 22:26:20 +08:00
|
|
|
H5RC_t * (*get_shared)(const H5F_t*, const void*); /*shared info for node */
|
2003-02-11 01:26:09 +08:00
|
|
|
herr_t (*new_node)(H5F_t*, hid_t, H5B_ins_t, void*, void*, void*, haddr_t*);
|
|
|
|
int (*cmp2)(H5F_t*, hid_t, void*, void*, void*); /*compare 2 keys */
|
|
|
|
int (*cmp3)(H5F_t*, hid_t, void*, void*, void*); /*compare 3 keys */
|
2004-12-29 22:26:20 +08:00
|
|
|
herr_t (*found)(H5F_t*, hid_t, haddr_t, const void*, void*);
|
2005-08-14 04:53:35 +08:00
|
|
|
|
1998-09-22 23:27:26 +08:00
|
|
|
/* insert new data */
|
2003-02-11 01:26:09 +08:00
|
|
|
H5B_ins_t (*insert)(H5F_t*, hid_t, haddr_t, void*, hbool_t*, void*, void*,
|
1999-07-29 02:25:43 +08:00
|
|
|
void*, hbool_t*, haddr_t*);
|
1998-09-22 23:27:26 +08:00
|
|
|
|
1998-01-23 00:41:32 +08:00
|
|
|
/* min insert uses min leaf, not new(), similarily for max insert */
|
1998-09-22 23:27:26 +08:00
|
|
|
hbool_t follow_min;
|
|
|
|
hbool_t follow_max;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
1998-09-22 23:27:26 +08:00
|
|
|
/* remove existing data */
|
2003-02-11 01:26:09 +08:00
|
|
|
H5B_ins_t (*remove)(H5F_t*, hid_t, haddr_t, void*, hbool_t*, void*, void*,
|
1999-07-29 02:25:43 +08:00
|
|
|
hbool_t*);
|
1999-04-23 20:31:21 +08:00
|
|
|
|
|
|
|
/* encode, decode, debug key values */
|
2004-12-29 22:26:20 +08:00
|
|
|
herr_t (*decode)(const H5F_t*, const struct H5B_t*, const uint8_t*, void*);
|
|
|
|
herr_t (*encode)(const H5F_t*, const struct H5B_t*, uint8_t*, void*);
|
2003-03-04 04:06:29 +08:00
|
|
|
herr_t (*debug_key)(FILE*, H5F_t*, hid_t, int, int, const void*, const void*);
|
1997-07-31 05:17:56 +08:00
|
|
|
} H5B_class_t;
|
|
|
|
|
2007-07-18 03:35:09 +08:00
|
|
|
/* "user data" for iterating over B-tree when collecting B-tree metadata size */
|
2007-07-14 05:12:25 +08:00
|
|
|
typedef struct H5B_info_ud_t {
|
2007-07-18 03:35:09 +08:00
|
|
|
void *udata; /* Node type's 'udata' for loading */
|
|
|
|
hsize_t *btree_size; /* Accumulated size for B-tree metadata */
|
2007-07-14 05:12:25 +08:00
|
|
|
} H5B_info_ud_t;
|
|
|
|
|
2007-07-18 03:35:09 +08:00
|
|
|
|
2005-11-07 11:13:53 +08:00
|
|
|
/*****************************/
|
|
|
|
/* Library-private Variables */
|
|
|
|
/*****************************/
|
2006-06-27 22:45:06 +08:00
|
|
|
|
2005-11-07 11:13:53 +08:00
|
|
|
/* Declare a free list to manage the H5B_shared_t struct */
|
|
|
|
H5FL_EXTERN(H5B_shared_t);
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************/
|
|
|
|
/* Library-private Function Prototypes */
|
|
|
|
/***************************************/
|
2004-07-14 01:44:01 +08:00
|
|
|
H5_DLL size_t H5B_nodesize(const H5F_t *f, const H5B_shared_t *shared,
|
|
|
|
size_t *total_nkey_size);
|
2007-07-18 03:35:09 +08:00
|
|
|
H5_DLL herr_t H5B_create(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, void *udata,
|
1999-07-29 02:25:43 +08:00
|
|
|
haddr_t *addr_p/*out*/);
|
2007-07-18 03:35:09 +08:00
|
|
|
H5_DLL herr_t H5B_find(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
|
1999-07-29 02:25:43 +08:00
|
|
|
void *udata);
|
2007-07-18 03:35:09 +08:00
|
|
|
H5_DLL herr_t H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
|
2004-05-04 02:53:50 +08:00
|
|
|
void *udata);
|
2007-07-18 03:35:09 +08:00
|
|
|
H5_DLL herr_t H5B_iterate(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t
|
2002-04-24 00:01:43 +08:00
|
|
|
op, haddr_t addr, void *udata);
|
2007-07-18 03:35:09 +08:00
|
|
|
H5_DLL herr_t H5B_iterate_size(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t
|
2007-07-14 05:12:25 +08:00
|
|
|
op, haddr_t addr, H5B_info_ud_t *bh_udata);
|
2003-02-11 01:26:09 +08:00
|
|
|
H5_DLL herr_t H5B_remove(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
|
|
|
|
void *udata);
|
2003-04-14 12:30:32 +08:00
|
|
|
H5_DLL herr_t H5B_delete(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
|
|
|
|
void *udata);
|
2007-07-18 03:35:09 +08:00
|
|
|
H5_DLL herr_t H5B_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream,
|
2003-02-11 01:26:09 +08:00
|
|
|
int indent, int fwidth, const H5B_class_t *type,
|
|
|
|
void *udata);
|
2007-07-18 03:35:09 +08:00
|
|
|
#endif /* _H5Bprivate_H */
|
|
|
|
|