/** * Set the query execution options for the specified plans. * * @param plans the physical query plan * @param ftMode the fault tolerance mode under which the query will be executed * @param profilingMode how the query should be profiled */ public static void setQueryExecutionOptions( final Map<Integer, SubQueryPlan> plans, final FTMode ftMode, @Nonnull final Set<ProfilingMode> profilingMode) { for (SubQueryPlan plan : plans.values()) { plan.setFTMode(ftMode); plan.setProfilingMode(profilingMode); } }
/** * Instantiate the server's desired physical plan from a list of JSON encodings of fragments. This * list must contain a self-consistent, complete query. All fragments will be executed in * parallel. * * @param fragments the JSON-encoded query fragments to be executed in parallel * @param server the server on which the query will be executed * @return the physical plan * @throws CatalogException if there is an error instantiating the plan */ public static Map<Integer, SubQueryPlan> instantiate( final List<PlanFragmentEncoding> fragments, final ConstructArgs args) throws CatalogException { // Assign fragment index before everything else int idx = 0; for (PlanFragmentEncoding fragment : fragments) { fragment.setFragmentIndex(idx++); } /* Sanity check the edges between fragments. */ sanityCheckEdges(fragments); assignWorkersToFragments(fragments, args); Map<Integer, PlanFragmentEncoding> op2OwnerFragmentMapping = Maps.newHashMap(); for (PlanFragmentEncoding fragment : fragments) { for (OperatorEncoding<?> op : fragment.operators) { op2OwnerFragmentMapping.put(op.opId, fragment); } } Map<Integer, SubQueryPlan> plan = Maps.newHashMap(); Map<PlanFragmentEncoding, RootOperator> instantiatedFragments = Maps.newHashMap(); Map<Integer, Operator> allOperators = Maps.newHashMap(); for (PlanFragmentEncoding fragment : fragments) { RootOperator op = instantiateFragment( fragment, args, instantiatedFragments, op2OwnerFragmentMapping, allOperators); for (Integer worker : fragment.workers) { SubQueryPlan workerPlan = plan.get(worker); if (workerPlan == null) { workerPlan = new SubQueryPlan(); plan.put(worker, workerPlan); } workerPlan.addRootOp(op); } } return plan; }