-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Storages: Separate ColumnFileTinyReader & ColumnFileSetInputStream (#…
…9527) ref #6233 Stroages: Separate ColumnFileTinyReader & ColumnFileSetInputStream Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com> Co-authored-by: jinhelin <[email protected]> Co-authored-by: JaySon <[email protected]>
- Loading branch information
1 parent
5e44fe9
commit aaf95f7
Showing
17 changed files
with
347 additions
and
275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
dbms/src/Storages/DeltaMerge/ColumnFile/ColumnFileSetInputStream.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// Copyright 2024 PingCAP, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include <Storages/DeltaMerge/ColumnFile/ColumnFileSetInputStream.h> | ||
|
||
namespace DB::DM | ||
{ | ||
|
||
size_t ColumnFileSetInputStream::skipNextBlock() | ||
{ | ||
while (cur_column_file_reader != reader.column_file_readers.end()) | ||
{ | ||
if (*cur_column_file_reader == nullptr) | ||
{ | ||
++cur_column_file_reader; | ||
continue; | ||
} | ||
auto skipped_rows = (*cur_column_file_reader)->skipNextBlock(); | ||
read_rows += skipped_rows; | ||
if (skipped_rows) | ||
return skipped_rows; | ||
else | ||
{ | ||
(*cur_column_file_reader).reset(); | ||
++cur_column_file_reader; | ||
} | ||
} | ||
return 0; | ||
} | ||
|
||
Block ColumnFileSetInputStream::read() | ||
{ | ||
while (cur_column_file_reader != reader.column_file_readers.end()) | ||
{ | ||
if (*cur_column_file_reader == nullptr) | ||
{ | ||
++cur_column_file_reader; | ||
continue; | ||
} | ||
auto block = (*cur_column_file_reader)->readNextBlock(); | ||
if (block) | ||
{ | ||
block.setStartOffset(read_rows); | ||
read_rows += block.rows(); | ||
return block; | ||
} | ||
else | ||
{ | ||
(*cur_column_file_reader).reset(); | ||
++cur_column_file_reader; | ||
} | ||
} | ||
return {}; | ||
} | ||
|
||
Block ColumnFileSetInputStream::readWithFilter(const IColumn::Filter & filter) | ||
{ | ||
auto block = read(); | ||
if (size_t passed_count = countBytesInFilter(filter); passed_count != block.rows()) | ||
{ | ||
for (auto & col : block) | ||
{ | ||
col.column = col.column->filter(filter, passed_count); | ||
} | ||
} | ||
return block; | ||
} | ||
|
||
} // namespace DB::DM |
57 changes: 57 additions & 0 deletions
57
dbms/src/Storages/DeltaMerge/ColumnFile/ColumnFileSetInputStream.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright 2024 PingCAP, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#pragma once | ||
|
||
#include <Storages/DeltaMerge/ColumnFile/ColumnFileSetReader.h> | ||
#include <Storages/DeltaMerge/SkippableBlockInputStream.h> | ||
|
||
namespace DB::DM | ||
{ | ||
|
||
class ColumnFileSetInputStream : public SkippableBlockInputStream | ||
{ | ||
protected: | ||
ColumnFileSetReader reader; | ||
|
||
std::vector<ColumnFileReaderPtr>::iterator cur_column_file_reader; | ||
size_t read_rows = 0; | ||
|
||
public: | ||
ColumnFileSetInputStream( | ||
const DMContext & context_, | ||
const ColumnFileSetSnapshotPtr & delta_snap_, | ||
const ColumnDefinesPtr & col_defs_, | ||
const RowKeyRange & segment_range_, | ||
ReadTag read_tag_) | ||
: reader(context_, delta_snap_, col_defs_, segment_range_, read_tag_) | ||
{ | ||
cur_column_file_reader = reader.column_file_readers.begin(); | ||
} | ||
|
||
String getName() const override { return "ColumnFileSet"; } | ||
Block getHeader() const override { return toEmptyBlock(*(reader.col_defs)); } | ||
|
||
bool getSkippedRows(size_t &) override { throw Exception("Not implemented", ErrorCodes::NOT_IMPLEMENTED); } | ||
|
||
size_t skipNextBlock() override; | ||
|
||
Block read() override; | ||
|
||
Block readWithFilter(const IColumn::Filter & filter) override; | ||
}; | ||
|
||
using ColumnFileSetInputStreamPtr = std::shared_ptr<ColumnFileSetInputStream>; | ||
|
||
} // namespace DB::DM |
Oops, something went wrong.