Skip to content

Commit

Permalink
[OPPRO-173] Make batch size configurable (facebookincubator#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
rui-mo authored and zhejiangxiaomai committed Aug 9, 2022
1 parent 7747abc commit 726fd3d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 7 additions & 1 deletion velox/exec/TableScan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ TableScan::TableScan(
"TableScan"),
tableHandle_(tableScanNode->tableHandle()),
columnHandles_(tableScanNode->assignments()),
driverCtx_(driverCtx) {
driverCtx_(driverCtx),
preferredBatchSize_(driverCtx->queryConfig().preferredOutputBatchSize()) {
connector_ = connector::getConnector(tableHandle_->connectorId());
}

Expand Down Expand Up @@ -138,6 +139,11 @@ bool TableScan::isFinished() {
}

void TableScan::setBatchSize() {
if (preferredBatchSize_ != 1024) {
// Not the default value.
readBatchSize_ = preferredBatchSize_;
return;
}
constexpr int64_t kMB = 1 << 20;
auto estimate = dataSource_->estimatedRowSize();
if (estimate == connector::DataSource::kUnknownRowSize) {
Expand Down
2 changes: 2 additions & 0 deletions velox/exec/TableScan.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ class TableScan : public SourceOperator {
std::unordered_map<column_index_t, std::shared_ptr<common::Filter>>
pendingDynamicFilters_;
int32_t readBatchSize_{kDefaultBatchSize};
// A preferred batch size from configuration.
uint32_t preferredBatchSize_;

// String shown in ExceptionContext inside DataSource and LazyVector loading.
std::string debugString_;
Expand Down

0 comments on commit 726fd3d

Please sign in to comment.