Skip to content

Commit

Permalink
change name
Browse files Browse the repository at this point in the history
  • Loading branch information
hongyunyan committed Jul 15, 2022
1 parent 620060f commit d48eed7
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ DMFileBlockInputStreamPtr DMFileBlockInputStreamBuilder::build(const DMFilePtr &
read_columns,
is_common_handle,
enable_clean_read,
is_raw_read,
is_fast_mode,
max_data_version,
std::move(pack_filter),
mark_cache,
Expand Down
15 changes: 9 additions & 6 deletions dbms/src/Storages/DeltaMerge/File/DMFileBlockInputStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,18 @@ class DMFileBlockInputStreamBuilder

// **** filters **** //

// Only set this param to true when
// 1. There is no delta.
// 2. You don't need pk, version and delete_tag columns
// Only set enable param to true when
// in normal mode:
// 1. There is no delta.
// 2. You don't need pk, version and delete_tag columns
// in fast mode:
// 1. You don't need pk columns
// If you have no idea what it means, then simply set it to false.
// `max_data_version_` is the MVCC filter version for reading. Used by clean read check
DMFileBlockInputStreamBuilder & enableCleanRead(bool enable, bool is_raw_read_, UInt64 max_data_version_)
DMFileBlockInputStreamBuilder & enableCleanRead(bool enable, bool is_fast_mode_, UInt64 max_data_version_)
{
enable_clean_read = enable;
is_raw_read = is_raw_read_;
is_fast_mode = is_fast_mode_;
max_data_version = max_data_version_;
return *this;
}
Expand Down Expand Up @@ -140,7 +143,7 @@ class DMFileBlockInputStreamBuilder

// clean read
bool enable_clean_read = false;
bool is_raw_read = false;
bool is_fast_mode = false;
UInt64 max_data_version = std::numeric_limits<UInt64>::max();
// Rough set filter
RSOperatorPtr rs_filter;
Expand Down
9 changes: 4 additions & 5 deletions dbms/src/Storages/DeltaMerge/File/DMFileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ DMFileReader::DMFileReader(
bool is_common_handle_,
// clean read
bool enable_clean_read_,
bool is_raw_read_,
bool is_fast_mode_,
UInt64 max_read_version_,
// filters
DMFilePackFilter && pack_filter_,
Expand All @@ -233,7 +233,7 @@ DMFileReader::DMFileReader(
, read_one_pack_every_time(read_one_pack_every_time_)
, single_file_mode(dmfile_->isSingleFileMode())
, enable_clean_read(enable_clean_read_)
, is_raw_read(is_raw_read_)
, is_fast_mode(is_fast_mode_)
, max_read_version(max_read_version_)
, pack_filter(std::move(pack_filter_))
, skip_packs_by_column(read_columns.size(), 0)
Expand Down Expand Up @@ -342,10 +342,9 @@ Block DMFileReader::read()
}

// TODO: this will need better algorithm: we should separate those packs which can and can not do clean read.
bool do_clean_read_on_normal_mode = enable_clean_read && expected_handle_res == All && not_clean_rows == 0 && (!is_raw_read);
bool do_clean_read_on_normal_mode = enable_clean_read && expected_handle_res == All && not_clean_rows == 0 && (!is_fast_mode);

// when is in fast mode and all pack's max del index is 0, then we don't need to read del column
bool do_clean_read_on_handle = enable_clean_read && is_raw_read && expected_handle_res == All;
bool do_clean_read_on_handle = enable_clean_read && is_fast_mode && expected_handle_res == All;

if (do_clean_read_on_normal_mode)
{
Expand Down
4 changes: 2 additions & 2 deletions dbms/src/Storages/DeltaMerge/File/DMFileReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class DMFileReader
// 2. You don't need pk, version and delete_tag columns
// If you have no idea what it means, then simply set it to false.
bool enable_clean_read_,
bool is_raw_read_,
bool is_fast_mode_,
// The the MVCC filter version. Used by clean read check.
UInt64 max_read_version_,
// filters
Expand Down Expand Up @@ -126,7 +126,7 @@ class DMFileReader
// In normal mode, if there is no delta for some packs in stable, we can try to do clean read.
// In fast mode, we always try to do clean read.
const bool enable_clean_read;
const bool is_raw_read;
const bool is_fast_mode;
const UInt64 max_read_version;

/// Filters
Expand Down
9 changes: 3 additions & 6 deletions dbms/src/Storages/DeltaMerge/Segment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,15 +540,12 @@ BlockInputStreamPtr Segment::getInputStreamRaw(const DMContext & dm_context,
}
}

/// Whether fast mode or raw read(selraw), if columns_to_read does not include EXTRA_HANDLE_COLUMN_ID,
/// when we read in fast mode, if columns_to_read does not include EXTRA_HANDLE_COLUMN_ID,
/// we can try to use clean read to make optimization in stable part.

/// Especially for fast mode,
/// when the pack is under totally data_ranges and has no rows whose del_mark = 1 --> we don't need read handle_column/tag_column/version_column
/// when the pack is under totally data_ranges and has rows whose del_mark = 1 --> we don't need read handle_column/version_column
/// others --> we don't need read version_column

/// Considering the del min max index has some problem now, we first only handle with handle column.
/// Considering the del min max index has some problem now, we first only optimize with handle column.

BlockInputStreamPtr stable_stream = segment_snap->stable->getInputStream(
dm_context,
Expand All @@ -558,7 +555,7 @@ BlockInputStreamPtr Segment::getInputStreamRaw(const DMContext & dm_context,
std::numeric_limits<UInt64>::max(),
expected_block_size,
/* enable_clean_read */ enable_clean_read,
/* is_raw_read */ filter_delete_mark);
/* is_fast_mode */ filter_delete_mark);

BlockInputStreamPtr delta_stream = std::make_shared<DeltaValueInputStream>(dm_context, segment_snap->delta, new_columns_to_read, this->rowkey_range);

Expand Down
4 changes: 2 additions & 2 deletions dbms/src/Storages/DeltaMerge/StableValueSpace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ StableValueSpace::Snapshot::getInputStream(
UInt64 max_data_version,
size_t expected_block_size,
bool enable_clean_read,
bool is_raw_read)
bool is_fast_mode)
{
LOG_FMT_DEBUG(log, "max_data_version: {}, enable_clean_read: {}", max_data_version, enable_clean_read);
SkippableBlockInputStreams streams;
Expand All @@ -338,7 +338,7 @@ StableValueSpace::Snapshot::getInputStream(
{
DMFileBlockInputStreamBuilder builder(context.db_context);
builder
.enableCleanRead(enable_clean_read, is_raw_read, max_data_version)
.enableCleanRead(enable_clean_read, is_fast_mode, max_data_version)
.setRSOperator(filter)
.setColumnCache(column_caches[i])
.setTracingID(context.tracing_id)
Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Storages/DeltaMerge/StableValueSpace.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class StableValueSpace : public std::enable_shared_from_this<StableValueSpace>
UInt64 max_data_version,
size_t expected_block_size,
bool enable_clean_read,
bool is_raw_read = false);
bool is_fast_mode = false);

RowsAndBytes getApproxRowsAndBytes(const DMContext & context, const RowKeyRange & range) const;

Expand Down

0 comments on commit d48eed7

Please sign in to comment.