diff --git a/cpp/arcticdb/column_store/chunked_buffer.hpp b/cpp/arcticdb/column_store/chunked_buffer.hpp index 2cc35f6251..4daa91b1ca 100644 --- a/cpp/arcticdb/column_store/chunked_buffer.hpp +++ b/cpp/arcticdb/column_store/chunked_buffer.hpp @@ -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(blocks_.size() == 1, + "Taking a pointer to the beginning of a non-contiguous buffer"); blocks_[0]->magic_.check(); return blocks_[0]->data(); } diff --git a/cpp/arcticdb/pipeline/read_frame.cpp b/cpp/arcticdb/pipeline/read_frame.cpp index a7d63f3407..7fc44cd37c 100644 --- a/cpp/arcticdb/pipeline/read_frame.cpp +++ b/cpp/arcticdb/pipeline/read_frame.cpp @@ -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() { diff --git a/python/tests/integration/arcticdb/version_store/test_basic_version_store.py b/python/tests/integration/arcticdb/version_store/test_basic_version_store.py index 4987a5066e..e524c8b773 100644 --- a/python/tests/integration/arcticdb/version_store/test_basic_version_store.py +++ b/python/tests/integration/arcticdb/version_store/test_basic_version_store.py @@ -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