Skip to content

Commit

Permalink
Skip iterations in streaming API
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed Apr 5, 2022
1 parent c7a4b41 commit 91eed89
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions src/ReadIterations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#include "openPMD/Series.hpp"

#include <iostream>

namespace openPMD
{

Expand Down Expand Up @@ -108,7 +110,23 @@ SeriesIterator &SeriesIterator::operator++()
// since we are in group-based iteration layout, it does not
// matter which iteration we begin a step upon
AdvanceStatus status{};
status = currentIteration.beginStep(/* reread = */ true);
try
{
status = currentIteration.beginStep(/* reread = */ true);
}
catch (error::ReadError const &err)
{
std::cerr << "[SeriesIterator] Cannot read iteration due to error "
"below, will skip it.\n"
<< err.what() << std::endl;
// Need to close the current step manually because there is no
// iteration to close
Parameter<Operation::ADVANCE> param;
param.mode = AdvanceMode::ENDSTEP;
series.IOHandler()->enqueue(IOTask(&series, std::move(param)));
series.IOHandler()->flush({FlushLevel::UserFlush});
return operator++();
}
if (status == AdvanceStatus::OVER)
{
*this = end();
Expand Down Expand Up @@ -144,7 +162,17 @@ SeriesIterator &SeriesIterator::operator++()
case IE::fileBased: {
auto &iteration = series.iterations[m_currentIteration];
AdvanceStatus status{};
status = iteration.beginStep(/* reread = */ true);
try
{
status = iteration.beginStep(/* reread = */ true);
}
catch (error::ReadError const &err)
{
std::cerr << "[SeriesIterator] Cannot read iteration due to error "
"below, will skip it.\n"
<< err.what() << std::endl;
return operator++();
}
if (status == AdvanceStatus::OVER)
{
*this = end();
Expand Down

0 comments on commit 91eed89

Please sign in to comment.