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

Commit a8b1a6b

Browse files
committed
Remove unused code
1 parent 23179e1 commit a8b1a6b

File tree

2 files changed

+0
-198
lines changed

2 files changed

+0
-198
lines changed

src/include/optimizer/util.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,6 @@ void SetUnion(std::unordered_set<T> &new_set, std::unordered_set<T> &old_set) {
5151
for (auto element : old_set) new_set.insert(element);
5252
}
5353

54-
// get the column IDs evaluated in a predicate
55-
void GetPredicateColumns(const catalog::Schema *schema,
56-
expression::AbstractExpression *expression,
57-
std::vector<oid_t> &column_ids,
58-
std::vector<ExpressionType> &expr_types,
59-
std::vector<type::Value> &values,
60-
bool &index_searchable);
61-
62-
bool CheckIndexSearchable(storage::DataTable *target_table,
63-
expression::AbstractExpression *expression,
64-
std::vector<oid_t> &key_column_ids,
65-
std::vector<ExpressionType> &expr_types,
66-
std::vector<type::Value> &values, oid_t &index_id);
67-
6854
void SplitPredicates(expression::AbstractExpression *expr,
6955
std::vector<expression::AbstractExpression *> &predicates);
7056

src/optimizer/util.cpp

Lines changed: 0 additions & 184 deletions
Original file line numberDiff line numberDiff line change
@@ -23,190 +23,6 @@ namespace peloton {
2323
namespace optimizer {
2424
namespace util {
2525

26-
// TODO(boweic): This legacy function seems to be a little bit hacky and may not
27-
// work, we may want to further investigate it
28-
/**
29-
* @breif This function checks whether the current expression can enable index
30-
* scan for the statement. If it is index searchable, returns true and
31-
* set the corresponding data structures that will be used in creating
32-
* index scan node. Otherwise, returns false.
33-
*
34-
* @return Return if the current table is index-searchable
35-
*/
36-
bool CheckIndexSearchable(storage::DataTable *target_table,
37-
expression::AbstractExpression *expression,
38-
std::vector<oid_t> &key_column_ids,
39-
std::vector<ExpressionType> &expr_types,
40-
std::vector<type::Value> &values, oid_t &index_id) {
41-
bool index_searchable = false;
42-
index_id = 0;
43-
44-
// column predicates between the tuple value and the constant in the where
45-
// clause
46-
std::vector<oid_t> predicate_column_ids = {};
47-
std::vector<ExpressionType> predicate_expr_types;
48-
std::vector<type::Value> predicate_values;
49-
50-
if (expression != NULL) {
51-
index_searchable = true;
52-
53-
LOG_TRACE("Getting predicate columns");
54-
GetPredicateColumns(target_table->GetSchema(), expression,
55-
predicate_column_ids, predicate_expr_types,
56-
predicate_values, index_searchable);
57-
LOG_TRACE("Finished Getting predicate columns");
58-
59-
if (index_searchable == true) {
60-
index_searchable = false;
61-
62-
// Loop through the indexes to find to most proper one (if any)
63-
int max_columns = 0;
64-
int index_index = 0;
65-
for (auto &column_set : target_table->GetIndexColumns()) {
66-
int matched_columns = 0;
67-
for (auto column_id : predicate_column_ids)
68-
if (column_set.find(column_id) != column_set.end()) matched_columns++;
69-
if (matched_columns > max_columns) {
70-
index_searchable = true;
71-
index_id = index_index;
72-
max_columns = matched_columns;
73-
}
74-
index_index++;
75-
}
76-
}
77-
}
78-
79-
if (!index_searchable) {
80-
LOG_DEBUG("No suitable index for table '%s' exists. Skipping...",
81-
target_table->GetName().c_str());
82-
return (false);
83-
}
84-
85-
// Prepares arguments for the index scan plan
86-
auto index = target_table->GetIndex(index_id);
87-
88-
// Check whether the index is visible
89-
// This is for the IndexTuner demo
90-
if (index->GetMetadata()->GetVisibility() == false) {
91-
LOG_DEBUG("Index '%s.%s' is not visible. Skipping...",
92-
target_table->GetName().c_str(), index->GetName().c_str());
93-
return (false);
94-
}
95-
96-
auto index_columns = target_table->GetIndexColumns()[index_id];
97-
int column_idx = 0;
98-
for (auto column_id : predicate_column_ids) {
99-
if (index_columns.find(column_id) != index_columns.end()) {
100-
key_column_ids.push_back(column_id);
101-
expr_types.push_back(predicate_expr_types[column_idx]);
102-
values.push_back(predicate_values[column_idx]);
103-
LOG_TRACE("Adding for IndexScanDesc: id(%d), expr(%s), values(%s)",
104-
column_id, ExpressionTypeToString(*expr_types.rbegin()).c_str(),
105-
(*values.rbegin()).GetInfo().c_str());
106-
}
107-
column_idx++;
108-
}
109-
110-
return true;
111-
}
112-
113-
/**
114-
* @breif This function replaces all COLUMN_REF expressions with TupleValue
115-
* expressions
116-
*/
117-
void GetPredicateColumns(const catalog::Schema *schema,
118-
expression::AbstractExpression *expression,
119-
std::vector<oid_t> &column_ids,
120-
std::vector<ExpressionType> &expr_types,
121-
std::vector<type::Value> &values,
122-
bool &index_searchable) {
123-
// For now, all conjunctions should be AND when using index scan.
124-
if (expression->GetExpressionType() == ExpressionType::CONJUNCTION_OR)
125-
index_searchable = false;
126-
127-
LOG_TRACE("Expression Type --> %s",
128-
ExpressionTypeToString(expression->GetExpressionType()).c_str());
129-
if (!(expression->GetChild(0) && expression->GetChild(1))) return;
130-
LOG_TRACE("Left Type --> %s",
131-
ExpressionTypeToString(expression->GetChild(0)->GetExpressionType())
132-
.c_str());
133-
LOG_TRACE("Right Type --> %s",
134-
ExpressionTypeToString(expression->GetChild(1)->GetExpressionType())
135-
.c_str());
136-
137-
// We're only supporting comparing a column_ref to a constant/parameter for
138-
// index scan right now
139-
if (expression->GetChild(0)->GetExpressionType() ==
140-
ExpressionType::VALUE_TUPLE) {
141-
auto right_type = expression->GetChild(1)->GetExpressionType();
142-
if (right_type == ExpressionType::VALUE_CONSTANT ||
143-
right_type == ExpressionType::VALUE_PARAMETER) {
144-
auto expr = (expression::TupleValueExpression *)expression->GetChild(0);
145-
std::string col_name(expr->GetColumnName());
146-
LOG_TRACE("Column name: %s", col_name.c_str());
147-
auto column_id = schema->GetColumnID(col_name);
148-
column_ids.push_back(column_id);
149-
expr_types.push_back(expression->GetExpressionType());
150-
151-
if (right_type == ExpressionType::VALUE_CONSTANT) {
152-
values.push_back(
153-
reinterpret_cast<expression::ConstantValueExpression *>(
154-
expression->GetModifiableChild(1))
155-
->GetValue());
156-
LOG_TRACE("Value Type: %d",
157-
static_cast<int>(
158-
reinterpret_cast<expression::ConstantValueExpression *>(
159-
expression->GetModifiableChild(1))
160-
->GetValueType()));
161-
} else
162-
values.push_back(
163-
type::ValueFactory::GetParameterOffsetValue(
164-
reinterpret_cast<expression::ParameterValueExpression *>(
165-
expression->GetModifiableChild(1))
166-
->GetValueIdx())
167-
.Copy());
168-
LOG_TRACE("Parameter offset: %s", (*values.rbegin()).GetInfo().c_str());
169-
}
170-
} else if (expression->GetChild(1)->GetExpressionType() ==
171-
ExpressionType::VALUE_TUPLE) {
172-
auto left_type = expression->GetChild(0)->GetExpressionType();
173-
if (left_type == ExpressionType::VALUE_CONSTANT ||
174-
left_type == ExpressionType::VALUE_PARAMETER) {
175-
auto expr = (expression::TupleValueExpression *)expression->GetChild(1);
176-
std::string col_name(expr->GetColumnName());
177-
LOG_TRACE("Column name: %s", col_name.c_str());
178-
auto column_id = schema->GetColumnID(col_name);
179-
LOG_TRACE("Column id: %d", column_id);
180-
column_ids.push_back(column_id);
181-
expr_types.push_back(expression->GetExpressionType());
182-
183-
if (left_type == ExpressionType::VALUE_CONSTANT) {
184-
values.push_back(
185-
reinterpret_cast<expression::ConstantValueExpression *>(
186-
expression->GetModifiableChild(1))
187-
->GetValue());
188-
LOG_TRACE("Value Type: %d",
189-
static_cast<int>(
190-
reinterpret_cast<expression::ConstantValueExpression *>(
191-
expression->GetModifiableChild(0))
192-
->GetValueType()));
193-
} else
194-
values.push_back(
195-
type::ValueFactory::GetParameterOffsetValue(
196-
reinterpret_cast<expression::ParameterValueExpression *>(
197-
expression->GetModifiableChild(0))
198-
->GetValueIdx())
199-
.Copy());
200-
LOG_TRACE("Parameter offset: %s", (*values.rbegin()).GetInfo().c_str());
201-
}
202-
} else {
203-
GetPredicateColumns(schema, expression->GetModifiableChild(0), column_ids,
204-
expr_types, values, index_searchable);
205-
GetPredicateColumns(schema, expression->GetModifiableChild(1), column_ids,
206-
expr_types, values, index_searchable);
207-
}
208-
}
209-
21026
/**
21127
* @brief Extract single table precates and multi-table predicates from the expr
21228
*

0 commit comments

Comments
 (0)