public ScanResult getScanResult() { return context.getScanResult(); }
public static boolean isRegistered(int operatorType, int metricId){ CoreOperatorTypeMetricsMap coreOperatorTypeMetricsMap = getCoreOperatorTypeMetricsMap(); return getMetricById(coreOperatorTypeMetricsMap, operatorType, metricId).isPresent(); }
ExpansionHelper(QueryContext context) { this.context = Preconditions.checkNotNull(context, "query context required"); converter = new SqlConverter( context.getPlannerSettings(), context.getOperatorTable(), context, MaterializationDescriptorProvider.EMPTY, context.getFunctionRegistry(), context.getSession(), AbstractAttemptObserver.NOOP, context.getCatalog(), context.getSubstitutionProviderFactory(), context.getConfig(), context.getScanResult()); }
@Override public QueryContext get() { final UserSession session = systemSession(getOptionManager()); return new QueryContext(session, sabotContext.get(), new AttemptId().toQueryId()); } };
public static UserClientConnection mockUserClientConnection(QueryContext context){ final UserSession session = context != null ? context.getSession() : Mockito.mock(UserSession.class); return new UserClientConnection(){ @Override public void addTerminationListener(GenericFutureListener<? extends Future<? super Void>> listener) { } @Override public void removeTerminationListener(GenericFutureListener<? extends Future<? super Void>> listener) { } @Override public UserSession getSession() { return session; } @Override public void sendResult(RpcOutcomeListener<Ack> listener, QueryResult result) { listener.success(Acks.OK, null); } @Override public void sendData(RpcOutcomeListener<Ack> listener, QueryWritableBatch result) { try{ AutoCloseables.close((AutoCloseable[]) result.getBuffers()); listener.success(Acks.OK, null); }catch(Exception ex){ listener.failed(new RpcException(ex)); } } }; }
/** * Resume a paused query */ public void resume() { queryContext.getExecutionControls().unpauseAll(); }
PlanNormalizer(SqlHandlerConfig sqlHandlerConfig) { this.optionManager = sqlHandlerConfig.getContext().getOptions(); }
public RuleSet getRules(PlannerPhase phase) { return PlannerPhase.mergedRuleSets( phase.getRules(context), context.getCatalogService().getStorageRules(context, phase)); }
@Override public RuleSet getRules(OptimizerRulesContext context) { // Check if multi-join optimization has been disabled if (!context.getPlannerSettings().isJoinOptimizationEnabled()) { return RuleSets.ofList(); } return RuleSets.ofList( MULTIJOIN_BOTH_PROJECTS_TRANSPOSE_RULE, MULTIJOIN_LEFT_PROJECT_TRANSPOSE_RULE, MULTIJOIN_RIGHT_PROJECT_TRANSPOSE_RULE, JOIN_TO_MULTIJOIN_RULE, PROJECT_MULTIJOIN_MERGE_RULE, FILTER_MULTIJOIN_MERGE_RULE, MergeProjectRule.LOGICAL_INSTANCE, PROJECT_REMOVE_DRULE, FILTER_MERGE_DRULE ); } },
private LogicalExpression materializePruneExpr(LogicalExpression pruneCondition, PlannerSettings settings, RelNode scanRel, VectorContainer container) { // materialize the expression container.buildSchema(); return ExpressionTreeMaterializer.materializeAndCheckErrors(pruneCondition, container.getSchema(), optimizerContext.getFunctionRegistry()); }
/** * @param coreOperatorTypeMetricsMap * @param operatorType * @param metricId * @return Optional<MetricDef> containing metric defination if present in the map */ public static Optional<UserBitShared.MetricDef> getMetricById(CoreOperatorTypeMetricsMap coreOperatorTypeMetricsMap, int operatorType, int metricId) { Optional<MetricsDef> metricsDef = getMetricsDef(coreOperatorTypeMetricsMap, operatorType); if (metricsDef.isPresent() && metricId < metricsDef.get().getMetricDefCount()) { return Optional.ofNullable(metricsDef.get().getMetricDef(metricId)); } return Optional.empty(); }
@Override public ValueHolder getConstantValueHolder(String value, MinorType type, Function<ArrowBuf, ValueHolder> holderInitializer) { if (!constantValueHolderCache.containsKey(value)) { constantValueHolderCache.put(value, Maps.<MinorType, ValueHolder>newHashMap()); } Map<MinorType, ValueHolder> holdersByType = constantValueHolderCache.get(value); ValueHolder valueHolder = holdersByType.get(type); if (valueHolder == null) { valueHolder = holderInitializer.apply(getManagedBuffer()); holdersByType.put(type, valueHolder); } return valueHolder; }
protected AttemptManager newAttemptManager(SabotContext context, AttemptId attemptId, UserRequest queryRequest, AttemptObserver observer, UserSession session, OptionProvider options, CoordToExecTunnelCreator tunnelCreator, Cache<Long, PreparedPlan> plans, Predicate<DatasetConfig> datasetValidityChecker) { final QueryContext queryContext = new QueryContext(session, context, attemptId.toQueryId(), queryRequest.getPriority(), queryRequest.getMaxAllocation(), datasetValidityChecker); return new AttemptManager(context, attemptId, queryRequest, observer, options, tunnelCreator, plans, queryContext, queryResourceManager); }
/** * Method that injects an IOException with a site description of THROWS_IOEXCEPTION. * * @throws IOException */ public void throwsIOException() throws IOException { // ... code ... // simulated IOException injector.injectChecked(context.getExecutionControls(), THROWS_IOEXCEPTION, IOException.class); // ... code ... } }
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(); }
/** * @param coreOperatorTypeMetricsMap * @param operatorType * @return Array of Metric Ids if operator type is present in the map else empty list */ public static Integer[] getMetricIds(CoreOperatorTypeMetricsMap coreOperatorTypeMetricsMap, int operatorType) { Optional<MetricsDef> metricsDef = getMetricsDef(coreOperatorTypeMetricsMap, operatorType); return metricsDef.map((metricDef) -> metricDef.getMetricDefList().stream().map(UserBitShared.MetricDef::getId).toArray(Integer[]::new)).orElse(ArrayUtils.EMPTY_INTEGER_OBJECT_ARRAY); }
@BeforeClass public static void beforeClass() { context = new QueryContext(session(), getSabotContext(), QueryId.getDefaultInstance()); }
/** * Method that injects an unchecked exception with the given site description. * * @param desc the injection site description */ public void descPassthroughMethod(final String desc) { // ... code ... // simulated unchecked exception injector.injectUnchecked(context.getExecutionControls(), desc); // ... code ... }
public void countDown() { // ... code ... injector.getLatch(context.getExecutionControls(), LATCH_NAME).countDown(); // ... code ... } }
@Override public void run() { latch.awaitUninterruptibly(); try { Thread.sleep(millis); } catch (final InterruptedException ex) { this.ex.value = ex; } context.getExecutionControls().unpauseAll(); } }