Skip to content
This repository was archived by the owner on Sep 27, 2019. It is now read-only.

Commit 1bfd3eb

Browse files
Modify TargetIndex fetch in update_transalator.cpp
1 parent 27c017b commit 1bfd3eb

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/codegen/operator/update_translator.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#include <include/codegen/type/varchar_type.h>
1314
#include "codegen/lang/if.h"
1415
#include "codegen/proxy/storage_manager_proxy.h"
1516
#include "codegen/proxy/target_proxy.h"
@@ -41,13 +42,14 @@ UpdateTranslator::UpdateTranslator(const planner::UpdatePlan &update_plan,
4142
UpdaterProxy::GetType(GetCodeGen()));
4243
}
4344

44-
bool IsTarget(const TargetList &target_list, uint32_t index) {
45-
for (const auto &target : target_list) {
46-
if (target.first == index) {
47-
return true;
48-
}
45+
oid_t GetTargetIndex(const TargetList &target_list, uint32_t index) {
46+
oid_t target_size = target_list.size();
47+
for (oid_t i = 0; i < target_size; i++) {
48+
if (target_list[i].first == index) {
49+
return i;
50+
}
4951
}
50-
return false;
52+
return INVALID_OID;
5153
}
5254

5355
void UpdateTranslator::InitializeState() {
@@ -93,13 +95,12 @@ void UpdateTranslator::Consume(ConsumerContext &, RowBatch::Row &row) const {
9395

9496
// Collect all the column values
9597
std::vector<codegen::Value> values;
96-
for (uint32_t i = 0, target_id = 0; i < column_num; i++) {
98+
for (uint32_t i = 0; i < column_num; i++) {
9799
codegen::Value val;
98-
if (IsTarget(target_list, i)) {
99-
// Set the value for the update
100-
const auto &derived_attribute = target_list[target_id].second;
100+
uint32_t target_index = GetTargetIndex(target_list,i);
101+
if (target_index != INVALID_OID) {
102+
const auto &derived_attribute = target_list[target_index].second;
101103
val = row.DeriveValue(codegen, *derived_attribute.expr);
102-
target_id++;
103104
} else {
104105
val = row.DeriveValue(codegen, ais[i]);
105106
}

0 commit comments

Comments
 (0)