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


Java RelDataType.isStruct方法代码示例

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


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

示例1: containsStarColumnInProject

import org.apache.calcite.rel.type.RelDataType; //导入方法依赖的package包/类
public static boolean containsStarColumnInProject(RelDataType inputRowType, List<RexNode> projExprs) {
  if (! inputRowType.isStruct()) {
    return false;
  }

  for (RexNode expr : projExprs) {
    if (expr instanceof RexInputRef) {
      String name = inputRowType.getFieldNames().get(((RexInputRef) expr).getIndex());

      if (name.startsWith(STAR_COLUMN)) {
        return true;
      }
    }
  }

  return false;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:18,代码来源:StarColumnHelper.java

示例2: containsStarColumn

import org.apache.calcite.rel.type.RelDataType; //导入方法依赖的package包/类
public static boolean containsStarColumn(RelDataType type) {
  if (! type.isStruct()) {
    return false;
  }

  List<String> fieldNames = type.getFieldNames();

  for (String s : fieldNames) {
    if (s.startsWith(STAR_COLUMN)) {
      return true;
    }
  }

  return false;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:16,代码来源:StarColumnHelper.java

示例3: computeSelfCost

import org.apache.calcite.rel.type.RelDataType; //导入方法依赖的package包/类
/**
 * Computes the cost honoring column pushdown and relative costs across {@link GroupScan group scans}.
 *
 * The cost model is a function of row count, column and scan factors. Row count may or may not be precise and is
 * obtained from{@link GroupScan#getScanStats(PlannerSettings)}. Column factor is relative to number of columns to
 * scan. Scan factor represents the relative cost of making the scan as compared to other scans kinds.
 *
 * An exact field contributes 1 whole points to column factor. A sub field scan contributes proportionately anywhere
 * from (0, 1], weighting subsequent sub fields less through a logarithmic model.
 */
@Override
public RelOptCost computeSelfCost(final RelOptPlanner planner, final RelMetadataQuery mq) {
  final List<SchemaPath> columns = getColumns();
  final boolean isStarQuery = ColumnUtils.isStarQuery(columns);
  final int allColumns = getTable().getRowType().getFieldCount();

  final double columnFactor;
  if (isStarQuery) {
    columnFactor = allColumns;
  } else {
    double runningFactor = 0;
    // Maintain map of root to child segments to determine what fraction of a whole field is projected.
    final Multimap<NameSegment, SchemaPath> subFields = HashMultimap.create();
    for (final SchemaPath column : columns) {
      subFields.put(column.getRootSegment(), column);
    }

    for (Map.Entry<PathSegment.NameSegment, SchemaPath> entry : subFields.entries()) {
      final PathSegment.NameSegment root = entry.getKey();
      final SchemaPath field = entry.getValue();
      final String rootPath = root.getPath();
      final boolean entireColSelected = rootPath.equalsIgnoreCase(field.getAsUnescapedPath());
      if (entireColSelected) {
        runningFactor += 1;
      } else {
        final RelDataType dataType = getRowType().getField(rootPath, false, false).getType();
        final int subFieldCount = dataType.isStruct() ? dataType.getFieldCount() : 1;
        // sandwich impact of this projection between (0, 1]
        final double impact = Math.log10(1 + (Math.min(1, subFieldCount/MAX_COLUMNS) * 9));
        runningFactor += impact;
      }
    }
    columnFactor = runningFactor;
  }

  final double estimatedCount = estimateRowCount(mq);
  // If the estimatedCount is actually 0, then make it 1, so that at least, we choose the scan that
  // has fewer columns pushed down since all the cost scales with rowCount.
  final double rowCount = Math.max(1, estimatedCount);
  final double scanFactor = getGroupScan().getScanCostFactor().getFactor();
  final double cpuCost = rowCount * columnFactor * scanFactor;
  final double ioCost = cpuCost;

  if (PrelUtil.getSettings(getCluster()).useDefaultCosting()) {
    return planner.getCostFactory().makeCost(estimatedCount, cpuCost, ioCost);
  }

  final double networkCost = ioCost;
  // Even though scan is reading from disk, in the currently generated plans all plans will
  // need to read the same amount of data, so keeping the disk io cost 0 is ok for now.
  // In the future we might consider alternative scans that go against projections or
  // different compression schemes etc that affect the amount of data read. Such alternatives
  // would affect both cpu and io cost.
  final DremioCost.Factory costFactory = (DremioCost.Factory)planner.getCostFactory();
  return costFactory.makeCost(estimatedCount, cpuCost, ioCost, networkCost);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:67,代码来源:OldScanRelBase.java


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