本文整理汇总了C++中Group::AddExpression方法的典型用法代码示例。如果您正苦于以下问题:C++ Group::AddExpression方法的具体用法?C++ Group::AddExpression怎么用?C++ Group::AddExpression使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Group
的用法示例。
在下文中一共展示了Group::AddExpression方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddNewGroup
GroupExpression *Memo::InsertExpression(std::shared_ptr<GroupExpression> gexpr,
GroupID target_group, bool enforced) {
// If leaf, then just return
if (gexpr->Op().GetType() == OpType::Leaf) {
const LeafOperator *leaf = gexpr->Op().As<LeafOperator>();
PELOTON_ASSERT(target_group == UNDEFINED_GROUP ||
target_group == leaf->origin_group);
gexpr->SetGroupID(leaf->origin_group);
return nullptr;
}
// Lookup in hash table
auto it = group_expressions_.find(gexpr.get());
if (it != group_expressions_.end()) {
gexpr->SetGroupID((*it)->GetGroupID());
return *it;
} else {
group_expressions_.insert(gexpr.get());
// New expression, so try to insert into an existing group or
// create a new group if none specified
GroupID group_id;
if (target_group == UNDEFINED_GROUP) {
group_id = AddNewGroup(gexpr);
} else {
group_id = target_group;
}
Group *group = GetGroupByID(group_id);
group->AddExpression(gexpr, enforced);
return gexpr.get();
}
}
示例2: InsertExpression
bool Memo::InsertExpression(std::shared_ptr<GroupExpression> gexpr,
GroupID target_group)
{
// If leaf, then just return
if (gexpr->Op().type() == OpType::Leaf) {
const LeafOperator *leaf = gexpr->Op().as<LeafOperator>();
assert(target_group == UNDEFINED_GROUP ||
target_group == leaf->origin_group);
gexpr->SetGroupID(leaf->origin_group);
return false;
}
// Lookup in hash table
auto it = group_expressions.find(gexpr.get());
bool new_expression;
if (it != group_expressions.end()) {
new_expression = false;
assert(target_group == UNDEFINED_GROUP ||
target_group == (*it)->GetGroupID());
gexpr->SetGroupID((*it)->GetGroupID());
} else {
new_expression = true;
group_expressions.insert(gexpr.get());
// New expression, so try to insert into an existing group or
// create a new group if none specified
GroupID group_id;
if (target_group == UNDEFINED_GROUP) {
group_id = AddNewGroup();
} else {
group_id = target_group;
}
Group *group = GetGroupByID(group_id);
group->AddExpression(gexpr);
}
return new_expression;
}