return fullTableScanPayload.getLeadingRowCount(); } else if (condition != null) { conditionAsStr = convertRexToString(condition, scanRel.getRowType()); payloadMap = statsCache.get(conditionAsStr); if (payloadMap != null) {
public boolean initialize(RexNode condition, DrillScanRelBase scanRel, IndexCallContext context) { GroupScan scan = IndexPlanUtils.getGroupScan(scanRel); PlannerSettings settings = PrelUtil.getPlannerSettings(scanRel.getCluster().getPlanner()); rowKeyJoinBackIOFactor = settings.getIndexRowKeyJoinCostFactor(); if (scan instanceof DbGroupScan) { String conditionAsStr = convertRexToString(condition, scanRel.getRowType()); if (statsCache.get(conditionAsStr) == null) { IndexCollection indexes = ((DbGroupScan)scan).getSecondaryIndexCollection(scanRel); populateStats(condition, indexes, scanRel, context); logger.info("index_plan_info: initialize: scanRel #{} and groupScan {} got fulltable {}, statsCache: {}, fiStatsCache: {}", scanRel.getId(), System.identityHashCode(scan), fullTableScanPayload, statsCache, fIStatsCache); return true; } } return false; }
newRowType = FunctionalIndexHelper.rewriteFunctionalRowType(scanRel, context, functionInfo); } else { newRowType = scanRel.getRowType(); StatisticsPayload payload = new MapRDBStatisticsPayload(rowCount, leadingRowCount, avgRowSize); addToCache(idxCondition, idx, context, payload, jTabGrpScan, scanRel, newRowType); addBaseConditions(idxCondition, payload, false, baseConditionMap, scanRel.getRowType()); RexNode idxTotColCondition = IndexPlanUtils.getTotalFilter(idxLeadColCondition, idxTotRemColCondition, builder); FunctionalIndexInfo functionInfo = idx.getFunctionalInfo(); RelDataType newRowType = scanRel.getRowType(); if (functionInfo.hasFunctional()) { newRowType = FunctionalIndexHelper.rewriteFunctionalRowType(scanRel, context, functionInfo); convertToLogicalExpression(condition, scanRel.getRowType(), settings, builder)), null, scanRel); addToCache(condition, null, null, new MapRDBStatisticsPayload(rowCount, ftsLeadingKeyPayload.getRowCount(), ftsPayload.getAvgRowSize()), jTabGrpScan, scanRel, scanRel.getRowType()); ftsPayload.getAvgRowSize()), jTabGrpScan, scanRel, scanRel.getRowType());
/** * Build the collation property for index scan * @param indexDesc the index for which we are building index plan * @param context the context of this index planning process * @return the output RelCollation for the scan on index */ public static RelCollation buildCollationCoveringIndexScan(IndexDescriptor indexDesc, IndexCallContext context) { Map<LogicalExpression, Integer> rowTypeExprs = getExprsFromRowType(context.getScan().getRowType()); return buildCollationForExpressions(rowTypeExprs, indexDesc, context); }
return fullTableScanPayload.getLeadingRowCount(); } else if (condition != null) { conditionAsStr = convertRexToString(condition, scanRel.getRowType()); payloadMap = statsCache.get(conditionAsStr); if (payloadMap != null) {
public boolean initialize(RexNode condition, DrillScanRelBase scanRel, IndexCallContext context) { GroupScan scan = IndexPlanUtils.getGroupScan(scanRel); PlannerSettings settings = PrelUtil.getPlannerSettings(scanRel.getCluster().getPlanner()); rowKeyJoinBackIOFactor = settings.getIndexRowKeyJoinCostFactor(); if (scan instanceof DbGroupScan) { String conditionAsStr = convertRexToString(condition, scanRel.getRowType()); if (statsCache.get(conditionAsStr) == null) { IndexCollection indexes = ((DbGroupScan)scan).getSecondaryIndexCollection(scanRel); populateStats(condition, indexes, scanRel, context); logger.info("index_plan_info: initialize: scanRel #{} and groupScan {} got fulltable {}, statsCache: {}, fiStatsCache: {}", scanRel.getId(), System.identityHashCode(scan), fullTableScanPayload, statsCache, fIStatsCache); return true; } } return false; }
public RelNode buildOriginalProject (RelNode newRel) { RelDataType origRowType = origProject == null ? origScan.getRowType() : origProject.getRowType(); final RelDataTypeFactory.FieldInfoBuilder finalFieldTypeBuilder = origScan.getCluster().getTypeFactory().builder(); List<RelDataTypeField> hjRowFields = newRel.getRowType().getFieldList(); int toRemoveRowKeyCount = 1; if (getRowKeyIndex(origRowType, origScan) < 0 ) { toRemoveRowKeyCount = 2; } finalFieldTypeBuilder.addAll(hjRowFields.subList(0, hjRowFields.size()-toRemoveRowKeyCount)); final RelDataType finalProjectRowType = finalFieldTypeBuilder.build(); List<RexNode> resetExprs = Lists.newArrayList(); for (int idx=0; idx<hjRowFields.size()-toRemoveRowKeyCount; ++idx) { resetExprs.add(RexInputRef.of(idx, newRel.getRowType())); } final ProjectPrel resetProjectPrel = new ProjectPrel(newRel.getCluster(), newRel.getTraitSet(), newRel, resetExprs, finalProjectRowType); newRel = resetProjectPrel; RelNode finalRel = Prule.convert(newRel, newRel.getTraitSet()); return finalRel; }
RelDataTypeField f = indexContext.getScan().getRowType().getFieldList().get(idx); String pathSeg = f.getName().replaceAll("`", ""); final String[] segs = pathSeg.split("\\.");
newRowType = FunctionalIndexHelper.rewriteFunctionalRowType(scanRel, context, functionInfo); } else { newRowType = scanRel.getRowType(); StatisticsPayload payload = new MapRDBStatisticsPayload(rowCount, leadingRowCount, avgRowSize); addToCache(idxCondition, idx, context, payload, jTabGrpScan, scanRel, newRowType); addBaseConditions(idxCondition, payload, false, baseConditionMap, scanRel.getRowType()); RexNode idxTotColCondition = IndexPlanUtils.getTotalFilter(idxLeadColCondition, idxTotRemColCondition, builder); FunctionalIndexInfo functionInfo = idx.getFunctionalInfo(); RelDataType newRowType = scanRel.getRowType(); if (functionInfo.hasFunctional()) { newRowType = FunctionalIndexHelper.rewriteFunctionalRowType(scanRel, context, functionInfo); convertToLogicalExpression(condition, scanRel.getRowType(), settings, builder)), null, scanRel); addToCache(condition, null, null, new MapRDBStatisticsPayload(rowCount, ftsLeadingKeyPayload.getRowCount(), ftsPayload.getAvgRowSize()), jTabGrpScan, scanRel, scanRel.getRowType()); ftsPayload.getAvgRowSize()), jTabGrpScan, scanRel, scanRel.getRowType());
RelDataType dbscanRowType = convertRowType(origScan.getRowType(), origScan.getCluster().getTypeFactory()); ScanPrel dbScan = new ScanPrel(origScan.getCluster(), origScan.getTraitSet().plus(Prel.DRILL_PHYSICAL).plus(partition), restrictedGroupScan, dbscanRowType, origScan.getTable());
RelDataType dbscanRowType = convertRowType(origScan.getRowType(), origScan.getCluster().getTypeFactory()); RelDataType indexScanRowType = FunctionalIndexHelper.convertRowTypeForIndexScan( origScan, indexContext.getOrigMarker(), indexGroupScan, functionInfo); origScan.getTable(), origScan.getRowType(), indexContext.getScanColumns()); double rightIdxRowCount = indexGroupScan.getRowCount(indexCondition, rightIdxRel); restrictedGroupScan.setRowCount(null, rightIdxRowCount, rightIdxRowCount); RelDataType origRowType = origProject == null ? origScan.getRowType() : origProject.getRowType();