@@ -500,6 +500,10 @@ SeriesImpl::flushFileBased( iterations_iterator begin, iterations_iterator end )
500500 if ( IOHandler ()->m_frontendAccess == Access::READ_ONLY )
501501 for ( auto it = begin; it != end; ++it )
502502 {
503+ if ( *it->second .m_closed == Iteration::CloseStatus::NotYetAccessed )
504+ {
505+ continue ;
506+ }
503507 bool const dirtyRecursive = it->second .dirtyRecursive ();
504508 if ( *it->second .m_closed
505509 == Iteration::CloseStatus::ClosedInBackend )
@@ -544,6 +548,10 @@ SeriesImpl::flushFileBased( iterations_iterator begin, iterations_iterator end )
544548 bool allDirty = dirty ();
545549 for ( auto it = begin; it != end; ++it )
546550 {
551+ if ( *it->second .m_closed == Iteration::CloseStatus::NotYetAccessed )
552+ {
553+ continue ;
554+ }
547555 bool const dirtyRecursive = it->second .dirtyRecursive ();
548556 if ( *it->second .m_closed
549557 == Iteration::CloseStatus::ClosedInBackend )
@@ -629,6 +637,10 @@ SeriesImpl::flushGroupBased( iterations_iterator begin, iterations_iterator end
629637 if ( IOHandler ()->m_frontendAccess == Access::READ_ONLY )
630638 for ( auto it = begin; it != end; ++it )
631639 {
640+ if ( *it->second .m_closed == Iteration::CloseStatus::NotYetAccessed )
641+ {
642+ continue ;
643+ }
632644 if ( *it->second .m_closed ==
633645 Iteration::CloseStatus::ClosedInBackend )
634646 {
@@ -665,6 +677,10 @@ SeriesImpl::flushGroupBased( iterations_iterator begin, iterations_iterator end
665677
666678 for ( auto it = begin; it != end; ++it )
667679 {
680+ if ( *it->second .m_closed == Iteration::CloseStatus::NotYetAccessed )
681+ {
682+ continue ;
683+ }
668684 if ( *it->second .m_closed ==
669685 Iteration::CloseStatus::ClosedInBackend )
670686 {
@@ -774,6 +790,10 @@ SeriesImpl::readFileBased( )
774790 };
775791 if ( series.m_parseLazily )
776792 {
793+ for ( auto & iteration : series.iterations )
794+ {
795+ *iteration.second .m_closed = Iteration::CloseStatus::NotYetAccessed;
796+ }
777797 // open the last iteration, just to parse Series attributes
778798 auto getLastIteration = series.iterations .end ();
779799 getLastIteration--;
@@ -929,17 +949,38 @@ SeriesImpl::readGroupBased( bool do_init )
929949 IOHandler ()->enqueue (IOTask (&series.iterations , pList));
930950 IOHandler ()->flush ();
931951
932- for ( auto const & it : *pList.paths )
952+ for ( auto const & it : *pList.paths )
933953 {
934- Iteration& i = series. iterations [ std::stoull (it)] ;
935- if ( i. closedByWriter ( ) )
954+ uint64_t index = std::stoull ( it ) ;
955+ if ( series. iterations . contains ( index ) )
936956 {
937- continue ;
957+ // maybe re-read
958+ auto & i = series.iterations .at ( index );
959+ if ( i.closedByWriter () )
960+ {
961+ continue ;
962+ }
963+ if ( *i.m_closed != Iteration::CloseStatus::NotYetAccessed )
964+ {
965+ pOpen.path = it;
966+ IOHandler ()->enqueue ( IOTask ( &i, pOpen ) );
967+ i.read ();
968+ }
938969 }
939- i.deferRead ( {it, false , " " } );
940- if ( !series.m_parseLazily )
970+ else
941971 {
942- i.accessLazily ();
972+ // parse for the first time, resp. delay the parsing process
973+ Iteration & i = series.iterations [ std::stoull ( it ) ];
974+ i.deferRead ( { it, false , " " } );
975+ if ( !series.m_parseLazily )
976+ {
977+ i.accessLazily ();
978+ *i.m_closed = Iteration::CloseStatus::Open;
979+ }
980+ else
981+ {
982+ *i.m_closed = Iteration::CloseStatus::NotYetAccessed;
983+ }
943984 }
944985 }
945986}
@@ -1177,16 +1218,15 @@ SeriesImpl::openIteration( uint64_t index, Iteration iteration )
11771218 throw std::runtime_error (
11781219 " [Series] Detected illegal access to iteration that "
11791220 " has been closed previously." );
1221+ case CL ::NotYetAccessed:
11801222 case CL ::Open:
11811223 case CL ::ClosedTemporarily:
11821224 *iteration.m_closed = CL ::Open;
11831225 break ;
11841226 case CL ::ClosedInFrontend:
11851227 // just keep it like it is
11861228 break ;
1187- default :
1188- throw std::runtime_error ( " Unreachable!" );
1189- }
1229+ }
11901230}
11911231
11921232namespace internal
0 commit comments