org.apache.calcite.rel.core.Join.getRowType()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(10.3k)|赞(0)|评价(0)|浏览(92)

本文整理了Java中org.apache.calcite.rel.core.Join.getRowType()方法的一些代码示例,展示了Join.getRowType()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Join.getRowType()方法的具体详情如下:
包路径:org.apache.calcite.rel.core.Join
类名称:Join
方法名:getRowType

Join.getRowType介绍

暂无

代码示例

代码示例来源:origin: apache/hive

assert rel.getRowType().getFieldCount()
    == oldLeftFieldCount + oldRightFieldCount;

代码示例来源:origin: apache/hive

private boolean filterRefersToBothSidesOfJoin(RexNode filter, Join j) {
  boolean refersToBothSides = false;

  int joinNoOfProjects = j.getRowType().getFieldCount();
  ImmutableBitSet filterProjs = ImmutableBitSet.FROM_BIT_SET.apply(new BitSet(joinNoOfProjects));
  ImmutableBitSet allLeftProjs = filterProjs.union(ImmutableBitSet.range(0, j.getInput(0)
    .getRowType().getFieldCount()));
  ImmutableBitSet allRightProjs = filterProjs.union(ImmutableBitSet.range(j.getInput(0)
    .getRowType().getFieldCount(), joinNoOfProjects));

  filterProjs = filterProjs.union(InputFinder.bits(filter));

  if (allLeftProjs.intersects(filterProjs) && allRightProjs.intersects(filterProjs))
   refersToBothSides = true;

  return refersToBothSides;
 }
}

代码示例来源:origin: apache/hive

nullIndicatorPos,
typeFactory.createTypeWithNullability(
    join.getRowType().getFieldList().get(nullIndicatorPos)
        .getType(),
    true));

代码示例来源:origin: apache/hive

List<RelDataTypeField> joinFields = join.getRowType().getFieldList();
List<RelDataTypeField> swappedJoinFeilds = swappedJoin.getRowType().getFieldList();
for(RexNode project:topProject.getProjects()) {
 RexNode newProject = project.accept(new RelOptUtil.RexInputConverter(rexBuilder, swappedJoinFeilds,

代码示例来源:origin: apache/hive

@Override
public void onMatch(RelOptRuleCall call) {
 final Join join = call.rel(0);
 final HepRelVertex root = (HepRelVertex) call.getPlanner().getRoot();
 if (root.getCurrentRel() != join) {
  // Bail out
  return;
 }
 // The join is the root, but we should always end up with a Project operator
 // on top. We will add it.
 RelBuilder relBuilder = call.builder();
 relBuilder.push(join);
 List<RexNode> identityFields = relBuilder.fields(
   ImmutableBitSet.range(0, join.getRowType().getFieldCount()).asList());
 relBuilder.project(identityFields, ImmutableList.<String>of(), true);
 call.transformTo(relBuilder.build());
}

代码示例来源:origin: apache/drill

private boolean filterRefersToBothSidesOfJoin(RexNode filter, Join j) {
  boolean refersToBothSides = false;

  int joinNoOfProjects = j.getRowType().getFieldCount();
  ImmutableBitSet filterProjs = ImmutableBitSet.FROM_BIT_SET.apply(new BitSet(joinNoOfProjects));
  ImmutableBitSet allLeftProjs = filterProjs.union(ImmutableBitSet.range(0, j.getInput(0)
    .getRowType().getFieldCount()));
  ImmutableBitSet allRightProjs = filterProjs.union(ImmutableBitSet.range(j.getInput(0)
    .getRowType().getFieldCount(), joinNoOfProjects));

  filterProjs = filterProjs.union(InputFinder.bits(filter));

  if (allLeftProjs.intersects(filterProjs) && allRightProjs.intersects(filterProjs))
   refersToBothSides = true;

  return refersToBothSides;
 }
}

代码示例来源:origin: apache/hive

final ImmutableBitSet rightBits =
  ImmutableBitSet.range(left.getRowType().getFieldCount(),
             join.getRowType().getFieldCount());
if (topRefs.intersects(rightBits)) {
 return;
 Join rightJoin = (Join)(((HepRelVertex)aggregate.getInput()).getCurrentRel());
 List<RexNode> projects = new ArrayList<>();
 for(int i=0; i<rightJoin.getRowType().getFieldCount(); i++){
  projects.add(rexBuilder.makeInputRef(rightJoin, i));
 RelNode topProject =  call.builder().push(rightJoin).project(projects, rightJoin.getRowType().getFieldNames(),
                                true).build();
 semi = call.builder().push(left).push(topProject).semiJoin(newCondition).build();

代码示例来源:origin: apache/hive

int nullIndicatorPos = join.getRowType().getFieldCount() - 1;
        nullIndicatorPos,
        cluster.getTypeFactory().createTypeWithNullability(
            join.getRowType().getFieldList()
                .get(nullIndicatorPos).getType(),
            true));

代码示例来源:origin: apache/hive

final ImmutableBitSet rightBits =
  ImmutableBitSet.range(leftInput.getRowType().getFieldCount(),
    join.getRowType().getFieldCount());
 int joinFieldCount = join.getRowType().getFieldCount();
 Mapping mappingLR = Mappings.create(MappingType.PARTIAL_FUNCTION, joinFieldCount, joinFieldCount);
 Mapping mappingRL = Mappings.create(MappingType.PARTIAL_FUNCTION, joinFieldCount, joinFieldCount);

代码示例来源:origin: apache/hive

join.getRowType().getFieldCount(),
  belowOffset);
final RexNode newCondition =

代码示例来源:origin: apache/drill

final ImmutableBitSet rightBits =
  ImmutableBitSet.range(left.getRowType().getFieldCount(),
    join.getRowType().getFieldCount());
if (bits.intersects(rightBits)) {
 return;
  Join rightJoin = (Join)(((HepRelVertex)aggregate.getInput()).getCurrentRel());
  List<RexNode> projects = new ArrayList<>();
  for(int i=0; i<rightJoin.getRowType().getFieldCount(); i++){
   projects.add(rexBuilder.makeInputRef(rightJoin, i));
  RelNode topProject =  call.builder().push(rightJoin).project(projects, rightJoin.getRowType().getFieldNames(), true).build();
 semi = call.builder().push(left).push(topProject).semiJoin(newCondition).build();

代码示例来源:origin: apache/drill

join.getRowType().getFieldCount(),
  belowOffset);
final RexNode newCondition =

代码示例来源:origin: apache/incubator-druid

ImmutableBitSet.range(
  left.getRowType().getFieldCount(),
  join.getRowType().getFieldCount()
);

代码示例来源:origin: org.apache.calcite/calcite-core

private List<Double> averageJoinColumnSizes(Join rel, RelMetadataQuery mq,
  boolean semijoin) {
 final RelNode left = rel.getLeft();
 final RelNode right = rel.getRight();
 final List<Double> lefts = mq.getAverageColumnSizes(left);
 final List<Double> rights =
   semijoin ? null : mq.getAverageColumnSizes(right);
 if (lefts == null && rights == null) {
  return null;
 }
 final int fieldCount = rel.getRowType().getFieldCount();
 Double[] sizes = new Double[fieldCount];
 if (lefts != null) {
  lefts.toArray(sizes);
 }
 if (rights != null) {
  final int leftCount = left.getRowType().getFieldCount();
  for (int i = 0; i < rights.size(); i++) {
   sizes[leftCount + i] = rights.get(i);
  }
 }
 return ImmutableNullableList.copyOf(sizes);
}

代码示例来源:origin: Qihoo360/Quicksql

private List<Double> averageJoinColumnSizes(Join rel, RelMetadataQuery mq,
  boolean semijoin) {
 final RelNode left = rel.getLeft();
 final RelNode right = rel.getRight();
 final List<Double> lefts = mq.getAverageColumnSizes(left);
 final List<Double> rights =
   semijoin ? null : mq.getAverageColumnSizes(right);
 if (lefts == null && rights == null) {
  return null;
 }
 final int fieldCount = rel.getRowType().getFieldCount();
 Double[] sizes = new Double[fieldCount];
 if (lefts != null) {
  lefts.toArray(sizes);
 }
 if (rights != null) {
  final int leftCount = left.getRowType().getFieldCount();
  for (int i = 0; i < rights.size(); i++) {
   sizes[leftCount + i] = rights.get(i);
  }
 }
 return ImmutableNullableList.copyOf(sizes);
}

代码示例来源:origin: Qihoo360/Quicksql

public void run() throws InterruptedException {
  List<Row> rightList = null;
  final int leftCount = rel.getLeft().getRowType().getFieldCount();
  final int rightCount = rel.getRight().getRowType().getFieldCount();
  context.values = new Object[rel.getRowType().getFieldCount()];
  Row left;
  Row right;
  while ((left = leftSource.receive()) != null) {
   System.arraycopy(left.getValues(), 0, context.values, 0, leftCount);
   if (rightList == null) {
    rightList = new ArrayList<>();
    while ((right = rightSource.receive()) != null) {
     rightList.add(right);
    }
   }
   for (Row right2 : rightList) {
    System.arraycopy(right2.getValues(), 0, context.values, leftCount,
      rightCount);
    final Boolean execute = (Boolean) condition.execute(context);
    if (execute != null && execute) {
     sink.send(Row.asCopy(context.values));
    }
   }
  }
 }
}

代码示例来源:origin: Qihoo360/Quicksql

public void onMatch(RelOptRuleCall call) {
  final Join join = call.rel(0);
  final RelBuilder builder = call.builder();
  final RexSubQuery e =
    RexUtil.SubQueryFinder.find(join.getCondition());
  assert e != null;
  final RelOptUtil.Logic logic =
    LogicVisitor.find(RelOptUtil.Logic.TRUE,
      ImmutableList.of(join.getCondition()), e);
  builder.push(join.getLeft());
  builder.push(join.getRight());
  final int fieldCount = join.getRowType().getFieldCount();
  final RexNode target = apply(e, ImmutableSet.of(),
    logic, builder, 2, fieldCount);
  final RexShuttle shuttle = new ReplaceSubQueryShuttle(e, target);
  builder.join(join.getJoinType(), shuttle.apply(join.getCondition()));
  builder.project(fields(builder, join.getRowType().getFieldCount()));
  call.transformTo(builder.build());
 }
}

代码示例来源:origin: org.apache.calcite/calcite-core

public void onMatch(RelOptRuleCall call) {
  final Join join = call.rel(0);
  final RelBuilder builder = call.builder();
  final RexSubQuery e =
    RexUtil.SubQueryFinder.find(join.getCondition());
  assert e != null;
  final RelOptUtil.Logic logic =
    LogicVisitor.find(RelOptUtil.Logic.TRUE,
      ImmutableList.of(join.getCondition()), e);
  builder.push(join.getLeft());
  builder.push(join.getRight());
  final int fieldCount = join.getRowType().getFieldCount();
  final RexNode target = apply(e, ImmutableSet.of(),
    logic, builder, 2, fieldCount);
  final RexShuttle shuttle = new ReplaceSubQueryShuttle(e, target);
  builder.join(join.getJoinType(), shuttle.apply(join.getCondition()));
  builder.project(fields(builder, join.getRowType().getFieldCount()));
  call.transformTo(builder.build());
 }
}

代码示例来源:origin: com.facebook.presto.hive/hive-apache

private boolean filterRefersToBothSidesOfJoin(RexNode filter, Join j) {
  boolean refersToBothSides = false;

  int joinNoOfProjects = j.getRowType().getFieldCount();
  ImmutableBitSet filterProjs = ImmutableBitSet.FROM_BIT_SET.apply(new BitSet(joinNoOfProjects));
  ImmutableBitSet allLeftProjs = filterProjs.union(ImmutableBitSet.range(0, j.getInput(0)
    .getRowType().getFieldCount()));
  ImmutableBitSet allRightProjs = filterProjs.union(ImmutableBitSet.range(j.getInput(0)
    .getRowType().getFieldCount(), joinNoOfProjects));

  filterProjs = filterProjs.union(InputFinder.bits(filter));

  if (allLeftProjs.intersects(filterProjs) && allRightProjs.intersects(filterProjs))
   refersToBothSides = true;

  return refersToBothSides;
 }
}

代码示例来源:origin: org.apache.calcite/calcite-core

public void onMatch(final RelOptRuleCall call) {
 Join join = call.rel(0);
 if (!join.getSystemFieldList().isEmpty()) {
  // FIXME Enable this rule for joins with system fields
  return;
 }
 final RelNode swapped = swap(join, this.swapOuter, call.builder());
 if (swapped == null) {
  return;
 }
 // The result is either a Project or, if the project is trivial, a
 // raw Join.
 final Join newJoin =
   swapped instanceof Join
     ? (Join) swapped
     : (Join) swapped.getInput(0);
 call.transformTo(swapped);
 // We have converted join='a join b' into swapped='select
 // a0,a1,a2,b0,b1 from b join a'. Now register that project='select
 // b0,b1,a0,a1,a2 from (select a0,a1,a2,b0,b1 from b join a)' is the
 // same as 'b join a'. If we didn't do this, the swap join rule
 // would fire on the new join, ad infinitum.
 final RelBuilder relBuilder = call.builder();
 final List<RexNode> exps =
   RelOptUtil.createSwappedJoinExprs(newJoin, join, false);
 relBuilder.push(swapped)
   .project(exps, newJoin.getRowType().getFieldNames());
 call.getPlanner().ensureRegistered(relBuilder.build(), newJoin);
}

相关文章