1997-07-31 05:17:56 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
1998-09-22 23:27:26 +08:00
|
|
|
* Copyright (C) 1997 National Center for Supercomputing Applications.
|
|
|
|
* All rights reserved.
|
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
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef _H5Bprivate_H
|
|
|
|
#define _H5Bprivate_H
|
1998-01-23 00:41:32 +08:00
|
|
|
|
1998-09-22 23:27:26 +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 */
|
|
|
|
#include <H5private.h>
|
|
|
|
#include <H5Fprivate.h>
|
2000-06-02 07:45:11 +08:00
|
|
|
#include <H5ACprivate.h> /*cache */
|
1997-07-31 05:17:56 +08:00
|
|
|
|
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 */
|
|
|
|
#define H5B_SIZEOF_HDR(F) \
|
1998-10-21 23:14:15 +08:00
|
|
|
(H5B_SIZEOF_MAGIC + /*magic number */ \
|
|
|
|
4 + /*type, level, num entries */ \
|
1998-09-22 23:27:26 +08:00
|
|
|
2*H5F_SIZEOF_ADDR(F)) /*left and right sibling addresses */
|
1998-03-24 22:53:57 +08:00
|
|
|
|
1998-10-21 23:14:15 +08:00
|
|
|
#define H5B_K(F,TYPE) /*K value given file and Btree subclass */ \
|
1999-08-11 04:21:32 +08:00
|
|
|
((F)->shared->fcpl->btree_k[(TYPE)->id])
|
1997-08-13 23:36:47 +08:00
|
|
|
|
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
|
|
|
|
|
|
|
typedef enum H5B_subid_t {
|
1998-09-22 23:27:26 +08:00
|
|
|
H5B_SNODE_ID = 0, /*B-tree is for symbol table nodes */
|
|
|
|
H5B_ISTORE_ID = 1 /*B-tree is for indexed object storage */
|
1997-08-05 00:19:57 +08:00
|
|
|
} H5B_subid_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-09-22 23:27:26 +08:00
|
|
|
struct H5B_t; /*forward decl */
|
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*/
|
|
|
|
size_t (*get_sizeof_rkey)(H5F_t*, const void*); /*raw key size */
|
1999-07-29 02:25:43 +08:00
|
|
|
herr_t (*new_node)(H5F_t*, H5B_ins_t, void*, void*, void*, haddr_t*);
|
1998-09-22 23:27:26 +08:00
|
|
|
intn (*cmp2)(H5F_t*, void*, void*, void*); /*compare 2 keys */
|
|
|
|
intn (*cmp3)(H5F_t*, void*, void*, void*); /*compare 3 keys */
|
1999-07-29 02:25:43 +08:00
|
|
|
herr_t (*found)(H5F_t*, haddr_t, const void*, void*, const void*);
|
1998-01-23 00:41:32 +08:00
|
|
|
|
1998-09-22 23:27:26 +08:00
|
|
|
/* insert new data */
|
1999-07-29 02:25:43 +08:00
|
|
|
H5B_ins_t (*insert)(H5F_t*, haddr_t, void*, hbool_t*, void*, void*,
|
|
|
|
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;
|
|
|
|
|
|
|
|
/* remove existing data */
|
1999-07-29 02:25:43 +08:00
|
|
|
H5B_ins_t (*remove)(H5F_t*, haddr_t, void*, hbool_t*, void*, void*,
|
|
|
|
hbool_t*);
|
1999-04-23 20:31:21 +08:00
|
|
|
|
|
|
|
/* iterate through the leaf nodes */
|
1999-07-29 02:25:43 +08:00
|
|
|
herr_t (*list)(H5F_t*, void*, haddr_t, void*, void*);
|
1999-04-23 20:31:21 +08:00
|
|
|
|
|
|
|
/* encode, decode, debug key values */
|
1998-11-19 02:40:09 +08:00
|
|
|
herr_t (*decode)(H5F_t*, struct H5B_t*, uint8_t*, void*);
|
|
|
|
herr_t (*encode)(H5F_t*, struct H5B_t*, uint8_t*, void*);
|
1998-09-22 23:27:26 +08:00
|
|
|
herr_t (*debug_key)(FILE*, intn, intn, const void*, const void*);
|
1997-07-31 05:17:56 +08:00
|
|
|
} H5B_class_t;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The B-tree node as stored in memory...
|
|
|
|
*/
|
|
|
|
typedef struct H5B_key_t {
|
1998-09-22 23:27:26 +08:00
|
|
|
hbool_t dirty; /*native key is more recent than raw key */
|
1998-11-19 02:40:09 +08:00
|
|
|
uint8_t *rkey; /*ptr into node->page for raw key */
|
1998-09-22 23:27:26 +08:00
|
|
|
void *nkey; /*null or ptr into node->native for key */
|
1997-07-31 05:17:56 +08:00
|
|
|
} H5B_key_t;
|
|
|
|
|
|
|
|
typedef struct H5B_t {
|
2000-06-02 07:45:11 +08:00
|
|
|
H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */
|
|
|
|
/* first field in structure */
|
1998-09-22 23:27:26 +08:00
|
|
|
const H5B_class_t *type; /*type of tree */
|
|
|
|
size_t sizeof_rkey; /*size of raw (disk) key */
|
|
|
|
hbool_t dirty; /*something in the tree is dirty */
|
|
|
|
intn ndirty; /*num child ptrs to emit */
|
|
|
|
intn level; /*node level */
|
|
|
|
haddr_t left; /*address of left sibling */
|
|
|
|
haddr_t right; /*address of right sibling */
|
|
|
|
intn nchildren; /*number of child pointers */
|
1998-11-19 02:40:09 +08:00
|
|
|
uint8_t *page; /*disk page */
|
|
|
|
uint8_t *native; /*array of keys in native format */
|
1998-09-22 23:27:26 +08:00
|
|
|
H5B_key_t *key; /*2k+1 key entries */
|
|
|
|
haddr_t *child; /*2k child pointers */
|
1997-07-31 05:17:56 +08:00
|
|
|
} H5B_t;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Library prototypes.
|
|
|
|
*/
|
1999-07-29 02:25:43 +08:00
|
|
|
__DLL__ herr_t H5B_debug (H5F_t *f, haddr_t addr, FILE * stream,
|
1999-02-19 00:21:34 +08:00
|
|
|
intn indent, intn fwidth, const H5B_class_t *type,
|
|
|
|
void *udata);
|
|
|
|
__DLL__ herr_t H5B_create (H5F_t *f, const H5B_class_t *type, void *udata,
|
1999-07-29 02:25:43 +08:00
|
|
|
haddr_t *addr_p/*out*/);
|
|
|
|
__DLL__ herr_t H5B_find (H5F_t *f, const H5B_class_t *type, haddr_t addr,
|
|
|
|
void *udata);
|
|
|
|
__DLL__ herr_t H5B_insert (H5F_t *f, const H5B_class_t *type, haddr_t addr,
|
2000-04-21 00:36:38 +08:00
|
|
|
const double split_ratios[], void *udata);
|
1999-07-29 02:25:43 +08:00
|
|
|
__DLL__ herr_t H5B_remove(H5F_t *f, const H5B_class_t *type, haddr_t addr,
|
|
|
|
void *udata);
|
|
|
|
__DLL__ herr_t H5B_iterate (H5F_t *f, const H5B_class_t *type, haddr_t addr,
|
|
|
|
void *udata);
|
1997-08-16 00:51:34 +08:00
|
|
|
#endif
|