diff --git a/src/include/ranges/crange.h b/src/include/ranges/crange.h index 4083c68..5a9366e 100644 --- a/src/include/ranges/crange.h +++ b/src/include/ranges/crange.h @@ -185,7 +185,8 @@ namespace CNORXZ */ SizeT get(SizeT pos) const; - /** return position for given meta data + /** return position for given meta data. + Returns size() if metaPos is out of scope. @param metaPos meta data, size type */ SizeT getMeta(SizeT metaPos) const; diff --git a/src/include/ranges/urange.cc.h b/src/include/ranges/urange.cc.h index 41efa29..b8878f2 100644 --- a/src/include/ranges/urange.cc.h +++ b/src/include/ranges/urange.cc.h @@ -299,8 +299,12 @@ namespace CNORXZ auto b = mSpace.begin(); auto e = mSpace.end(); auto i = std::lower_bound(b, e, meta, std::less()); - CXZ_ASSERT(i != e, "element with meta data = " << toString(meta) << " not in range"); // check this first, otherwise the next test may potentially result in a seg fault! - CXZ_ASSERT(*i == meta, "element with meta data = " << toString(meta) << " not in range"); + if(i == e){ + return size(); + } + if(*i != meta){ + return size(); + } return i - b; } diff --git a/src/include/ranges/urange.h b/src/include/ranges/urange.h index adcbf25..7c3605a 100644 --- a/src/include/ranges/urange.h +++ b/src/include/ranges/urange.h @@ -197,6 +197,7 @@ namespace CNORXZ const MetaType* get() const; /** Get range position for given meta data. + Returns size() if metaPos is not part of the range. @param metaPos Meta data. @return Position of the given meta data if it is contained by the range. */ diff --git a/src/lib/ranges/crange.cc b/src/lib/ranges/crange.cc index 9b797d3..c5123b6 100644 --- a/src/lib/ranges/crange.cc +++ b/src/lib/ranges/crange.cc @@ -115,7 +115,7 @@ namespace CNORXZ CIndex& CIndex::at(const SizeT& metaPos) { - IB::mPos = metaPos; + IB::mPos = metaPos < lmax().val() ? metaPos : lmax().val(); return *this; } @@ -204,6 +204,9 @@ namespace CNORXZ SizeT CRange::getMeta(SizeT metaPos) const { + if(metaPos >= size()){ + return size(); + } return metaPos; } diff --git a/src/opt/hdf5/lib/h5_group.cc b/src/opt/hdf5/lib/h5_group.cc index 37f8bc3..e7f4d32 100644 --- a/src/opt/hdf5/lib/h5_group.cc +++ b/src/opt/hdf5/lib/h5_group.cc @@ -93,6 +93,7 @@ namespace CNORXZ const String next = name.substr(delimpos+1); auto g = getGroup(thisname); g->open(); + CHECK; return g->get(next); } auto i = this->getIndexTo(thisname); @@ -101,7 +102,7 @@ namespace CNORXZ Sptr Group::getGroup(const String& name) const { - auto group = this->get(name); + ContentPtr group = this->get(name); CXZ_ASSERT(group->type() == ContentType::GROUP, "element '" << name << "' is not of type GROUP"); return std::dynamic_pointer_cast( group ); @@ -236,6 +237,7 @@ namespace CNORXZ auto dvec = [](const String& n) { return Vector({DType(n)}); }; auto i = mCont.begin(); i.at(dvec(name)); + CXZ_ASSERT(i != mCont.end(), "no element '" << name << "' in group " << path()); return i; } @@ -245,6 +247,7 @@ namespace CNORXZ auto dvec = [](const String& n) { return Vector({DType(n)}); }; auto i = mCont.begin(); i.at(dvec(name)); + CXZ_ASSERT(i != mCont.end(), "no element '" << name << "' in group " << path()); return i; } diff --git a/src/opt/mpi/include/rrange.cc.h b/src/opt/mpi/include/rrange.cc.h index 18e9bfe..8efabf5 100644 --- a/src/opt/mpi/include/rrange.cc.h +++ b/src/opt/mpi/include/rrange.cc.h @@ -274,8 +274,7 @@ namespace CNORXZ template decltype(auto) RIndex::xpr(const Sptr>& _this) const { - CXZ_ERROR("not implemented"); - return 0; + return _this->local()->xpr( _this->local() ); } template