Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring for variable-based encoding: Use same backend object for Iterations container and the Iterations themselves #1707

Open
wants to merge 14 commits into
base: dev
Choose a base branch
from
Open
Prev Previous commit
Next Next commit
Further fixes
  • Loading branch information
franzpoeschel committed Dec 18, 2024
commit 957282c0bde8ad4fe3c291139b2f76d505cbe52a
10 changes: 6 additions & 4 deletions include/openPMD/Iteration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,6 @@ class IndexedIteration : public Iteration
{}
};

inline void breakpoint()
{}

namespace traits
{
template <>
Expand All @@ -473,9 +470,14 @@ namespace traits
template <typename T, typename Container>
void operator()(T &ret, Container *c)
{
breakpoint();
if (ret.IOHandler()->m_encoding == IterationEncoding::variableBased)
{
for (auto &pair :
static_cast<Attributable &>(ret).get().m_attributes)
{
static_cast<Attributable &>(*c).get().m_attributes.emplace(
std::move(pair));
}
static_cast<
std::shared_ptr<internal::SharedAttributableData> &>(
*ret.m_attri) =
Expand Down
14 changes: 2 additions & 12 deletions src/Iteration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,7 @@ void Iteration::flushGroupBased(
void Iteration::flushVariableBased(
IterationIndex_t i, internal::FlushParams const &flushParams)
{
if (!written())
{
/* create iteration path */
Parameter<Operation::OPEN_PATH> pOpen;
pOpen.path = "";
IOHandler()->enqueue(IOTask(this, pOpen));
}
setDirty(true);

switch (flushParams.flushLevel)
{
Expand All @@ -312,12 +306,8 @@ void Iteration::flushVariableBased(
break;
}

if (!written())
// @todo maybe dont repeat this upon each invocation
{
/* create iteration path */
Parameter<Operation::OPEN_PATH> pOpen;
pOpen.path = "";
IOHandler()->enqueue(IOTask(this, pOpen));
/*
* In v-based encoding, the snapshot attribute must always be written.
* Reason: Even in backends that don't support changing attributes,
Expand Down
4 changes: 1 addition & 3 deletions src/Series.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1500,8 +1500,6 @@ void Series::flushGorVBased(
series.iterations.flush(
auxiliary::replace_first(basePath(), "%T/", ""), flushParams);

debug::printDirty(*this);

for (auto it = begin; it != end; ++it)
{
// Phase 1
Expand Down Expand Up @@ -2417,7 +2415,7 @@ Series::iterations_iterator Series::indexOf(Iteration const &iteration)
for (auto it = series.iterations.begin(); it != series.iterations.end();
++it)
{
if (it->second.m_attri->get() == iteration.m_attri->get())
if (it->second.m_attri.get() == iteration.m_attri.get())
{
return it;
}
Expand Down