hdf5: fix group mkCont + improve error handling of urange/yrange at()
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
This commit is contained in:
parent
0bfee171e0
commit
f77132ddfe
5 changed files with 35 additions and 7 deletions
|
@ -299,7 +299,9 @@ namespace CNORXZ
|
||||||
{
|
{
|
||||||
auto b = mSpace.begin();
|
auto b = mSpace.begin();
|
||||||
auto e = mSpace.end();
|
auto e = mSpace.end();
|
||||||
return std::lower_bound(b, e, meta, std::less<MetaT>()) - b;
|
auto i = std::lower_bound(b, e, meta, std::less<MetaT>());
|
||||||
|
CXZ_ASSERT(*i == meta, "element with meta data = " << toString(meta) << " not in range");
|
||||||
|
return i - b;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename MetaT>
|
template <typename MetaT>
|
||||||
|
|
|
@ -334,12 +334,13 @@ namespace CNORXZ
|
||||||
|
|
||||||
YIndex& YIndex::at(const Vector<DType>& meta)
|
YIndex& YIndex::at(const Vector<DType>& meta)
|
||||||
{
|
{
|
||||||
assert(meta.size() == mIs.size());
|
CXZ_ASSERT(meta.size() == mIs.size(), "input meta size ("
|
||||||
IB::mPos = 0;
|
<< meta.size() << ") different from expected size ("
|
||||||
|
<< mIs.size() << ")");
|
||||||
for(SizeT i = 0; i != mIs.size(); ++i){
|
for(SizeT i = 0; i != mIs.size(); ++i){
|
||||||
mIs[i]->at(meta[i]);
|
mIs[i]->at(meta[i]);
|
||||||
IB::mPos += mIs[i]->pos() * mFormat[i].val();
|
|
||||||
}
|
}
|
||||||
|
mkPos();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,14 @@ namespace CNORXZ
|
||||||
return std::dynamic_pointer_cast<Group>( group );
|
return std::dynamic_pointer_cast<Group>( group );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Sptr<Table> Group::getTable(const String& name) const
|
||||||
|
{
|
||||||
|
auto table = this->get(name);
|
||||||
|
CXZ_ASSERT(table->type() == ContentType::TABLE,
|
||||||
|
"element '" << name << "' is not of type TABLE");
|
||||||
|
return std::dynamic_pointer_cast<Table>( table );
|
||||||
|
}
|
||||||
|
|
||||||
const MArray<ContentPtr>& Group::get() const
|
const MArray<ContentPtr>& Group::get() const
|
||||||
{
|
{
|
||||||
CXZ_ASSERT(this->isOpen(), "tried to get content of closed group");
|
CXZ_ASSERT(this->isOpen(), "tried to get content of closed group");
|
||||||
|
@ -118,10 +126,12 @@ namespace CNORXZ
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isTable(hid_t id)
|
static bool isTable(hid_t loc_id, const char* name)
|
||||||
{
|
{
|
||||||
|
const hid_t id = H5Dopen(loc_id, name, H5P_DEFAULT);
|
||||||
if(not H5Aexists(id, "CLASS")){
|
if(not H5Aexists(id, "CLASS")){
|
||||||
return false;
|
return false;
|
||||||
|
H5Dclose(id);
|
||||||
}
|
}
|
||||||
hid_t attrid = H5Aopen(id, "CLASS", H5P_DEFAULT);
|
hid_t attrid = H5Aopen(id, "CLASS", H5P_DEFAULT);
|
||||||
const hid_t atype = H5Aget_type(attrid);
|
const hid_t atype = H5Aget_type(attrid);
|
||||||
|
@ -130,6 +140,7 @@ namespace CNORXZ
|
||||||
const herr_t ret = H5Aread(attrid, atype, buff.data());
|
const herr_t ret = H5Aread(attrid, atype, buff.data());
|
||||||
H5Tclose(atype);
|
H5Tclose(atype);
|
||||||
H5Aclose(attrid);
|
H5Aclose(attrid);
|
||||||
|
H5Dclose(id);
|
||||||
if(ret != 0){
|
if(ret != 0){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -149,7 +160,8 @@ namespace CNORXZ
|
||||||
index();
|
index();
|
||||||
H5O_info_t oinfo;
|
H5O_info_t oinfo;
|
||||||
#if H5_VERS_MINOR > 10
|
#if H5_VERS_MINOR > 10
|
||||||
H5Oget_info(id, &oinfo, H5O_INFO_BASIC);
|
//H5Oget_info(id, &oinfo, H5O_INFO_BASIC);
|
||||||
|
H5Oget_info_by_name(id, name, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT);
|
||||||
#else
|
#else
|
||||||
H5Oget_info(id, &oinfo);
|
H5Oget_info(id, &oinfo);
|
||||||
#endif
|
#endif
|
||||||
|
@ -159,7 +171,7 @@ namespace CNORXZ
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case H5O_TYPE_DATASET: {
|
case H5O_TYPE_DATASET: {
|
||||||
if(isTable(id)){
|
if(isTable(id, name)){
|
||||||
*index = std::make_shared<Table>(sname, icd->parent);
|
*index = std::make_shared<Table>(sname, icd->parent);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -14,7 +14,11 @@ namespace CNORXZ
|
||||||
hsize_t nrecords = 0;
|
hsize_t nrecords = 0;
|
||||||
H5TBget_table_info(mParent->id(), mName.c_str(), &nfields, &nrecords);
|
H5TBget_table_info(mParent->id(), mName.c_str(), &nfields, &nrecords);
|
||||||
mRecords = CRangeFactory( nrecords ).create();
|
mRecords = CRangeFactory( nrecords ).create();
|
||||||
|
Vector<Arr<char,256>> fieldnames(nfields);
|
||||||
Vector<char*> fieldsptr(nfields);
|
Vector<char*> fieldsptr(nfields);
|
||||||
|
for(SizeT i = 0; i != nfields; ++i){
|
||||||
|
fieldsptr[i] = fieldnames[i].data();
|
||||||
|
}
|
||||||
Vector<SizeT> offsets(nfields);
|
Vector<SizeT> offsets(nfields);
|
||||||
Vector<SizeT> sizes(nfields);
|
Vector<SizeT> sizes(nfields);
|
||||||
SizeT typesize = 0;
|
SizeT typesize = 0;
|
||||||
|
@ -71,6 +75,7 @@ namespace CNORXZ
|
||||||
if(mId != 0){
|
if(mId != 0){
|
||||||
H5Tclose(mType);
|
H5Tclose(mType);
|
||||||
H5Dclose(mId);
|
H5Dclose(mId);
|
||||||
|
mId = 0;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,6 +101,14 @@ namespace
|
||||||
h5f.open();
|
h5f.open();
|
||||||
EXPECT_TRUE(h5f.ro());
|
EXPECT_TRUE(h5f.ro());
|
||||||
EXPECT_EQ(h5f.get().size(), 2u);
|
EXPECT_EQ(h5f.get().size(), 2u);
|
||||||
|
|
||||||
|
EXPECT_THROW(h5f.getGroup("gr0"), std::runtime_error);
|
||||||
|
auto gr1 = h5f.getGroup("gr1");
|
||||||
|
gr1->open();
|
||||||
|
auto tab = gr1->getTable("tab1");
|
||||||
|
EXPECT_EQ(tab->fields()->size(), 3u);
|
||||||
|
EXPECT_EQ(tab->records()->size(), 5u);
|
||||||
|
h5f.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue