summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2009-02-24 19:45:17 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2009-02-24 19:45:17 (GMT)
commit24341c6eb4bb584583efeb4b7d1592ae7f5f0680 (patch)
treed30d579fdb6dd511055fd0797b41dcf95d888715
parentd77d4b17425e00f99f3cc1512e94dedf05f27aa5 (diff)
downloadhdf5-24341c6eb4bb584583efeb4b7d1592ae7f5f0680.zip
hdf5-24341c6eb4bb584583efeb4b7d1592ae7f5f0680.tar.gz
hdf5-24341c6eb4bb584583efeb4b7d1592ae7f5f0680.tar.bz2
[svn-r16516] To improve the performance of querying the info of a link (bug #1404). When the index was set to
creation order in query function but there's no creation order indexed in the file, the library tried to build and sort a table of all links. To optimize it, let the library use the B-tree for names of the links. Tested on jam. I tested the same change for v1.8 with h5committest.
-rw-r--r--src/H5Gdense.c111
1 files changed, 66 insertions, 45 deletions
diff --git a/src/H5Gdense.c b/src/H5Gdense.c
index 2bca4fa..6cc15b8 100644
--- a/src/H5Gdense.c
+++ b/src/H5Gdense.c
@@ -656,29 +656,34 @@ H5G_dense_lookup_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo,
/* Determine the address of the index to use */
if(idx_type == H5_INDEX_NAME) {
- /* Check if "native" order is OK - since names are hashed, getting them
- * in strictly increasing or decreasing order requires building a
- * table and sorting it.
+ /* Since names are hashed, getting them in strictly increasing or
+ * decreasing order requires building a table and sorting it.
+ * If the order is native, use the B-tree for names.
*/
- if(order == H5_ITER_NATIVE) {
- bt2_addr = linfo->name_bt2_addr;
- bt2_class = H5G_BT2_NAME;
- HDassert(H5F_addr_defined(bt2_addr));
- } /* end if */
- else
- bt2_addr = HADDR_UNDEF;
+ bt2_addr = HADDR_UNDEF;
} /* end if */
else {
HDassert(idx_type == H5_INDEX_CRT_ORDER);
/* This address may not be defined if creation order is tracked, but
* there's no index on it. If there's no v2 B-tree that indexes
- * the links, a table will be built.
+ * the links and the order is native, use the B-tree for names.
+ * Otherwise, build a table.
*/
bt2_addr = linfo->corder_bt2_addr;
bt2_class = H5G_BT2_CORDER;
} /* end else */
+ /* If the order is native and there's no B-tree for indexing the links,
+ * use the B-tree for names instead of building a table to speed up the
+ * process.
+ */
+ if(order == H5_ITER_NATIVE && !H5F_addr_defined(bt2_addr)) {
+ bt2_addr = linfo->name_bt2_addr;
+ bt2_class = H5G_BT2_NAME;
+ HDassert(H5F_addr_defined(bt2_addr));
+ } /* end if */
+
/* If there is an index defined for the field, use it */
if(H5F_addr_defined(bt2_addr)) {
H5G_bt2_ud_lbi_t udata; /* User data for v2 B-tree link lookup */
@@ -953,31 +958,37 @@ H5G_dense_iterate(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo,
/* Determine the address of the index to use */
if(idx_type == H5_INDEX_NAME) {
- /* Check if "native" order is OK - since names are hashed, getting them
- * in strictly increasing or decreasing order requires building a
- * table and sorting it.
+ /* Since names are hashed, getting them in strictly increasing or
+ * decreasing order requires building a table and sorting it. If
+ * the order is native, use the B-tree for names.
*/
- if(order == H5_ITER_NATIVE) {
- HDassert(H5F_addr_defined(linfo->name_bt2_addr));
- bt2_addr = linfo->name_bt2_addr;
- bt2_class = H5G_BT2_NAME;
- } /* end if */
- else
- bt2_addr = HADDR_UNDEF;
+ bt2_addr = HADDR_UNDEF;
} /* end if */
else {
HDassert(idx_type == H5_INDEX_CRT_ORDER);
/* This address may not be defined if creation order is tracked, but
* there's no index on it. If there's no v2 B-tree that indexes
- * the links, a table will be built.
+ * the links and the order is native, use the B-tree for names.
+ * Otherwise, build a table.
*/
bt2_addr = linfo->corder_bt2_addr;
bt2_class = H5G_BT2_CORDER;
} /* end else */
+ /* If the order is native and there's no B-tree for indexing the links,
+ * use the B-tree for names instead of building a table to speed up the
+ * process.
+ */
+ if(order == H5_ITER_NATIVE && !H5F_addr_defined(bt2_addr)) {
+ HDassert(H5F_addr_defined(linfo->name_bt2_addr));
+ bt2_addr = linfo->name_bt2_addr;
+ bt2_class = H5G_BT2_NAME;
+ } /* end if */
+
/* Check on iteration order */
- if(order == H5_ITER_NATIVE && H5F_addr_defined(bt2_addr)) {
+ if(order == H5_ITER_NATIVE) {
+ HDassert(H5F_addr_defined(bt2_addr));
H5G_bt2_ud_it_t udata; /* User data for iterator callback */
/* Open the fractal heap */
@@ -1146,29 +1157,34 @@ H5G_dense_get_name_by_idx(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo,
/* Determine the address of the index to use */
if(idx_type == H5_INDEX_NAME) {
- /* Check if "native" order is OK - since names are hashed, getting them
- * in strictly increasing or decreasing order requires building a
- * table and sorting it.
+ /* Since names are hashed, getting them in strictly increasing or
+ * decreasing order requires building a table and sorting it. If
+ * the order is native, use the B-tree for names.
*/
- if(order == H5_ITER_NATIVE) {
- bt2_addr = linfo->name_bt2_addr;
- bt2_class = H5G_BT2_NAME;
- HDassert(H5F_addr_defined(bt2_addr));
- } /* end if */
- else
- bt2_addr = HADDR_UNDEF;
+ bt2_addr = HADDR_UNDEF;
} /* end if */
else {
HDassert(idx_type == H5_INDEX_CRT_ORDER);
/* This address may not be defined if creation order is tracked, but
* there's no index on it. If there's no v2 B-tree that indexes
- * the links, a table will be built.
+ * the links and the order is native, use the B-tree for names.
+ * Otherwise, build a table.
*/
bt2_addr = linfo->corder_bt2_addr;
bt2_class = H5G_BT2_CORDER;
} /* end else */
+ /* If the order is native and there's no B-tree for indexing the links,
+ * use the B-tree for names instead of building a table to speed up the
+ * process.
+ */
+ if(order == H5_ITER_NATIVE && !H5F_addr_defined(bt2_addr)) {
+ bt2_addr = linfo->name_bt2_addr;
+ bt2_class = H5G_BT2_NAME;
+ HDassert(H5F_addr_defined(bt2_addr));
+ } /* end if */
+
/* If there is an index defined for the field, use it */
if(H5F_addr_defined(bt2_addr)) {
H5G_bt2_ud_gnbi_t udata; /* User data for v2 B-tree callback */
@@ -1561,29 +1577,34 @@ H5G_dense_remove_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo,
/* Determine the address of the index to use */
if(idx_type == H5_INDEX_NAME) {
- /* Check if "native" order is OK - since names are hashed, getting them
- * in strictly increasing or decreasing order requires building a
- * table and sorting it.
+ /* Since names are hashed, getting them in strictly increasing or
+ * decreasing order requires building a table and sorting it. If
+ * the order is native, use the B-tree for names.
*/
- if(order == H5_ITER_NATIVE) {
- bt2_addr = linfo->name_bt2_addr;
- bt2_class = H5G_BT2_NAME;
- HDassert(H5F_addr_defined(bt2_addr));
- } /* end if */
- else
- bt2_addr = HADDR_UNDEF;
+ bt2_addr = HADDR_UNDEF;
} /* end if */
else {
HDassert(idx_type == H5_INDEX_CRT_ORDER);
/* This address may not be defined if creation order is tracked, but
* there's no index on it. If there's no v2 B-tree that indexes
- * the links, a table will be built.
+ * the links and the order is native, use the B-tree for names.
+ * Otherwise, build a table.
*/
bt2_addr = linfo->corder_bt2_addr;
bt2_class = H5G_BT2_CORDER;
} /* end else */
+ /* If the order is native and there's no B-tree for indexing the links,
+ * use the B-tree for names instead of building a table to speed up the
+ * process.
+ */
+ if(order == H5_ITER_NATIVE && !H5F_addr_defined(bt2_addr)) {
+ bt2_addr = linfo->name_bt2_addr;
+ bt2_class = H5G_BT2_NAME;
+ HDassert(H5F_addr_defined(bt2_addr));
+ } /* end if */
+
/* If there is an index defined for the field, use it */
if(H5F_addr_defined(bt2_addr)) {
H5G_bt2_ud_rmbi_t udata; /* User data for v2 B-tree record removal */