Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refine DAGStorageInterpreter #4070

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions dbms/src/Common/UniformRandomIntGenerator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once

#include <random>

namespace DB
{
template <typename IntType>
class UniformRandomIntGenerator
{
public:
/// [min, max]
UniformRandomIntGenerator(IntType min, IntType max)
: dis(std::uniform_int_distribution<IntType>(min, max))
, gen(std::default_random_engine(std::random_device{}()))
{}

IntType rand()
{
return dis(gen);
}

private:
std::uniform_int_distribution<IntType> dis;
std::default_random_engine gen;
};
} // namespace DB
13 changes: 9 additions & 4 deletions dbms/src/Flash/Coprocessor/DAGQueryBlockInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <DataStreams/PartialSortingBlockInputStream.h>
#include <DataStreams/SquashingBlockInputStream.h>
#include <DataStreams/TiRemoteBlockInputStream.h>
#include <DataStreams/UnionBlockInputStream.h>
#include <DataTypes/DataTypeNullable.h>
#include <DataTypes/DataTypesNumber.h>
#include <DataTypes/getLeastSupertype.h>
Expand Down Expand Up @@ -244,16 +243,22 @@ void DAGQueryBlockInterpreter::handleTableScan(const tipb::TableScan & ts, DAGPi
if (ts.next_read_engine() != tipb::EngineType::Local)
throw TiFlashException("Unsupported remote query.", Errors::Coprocessor::BadRequest);

DAGStorageInterpreter storage_interpreter(context, query_block.source_name, ts, max_streams);
// construct pushed down filter conditions.
std::vector<const tipb::Expr *> conditions;
if (query_block.selection)
{
for (const auto & condition : query_block.selection->selection().conditions())
conditions.push_back(&condition);
}

DAGStorageInterpreter storage_interpreter(context, query_block, ts, conditions, max_streams);
storage_interpreter.execute(pipeline);
assert(!conditions.empty());
assert(!query_block.selection_name.empty());
storage_interpreter.execute(pipeline, query_block.selection_name, conditions);
}
else
{
storage_interpreter.execute(pipeline);
}

analyzer = std::move(storage_interpreter.analyzer);

Expand Down
Loading