Skip to content

Commit

Permalink
feat(format): format code with clang-format-10
Browse files Browse the repository at this point in the history
  • Loading branch information
hustjieke committed Oct 20, 2022
1 parent 76393a2 commit 764d5be
Show file tree
Hide file tree
Showing 17 changed files with 92 additions and 86 deletions.
2 changes: 1 addition & 1 deletion storage/tianmu/core/aggregation_algorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void AggregationAlgorithm::Aggregate(bool just_distinct, int64_t &limit, int64_t
continue;
}
if ((!just_distinct && cur_a.mode != common::ColOperation::GROUP_BY) || // aggregation
(just_distinct && cur_a.alias == nullptr)) { // special case: hidden column for DISTINCT
(just_distinct && cur_a.alias == nullptr)) { // special case: hidden column for DISTINCT
bool already_added = false;
for (uint j = 0; j < i; j++) {
if (*(t->GetAttrP(j)) == cur_a) {
Expand Down
4 changes: 2 additions & 2 deletions storage/tianmu/core/compiled_query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -599,8 +599,8 @@ void CompiledQuery::AddColumn(AttrID &a_out, const TableID &t1, CQTerm e1, commo
std::strcpy(s.alias, alias);
} else
s.alias = nullptr;
s.n1 = distinct ? 1 : 0;
steps.push_back(s);
s.n1 = distinct ? 1 : 0;
steps.push_back(s);
if (op == common::ColOperation::GROUP_BY) steps_group_by_cols.push_back(s);
}

Expand Down
7 changes: 4 additions & 3 deletions storage/tianmu/core/condition_encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -758,9 +758,10 @@ void ConditionEncoder::EncodeIfPossible(Descriptor &desc, bool for_rough_query,
vcolumn::ExpressionColumn *vcec = dynamic_cast<vcolumn::ExpressionColumn *>(desc.attr.vc);
if (vcec == nullptr && (vcsc == nullptr || vcsc->GetVarMap()[0].GetTabPtr()->TableType() != TType::TABLE)) return;
if (vcec != nullptr) {
encode_now = (vcec->ExactlyOneLookup() &&
(desc.op == common::Operator::O_IS_NULL || desc.op == common::Operator::O_NOT_NULL ||
(desc.val1.vc && desc.val1.vc->IsConst() && (desc.val2.vc == nullptr || desc.val2.vc->IsConst()))));
encode_now =
(vcec->ExactlyOneLookup() &&
(desc.op == common::Operator::O_IS_NULL || desc.op == common::Operator::O_NOT_NULL ||
(desc.val1.vc && desc.val1.vc->IsConst() && (desc.val2.vc == nullptr || desc.val2.vc->IsConst()))));
} else {
encode_now = (desc.IsType_AttrValOrAttrValVal() || desc.IsType_AttrMultiVal() ||
desc.op == common::Operator::O_IS_NULL || desc.op == common::Operator::O_NOT_NULL) &&
Expand Down
60 changes: 30 additions & 30 deletions storage/tianmu/core/descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -658,38 +658,38 @@ to that effect.
*/
const QueryOperator *Descriptor::CreateQueryOperator(common::Operator type) const {
const char *string_rep[static_cast<int>(common::Operator::OPERATOR_ENUM_COUNT)] = {
"=", // common::Operator::O_EQ
"=ALL", // common::Operator::O_EQ_ALL
"=ANY", // common::Operator::O_EQ_ANY
"<>", // common::Operator::O_NOT_EQ
"<>ALL", // common::Operator::O_NOT_EQ_ALL
"<>ANY", // common::Operator::O_NOT_EQ_ANY
"<", // common::Operator::O_LESS
"<ALL", // common::Operator::O_LESS_ALL
"<ANY", // common::Operator::O_LESS_ANY
">", // common::Operator::O_MORE
">ALL", // common::Operator::O_MORE_ALL
">ANY", // common::Operator::O_MORE_ANY
"<=", // common::Operator::O_LESS_EQ
"<=ALL", // common::Operator::O_LESS_EQ_ALL
"<=ANY", // common::Operator::O_LESS_EQ_ANY
">=", // common::Operator::O_MORE_EQ
">=ALL", // common::Operator::O_MORE_EQ_ALL
">=ANY", // common::Operator::O_MORE_EQ_ANY
"=", // common::Operator::O_EQ
"=ALL", // common::Operator::O_EQ_ALL
"=ANY", // common::Operator::O_EQ_ANY
"<>", // common::Operator::O_NOT_EQ
"<>ALL", // common::Operator::O_NOT_EQ_ALL
"<>ANY", // common::Operator::O_NOT_EQ_ANY
"<", // common::Operator::O_LESS
"<ALL", // common::Operator::O_LESS_ALL
"<ANY", // common::Operator::O_LESS_ANY
">", // common::Operator::O_MORE
">ALL", // common::Operator::O_MORE_ALL
">ANY", // common::Operator::O_MORE_ANY
"<=", // common::Operator::O_LESS_EQ
"<=ALL", // common::Operator::O_LESS_EQ_ALL
"<=ANY", // common::Operator::O_LESS_EQ_ANY
">=", // common::Operator::O_MORE_EQ
">=ALL", // common::Operator::O_MORE_EQ_ALL
">=ANY", // common::Operator::O_MORE_EQ_ANY
"IS nullptr", // common::Operator::O_IS_NULL
"IS NOT nullptr", // common::Operator::O_NOT_NULL
"BET.", // common::Operator::O_BETWEEN
"NOT BET.", // common::Operator::O_NOT_BETWEEN
"LIKE", // common::Operator::O_LIKE
"NOT LIKE", // common::Operator::O_NOT_LIKE
"IN", // common::Operator::O_IN
"NOT IN", // common::Operator::O_NOT_IN
"EXISTS", // common::Operator::O_EXISTS
"NOT EXISTS", // common::Operator::O_NOT_EXISTS
"FALSE", // common::Operator::O_FALSE
"TRUE", // common::Operator::O_TRUE
"ESCAPE", // common::Operator::O_ESCAPE
"OR TREE" // common::Operator::O_OR_TREE
"BET.", // common::Operator::O_BETWEEN
"NOT BET.", // common::Operator::O_NOT_BETWEEN
"LIKE", // common::Operator::O_LIKE
"NOT LIKE", // common::Operator::O_NOT_LIKE
"IN", // common::Operator::O_IN
"NOT IN", // common::Operator::O_NOT_IN
"EXISTS", // common::Operator::O_EXISTS
"NOT EXISTS", // common::Operator::O_NOT_EXISTS
"FALSE", // common::Operator::O_FALSE
"TRUE", // common::Operator::O_TRUE
"ESCAPE", // common::Operator::O_ESCAPE
"OR TREE" // common::Operator::O_OR_TREE
};

return new QueryOperator(type, string_rep[static_cast<int>(type)]);
Expand Down
2 changes: 1 addition & 1 deletion storage/tianmu/core/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@ static void HandleDelayedLoad(int tid, std::vector<std::unique_ptr<char[]>> &vec
// stonedb8 end

thd->set_catalog({0, 1}); // TIANMU UPGRADE
thd->set_db({nullptr, 0}); /* will free the current database */
thd->set_db({nullptr, 0}); /* will free the current database */
thd->reset_query();
thd->get_stmt_da()->set_overwrite_status(true);
thd->is_error() ? trans_rollback_stmt(thd) : trans_commit_stmt(thd);
Expand Down
16 changes: 8 additions & 8 deletions storage/tianmu/core/physical_column.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,16 +206,16 @@ class PhysicalColumn : public Column {
}
virtual int64_t RoughMin(Filter *f = nullptr,
common::RSValue *rf = nullptr) = 0; // for numerical: best
// rough approximation of
// min for a given filter
// (or global min if filter
// is nullptr)
// rough approximation of
// min for a given filter
// (or global min if filter
// is nullptr)
virtual int64_t RoughMax(Filter *f = nullptr,
common::RSValue *rf = nullptr) = 0; // for numerical: best
// rough approximation of
// max for a given filter
// (or global max if filter
// is nullptr)
// rough approximation of
// max for a given filter
// (or global max if filter
// is nullptr)
virtual void GetTextStat(types::TextStat &s, [[maybe_unused]] Filter *f = nullptr) { s.Invalidate(); }
virtual double RoughSelectivity() { return 1; }
/*! \brief Return true if the column (filtered) contain only non-null distinct
Expand Down
12 changes: 8 additions & 4 deletions storage/tianmu/core/query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,8 @@ TempTable *Query::Preexecute(CompiledQuery &qu, ResultSender *sender, [[maybe_un
ta[-step.t1.n - 1] = TempTable::Create(*(TempTable *)ta[-step.t2.n - 1].get(), false);
if (IsRoughQuery()) {
if (step.t3.n == common::NULL_VALUE_32)
((TempTable *)ta[-step.t1.n - 1].get())->RoughUnion(nullptr, qu.IsResultTable(step.t1) ? sender : nullptr);
((TempTable *)ta[-step.t1.n - 1].get())
->RoughUnion(nullptr, qu.IsResultTable(step.t1) ? sender : nullptr);
else
((TempTable *)ta[-step.t1.n - 1].get())
->RoughUnion((TempTable *)ta[-step.t3.n - 1].get(), qu.IsResultTable(step.t1) ? sender : nullptr);
Expand Down Expand Up @@ -943,7 +944,8 @@ Query_route_to Query::Item2CQTerm(Item *an_arg, CQTerm &term, const TableID &tmp
dynamic_cast<Item_in_subselect *>(item_subs) != nullptr) {
if (negative) {
MarkWithAll(*oper_for_subselect);
if (dynamic_cast<Item_in_subselect *>(item_subs) != nullptr && *oper_for_subselect == common::Operator::O_IN)
if (dynamic_cast<Item_in_subselect *>(item_subs) != nullptr &&
*oper_for_subselect == common::Operator::O_IN)
*oper_for_subselect = common::Operator::O_EQ_ALL;
} else {
MarkWithAny(*oper_for_subselect);
Expand Down Expand Up @@ -1304,7 +1306,8 @@ CondID Query::ConditionNumberFromComparison(Item *conds, const TableID &tmp_tabl
}
} else {
if (Item2CQTerm(an_arg, terms[i], tmp_table, filter_type,
an_arg->type() == Item::SUBSELECT_ITEM ? negative : false, nullptr, &op) == Query_route_to::TO_MYSQL)
an_arg->type() == Item::SUBSELECT_ITEM ? negative : false, nullptr,
&op) == Query_route_to::TO_MYSQL)
return CondID(-1);
if ((op == common::Operator::O_LIKE || op == common::Operator::O_NOT_LIKE) &&
!(an_arg->data_type() == MYSQL_TYPE_VARCHAR || an_arg->data_type() == MYSQL_TYPE_STRING ||
Expand Down Expand Up @@ -1342,7 +1345,8 @@ CondID Query::ConditionNumberFromNaked(Item *conds, const TableID &tmp_table, Co
CondID filter;
CQTerm naked_col;
if (Item2CQTerm(conds, naked_col, tmp_table, filter_type,
conds->type() == Item::SUBSELECT_ITEM ? (and_me_filter != nullptr) : false) == Query_route_to::TO_MYSQL)
conds->type() == Item::SUBSELECT_ITEM ? (and_me_filter != nullptr) : false) ==
Query_route_to::TO_MYSQL)
return CondID(-1);

bool is_string = conds->result_type() == STRING_RESULT;
Expand Down
3 changes: 2 additions & 1 deletion storage/tianmu/core/query_compile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,8 @@ Query_route_to Query::Compile(CompiledQuery *compiled_query, Query_block *select
fields->push_back(field_for_subselect);
}
bool aggr_used = false;
if (AddFields(*fields, tmp_table, group != nullptr, col_count, ignore_minmax, aggr_used) == Query_route_to::TO_MYSQL)
if (AddFields(*fields, tmp_table, group != nullptr, col_count, ignore_minmax, aggr_used) ==
Query_route_to::TO_MYSQL)
throw CompilationError();

if (AddGroupByFields(group, tmp_table) == Query_route_to::TO_MYSQL) throw CompilationError();
Expand Down
2 changes: 1 addition & 1 deletion storage/tianmu/core/rcattr_exeq_rs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ uint64_t RCAttr::ExactDistinctVals(Filter *f) // provide the exact number of di
// possible, or common::NULL_VALUE_64
{
if (f == nullptr) // no exact information about tuples => nothing can be
// determined for sure
// determined for sure
return common::NULL_VALUE_64;
LoadPackInfo();
if (Type().IsLookup() && !types::RequiresUTFConversions(GetCollation()) && f->IsFull()) return RoughMax(nullptr) + 1;
Expand Down
2 changes: 1 addition & 1 deletion storage/tianmu/core/rcattr_exqp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ bool RCAttr::IsDistinct(Filter *f) {
MEASURE_FET("RCAttr::IsDistinct(...)");
if (ct.IsLookup() && types::RequiresUTFConversions(GetCollation())) return false;
if (PhysicalColumn::IsDistinct() == common::RSValue::RS_ALL) { // = is_unique_updated && is_unique
if (f == nullptr) return (NumOfNulls() == 0); // no nulls at all, and is_unique => distinct
if (f == nullptr) return (NumOfNulls() == 0); // no nulls at all, and is_unique => distinct
LoadPackInfo();
for (uint b = 0; b < SizeOfPack(); b++)
if (!f->IsEmpty(b) && get_dpn(b).nn > 0) // any null in nonempty pack?
Expand Down
2 changes: 1 addition & 1 deletion storage/tianmu/core/sorter3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ void SorterMultiPass::InitHeap() {

SorterMultiPass::Keyblock SorterMultiPass::GetFromBlock(int b, bool &reloaded) {
if (blocks[b].read_offset == -2) return SorterMultiPass::Keyblock(-1, nullptr, 0); // end of block
if (blocks[b].read_offset == -1) { // new buffer, to be read
if (blocks[b].read_offset == -1) { // new buffer, to be read
if (blocks[b].file_offset > 0) { // preserve the last row before overwriting the whole buffer
std::memcpy(last_row, blocks[b].block_start + blocks[b].buf_size - total_bytes, total_bytes);
reloaded = true;
Expand Down
8 changes: 4 additions & 4 deletions storage/tianmu/core/temp_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,10 @@ class TempTable : public JustATable {

bool OrderByAndMaterialize(std::vector<SortDescriptor> &ord, int64_t limit, int64_t offset,
ResultSender *sender = nullptr); // Sort data contained in
// ParameterizedFilter by using some
// attributes (usually specified by
// AddOrder, but in general -
// arbitrary)
// ParameterizedFilter by using some
// attributes (usually specified by
// AddOrder, but in general -
// arbitrary)
// just materialize as SELECT *
void FillMaterializedBuffers(int64_t local_limit, int64_t local_offset, ResultSender *sender, bool pagewise);

Expand Down
10 changes: 4 additions & 6 deletions storage/tianmu/handler/ha_my_tianmu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static bool Tianmu_SetStatementAllowed(THD *thd, Query_expression *qe) {
}

void ha_my_tianmu_update_and_store_col_comment(TABLE *table, int field_id, Field *source_field, int source_field_id,
CHARSET_INFO *cs) {
CHARSET_INFO *cs) {
try {
ha_rcengine_->UpdateAndStoreColumnComment(table, field_id, source_field, source_field_id, cs);
} catch (std::exception &e) {
Expand All @@ -78,9 +78,8 @@ void ha_my_tianmu_update_and_store_col_comment(TABLE *table, int field_id, Field
}
}

Query_route_to ha_my_tianmu_query(THD *thd, Query_expression *qe, Query_result *&result,
ulong setup_tables_done_option, int &res, int &optimize_after_tianmu,
int &tianmu_free_join, int with_insert) {
Query_route_to ha_my_tianmu_query(THD *thd, Query_expression *qe, Query_result *&result, ulong setup_tables_done_option,
int &res, int &optimize_after_tianmu, int &tianmu_free_join, int with_insert) {
Query_route_to ret = Query_route_to::TO_TIANMU;
try {
// ret is introduced here because in case of some exceptions
Expand All @@ -93,8 +92,7 @@ Query_route_to ha_my_tianmu_query(THD *thd, Query_expression *qe, Query_result *
ret = ha_rcengine_->Handle_Query(thd, qe, result, setup_tables_done_option, res, optimize_after_tianmu,
tianmu_free_join, with_insert);

if (ret == handler::Query_route_to::TO_MYSQL && AtLeastOneTianmuTableInvolved(qe) &&
ForbiddenMySQLQueryPath(qe)) {
if (ret == handler::Query_route_to::TO_MYSQL && AtLeastOneTianmuTableInvolved(qe) && ForbiddenMySQLQueryPath(qe)) {
my_message(static_cast<int>(common::ErrorCode::UNKNOWN_ERROR),
"The query includes syntax that is not supported by the storage engine. "
"Either restructure the query with supported syntax, or enable the MySQL core::Query Path "
Expand Down
6 changes: 3 additions & 3 deletions storage/tianmu/handler/ha_my_tianmu.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ enum class Query_route_to : unsigned int { TO_MYSQL = 0, TO_TIANMU = 1 };

// processing the queries which routed to Tianmu Engine.
Query_route_to ha_my_tianmu_query(THD *thd, Query_expression *qe, Query_result *&result_output,
ulong setup_tables_done_option, int &res, int &optimize_after_tianmu,
int &tianmu_free_join, int with_insert = false);
ulong setup_tables_done_option, int &res, int &optimize_after_tianmu,
int &tianmu_free_join, int with_insert = false);

// update the comment for a column.
void ha_my_tianmu_update_and_store_col_comment(TABLE *table, int field_id, Field *source_field, int source_field_id,
CHARSET_INFO *cs);
CHARSET_INFO *cs);
// processing the load operation.
bool ha_my_tianmu_load(THD *thd, sql_exchange *ex, TABLE_LIST *table_list, void *arg);

Expand Down
Loading

0 comments on commit 764d5be

Please sign in to comment.