Skip to content

Commit

Permalink
[refactor](jni) unified jni framework for jdbc catalog (apache#26317)
Browse files Browse the repository at this point in the history
This commit overhauls the JDBC connector logic within our project, transitioning from the previous mechanism of fetching data through JNI calls for individual ResultSet items to a more efficient and unified approach using the VectorTable data structure.
  • Loading branch information
zy-kkk authored Nov 13, 2023
1 parent 5a7c0ec commit 2f32a72
Show file tree
Hide file tree
Showing 7 changed files with 873 additions and 2,402 deletions.
26 changes: 1 addition & 25 deletions be/src/vec/exec/scan/new_jdbc_scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,25 +171,13 @@ Status NewJdbcScanner::_get_block_impl(RuntimeState* state, Block* block, bool*
return Status::OK();
}

auto column_size = _tuple_desc->slots().size();
std::vector<MutableColumnPtr> columns(column_size);
bool mem_reuse = block->mem_reuse();
// only empty block should be here
DCHECK(block->rows() == 0);

do {
RETURN_IF_CANCELLED(state);

columns.resize(column_size);
for (auto i = 0; i < column_size; i++) {
if (mem_reuse) {
columns[i] = std::move(*block->get_by_position(i).column).mutate();
} else {
columns[i] = _tuple_desc->slots()[i]->get_empty_mutable_column();
}
}

RETURN_IF_ERROR(_jdbc_connector->get_next(&_jdbc_eos, columns, block, state->batch_size()));
RETURN_IF_ERROR(_jdbc_connector->get_next(&_jdbc_eos, block, state->batch_size()));

if (_jdbc_eos == true) {
if (block->rows() == 0) {
Expand All @@ -199,18 +187,6 @@ Status NewJdbcScanner::_get_block_impl(RuntimeState* state, Block* block, bool*
break;
}

// Before really use the Block, must clear other ptr of column in block
// So here need do std::move and clear in `columns`
if (!mem_reuse) {
int column_index = 0;
for (const auto slot_desc : _tuple_desc->slots()) {
block->insert(ColumnWithTypeAndName(std::move(columns[column_index++]),
slot_desc->get_data_type_ptr(),
slot_desc->col_name()));
}
} else {
columns.clear();
}
VLOG_ROW << "NewJdbcScanNode output rows: " << block->rows();
} while (block->rows() == 0 && !(*eof));
return Status::OK();
Expand Down
Loading

0 comments on commit 2f32a72

Please sign in to comment.