Skip to content

Commit

Permalink
wip: Edge case for empty ChunkedBufferImpl
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
  • Loading branch information
jjerphan committed Oct 25, 2023
1 parent 27a4a44 commit 8e4a390
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 12 deletions.
5 changes: 1 addition & 4 deletions cpp/arcticdb/column_store/chunked_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,8 @@ template std::vector<ChunkedBufferImpl<3968>> split(const ChunkedBufferImpl<3968
// Inclusive of start_byte, exclusive of end_byte
template <size_t BlockSize>
ChunkedBufferImpl<BlockSize> truncate(const ChunkedBufferImpl<BlockSize>& input, size_t start_byte, size_t end_byte) {
internal::check<ErrorCode::E_ASSERTION_FAILURE>(
end_byte >= start_byte,
"ChunkedBufferImpl::truncate expects end_byte {} to be >= start_byte {}", end_byte, start_byte);
ARCTICDB_DEBUG(log::version(), "Truncating buffer of size {} between bytes {} and {}", input.bytes(), start_byte, end_byte);
const auto output_size = end_byte - start_byte;
const auto output_size = start_byte >= end_byte ? 0 : end_byte - start_byte;
// This is trivially extendable to use presized_in_blocks, but there is no use case for this right now, and
// copy_frame_data_to_buffer expects a contiguous buffer
auto output = ChunkedBufferImpl<BlockSize>::presized(output_size);
Expand Down
6 changes: 0 additions & 6 deletions cpp/arcticdb/processing/clause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -698,12 +698,6 @@ void RowRangeClause::set_processing_config(const ProcessingConfig& processing_co
std::min(user_provided_end_, total_rows) :
std::max(total_rows + user_provided_end_, static_cast<int64_t>(0))
);
if (start_ > end_) {
user_input::raise<ErrorCode::E_INVALID_USER_ARGUMENT>(
"RowRangeClause start index {} is greater than end index {}; originally (start, end)=({}, {}) ",
start_, end_, user_provided_start_, user_provided_end_);
}
n_ = end_ - start_;
break;

default:
Expand Down
4 changes: 2 additions & 2 deletions python/tests/unit/arcticdb/version_store/test_row_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ def generic_row_range_test(version_store, symbol, df, start_row, end_row):

expected_array = df.iloc[start_row:end_row]
received_array = version_store.read(symbol, row_range=(start_row, end_row)).data
q = QueryBuilder()._row_range(start_row, end_row)
q = QueryBuilder()._row_range((start_row, end_row))
received_array_via_querybuilder = version_store.read(symbol, query_builder=q).data

np.testing.assert_array_equal(expected_array, received_array)
np.testing.assert_array_equal(expected_array, received_array_via_querybuilder)

expected_array = df.iloc[-end_row:-start_row]
received_array = version_store.read(symbol, row_range=(-end_row, -start_row)).data
q = QueryBuilder()._row_range(-end_row, -start_row)
q = QueryBuilder()._row_range((-end_row, -start_row))
received_array_via_querybuilder = version_store.read(symbol, query_builder=q).data

np.testing.assert_array_equal(expected_array, received_array)
Expand Down

0 comments on commit 8e4a390

Please sign in to comment.