当前位置: 首页>>代码示例>>Java>>正文


Java ImmutableIntList.copyOf方法代码示例

本文整理汇总了Java中org.apache.calcite.util.ImmutableIntList.copyOf方法的典型用法代码示例。如果您正苦于以下问题:Java ImmutableIntList.copyOf方法的具体用法?Java ImmutableIntList.copyOf怎么用?Java ImmutableIntList.copyOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.calcite.util.ImmutableIntList的用法示例。


在下文中一共展示了ImmutableIntList.copyOf方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: of

import org.apache.calcite.util.ImmutableIntList; //导入方法依赖的package包/类
/** Creates a {@code JoinInfo} by analyzing a condition. */
public static JoinInfo of(RelNode left, RelNode right, RexNode condition) {
  final List<Integer> leftKeys = new ArrayList<Integer>();
  final List<Integer> rightKeys = new ArrayList<Integer>();
  final List<Boolean> filterNulls = new ArrayList<Boolean>();
  RexNode remaining =
      RelOptUtil.splitJoinCondition(left, right, condition, leftKeys,
          rightKeys, filterNulls);
  if (remaining.isAlwaysTrue()) {
    return new EquiJoinInfo(ImmutableIntList.copyOf(leftKeys),
        ImmutableIntList.copyOf(rightKeys));
  } else {
    return new NonEquiJoinInfo(ImmutableIntList.copyOf(leftKeys),
        ImmutableIntList.copyOf(rightKeys), remaining);
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:17,代码来源:JoinInfo.java

示例2: getNewColumnMapping

import org.apache.calcite.util.ImmutableIntList; //导入方法依赖的package包/类
/**
 * Creates a mapping from the view index to the index in the underlying table.
 */
private static ImmutableIntList getNewColumnMapping(Table underlying,
    ImmutableIntList oldColumnMapping, List<RelDataTypeField> extendedColumns,
    RelDataTypeFactory typeFactory) {
  final List<RelDataTypeField> baseColumns =
      underlying.getRowType(typeFactory).getFieldList();
  final Map<String, Integer> nameToIndex = mapNameToIndex(baseColumns);

  final ImmutableList.Builder<Integer> newMapping = ImmutableList.builder();
  newMapping.addAll(oldColumnMapping);
  int newMappedIndex = baseColumns.size();
  for (RelDataTypeField extendedColumn : extendedColumns) {
    if (nameToIndex.containsKey(extendedColumn.getName())) {
      // The extended column duplicates a column in the underlying table.
      // Map to the index in the underlying table.
      newMapping.add(nameToIndex.get(extendedColumn.getName()));
    } else {
      // The extended column is not in the underlying table.
      newMapping.add(newMappedIndex++);
    }
  }
  return ImmutableIntList.copyOf(newMapping.build());
}
 
开发者ID:apache,项目名称:calcite,代码行数:26,代码来源:ModifiableViewTable.java

示例3: create

import org.apache.calcite.util.ImmutableIntList; //导入方法依赖的package包/类
/** Creates a BindableTableScan. */
public static BindableTableScan create(RelOptCluster cluster,
    RelOptTable relOptTable, List<RexNode> filters,
    List<Integer> projects) {
  final Table table = relOptTable.unwrap(Table.class);
  final RelTraitSet traitSet =
      cluster.traitSetOf(BindableConvention.INSTANCE)
          .replaceIfs(RelCollationTraitDef.INSTANCE,
              new Supplier<List<RelCollation>>() {
                public List<RelCollation> get() {
                  if (table != null) {
                    return table.getStatistic().getCollations();
                  }
                  return ImmutableList.of();
                }
              });
  return new BindableTableScan(cluster, traitSet, relOptTable,
      ImmutableList.copyOf(filters), ImmutableIntList.copyOf(projects));
}
 
开发者ID:apache,项目名称:calcite,代码行数:20,代码来源:Bindables.java

示例4: hash

import org.apache.calcite.util.ImmutableIntList; //导入方法依赖的package包/类
/** Creates a hash distribution. */
public static RelDistribution hash(Collection<? extends Number> numbers) {
  ImmutableIntList list = ImmutableIntList.copyOf(numbers);
  if (numbers.size() > 1
      && !Ordering.natural().isOrdered(list)) {
    list = ImmutableIntList.copyOf(Ordering.natural().sortedCopy(list));
  }
  RelDistributionImpl trait =
      new RelDistributionImpl(RelDistribution.Type.HASH_DISTRIBUTED, list);
  return RelDistributionTraitDef.INSTANCE.canonize(trait);
}
 
开发者ID:apache,项目名称:calcite,代码行数:12,代码来源:RelDistributions.java

示例5: range

import org.apache.calcite.util.ImmutableIntList; //导入方法依赖的package包/类
/** Creates a range distribution. */
public static RelDistribution range(Collection<? extends Number> numbers) {
  ImmutableIntList list = ImmutableIntList.copyOf(numbers);
  RelDistributionImpl trait =
      new RelDistributionImpl(RelDistribution.Type.RANGE_DISTRIBUTED, list);
  return RelDistributionTraitDef.INSTANCE.canonize(trait);
}
 
开发者ID:apache,项目名称:calcite,代码行数:8,代码来源:RelDistributions.java

示例6: getProjectOrdinals

import org.apache.calcite.util.ImmutableIntList; //导入方法依赖的package包/类
public static ImmutableIntList getProjectOrdinals(final List<RexNode> exprs) {
  return ImmutableIntList.copyOf(
      new AbstractList<Integer>() {
        public Integer get(int index) {
          return ((RexSlot) exprs.get(index)).getIndex();
        }

        public int size() {
          return exprs.size();
        }
      });
}
 
开发者ID:apache,项目名称:calcite,代码行数:13,代码来源:Window.java

示例7: getRowType

import org.apache.calcite.util.ImmutableIntList; //导入方法依赖的package包/类
public RelDataType getRowType(RelDataTypeFactory typeFactory) {
  final List<RelDataType> typeList = new ArrayList<RelDataType>();
  final List<Integer> fieldCounts = new ArrayList<Integer>();
  for (Table table : tables) {
    final RelDataType rowType = table.getRowType(typeFactory);
    typeList.addAll(RelOptUtil.getFieldTypeList(rowType));
    fieldCounts.add(rowType.getFieldCount());
  }
  // Compute fieldCounts the first time this method is called. Safe to assume
  // that the field counts will be the same whichever type factory is used.
  if (this.fieldCounts == null) {
    this.fieldCounts = ImmutableIntList.copyOf(fieldCounts);
  }
  return typeFactory.createStructType(typeList, lattice.uniqueColumnNames);
}
 
开发者ID:apache,项目名称:calcite,代码行数:16,代码来源:StarTable.java

示例8: setFactorWeights

import org.apache.calcite.util.ImmutableIntList; //导入方法依赖的package包/类
/**
 * Sets weighting for each combination of factors, depending on which join
 * filters reference which factors. Greater weight is given to equality
 * conditions. Also, sets bitmaps indicating which factors are referenced by
 * each factor within join filters that are comparisons.
 */
public void setFactorWeights() {
  factorWeights = new int[nJoinFactors][nJoinFactors];
  factorsRefByFactor = new ImmutableBitSet[nJoinFactors];
  for (int i = 0; i < nJoinFactors; i++) {
    factorsRefByFactor[i] = ImmutableBitSet.of();
  }

  for (RexNode joinFilter : allJoinFilters) {
    ImmutableBitSet factorRefs = factorsRefByJoinFilter.get(joinFilter);

    // don't give weights to non-comparison expressions
    if (!(joinFilter instanceof RexCall)) {
      continue;
    }
    if (!joinFilter.isA(SqlKind.COMPARISON)) {
      continue;
    }

    // OR the factors referenced in this join filter into the
    // bitmaps corresponding to each of the factors; however,
    // exclude the bit corresponding to the factor itself
    for (int factor : factorRefs) {
      factorsRefByFactor[factor] =
          factorsRefByFactor[factor]
              .rebuild()
              .addAll(factorRefs)
              .clear(factor)
              .build();
    }

    if (factorRefs.cardinality() == 2) {
      int leftFactor = factorRefs.nextSetBit(0);
      int rightFactor = factorRefs.nextSetBit(leftFactor + 1);

      final RexCall call = (RexCall) joinFilter;
      ImmutableBitSet leftFields = fieldBitmap(call.getOperands().get(0));
      ImmutableBitSet leftBitmap = factorBitmap(leftFields);

      // filter contains only two factor references, one on each
      // side of the operator
      int weight;
      if (leftBitmap.cardinality() == 1) {
        // give higher weight to equi-joins
        switch (joinFilter.getKind()) {
        case EQUALS:
          weight = 3;
          break;
        default:
          weight = 2;
        }
      } else {
        // cross product of two tables
        weight = 1;
      }
      setFactorWeight(weight, leftFactor, rightFactor);
    } else {
      // multiple factor references -- set a weight for each
      // combination of factors referenced within the filter
      final List<Integer> list  = ImmutableIntList.copyOf(factorRefs);
      for (int outer : list) {
        for (int inner : list) {
          if (outer != inner) {
            setFactorWeight(1, outer, inner);
          }
        }
      }
    }
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:76,代码来源:LoptMultiJoin.java

示例9: perform

import org.apache.calcite.util.ImmutableIntList; //导入方法依赖的package包/类
protected void perform(RelOptRuleCall call, Project project,
    Join join, RelNode left, Aggregate aggregate) {
  final RelOptCluster cluster = join.getCluster();
  final RexBuilder rexBuilder = cluster.getRexBuilder();
  if (project != null) {
    final ImmutableBitSet bits =
        RelOptUtil.InputFinder.bits(project.getProjects(), null);
    final ImmutableBitSet rightBits =
        ImmutableBitSet.range(left.getRowType().getFieldCount(),
            join.getRowType().getFieldCount());
    if (bits.intersects(rightBits)) {
      return;
    }
  }
  final JoinInfo joinInfo = join.analyzeCondition();
  if (!joinInfo.rightSet().equals(
      ImmutableBitSet.range(aggregate.getGroupCount()))) {
    // Rule requires that aggregate key to be the same as the join key.
    // By the way, neither a super-set nor a sub-set would work.
    return;
  }
  if (!joinInfo.isEqui()) {
    return;
  }
  final RelBuilder relBuilder = call.builder();
  relBuilder.push(left);
  switch (join.getJoinType()) {
  case INNER:
    final List<Integer> newRightKeyBuilder = Lists.newArrayList();
    final List<Integer> aggregateKeys = aggregate.getGroupSet().asList();
    for (int key : joinInfo.rightKeys) {
      newRightKeyBuilder.add(aggregateKeys.get(key));
    }
    final ImmutableIntList newRightKeys = ImmutableIntList.copyOf(newRightKeyBuilder);
    relBuilder.push(aggregate.getInput());
    final RexNode newCondition =
        RelOptUtil.createEquiJoinCondition(relBuilder.peek(2, 0),
            joinInfo.leftKeys, relBuilder.peek(2, 1), newRightKeys,
            rexBuilder);
    relBuilder.semiJoin(newCondition);
    break;

  case LEFT:
    // The right-hand side produces no more than 1 row (because of the
    // Aggregate) and no fewer than 1 row (because of LEFT), and therefore
    // we can eliminate the semi-join.
    break;

  default:
    throw new AssertionError(join.getJoinType());
  }
  if (project != null) {
    relBuilder.project(project.getProjects(), project.getRowType().getFieldNames());
  }
  call.transformTo(relBuilder.build());
}
 
开发者ID:apache,项目名称:calcite,代码行数:57,代码来源:SemiJoinRule.java

示例10: createProjectableFilterable

import org.apache.calcite.util.ImmutableIntList; //导入方法依赖的package包/类
private static TableScanNode createProjectableFilterable(Compiler compiler,
    TableScan rel, ImmutableList<RexNode> filters, ImmutableIntList projects,
    ProjectableFilterableTable pfTable) {
  final DataContext root = compiler.getDataContext();
  final ImmutableIntList originalProjects = projects;
  for (;;) {
    final List<RexNode> mutableFilters = Lists.newArrayList(filters);
    final int[] projectInts;
    if (projects == null
        || projects.equals(TableScan.identity(rel.getTable()))) {
      projectInts = null;
    } else {
      projectInts = projects.toIntArray();
    }
    final Enumerable<Object[]> enumerable1 =
        pfTable.scan(root, mutableFilters, projectInts);
    for (RexNode filter : mutableFilters) {
      if (!filters.contains(filter)) {
        throw RESOURCE.filterableTableInventedFilter(filter.toString())
            .ex();
      }
    }
    final ImmutableBitSet usedFields =
        RelOptUtil.InputFinder.bits(mutableFilters, null);
    if (projects != null) {
      int changeCount = 0;
      for (int usedField : usedFields) {
        if (!projects.contains(usedField)) {
          // A field that is not projected is used in a filter that the
          // table rejected. We won't be able to apply the filter later.
          // Try again without any projects.
          projects =
              ImmutableIntList.copyOf(
                  Iterables.concat(projects, ImmutableList.of(usedField)));
          ++changeCount;
        }
      }
      if (changeCount > 0) {
        continue;
      }
    }
    final Enumerable<Row> rowEnumerable = Enumerables.toRow(enumerable1);
    final ImmutableIntList rejectedProjects;
    if (Objects.equals(projects, originalProjects)) {
      rejectedProjects = null;
    } else {
      // We projected extra columns because they were needed in filters. Now
      // project the leading columns.
      rejectedProjects = ImmutableIntList.identity(originalProjects.size());
    }
    return createEnumerable(compiler, rel, rowEnumerable, projects,
        mutableFilters, rejectedProjects);
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:55,代码来源:TableScanNode.java


注:本文中的org.apache.calcite.util.ImmutableIntList.copyOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。