Skip to content

Commit 1ff5cf7

Browse files
Safeguards for READ_LINEAR mode (#1753)
* Check that the Series has been parsed * Do not attempt to read all steps when parse preference is per step
1 parent aa2cc99 commit 1ff5cf7

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

src/Series.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1244,6 +1244,17 @@ std::future<void> Series::flush_impl(
12441244
internal::FlushParams const &flushParams,
12451245
bool flushIOHandler)
12461246
{
1247+
if (!written() && access::readOnly(IOHandler()->m_frontendAccess) &&
1248+
IOHandler()->m_work.empty())
1249+
{
1250+
throw error::WrongAPIUsage(
1251+
"Attempting to flush the Series in Read mode even though no "
1252+
"operation has been performed yet. If this error occurs to you in "
1253+
"Access::READ_LINEAR mode, then either try using "
1254+
"Series::parseBase() or use Series::snapshots() / "
1255+
"Series::readIterations() to access the first Iteration. If this "
1256+
"occurs in Access::READ_ONLY, then this is likely a bug.");
1257+
}
12471258
IOHandler()->m_lastFlushSuccessful = true;
12481259
try
12491260
{
@@ -3514,7 +3525,10 @@ bool Series::randomAccessSteps() const
35143525
}
35153526
return false;
35163527
};
3517-
return iterationEncoding() == IterationEncoding::variableBased &&
3528+
return get().m_parsePreference.value_or(
3529+
internal::ParsePreference::UpFront) ==
3530+
internal::ParsePreference::UpFront &&
3531+
iterationEncoding() == IterationEncoding::variableBased &&
35183532
randomAccess(IOHandler()->m_backendAccess);
35193533
}
35203534

0 commit comments

Comments
 (0)