@@ -95,10 +95,7 @@ RecordComponent &RecordComponent::resetDataset(Dataset d)
9595 }
9696 // if( d.extent.empty() )
9797 // throw std::runtime_error("Dataset extent must be at least 1D.");
98- if (std::any_of (
99- d.extent .begin (), d.extent .end (), [](Extent::value_type const &i) {
100- return i == 0u ;
101- }))
98+ if (d.empty ())
10299 return makeEmpty (std::move (d));
103100
104101 rc.m_isEmpty = false ;
@@ -283,6 +280,7 @@ void RecordComponent::flush(
283280 dCreate.extent = getExtent ();
284281 dCreate.dtype = getDatatype ();
285282 dCreate.options = rc.m_dataset .value ().options ;
283+ dCreate.joinedDimension = joinedDimension ();
286284 IOHandler ()->enqueue (IOTask (this , dCreate));
287285 }
288286 }
@@ -451,21 +449,56 @@ void RecordComponent::verifyChunk(
451449 uint8_t dim = getDimensionality ();
452450 Extent dse = getExtent ();
453451
454- if (e. size () != dim || o. size () != dim )
452+ if (auto jd = joinedDimension (); jd. has_value () )
455453 {
456- std::ostringstream oss;
457- oss << " Dimensionality of chunk ("
458- << " offset=" << o.size () << " D, "
459- << " extent=" << e.size () << " D) "
460- << " and record component (" << int (dim) << " D) "
461- << " do not match." ;
462- throw std::runtime_error (oss.str ());
454+ if (o.size () != 0 )
455+ {
456+ std::ostringstream oss;
457+ oss << " Joined array: Must specify an empty offset (given: "
458+ << " offset=" << o.size () << " D, "
459+ << " extent=" << e.size () << " D)." ;
460+ throw std::runtime_error (oss.str ());
461+ }
462+ if (e.size () != dim)
463+ {
464+ std::ostringstream oss;
465+ oss << " Joined array: Dimensionalities of chunk extent and dataset "
466+ " extent must be equivalent (given: "
467+ << " offset=" << o.size () << " D, "
468+ << " extent=" << e.size () << " D)." ;
469+ throw std::runtime_error (oss.str ());
470+ }
471+ for (size_t i = 0 ; i < dim; ++i)
472+ {
473+ if (i != jd.value () && e[i] != dse[i])
474+ {
475+ throw std::runtime_error (
476+ " Joined array: Chunk extent on non-joined dimensions must "
477+ " be equivalent to dataset extents (Dimension on index " +
478+ std::to_string (i) + " . DS: " + std::to_string (dse[i]) +
479+ " - Chunk: " + std::to_string (o[i] + e[i]) + " )" );
480+ }
481+ }
482+ }
483+ else
484+ {
485+ if (e.size () != dim || o.size () != dim)
486+ {
487+ std::ostringstream oss;
488+ oss << " Dimensionality of chunk ("
489+ << " offset=" << o.size () << " D, "
490+ << " extent=" << e.size () << " D) "
491+ << " and record component (" << int (dim) << " D) "
492+ << " do not match." ;
493+ throw std::runtime_error (oss.str ());
494+ }
495+ for (uint8_t i = 0 ; i < dim; ++i)
496+ if (dse[i] < o[i] + e[i])
497+ throw std::runtime_error (
498+ " Chunk does not reside inside dataset (Dimension on "
499+ " index " +
500+ std::to_string (i) + " . DS: " + std::to_string (dse[i]) +
501+ " - Chunk: " + std::to_string (o[i] + e[i]) + " )" );
463502 }
464- for (uint8_t i = 0 ; i < dim; ++i)
465- if (dse[i] < o[i] + e[i])
466- throw std::runtime_error (
467- " Chunk does not reside inside dataset (Dimension on index " +
468- std::to_string (i) + " . DS: " + std::to_string (dse[i]) +
469- " - Chunk: " + std::to_string (o[i] + e[i]) + " )" );
470503}
471504} // namespace openPMD
0 commit comments