Skip to content

Commit b155576

Browse files
authored
fix local ddl (#257)
* Update rocksdb_scan_node.cpp fix local ddl * Update ddl_work_planner.cpp * Update full_export_node.cpp * Update access_path.cpp * Update select_manager_node.cpp * Update schema_factory.cpp * Update schema_factory.cpp
1 parent bffa7fe commit b155576

File tree

6 files changed

+27
-28
lines changed

6 files changed

+27
-28
lines changed

src/common/schema_factory.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3035,21 +3035,23 @@ int SchemaFactory::get_region_by_key(int64_t main_table_id,
30353035
template_primary.mutable_sort_index()->CopyFrom(primary->sort_index());
30363036
}
30373037
template_primary.mutable_index_conjuncts()->CopyFrom(primary->index_conjuncts());
3038-
template_primary.set_is_eq(primary->is_eq());
3039-
template_primary.set_left_field_cnt(primary->left_field_cnt());
3040-
template_primary.set_right_field_cnt(primary->right_field_cnt());
3041-
template_primary.set_left_open(primary->left_open());
3042-
template_primary.set_right_open(primary->right_open());
3043-
template_primary.set_like_prefix(primary->like_prefix());
3038+
if (primary->has_left_field_cnt() || primary->has_right_field_cnt()) {
3039+
template_primary.set_is_eq(primary->is_eq());
3040+
template_primary.set_left_field_cnt(primary->left_field_cnt());
3041+
template_primary.set_right_field_cnt(primary->right_field_cnt());
3042+
template_primary.set_left_open(primary->left_open());
3043+
template_primary.set_right_open(primary->right_open());
3044+
template_primary.set_like_prefix(primary->like_prefix());
3045+
}
30443046

30453047
std::map<int64_t, std::vector<int>> region_idx_map;
30463048
auto record_template = TableRecord::new_record(main_table_id);
30473049
int range_size = primary->ranges_size();
30483050
for (int i = 0; i < range_size; ++i) {
30493051
const auto& range = primary->ranges(i);
3050-
bool like_prefix = template_primary.has_like_prefix();
3051-
bool left_open = template_primary.has_left_open();
3052-
bool right_open = template_primary.has_right_open();
3052+
bool like_prefix = template_primary.has_like_prefix() ? template_primary.like_prefix() : range.like_prefix();
3053+
bool left_open = template_primary.has_left_open() ? template_primary.left_open() : range.left_open();
3054+
bool right_open = template_primary.has_right_open() ? template_primary.right_open() : range.right_open();
30533055
MutTableKey start;
30543056
MutTableKey end;
30553057
if (!range.left_key().empty()) {

src/exec/access_path.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ void AccessPath::calc_index_range(
508508
pos_index.set_left_open(_left_open);
509509
pos_index.set_right_open(_right_open);
510510
if (_left_field_cnt == 0 && _right_field_cnt == 0) {
511-
pos_index.clear_is_eq();//无命中条件非eq
511+
pos_index.set_is_eq(false);//无命中条件非eq
512512
pos_index.add_ranges();
513513
} else if (in_records.size() > 0) {
514514
is_possible = true;

src/exec/full_export_node.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ int FullExportNode::get_next_region_infos() {
105105
if (scan_index_info.router_index->ranges_size() == 0) {
106106
scan_index_info.router_index->add_ranges();
107107
}
108+
scan_index_info.router_index->set_left_field_cnt(index_ptr->fields.size());
109+
scan_index_info.router_index->set_left_open(false);
108110
scan_index_info.router_index->mutable_ranges(0)->set_left_key(_last_router_key);
109111
scan_index_info.router_index->mutable_ranges(0)->set_left_full(true);
110-
scan_index_info.router_index->mutable_ranges(0)->set_left_field_cnt(index_ptr->fields.size());
111-
scan_index_info.router_index->mutable_ranges(0)->set_left_open(false);
112112
scan_index_info.router_index->mutable_ranges(0)->mutable_partition_ids()->Clear();
113113
scan_index_info.router_index->mutable_ranges(0)->add_partition_ids(_current_partition);
114114
int ret = schema_factory->get_region_by_key(main_table_id,
@@ -168,14 +168,15 @@ int FullExportNode::calc_last_key(RuntimeState* state, MemRow* mem_row) {
168168
pos_index.ParseFromString(scan_index_info.raw_index);
169169
pos_index.set_index_id(main_table_id);
170170
// fullexport 非eq
171-
pos_index.clear_is_eq();
171+
pos_index.set_is_eq(false);
172172
if (pos_index.ranges_size() == 0) {
173173
pos_index.add_ranges();
174174
}
175+
pos_index.set_left_field_cnt(pri_info->fields.size());
176+
pos_index.set_left_open(true);
175177
pos_index.mutable_ranges(0)->set_left_key(key.data());
176178
pos_index.mutable_ranges(0)->set_left_full(key.get_full());
177-
pos_index.mutable_ranges(0)->set_left_field_cnt(pri_info->fields.size());
178-
pos_index.mutable_ranges(0)->set_left_open(true);
179+
179180
pos_index.mutable_ranges(0)->mutable_partition_ids()->Clear();
180181
pos_index.mutable_ranges(0)->add_partition_ids(_current_partition);
181182
pos_index.SerializeToString(&scan_index_info.raw_index);

src/exec/rocksdb_scan_node.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ int RocksdbScanNode::choose_index(RuntimeState* state) {
205205
check_memory = true;
206206
}
207207
bool has_global_param = false;
208-
if (pos_index.has_is_eq() && pos_index.has_left_field_cnt()) {
208+
if (pos_index.has_left_field_cnt() || pos_index.has_right_field_cnt()) {
209209
has_global_param = true;
210210
_is_eq = pos_index.is_eq();
211211
_like_prefix = pos_index.like_prefix();

src/exec/select_manager_node.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -737,14 +737,12 @@ int SelectManagerNode::construct_primary_possible_index(
737737
DB_FATAL("Fail to encode_key left, table:%ld", pri_info->id);
738738
return -1;
739739
}
740+
pos_index.set_is_eq(true);
740741
range->set_left_key(key.data());
741742
range->set_left_full(key.get_full());
742-
range->set_right_key(key.data());
743-
range->set_right_full(key.get_full());
744-
range->set_left_field_cnt(pri_info->fields.size());
745-
range->set_right_field_cnt(pri_info->fields.size());
746-
range->set_left_open(false);
747-
range->set_right_open(false);
743+
pos_index.set_left_field_cnt(pri_info->fields.size());
744+
pos_index.set_left_open(false);
745+
748746
range->add_partition_ids(mem_row->get_partition_id());
749747
limit_cnt --;
750748
if(!limit_cnt) {
@@ -869,14 +867,11 @@ int SelectManagerNode::construct_primary_possible_index_vectorize(
869867
DB_FATAL("Fail to encode_key left, table:%ld", pri_info->id);
870868
return -1;
871869
}
870+
pos_index.set_is_eq(true);
872871
range->set_left_key(key.data());
873872
range->set_left_full(key.get_full());
874-
range->set_right_key(key.data());
875-
range->set_right_full(key.get_full());
876-
range->set_left_field_cnt(pri_info->fields.size());
877-
range->set_right_field_cnt(pri_info->fields.size());
878-
range->set_left_open(false);
879-
range->set_right_open(false);
873+
pos_index.set_left_field_cnt(pri_info->fields.size());
874+
pos_index.set_left_open(false);
880875
// [ARROW todo] 全局索引反查partition分发
881876
// range->set_partition_id(mem_row->get_partition_id());
882877
}

src/logical_plan/ddl_work_planner.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ std::unique_ptr<ScanNode> DDLWorkPlanner::create_scan_node() {
211211
_pos_index.Clear();
212212
_pos_index.set_index_id(_table_id);
213213
auto range_index = _pos_index.add_ranges();
214+
_pos_index.set_is_eq(false);
214215
_pos_index.set_left_field_cnt(_field_num);
215216
_pos_index.set_left_open(true);
216217
if (_start_key != "") {

0 commit comments

Comments
 (0)