Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
NexusCPP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software Control System
Libraries
NexusCPP
Commits
a8184ff1
Commit
a8184ff1
authored
5 months ago
by
Stéphane Poirier
Browse files
Options
Downloads
Patches
Plain Diff
Fixed: dataset reading failure in case of string type
parent
6e694d43
No related branches found
No related tags found
1 merge request
!2
HDF5 1.14.3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/nxhdf5.cpp
+43
-11
43 additions, 11 deletions
src/nxhdf5.cpp
with
43 additions
and
11 deletions
src/nxhdf5.cpp
+
43
−
11
View file @
a8184ff1
...
...
@@ -2300,6 +2300,44 @@ public:
}
}
//--------------------------------------------------------------------------
std
::
size_t
get_in_mem_data_size
(
hid_t
dataset_id
)
const
{
// Get the data type of this attribute
H5Identifier
mem_type_id
=
H5Dget_type
(
dataset_id
);
if
(
!
mem_type_id
.
is_valid
()
)
throw
ImplException
(
"H5Dget_type failed"
,
"nxcpp::NexusFileImpl::get_in_mem_data_size"
);
// Get the data type's size by first getting its native type then getting
// the native type's size.
H5Identifier
native_type
=
H5Tget_native_type
(
mem_type_id
,
H5T_DIR_DEFAULT
);
if
(
!
native_type
.
is_valid
()
)
throw
ImplException
(
"H5Tget_native_type failed"
,
"nxcpp::NexusFileImpl::get_in_mem_data_size"
);
std
::
size_t
type_size
=
H5Tget_size
(
native_type
);
if
(
type_size
==
0
)
throw
ImplException
(
"H5Tget_size failed"
,
"nxcpp::NexusFileImpl::get_in_mem_data_size"
);
// Get number of elements of the attribute by first getting its dataspace
// then getting the number of elements in the dataspace
H5Identifier
space_id
=
H5Dget_space
(
dataset_id
);
if
(
!
space_id
.
is_valid
()
)
throw
ImplException
(
"H5Aget_space failed"
,
"nxcpp::NexusFileImpl::get_in_mem_data_size"
);
hssize_t
num_elements
=
H5Sget_simple_extent_npoints
(
space_id
);
if
(
num_elements
<
0
)
throw
ImplException
(
"H5Sget_simple_extent_npoints failed"
,
"nxcpp::NexusFileImpl::get_in_mem_data_size"
);
// Calculate and return the size of the data
return
type_size
*
static_cast
<
size_t
>
(
num_elements
);
}
//--------------------------------------------------------------------------
void
GetDataSetInfo
(
const
std
::
string
&
name
,
NexusDataSetInfo
*
dataSetInfo
)
{
...
...
@@ -2317,22 +2355,15 @@ public:
if
(
H5Tget_class
(
type_id
)
==
H5T_STRING
)
{
std
::
string
buf
;
char
*
buf_p
;
herr_t
ret_value
=
H5Dread
(
dataset_id
,
type_id
,
space_id
,
H5S_ALL
,
H5P_DEFAULT
,
buf_p
);
if
(
ret_value
<
0
)
throw
ImplException
(
"H5Dread failed"
,
"nxcpp::NexusFileImpl::GetDataSetInfo"
);
buf
=
buf_p
;
free
(
buf_p
);
std
::
size_t
size
=
get_in_mem_data_size
(
dataset_id
.
get
());
if
(
0
==
rank
)
{
dataDims
.
push_back
(
(
int
)
buf
.
size
()
);
dataDims
.
push_back
((
int
)
size
);
rank
=
1
;
}
else
dataDims
.
front
()
=
(
int
)
buf
.
size
()
;
// update true size
dataDims
.
front
()
=
(
int
)
size
;
// update true size
}
// update nexus dataset info
dataSetInfo
->
Clear
();
...
...
@@ -2342,7 +2373,8 @@ public:
dataSetInfo
->
SetInfo
(
h5Data2nexusData
(
type_id
),
rank
);
dataSetInfo
->
SetTotalDim
(
rank
,
dataSetInfo
->
DimArray
());
}
NEXUS_CATCH
(
"Unable to get dataset information"
,
"nxcpp::NexusFileImpl::GetDataSetInfo"
);
NEXUS_CATCH
(
"Unable to get dataset information"
,
"nxcpp::NexusFileImpl::GetDataSetInfo"
);
}
/* CPPAPI
void GetDataSetInfo(const std::string& name, NexusDataSetInfo* dataSetInfo)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment