Skip to content

copy the value store payload in binary mode in append merges - #499

Merged
hendrikmuhs merged 4 commits into
KeyviDev:masterfrom
hendrikmuhs:fix-append-merge-binary-copy
Nov 25, 2026
Merged

hendrikmuhs merged 4 commits into
KeyviDev:masterfrom
hendrikmuhs:fix-append-merge-binary-copy

Conversation

@hendrikmuhs

Copy link
Copy Markdown
Contributor

No description provided.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

namespace keyvi {
namespace dictionary {
namespace fsa {
namespace internal {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]

Suggested change
namespace internal {
namespace keyvi::dictionary::fsa::internal {

keyvi/include/keyvi/dictionary/fsa/internal/value_store_append_merge.h:71:

- } /* namespace internal */
- } /* namespace fsa */
- } /* namespace dictionary */
- } /* namespace keyvi */
+ } // namespace keyvi::dictionary::fsa::internal
+ 
+ 

*/
inline void CopyValueStorePayload(const std::string& filename, const ValueStoreProperties& properties,
std::ostream* stream) {
std::ifstream in_stream(filename, std::ios::binary);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "std::ios" is directly included [misc-include-cleaner]

keyvi/include/keyvi/dictionary/fsa/internal/value_store_append_merge.h:29:

- #include <ostream>
+ #include <ios>
+ #include <ostream>

if (!in_stream.good()) {
throw std::invalid_argument("can not open dictionary file: " + filename);
}
in_stream.seekg(properties.GetOffset());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'streamoff' (aka 'long') is implementation-defined [bugprone-narrowing-conversions]

  in_stream.seekg(properties.GetOffset());
                  ^

throw std::invalid_argument("file is corrupt(truncated): " + filename);
}

std::vector<char> buffer(64 * 1024);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: performing an implicit widening conversion to type 'size_type' (aka 'unsigned long') of a multiplication performed in type 'int' [bugprone-implicit-widening-of-multiplication-result]

  std::vector<char> buffer(64 * 1024);
                           ^
Additional context

keyvi/include/keyvi/dictionary/fsa/internal/value_store_append_merge.h:58: make conversion explicit to silence this warning

  std::vector<char> buffer(64 * 1024);
                           ^

keyvi/include/keyvi/dictionary/fsa/internal/value_store_append_merge.h:58: perform multiplication in a wider type

  std::vector<char> buffer(64 * 1024);
                           ^

size_t remaining = properties.GetSize();
while (remaining > 0) {
const size_t chunk_size = std::min(remaining, buffer.size());
in_stream.read(buffer.data(), chunk_size);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'streamsize' (aka 'long') is implementation-defined [bugprone-narrowing-conversions]

    in_stream.read(buffer.data(), chunk_size);
                                  ^

if (static_cast<size_t>(in_stream.gcount()) != chunk_size) {
throw std::invalid_argument("file is corrupt(truncated): " + filename);
}
stream->write(buffer.data(), chunk_size);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'streamsize' (aka 'long') is implementation-defined [bugprone-narrowing-conversions]

    stream->write(buffer.data(), chunk_size);
                                 ^

@codecov

codecov Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.57%. Comparing base (f9716ba) to head (a7a580b).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #499      +/-   ##
==========================================
+ Coverage   87.55%   87.57%   +0.01%     
==========================================
  Files          99      100       +1     
  Lines        5826     5834       +8     
  Branches     2518     2522       +4     
==========================================
+ Hits         5101     5109       +8     
  Misses        391      391              
  Partials      334      334              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hendrikmuhs
hendrikmuhs merged commit 13ce9a6 into KeyviDev:master Nov 25, 2026
26 checks passed
@hendrikmuhs
hendrikmuhs deleted the fix-append-merge-binary-copy branch November 25, 2026 06:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant