Skip to content

Commit

Permalink
fix seek issue
Browse files Browse the repository at this point in the history
  • Loading branch information
davemarco committed Nov 6, 2024
1 parent c81cd4b commit 28d4250
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/clp_ffi_js/ir/StreamReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,21 +153,19 @@ auto StreamReader::create(DataArrayTsType const& data_array) -> std::unique_ptr<
auto zstd_decompressor{std::make_unique<ZstdDecompressor>()};
zstd_decompressor->open(data_buffer.data(), length);

size_t reader_offset = 0;
rewind_reader_and_validate_encoding_type(*zstd_decompressor);
reader_offset = zstd_decompressor->try_get_pos(reader_offset);

// Required to validate encoding type prior to getting version.
rewind_reader_and_validate_encoding_type(*zstd_decompressor);
auto const version{get_version(*zstd_decompressor)};
// Required that reader offset matches position after validation in order to decode log events.
zstd_decompressor->seek_from_begin(reader_offset);

// Required that reader offset matches position after validation in order to decode log events.
rewind_reader_and_validate_encoding_type(*zstd_decompressor);
if (std::ranges::find(cUnstructuredIrVersions, version) != cUnstructuredIrVersions.end()) {
return std::make_unique<UnstructuredIrStreamReader>(UnstructuredIrStreamReader::create(
std::move(zstd_decompressor),
std::move(data_buffer)
));
}
SPDLOG_INFO("did i get here 3");

throw ClpFfiJsException{
clp::ErrorCode::ErrorCode_Unsupported,
Expand Down

0 comments on commit 28d4250

Please sign in to comment.