Skip to content

Commit

Permalink
simplify group by
Browse files Browse the repository at this point in the history
  • Loading branch information
liulx20 committed Jan 19, 2025
1 parent b67c292 commit ee70ec1
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 70 deletions.
66 changes: 1 addition & 65 deletions flex/engines/graph_db/runtime/execute/ops/retrieve/group_by.cc
Original file line number Diff line number Diff line change
Expand Up @@ -215,29 +215,6 @@ struct _KeyBuilder {
std::move(exprs));
return _KeyBuilder<I - 1, SLVertexWrapper, EXPR...>::make_sp_key(
ctx, tag_alias, std::move(new_exprs));
} else if (vertex_col->vertex_column_type() ==
VertexColumnType::kMultiple) {
auto typed_vertex_col =
std::dynamic_pointer_cast<MLVertexColumn>(vertex_col);
MLVertexWrapper<decltype(*typed_vertex_col)> wrapper(
*typed_vertex_col);
auto new_exprs = std::tuple_cat(std::make_tuple(std::move(wrapper)),
std::move(exprs));
return _KeyBuilder<I - 1,
MLVertexWrapper<decltype(*typed_vertex_col)>,
EXPR...>::make_sp_key(ctx, tag_alias,
std::move(new_exprs));
} else {
auto typed_vertex_col =
std::dynamic_pointer_cast<MSVertexColumn>(vertex_col);
MLVertexWrapper<decltype(*typed_vertex_col)> wrapper(
*typed_vertex_col);
auto new_exprs = std::tuple_cat(std::make_tuple(std::move(wrapper)),
std::move(exprs));
return _KeyBuilder<I - 1,
MLVertexWrapper<decltype(*typed_vertex_col)>,
EXPR...>::make_sp_key(ctx, tag_alias,
std::move(new_exprs));
}

} else if (col->column_type() == ContextColumnType::kValue) {
Expand All @@ -257,15 +234,6 @@ struct _KeyBuilder {
return _KeyBuilder<I - 1, ValueWrapper<int32_t>,
EXPR...>::make_sp_key(ctx, tag_alias,
std::move(new_exprs));
} else if (col->elem_type() == RTAnyType::kStringValue) {
ValueWrapper<std::string_view> wrapper(
*dynamic_cast<const ValueColumn<std::string_view>*>(col.get()));
auto new_exprs = std::tuple_cat(std::make_tuple(std::move(wrapper)),
std::move(exprs));
return _KeyBuilder<I - 1, ValueWrapper<std::string_view>,
EXPR...>::make_sp_key(ctx, tag_alias,
std::move(new_exprs));

} else {
return nullptr;
}
Expand All @@ -290,27 +258,6 @@ struct KeyBuilder {
auto new_exprs = std::make_tuple<SLVertexWrapper>(std::move(wrapper));
return _KeyBuilder<I - 1, SLVertexWrapper>::make_sp_key(
ctx, tag_alias, std::move(new_exprs));
} else if (vertex_col->vertex_column_type() ==
VertexColumnType::kMultiple) {
auto typed_vertex_col =
std::dynamic_pointer_cast<MLVertexColumn>(vertex_col);
MLVertexWrapper<decltype(*typed_vertex_col)> wrapper(*typed_vertex_col);
auto new_exprs =
std::make_tuple<MLVertexWrapper<decltype(*typed_vertex_col)>>(
std::move(wrapper));
return _KeyBuilder<I - 1,
MLVertexWrapper<decltype(*typed_vertex_col)>>::
make_sp_key(ctx, tag_alias, std::move(new_exprs));
} else {
auto typed_vertex_col =
std::dynamic_pointer_cast<MSVertexColumn>(vertex_col);
MLVertexWrapper<decltype(*typed_vertex_col)> wrapper(*typed_vertex_col);
auto new_exprs =
std::make_tuple<MLVertexWrapper<decltype(*typed_vertex_col)>>(
std::move(wrapper));
return _KeyBuilder<I - 1,
MLVertexWrapper<decltype(*typed_vertex_col)>>::
make_sp_key(ctx, tag_alias, std::move(new_exprs));
}
} else if (col->column_type() == ContextColumnType::kValue) {
if (col->elem_type() == RTAnyType::kI64Value) {
Expand All @@ -327,13 +274,6 @@ struct KeyBuilder {
std::make_tuple<ValueWrapper<int32_t>>(std::move(wrapper));
return _KeyBuilder<I - 1, ValueWrapper<int32_t>>::make_sp_key(
ctx, tag_alias, std::move(new_exprs));
} else if (col->elem_type() == RTAnyType::kStringValue) {
ValueWrapper<std::string_view> wrapper(
*dynamic_cast<const ValueColumn<std::string_view>*>(col.get()));
auto new_exprs =
std::make_tuple<ValueWrapper<std::string_view>>(std::move(wrapper));
return _KeyBuilder<I - 1, ValueWrapper<std::string_view>>::make_sp_key(
ctx, tag_alias, std::move(new_exprs));
} else {
return nullptr;
}
Expand Down Expand Up @@ -1076,11 +1016,7 @@ std::pair<std::unique_ptr<IReadOperator>, ContextMeta> GroupByOprBuilder::Build(
const GraphReadInterface& graph,
const Context& ctx) -> std::unique_ptr<KeyBase> {
std::unique_ptr<KeyBase> key = nullptr;
if (mappings.size() == 3) {
key = KeyBuilder<3>::make_sp_key(ctx, mappings);
} else if (mappings.size() == 2) {
key = KeyBuilder<2>::make_sp_key(ctx, mappings);
} else if (mappings.size() == 1) {
if (mappings.size() == 1) {
key = KeyBuilder<1>::make_sp_key(ctx, mappings);
}
if (key == nullptr) {
Expand Down
5 changes: 0 additions & 5 deletions flex/engines/graph_db/runtime/execute/ops/retrieve/project.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1457,11 +1457,6 @@ ProjectOrderByOprBuilder::Build(const gs::Schema& schema,
std::move(exprs), index_set, order_by_pairs,
lower, upper, first_tuple),
ret_meta);
/*return std::make_pair(
std::make_unique<ProjectOrderByOpr>(
plan.plan(op_idx).opr().project(),
plan.plan(op_idx + 1).opr().order_by(), data_types),
ret_meta);*/
} else {
return std::make_pair(nullptr, ContextMeta());
}
Expand Down

0 comments on commit ee70ec1

Please sign in to comment.