本文整理汇总了Java中org.apache.drill.exec.planner.physical.ProjectPrel类的典型用法代码示例。如果您正苦于以下问题:Java ProjectPrel类的具体用法?Java ProjectPrel怎么用?Java ProjectPrel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ProjectPrel类属于org.apache.drill.exec.planner.physical包,在下文中一共展示了ProjectPrel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addTrivialOrderedProjectPrel
import org.apache.drill.exec.planner.physical.ProjectPrel; //导入依赖的package包/类
private Prel addTrivialOrderedProjectPrel(Prel prel) {
RelDataType t = prel.getRowType();
RexBuilder b = prel.getCluster().getRexBuilder();
List<RexNode> projections = Lists.newArrayList();
int projectCount = t.getFieldList().size();
// no point in reordering if we only have one column
if (projectCount < 2) {
return prel;
}
for (int i = 0; i < projectCount; i++) {
projections.add(b.makeInputRef(prel, i));
}
return new ProjectPrel(prel.getCluster(), prel.getTraitSet(), prel, projections, prel.getRowType());
}
示例2: onMatch
import org.apache.drill.exec.planner.physical.ProjectPrel; //导入依赖的package包/类
@Override
public void onMatch(RelOptRuleCall call) {
final ScanPrel scan = (ScanPrel) call.rel(2);
final ProjectPrel project = (ProjectPrel) call.rel(1);
final FilterPrel filter = (FilterPrel) call.rel(0);
HBaseGroupScan groupScan = (HBaseGroupScan)scan.getGroupScan();
if (groupScan.isFilterPushedDown()) {
/*
* The rule can get triggered again due to the transformed "scan => filter" sequence
* created by the earlier execution of this rule when we could not do a complete
* conversion of Optiq Filter's condition to HBase Filter. In such cases, we rely upon
* this flag to not do a re-processing of the rule on the already transformed call.
*/
return;
}
// convert the filter to one that references the child of the project
final RexNode condition = RelOptUtil.pushFilterPastProject(filter.getCondition(), project);
doPushFilterToScan(call, filter, project, scan, groupScan, condition);
}
示例3: onMatch
import org.apache.drill.exec.planner.physical.ProjectPrel; //导入依赖的package包/类
@Override
public void onMatch(RelOptRuleCall call) {
final ScanPrel scan = (ScanPrel) call.rel(2);
final ProjectPrel project = (ProjectPrel) call.rel(1);
final FilterPrel filter = (FilterPrel) call.rel(0);
HBaseGroupScan groupScan = (HBaseGroupScan)scan.getGroupScan();
if (groupScan.isFilterPushedDown()) {
/*
* The rule can get triggered again due to the transformed "scan => filter" sequence
* created by the earlier execution of this rule when we could not do a complete
* conversion of Optiq Filter's condition to HBase Filter. In such cases, we rely upon
* this flag to not do a re-processing of the rule on the already transformed call.
*/
return;
}
// convert the filter to one that references the child of the project
final RexNode condition = RelOptUtil.pushPastProject(filter.getCondition(), project);
doPushFilterToScan(call, filter, project, scan, groupScan, condition);
}
示例4: addColumnOrderingBelowUnion
import org.apache.drill.exec.planner.physical.ProjectPrel; //导入依赖的package包/类
private Prel addColumnOrderingBelowUnion(Prel prel) {
List<RelNode> children = Lists.newArrayList();
for (Prel p : prel) {
Prel child = p.accept(this, null);
boolean needProjectBelowUnion = !(p instanceof ProjectPrel);
if(needProjectBelowUnion) {
child = addTrivialOrderedProjectPrel(child, false);
}
children.add(child);
}
return (Prel) prel.copy(prel.getTraitSet(), children);
}
示例5: visitScan
import org.apache.drill.exec.planner.physical.ProjectPrel; //导入依赖的package包/类
@Override
public Prel visitScan(ScanPrel scanPrel, Void value) throws RuntimeException {
if (StarColumnHelper.containsStarColumn(scanPrel.getRowType()) && prefixedForStar ) {
List<RexNode> exprs = Lists.newArrayList();
for (RelDataTypeField field : scanPrel.getRowType().getFieldList()) {
RexNode expr = scanPrel.getCluster().getRexBuilder().makeInputRef(field.getType(), field.getIndex());
exprs.add(expr);
}
List<String> fieldNames = Lists.newArrayList();
long tableId = tableNumber.getAndIncrement();
for (String name : scanPrel.getRowType().getFieldNames()) {
if (StarColumnHelper.isNonPrefixedStarColumn(name)) {
fieldNames.add("T" + tableId + StarColumnHelper.PREFIX_DELIMITER + name); // Add prefix to * column.
} else {
fieldNames.add(name); // Keep regular column as it is.
}
}
RelDataType rowType = RexUtil.createStructType(scanPrel.getCluster().getTypeFactory(), exprs, fieldNames);
// insert a PAS.
ProjectPrel proj = new ProjectPrel(scanPrel.getCluster(), scanPrel.getTraitSet(), scanPrel, exprs, rowType);
return proj;
} else {
return visitPrel(scanPrel, value);
}
}
示例6: onMatch
import org.apache.drill.exec.planner.physical.ProjectPrel; //导入依赖的package包/类
@Override
public void onMatch(RelOptRuleCall call) {
final FilterPrel filterRel = (FilterPrel) call.rel(0);
final ProjectPrel projectRel = (ProjectPrel) call.rel(1);
final ScanPrel scanRel = call.rel(2);
doMatch(call, scanRel, projectRel, filterRel);
}
示例7: doMatch
import org.apache.drill.exec.planner.physical.ProjectPrel; //导入依赖的package包/类
protected void doMatch(RelOptRuleCall call, ScanPrel scan, ProjectPrel project, FilterPrel filter) {
final RexNode condition = filter.getCondition();
InfoSchemaGroupScan groupScan = (InfoSchemaGroupScan)scan.getGroupScan();
if (groupScan.isFilterPushedDown()) {
return;
}
LogicalExpression conditionExp =
DrillOptiq.toDrill(new DrillParseContext(PrelUtil.getPlannerSettings(call.getPlanner())), project != null ? project : scan, condition);
InfoSchemaFilterBuilder filterBuilder = new InfoSchemaFilterBuilder(conditionExp);
InfoSchemaFilter infoSchemaFilter = filterBuilder.build();
if (infoSchemaFilter == null) {
return; //no filter pushdown ==> No transformation.
}
final InfoSchemaGroupScan newGroupsScan = new InfoSchemaGroupScan(groupScan.getTable(), infoSchemaFilter);
newGroupsScan.setFilterPushedDown(true);
RelNode input = ScanPrel.create(scan, filter.getTraitSet(), newGroupsScan, scan.getRowType());
if (project != null) {
input = project.copy(project.getTraitSet(), input, project.getProjects(), filter.getRowType());
}
if (filterBuilder.isAllExpressionsConverted()) {
// Filter can be removed as all expressions in the filter are converted and pushed to scan
call.transformTo(input);
} else {
call.transformTo(filter.copy(filter.getTraitSet(), ImmutableList.of(input)));
}
}
示例8: doPushFilterToScan
import org.apache.drill.exec.planner.physical.ProjectPrel; //导入依赖的package包/类
protected void doPushFilterToScan(final RelOptRuleCall call, final FilterPrel filter, final ProjectPrel project, final ScanPrel scan, final HBaseGroupScan groupScan, final RexNode condition) {
final LogicalExpression conditionExp = DrillOptiq.toDrill(new DrillParseContext(PrelUtil.getPlannerSettings(call.getPlanner())), scan, condition);
final HBaseFilterBuilder hbaseFilterBuilder = new HBaseFilterBuilder(groupScan, conditionExp);
final HBaseScanSpec newScanSpec = hbaseFilterBuilder.parseTree();
if (newScanSpec == null) {
return; //no filter pushdown ==> No transformation.
}
final HBaseGroupScan newGroupsScan = new HBaseGroupScan(groupScan.getUserName(), groupScan.getStoragePlugin(),
newScanSpec, groupScan.getColumns());
newGroupsScan.setFilterPushedDown(true);
final ScanPrel newScanPrel = ScanPrel.create(scan, filter.getTraitSet(), newGroupsScan, scan.getRowType());
// Depending on whether is a project in the middle, assign either scan or copy of project to childRel.
final RelNode childRel = project == null ? newScanPrel : project.copy(project.getTraitSet(), ImmutableList.of((RelNode)newScanPrel));;
if (hbaseFilterBuilder.isAllExpressionsConverted()) {
/*
* Since we could convert the entire filter condition expression into an HBase filter,
* we can eliminate the filter operator altogether.
*/
call.transformTo(childRel);
} else {
call.transformTo(filter.copy(filter.getTraitSet(), ImmutableList.of(childRel)));
}
}
示例9: pushDown
import org.apache.drill.exec.planner.physical.ProjectPrel; //导入依赖的package包/类
@Override
protected void pushDown(RelOptRuleCall call) {
final FilterPrel filter = call.rel(0);
final ProjectPrel project = call.rel(1);
final ScanPrel scan = getScan(call);
// convert the filter to one that references the child of the project
final RexNode condition = RelOptUtil.pushPastProject(filter.getCondition(), project);
doPushFilterToScan(call, filter, project, scan, (DynamoGroupScan) scan.getGroupScan(),
condition);
}
示例10: doPushFilterToScan
import org.apache.drill.exec.planner.physical.ProjectPrel; //导入依赖的package包/类
private static void doPushFilterToScan(final RelOptRuleCall call, final FilterPrel filter,
final ProjectPrel project, final ScanPrel scan, final DynamoGroupScan groupScan,
final RexNode condition) {
// convert the expression
final LogicalExpression conditionExp =
toDrill(new DrillParseContext(getPlannerSettings(call.getPlanner())), scan, condition);
// try to build a new filter
final DynamoFilterBuilder filterBuilder = new DynamoFilterBuilder(groupScan, conditionExp);
final DynamoGroupScanSpec newScanSpec = filterBuilder.parseTree();
if (newScanSpec == null) {
return; //no filter pushDown ==> No transformation.
}
final DynamoGroupScan newGroupScan = new DynamoGroupScan(groupScan);
newGroupScan.setScanSpec(newScanSpec);
newGroupScan.setFilterPushedDown(true);
final ScanPrel newScanPrel =
ScanPrel.create(scan, filter.getTraitSet(), newGroupScan, scan.getRowType());
// Depending on whether is a project in the middle, assign either scan or copy of project to
// childRel.
final RelNode childRel = project == null ? newScanPrel : project
.copy(project.getTraitSet(), ImmutableList.of((RelNode) newScanPrel)); ;
if (filterBuilder.isAllExpressionsConverted()) {
/*
* Since we could convert the entire filter condition expression into a Dynamo filter,
* we can eliminate the filter operator altogether.
*/
call.transformTo(childRel);
} else {
call.transformTo(filter.copy(filter.getTraitSet(), ImmutableList.of(childRel)));
}
}
示例11: addTopProjectPrel
import org.apache.drill.exec.planner.physical.ProjectPrel; //导入依赖的package包/类
/**
* Adds top project to ensure final output field names are preserved.
* In case of duplicated column names, will rename duplicates.
* Top project will be added only if top project is non-trivial and
* child physical relational node is not project.
*
* @param prel physical relational node
* @param validatedRowType final output row type
* @return physical relational node with top project if necessary
*/
private Prel addTopProjectPrel(Prel prel, RelDataType validatedRowType) {
RelDataType rowType = prel.getRowType();
if (rowType.getFieldCount() != validatedRowType.getFieldCount()) {
return prel;
}
RexBuilder rexBuilder = prel.getCluster().getRexBuilder();
List<RexNode> projections = new ArrayList<>();
int projectCount = rowType.getFieldList().size();
for (int i = 0; i < projectCount; i++) {
projections.add(rexBuilder.makeInputRef(prel, i));
}
List<String> fieldNames = SqlValidatorUtil.uniquify(
validatedRowType.getFieldNames(),
SqlValidatorUtil.F_SUGGESTER2,
prel.getCluster().getTypeFactory().getTypeSystem().isSchemaCaseSensitive());
RelDataType newRowType = RexUtil.createStructType(prel.getCluster().getTypeFactory(), projections, fieldNames, null);
ProjectPrel topProject = new ProjectPrel(prel.getCluster(),
prel.getTraitSet(),
prel,
projections,
newRowType,
true); //outputProj = true : NONE -> OK_NEW_SCHEMA, also handle expression with NULL type.
if (prel instanceof Project && DrillRelOptUtil.isTrivialProject(topProject, true)) {
return new ProjectPrel(prel.getCluster(),
prel.getTraitSet(),
((Project) prel).getInput(),
((Project) prel).getProjects(),
prel.getRowType(),
true); //outputProj = true : NONE -> OK_NEW_SCHEMA, also handle expression with NULL type.
} else {
return topProject;
}
}
示例12: visitProject
import org.apache.drill.exec.planner.physical.ProjectPrel; //导入依赖的package包/类
@Override
public Prel visitProject(ProjectPrel node, Object unused) throws RelConversionException {
ProjectPrel project = node;
List<RexNode> exprList = new ArrayList<>();
boolean rewrite = false;
List<RelDataTypeField> relDataTypes = new ArrayList<>();
int i = 0;
RexNode flatttenExpr = null;
for (RexNode rex : project.getChildExps()) {
RexNode newExpr = rex;
if (rex instanceof RexCall) {
RexCall function = (RexCall) rex;
String functionName = function.getOperator().getName();
if (functionName.equalsIgnoreCase("flatten") ) {
rewrite = true;
if (function.getOperands().size() != 1) {
throw new RelConversionException("Flatten expression expects a single input.");
}
newExpr = function.getOperands().get(0);
RexBuilder builder = new RexBuilder(factory);
flatttenExpr = builder.makeInputRef( new RelDataTypeDrillImpl(new RelDataTypeHolder(), factory), i);
}
}
relDataTypes.add(project.getRowType().getFieldList().get(i));
i++;
exprList.add(newExpr);
}
if (rewrite == true) {
// TODO - figure out what is the right setting for the traits
Prel newChild = ((Prel)project.getInput(0)).accept(this, null);
ProjectPrel newProject = new ProjectPrel(node.getCluster(), project.getTraitSet(), newChild, exprList, new RelRecordType(relDataTypes));
FlattenPrel flatten = new FlattenPrel(project.getCluster(), project.getTraitSet(), newProject, flatttenExpr);
return flatten;
}
Prel child = ((Prel)project.getInput()).accept(this, null);
return (Prel) project.copy(project.getTraitSet(), child, exprList, new RelRecordType(relDataTypes));
}
示例13: visitProject
import org.apache.drill.exec.planner.physical.ProjectPrel; //导入依赖的package包/类
@Override
public Void visitProject(ProjectPrel prel, VisualizationState value)
throws Exception {
visitBasePrel(prel, value);
endNode(prel, value);
return null;
}
示例14: visitProject
import org.apache.drill.exec.planner.physical.ProjectPrel; //导入依赖的package包/类
@Override
public RETURN visitProject(ProjectPrel prel, EXTRA value) throws EXCEP {
return visitPrel(prel, value);
}
示例15: visitProject
import org.apache.drill.exec.planner.physical.ProjectPrel; //导入依赖的package包/类
@Override
public Prel visitProject(ProjectPrel node, Object unused) throws RelConversionException {
ProjectPrel project = node;
List<RexNode> exprList = new ArrayList<>();
boolean rewrite = false;
List<RelDataTypeField> relDataTypes = new ArrayList();
int i = 0;
RexNode flatttenExpr = null;
for (RexNode rex : project.getChildExps()) {
RexNode newExpr = rex;
if (rex instanceof RexCall) {
RexCall function = (RexCall) rex;
String functionName = function.getOperator().getName();
int nArgs = function.getOperands().size();
if (functionName.equalsIgnoreCase("flatten") ) {
rewrite = true;
if (function.getOperands().size() != 1) {
throw new RelConversionException("Flatten expression expects a single input.");
}
newExpr = function.getOperands().get(0);
RexBuilder builder = new RexBuilder(factory);
flatttenExpr = builder.makeInputRef( new RelDataTypeDrillImpl(new RelDataTypeHolder(), factory), i);
}
}
relDataTypes.add(project.getRowType().getFieldList().get(i));
i++;
exprList.add(newExpr);
}
if (rewrite == true) {
// TODO - figure out what is the right setting for the traits
Prel newChild = ((Prel)project.getInput(0)).accept(this, null);
ProjectPrel newProject = new ProjectPrel(node.getCluster(), project.getTraitSet(), newChild, exprList, new RelRecordType(relDataTypes));
FlattenPrel flatten = new FlattenPrel(project.getCluster(), project.getTraitSet(), newProject, flatttenExpr);
return flatten;
}
Prel child = ((Prel)project.getInput()).accept(this, null);
return (Prel) project.copy(project.getTraitSet(), child, exprList, new RelRecordType(relDataTypes));
}