Skip to content

Commit

Permalink
Remove hacks
Browse files Browse the repository at this point in the history
  • Loading branch information
JaySon-Huang committed Feb 5, 2024
1 parent f7ac6fa commit 5d665a7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
8 changes: 5 additions & 3 deletions dbms/src/Storages/DeltaMerge/File/DMFileBlockInputStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class Logger;
using LoggerPtr = std::shared_ptr<Logger>;
namespace DM
{
inline static const size_t DMFILE_READ_ROWS_THRESHOLD = DEFAULT_MERGE_BLOCK_SIZE * 3;

class DMFileBlockInputStream : public SkippableBlockInputStream
{
public:
Expand Down Expand Up @@ -62,11 +64,11 @@ class DMFileBlockInputStream : public SkippableBlockInputStream
Block read() override { return reader.read(); }

Block readWithFilter(const IColumn::Filter & filter) override { return reader.readWithFilter(filter); }
#ifndef DBMS_PUBLIC_GTEST

private:
#endif
friend class tests::DMFileMetaV2Test;
DMFileReader reader;
bool enable_data_sharing;
const bool enable_data_sharing;
};

using DMFileBlockInputStreamPtr = std::shared_ptr<DMFileBlockInputStream>;
Expand Down
11 changes: 3 additions & 8 deletions dbms/src/Storages/DeltaMerge/File/DMFileReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ namespace DB::DM
class RSOperator;
using RSOperatorPtr = std::shared_ptr<RSOperator>;

inline static const size_t DMFILE_READ_ROWS_THRESHOLD = DEFAULT_MERGE_BLOCK_SIZE * 3;

class DMFileReader
{
Expand Down Expand Up @@ -95,6 +94,7 @@ class DMFileReader

friend class MarkLoader;
friend class ColumnStream;
friend class tests::DMFileMetaV2Test;

private:
bool shouldSeek(size_t pack_id) const;
Expand Down Expand Up @@ -134,15 +134,9 @@ class DMFileReader

const UInt64 max_read_version;

/// Filters
#ifdef DBMS_PUBLIC_GTEST
public:
DMFilePackFilter pack_filter;

private:
#else
/// Filters
DMFilePackFilter pack_filter;
#endif

std::vector<size_t> skip_packs_by_column{};

Expand All @@ -162,6 +156,7 @@ class DMFileReader

LoggerPtr log;

// DataSharing
std::unique_ptr<ColumnSharingCacheMap> col_data_cache{};
std::unordered_map<ColId, bool> last_read_from_cache{};
};
Expand Down
13 changes: 9 additions & 4 deletions dbms/src/Storages/DeltaMerge/tests/gtest_dm_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ class DMFileMetaV2Test : public DB::base::TiFlashStorageTestBasic
ASSERT_EQ(n, s.size());
}

static std::vector<UInt8> & getReaderUsePacks(DMFileBlockInputStreamPtr & stream)
{
return stream->reader.pack_filter.getUsePacks();
}

protected:
std::unique_ptr<DMContext> dm_context{};
/// all these var live as ref in dm_context
Expand Down Expand Up @@ -793,7 +798,7 @@ try
auto stream
= builder.setColumnCache(column_cache)
.build(dm_file, *cols, RowKeyRanges{RowKeyRange::newAll(false, 1)}, std::make_shared<ScanContext>());
auto & use_packs = stream->reader.pack_filter.getUsePacks();
auto & use_packs = getReaderUsePacks(stream);
use_packs[1] = false;
stream->skipNextBlock();
use_packs[1] = true;
Expand All @@ -817,7 +822,7 @@ try
= builder.setColumnCache(column_cache)
.enableCleanRead(false, true, false, std::numeric_limits<UInt64>::max())
.build(dm_file, *cols, RowKeyRanges{RowKeyRange::newAll(false, 1)}, std::make_shared<ScanContext>());
auto & use_packs = stream->reader.pack_filter.getUsePacks();
auto & use_packs = getReaderUsePacks(stream);
use_packs[1] = false;
// let next_pack_id = 1
stream->skipNextBlock();
Expand Down Expand Up @@ -1012,7 +1017,7 @@ try
auto stream
= builder.setColumnCache(column_cache)
.build(dm_file, *cols, RowKeyRanges{RowKeyRange::newAll(false, 1)}, std::make_shared<ScanContext>());
auto & use_packs = stream->reader.pack_filter.getUsePacks();
auto & use_packs = getReaderUsePacks(stream);
use_packs[1] = false;
stream->skipNextBlock();
use_packs[1] = true;
Expand All @@ -1030,7 +1035,7 @@ try
= builder.setColumnCache(column_cache)
.enableCleanRead(false, true, false, std::numeric_limits<UInt64>::max())
.build(dm_file, *cols, RowKeyRanges{RowKeyRange::newAll(false, 1)}, std::make_shared<ScanContext>());
auto & use_packs = stream->reader.pack_filter.getUsePacks();
auto & use_packs = getReaderUsePacks(stream);
use_packs[1] = false;
// let next_pack_id = 1
stream->skipNextBlock();
Expand Down

0 comments on commit 5d665a7

Please sign in to comment.