Skip to content

Commit

Permalink
Fix reading segments with no rows (#1438)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexowens90 authored Mar 20, 2024
1 parent 7d57f21 commit 2f70374
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
6 changes: 5 additions & 1 deletion cpp/arcticdb/column_store/chunked_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,11 @@ class ChunkedBufferImpl {
}

[[nodiscard]] const uint8_t* data() const {
util::check(blocks_.size() == 1, "Taking a pointer to the beginning of a non-contiguous buffer");
if (blocks_.empty()) {
return nullptr;
}
internal::check<ErrorCode::E_ASSERTION_FAILURE>(blocks_.size() == 1,
"Taking a pointer to the beginning of a non-contiguous buffer");
blocks_[0]->magic_.check();
return blocks_[0]->data();
}
Expand Down
4 changes: 3 additions & 1 deletion cpp/arcticdb/pipeline/read_frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,9 @@ class StringReducer {
column_width_(alloc_width),
dest_buffer_(ChunkedBuffer::presized(frame_.row_count() * column_width_)),
dst_(dest_buffer_.data()) {
std::memset(dest_buffer_.data(), 0, dest_buffer_.bytes());
if (dest_buffer_.bytes() > 0) {
std::memset(dest_buffer_.data(), 0, dest_buffer_.bytes());
}
}

virtual void finalize() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1947,6 +1947,13 @@ def test_get_index(object_version_store):
assert idx.iloc[0]["version_id"] == 0


def test_read_empty_index(lmdb_version_store_v1):
lib = lmdb_version_store_v1
sym = "test_read_empty_index"
lib.write(sym, pd.DataFrame())
assert len(lib.read_index(sym)) == 0


def test_snapshot_empty_segment(basic_store):
lib = basic_store

Expand Down

0 comments on commit 2f70374

Please sign in to comment.