-
Notifications
You must be signed in to change notification settings - Fork 623
Syntax-Based Query Rewriter, Code Review #2 #1495
base: master
Are you sure you want to change the base?
Changes from 9 commits
dec8194
1be43be
f4d4e8f
209c46a
17de3b9
3266f29
721323c
5caae6d
e3ac1ba
4984dbf
787cdfd
23a7fbf
da839e8
a0315c3
010407b
1d9bdd1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,6 +111,24 @@ class AbstractExpression : public Printable { | |
children_[index].reset(expr); | ||
} | ||
|
||
void ClearChildren() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great documentation for this function and how it fits in with the query rewriting process as a whole. Is this function only used once during the rewriting phase for a single query? If not, have you guys looked at how the rewriter’s performance is affected? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function is only used once during the rewriting phase in Peloton. As mentioned I believe in |
||
// The rewriter copies the AbstractExpression presented to the rewriter. | ||
// This function is used by the rewriter to properly wipe all the children | ||
// of AbstractExpression once the AbstractExpression tree has been converted | ||
// to the intermediary AbsExpr_Container/Expression tree. | ||
// | ||
// This function should only be invoked on copied AbstractExpressions and | ||
// never on original ones passed into the [rewriter] otherwise we would | ||
// violate immutable properties. We do not believe this function is strictly | ||
// necessary in terrier, however this function does serve some usefulness. | ||
// | ||
// This allows us to reduce our memory footprint while also providing better | ||
// implementation constraints within the rewriter (i.e: the rewriter should | ||
// not be trying to operate directly on AbstractExpression but rather on the | ||
// intermediary representation). | ||
children_.clear(); | ||
} | ||
|
||
void SetExpressionType(ExpressionType type) { exp_type_ = type; } | ||
|
||
////////////////////////////////////////////////////////////////////////////// | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Peloton | ||
// | ||
// group_marker_expression.h | ||
// | ||
// Identification: src/include/expression/group_marker_expression.h | ||
// | ||
// Copyright (c) 2015-2018, Carnegie Mellon University Database Group | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#pragma once | ||
|
||
#include "expression/abstract_expression.h" | ||
#include "optimizer/group_expression.h" | ||
#include "util/hash_util.h" | ||
|
||
namespace peloton { | ||
|
||
namespace executor { | ||
class ExecutorContext; | ||
} // namespace executor | ||
|
||
namespace expression { | ||
|
||
//===----------------------------------------------------------------------===// | ||
// GroupMarkerExpression | ||
//===----------------------------------------------------------------------===// | ||
|
||
class GroupMarkerExpression : public AbstractExpression { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add some brief high-level documentation about GroupMarkerExpression and how it is used? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved. |
||
public: | ||
GroupMarkerExpression(optimizer::GroupID group_id) : | ||
AbstractExpression(ExpressionType::GROUP_MARKER), | ||
group_id_(group_id) {}; | ||
|
||
optimizer::GroupID GetGroupID() { return group_id_; } | ||
|
||
AbstractExpression *Copy() const override { | ||
return new GroupMarkerExpression(group_id_); | ||
} | ||
|
||
type::Value Evaluate(const AbstractTuple *tuple1, | ||
const AbstractTuple *tuple2, | ||
executor::ExecutorContext *context) const { | ||
(void)tuple1; | ||
(void)tuple2; | ||
(void)context; | ||
PELOTON_ASSERT(0); | ||
} | ||
|
||
void Accept(SqlNodeVisitor *) { | ||
PELOTON_ASSERT(0); | ||
} | ||
|
||
protected: | ||
optimizer::GroupID group_id_; | ||
|
||
GroupMarkerExpression(const GroupMarkerExpression &other) | ||
: AbstractExpression(other), group_id_(other.group_id_) {} | ||
}; | ||
|
||
} // namespace expression | ||
} // namespace peloton |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a good issue to file, so that we don't make the same mistake when we write a new binder.