diff options
author | Jerome Soumagne <jsoumagne@hdfgroup.org> | 2015-09-28 01:18:07 (GMT) |
---|---|---|
committer | Jerome Soumagne <jsoumagne@hdfgroup.org> | 2016-11-29 23:42:31 (GMT) |
commit | b74282e3d34102cfe1becd05ac2f9722f607d845 (patch) | |
tree | 7776f378ebd64402292d03688e8050f3ab438b09 /src | |
parent | 1e19e219e5c9e63d1cb6e94352bb920140032ee4 (diff) | |
download | hdf5-b74282e3d34102cfe1becd05ac2f9722f607d845.zip hdf5-b74282e3d34102cfe1becd05ac2f9722f607d845.tar.gz hdf5-b74282e3d34102cfe1becd05ac2f9722f607d845.tar.bz2 |
Fix FastBit plugin to use hash values instead of strings for defining
column/array name
Diffstat (limited to 'src')
-rw-r--r-- | src/H5Xfastbit.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/src/H5Xfastbit.c b/src/H5Xfastbit.c index c5ac3a7..89ad3d6 100644 --- a/src/H5Xfastbit.c +++ b/src/H5Xfastbit.c @@ -89,7 +89,7 @@ typedef struct H5X_fastbit_t { uint64_t nbitmaps; uint32_t *bitmaps; - char column_name[64]; + char column_name[H5X_FASTBIT_MAX_NAME]; hbool_t idx_reconstructed; } H5X_fastbit_t; @@ -109,6 +109,9 @@ H5X__fastbit_init(hid_t dataset_id); static herr_t H5X__fastbit_term(H5X_fastbit_t *fastbit); +static unsigned int +H5X__fastbit_hash_string(const char *string); + static enum FastBitDataType H5X__fastbit_convert_type(hid_t type); @@ -248,7 +251,7 @@ H5X__fastbit_init(hid_t dataset_id) HGOTO_ERROR(H5E_INDEX, H5E_CANTGET, NULL, "can't get dataset name"); H5X_FASTBIT_LOG_DEBUG("Dataset Name : %s", dataset_name); - sprintf(fastbit->column_name, "%s", dataset_name); + sprintf(fastbit->column_name, "array%u", H5X__fastbit_hash_string(dataset_name)); fastbit->idx_reconstructed = FALSE; @@ -349,6 +352,34 @@ done: } /* H5X__fastbit_term() */ /*------------------------------------------------------------------------- + * Function: H5X__fastbit_hash_string + * + * Purpose: Hash string to create unique ID to register FastBit array. + * + * Return: ID of hashed string + * + *------------------------------------------------------------------------- + */ +static unsigned int +H5X__fastbit_hash_string(const char *string) +{ + /* This is the djb2 string hash function */ + unsigned int ret_value = 5381; + const unsigned char *p; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + p = (const unsigned char *) string; + + while (*p != '\0') { + ret_value = (ret_value << 5) + ret_value + *p; + ++p; + } + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5X__fastbit_hash_string */ + +/*------------------------------------------------------------------------- * Function: H5X__fastbit_convert_type * * Purpose: Convert H5 type to FastBit type. |