From 1b9363e7b5b84e6ff4c1c84579e063ed1f447881 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Mon, 1 Apr 2024 12:32:22 +0200 Subject: [PATCH] tested and works, cleaning up commented code --- src/fragment_store/fragment_store.cpp | 40 ++------------------------- 1 file changed, 2 insertions(+), 38 deletions(-) diff --git a/src/fragment_store/fragment_store.cpp b/src/fragment_store/fragment_store.cpp index 66d6f049..5d41853b 100644 --- a/src/fragment_store/fragment_store.cpp +++ b/src/fragment_store/fragment_store.cpp @@ -430,14 +430,8 @@ bool FragmentStore::loadFromStorage(FragmentID fid, std::function> data_file_stack; data_file_stack.push(std::make_unique(std::string_view{frag_path})); - //std::ifstream data_file{ - //frag_path, - //std::ios::in | std::ios::binary // always binary, also for text - //}; - if (!data_file_stack.top()->isGood()) { std::cerr << "FS error: fragment data file failed to open '" << frag_path << "'\n"; - // error return false; } @@ -453,15 +447,14 @@ bool FragmentStore::loadFromStorage(FragmentID fid, std::function(*data_file_stack.top().get())); if (!data_file_stack.top()->isGood()) { std::cerr << "FS error: fragment data file failed to add zstd decompression layer '" << frag_path << "'\n"; - // error return false; } } else { assert(data_comp == Compression::NONE); } - //if (data_comp == Compression::NONE) { - static constexpr int64_t chunk_size {1024 * 1024}; + // TODO: make it read in a single chunk instead? + static constexpr int64_t chunk_size {1024 * 1024}; // 1MiB should be good for read do { auto data_var = data_file_stack.top()->read(chunk_size); ByteSpan data; @@ -486,35 +479,6 @@ bool FragmentStore::loadFromStorage(FragmentID fid, std::functionisGood()); - //} else if (data_comp == Compression::ZSTD) { - //std::vector in_buffer(ZSTD_DStreamInSize()); - //std::vector out_buffer(ZSTD_DStreamOutSize()); - //std::unique_ptr dctx{ZSTD_createDCtx(), &ZSTD_freeDCtx}; - - //uint64_t buffer_actual_size {0}; - //do { - //data_file.read(reinterpret_cast(in_buffer.data()), in_buffer.size()); - //buffer_actual_size = data_file.gcount(); - //if (buffer_actual_size == 0) { - //break; - //} - - //ZSTD_inBuffer input {in_buffer.data(), buffer_actual_size, 0 }; - //do { - //ZSTD_outBuffer output = { out_buffer.data(), out_buffer.size(), 0 }; - //size_t const ret = ZSTD_decompressStream(dctx.get(), &output , &input); - //if (ZSTD_isError(ret)) { - //// error <.< - //std::cerr << "FS error: decompression error\n"; - //break; - //} - - //data_cb(out_buffer.data(), output.pos); - //} while (input.pos < input.size); - //} while (buffer_actual_size == in_buffer.size() && !data_file.eof()); - //} else { - //assert(false && "implement me"); - //} return true; }