PlanNormalizer(SqlHandlerConfig sqlHandlerConfig) { this.optionManager = sqlHandlerConfig.getContext().getOptions(); }
public ReflectionPlanNormalizer( SqlHandlerConfig sqlHandlerConfig, ReflectionGoal goal, ReflectionEntry entry, Materialization materialization, NamespaceService namespace, SabotConfig config, ReflectionSettings reflectionSettings, MaterializationStore materializationStore) { this.sqlHandlerConfig = sqlHandlerConfig; this.goal = goal; this.entry = entry; this.materialization = materialization; this.namespace = namespace; this.config = config; this.reflectionSettings = reflectionSettings; this.materializationStore = materializationStore; this.optionManager = sqlHandlerConfig.getContext().getOptions(); }
DirectBuilder(String sql, SqlNode sqlNode, boolean prepare) { this.sqlNode = sqlNode; this.prepare = prepare; this.sql = sql; final StoreQueryResultsPolicy storeQueryResultsPolicy = Optional .ofNullable(context.getOptions().getOption(STORE_QUERY_RESULTS.getOptionName())) .map(o -> StoreQueryResultsPolicy.valueOf(o.getStringVal().toUpperCase(Locale.ROOT))) .orElse(StoreQueryResultsPolicy.NO); this.storeResults = storeQueryResultsPolicy != StoreQueryResultsPolicy.NO; }
public SimpleParallelizer(QueryContext context, AttemptObserver observer, Collection<NodeEndpoint> activeEndpoints) { this.queryContext = context; OptionManager optionManager = context.getOptions(); long sliceTarget = context.getPlannerSettings().getSliceTarget(); this.parallelizationThreshold = sliceTarget > 0 ? sliceTarget : 1; final long configuredMaxWidthPerNode = context.getClusterResourceInformation().getAverageExecutorCores(optionManager); final double maxWidthFactor = context.getWorkStatsProvider().get().getMaxWidthFactor(); this.maxWidthPerNode = (int) Math.max(1, configuredMaxWidthPerNode * maxWidthFactor); if (logger.isDebugEnabled() && maxWidthFactor < 1) { final float clusterLoad = context.getWorkStatsProvider().get().getClusterLoad(); logger.debug("Cluster load {} exceeded cutoff, max_width_factor = {}. current max_width = {}", clusterLoad, maxWidthFactor, this.maxWidthPerNode); } this.executionMap = new ExecutionNodeMap(Optional.ofNullable(activeEndpoints).orElse(context.getActiveEndpoints())); this.maxGlobalWidth = (int) optionManager.getOption(ExecConstants.MAX_WIDTH_GLOBAL); this.affinityFactor = optionManager.getOption(ExecConstants.AFFINITY_FACTOR); this.useNewAssignmentCreator = !optionManager.getOption(ExecConstants.OLD_ASSIGNMENT_CREATOR); this.assignmentCreatorBalanceFactor = optionManager.getOption(ExecConstants.ASSIGNMENT_CREATOR_BALANCE_FACTOR); this.observer = observer; this.fragmentCodec = FragmentCodec.valueOf(optionManager.getOption(ExecConstants.FRAGMENT_CODEC).toUpperCase()); }
protected void setQueueTypeFromPlan(PhysicalPlan plan) { final long queueThreshold = context.getOptions().getOption(BasicResourceConstants.QUEUE_THRESHOLD_SIZE); if (context.getQueryContextInfo().getPriority().getWorkloadClass().equals(WorkloadClass.BACKGROUND)) { setQueueType((plan.getCost() > queueThreshold) ? QueueType.REFLECTION_LARGE : QueueType.REFLECTION_SMALL); } else { setQueueType((plan.getCost() > queueThreshold) ? QueueType.LARGE : QueueType.SMALL); } }
public static PhysicalPlan convertToPlan(SqlHandlerConfig config, PhysicalOperator op) { PlanPropertiesBuilder propsBuilder = PlanProperties.builder(); propsBuilder.type(PlanType.PHYSICAL); propsBuilder.version(1); propsBuilder.options(new JSONOptions(config.getContext().getOptions().getOptionList())); propsBuilder.resultMode(ResultMode.EXEC); propsBuilder.generator("default", "handler"); List<PhysicalOperator> ops = Lists.newArrayList(); PopCollector c = new PopCollector(); op.accept(c, ops); return new PhysicalPlan(propsBuilder.build(), ops); }
protected QueryContext mockQueryContext(SabotContext dbContext) throws Exception { final UserSession userSession = UserSession.Builder.newBuilder().withOptionManager(dbContext.getOptionManager()).build(); final SessionOptionManager sessionOptions = (SessionOptionManager) userSession.getOptions(); final QueryOptionManager queryOptions = new QueryOptionManager(sessionOptions); final ExecutionControls executionControls = new ExecutionControls(queryOptions, NodeEndpoint.getDefaultInstance()); final OperatorTable table = new OperatorTable(FUNCTIONS()); final LogicalPlanPersistence lp = dbContext.getLpPersistence(); final CatalogService registry = dbContext.getCatalogService(); final QueryContext context = Mockito.mock(QueryContext.class); when(context.getSession()).thenReturn(userSession); when(context.getLpPersistence()).thenReturn(lp); when(context.getCatalogService()).thenReturn(registry); when(context.getFunctionRegistry()).thenReturn(FUNCTIONS()); when(context.getSession()).thenReturn(UserSession.Builder.newBuilder().setSupportComplexTypes(true).build()); when(context.getCurrentEndpoint()).thenReturn(NodeEndpoint.getDefaultInstance()); when(context.getActiveEndpoints()).thenReturn(ImmutableList.of(NodeEndpoint.getDefaultInstance())); when(context.getPlannerSettings()).thenReturn(new PlannerSettings(dbContext.getConfig(), queryOptions, dbContext.getClusterResourceInformation())); when(context.getOptions()).thenReturn(queryOptions); when(context.getConfig()).thenReturn(DEFAULT_SABOT_CONFIG); when(context.getOperatorTable()).thenReturn(table); when(context.getAllocator()).thenReturn(allocator); when(context.getExecutionControls()).thenReturn(executionControls); when(context.getMaterializationProvider()).thenReturn(Mockito.mock(MaterializationDescriptorProvider.class)); return context; }
final OptionManager options = context.getOptions(); final StoreQueryResultsPolicy storeQueryResultsPolicy = Optional .ofNullable(options.getOption(STORE_QUERY_RESULTS.getOptionName()))
private boolean initialCanVectorize(PhysicalPlanCreator creator, PhysicalOperator child){ if(!creator.getContext().getOptions().getOption(ExecConstants.ENABLE_VECTORIZED_HASHAGG)){ return false;
private PhysicalOperator getHashJoinPop(PhysicalPlanCreator creator, RelNode left, RelNode right, List<Integer> leftKeys, List<Integer> rightKeys) throws IOException{ final List<String> fields = getRowType().getFieldNames(); assert isUnique(fields); final List<String> leftFields = left.getRowType().getFieldNames(); final List<String> rightFields = right.getRowType().getFieldNames(); PhysicalOperator leftPop = ((Prel)left).getPhysicalOperator(creator); PhysicalOperator rightPop = ((Prel)right).getPhysicalOperator(creator); JoinRelType jtype = this.getJoinType(); final List<JoinCondition> conditions = Lists.newArrayList(); buildJoinConditions(conditions, leftFields, rightFields, leftKeys, rightKeys); final boolean vectorize = creator.getContext().getOptions().getOption(ExecConstants.ENABLE_VECTORIZED_HASHJOIN) && canVectorize(creator.getContext().getFunctionRegistry(), leftPop, rightPop, conditions); final HashJoinPOP hjoin = new HashJoinPOP(leftPop, rightPop, conditions, jtype, vectorize); return creator.addMetadata(this, hjoin); }
private OperatorContextImpl createContext(Writer writer) { BufferAllocator allocator = context.getAllocator().newChildAllocator("direct-command", 0, Long.MAX_VALUE); final OperatorStats stats = new OperatorStats(new OpProfileDef(0,0,0), allocator); final OperatorContextImpl oc = new OperatorContextImpl( context.getConfig(), FragmentHandle.newBuilder().setQueryId(context.getQueryId()).setMajorFragmentId(0).setMinorFragmentId(0).build(), writer, allocator, allocator, null, stats, null, null, context.getFunctionRegistry(), null, context.getOptions(), context.getNamespaceService(), null, NodeDebugContextProvider.NOOP, 60000, null, ImmutableList.of()); return oc; } }
final long ringCount = config.getContext().getOptions().getOption(PlannerSettings.RING_COUNT); final Rel writerDrel = new WriterRel(drel.getCluster(), drel.getCluster().traitSet().plus(Rel.LOGICAL), drel, config.getContext().getCatalog().createNewTable(
OptionManager queryOptions = context.getOptions();
this.observers = AttemptObservers.of(observer); final OptionManager optionManager = this.queryContext.getOptions(); if(options != null){ options.applyOptions(optionManager);
final OptionManager options = queryContext.getOptions(); final boolean memoryControlEnabled = options.getOption(BasicResourceConstants.ENABLE_QUEUE_MEMORY_LIMIT); final long memoryLimit = (queueType == QueueType.SMALL) ?
PreparedPlan plan = plans.getIfPresent(handle); if(plan != null){ if (!context.getOptions().getOption(REUSE_PREPARE_HANDLES)) { plans.invalidate(handle);
if(!context.getOptions().getOption(ExecConstants.ENABLE_WINDOW_FUNCTIONS).getBoolVal()) {
queryContext.getOptions(), queryContext.getClusterResourceInformation(), planningSet,
final BatchSchema schema = PojoRecordReader.getSchema(handler.getResultType()); final CollectingOutcomeListener listener = new CollectingOutcomeListener(); Writer writer = getWriter(context.getOptions());
final RelNode newTblRelNode = SqlHandlerUtil.resolveNewTableRel(false, sqlCreateTable.getFieldNames(), validatedRowType, queryRelNode); final long ringCount = config.getContext().getOptions().getOption(PlannerSettings.RING_COUNT);