本文整理汇总了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;
}
示例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;
}
示例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);
}