dev #2
5 changed files with 35 additions and 7 deletions
|
@ -299,7 +299,9 @@ namespace CNORXZ
|
|||
{
|
||||
auto b = mSpace.begin();
|
||||
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>
|
||||
|
|
|
@ -334,12 +334,13 @@ namespace CNORXZ
|
|||
|
||||
YIndex& YIndex::at(const Vector<DType>& meta)
|
||||
{
|
||||
assert(meta.size() == mIs.size());
|
||||
IB::mPos = 0;
|
||||
CXZ_ASSERT(meta.size() == mIs.size(), "input meta size ("
|
||||
<< meta.size() << ") different from expected size ("
|
||||
<< mIs.size() << ")");
|
||||
for(SizeT i = 0; i != mIs.size(); ++i){
|
||||
mIs[i]->at(meta[i]);
|
||||
IB::mPos += mIs[i]->pos() * mFormat[i].val();
|
||||
}
|
||||
mkPos();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -85,6 +85,14 @@ namespace CNORXZ
|
|||
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
|
||||
{
|
||||
CXZ_ASSERT(this->isOpen(), "tried to get content of closed group");
|
||||
|
@ -118,10 +126,12 @@ namespace CNORXZ
|
|||
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")){
|
||||
return false;
|
||||
H5Dclose(id);
|
||||
}
|
||||
hid_t attrid = H5Aopen(id, "CLASS", H5P_DEFAULT);
|
||||
const hid_t atype = H5Aget_type(attrid);
|
||||
|
@ -130,6 +140,7 @@ namespace CNORXZ
|
|||
const herr_t ret = H5Aread(attrid, atype, buff.data());
|
||||
H5Tclose(atype);
|
||||
H5Aclose(attrid);
|
||||
H5Dclose(id);
|
||||
if(ret != 0){
|
||||
return false;
|
||||
}
|
||||
|
@ -149,7 +160,8 @@ namespace CNORXZ
|
|||
index();
|
||||
H5O_info_t oinfo;
|
||||
#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
|
||||
H5Oget_info(id, &oinfo);
|
||||
#endif
|
||||
|
@ -159,7 +171,7 @@ namespace CNORXZ
|
|||
break;
|
||||
}
|
||||
case H5O_TYPE_DATASET: {
|
||||
if(isTable(id)){
|
||||
if(isTable(id, name)){
|
||||
*index = std::make_shared<Table>(sname, icd->parent);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -14,7 +14,11 @@ namespace CNORXZ
|
|||
hsize_t nrecords = 0;
|
||||
H5TBget_table_info(mParent->id(), mName.c_str(), &nfields, &nrecords);
|
||||
mRecords = CRangeFactory( nrecords ).create();
|
||||
Vector<Arr<char,256>> fieldnames(nfields);
|
||||
Vector<char*> fieldsptr(nfields);
|
||||
for(SizeT i = 0; i != nfields; ++i){
|
||||
fieldsptr[i] = fieldnames[i].data();
|
||||
}
|
||||
Vector<SizeT> offsets(nfields);
|
||||
Vector<SizeT> sizes(nfields);
|
||||
SizeT typesize = 0;
|
||||
|
@ -71,6 +75,7 @@ namespace CNORXZ
|
|||
if(mId != 0){
|
||||
H5Tclose(mType);
|
||||
H5Dclose(mId);
|
||||
mId = 0;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
|
|
@ -101,6 +101,14 @@ namespace
|
|||
h5f.open();
|
||||
EXPECT_TRUE(h5f.ro());
|
||||
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