Package org.voltdb.catalog

Examples of org.voltdb.catalog.ProcParameter


                    int idx = ((StmtParameter)catalog_param).getIndex();
                    sig += hasher.hash(params[idx]);
                   
                // ProcParameter
                } else if (catalog_param instanceof ProcParameter) {
                    ProcParameter catalog_procparam = (ProcParameter)catalog_param;
                    int idx = catalog_procparam.getIndex();
                   
                    // ARRAY
                    if (catalog_procparam.getIsarray()) {
                        Set<Integer> hashes = new TreeSet<Integer>();
                        for (Object o : (Object[])params[idx]) {
                            hashes.add(hasher.hash(o));
                        } // FOR
                        boolean first_hash = true;
View Full Code Here


            if (!table_attributes.contains(catalog_tbl))
                orig_solution.put(catalog_tbl, catalog_tbl.getPartitioncolumn());
        }
        for (Procedure catalog_proc : info.catalogContext.database.getProcedures()) {
            if (!proc_attributes.contains(catalog_proc)) {
                ProcParameter catalog_param = catalog_proc.getParameters().get(catalog_proc.getPartitionparameter());
                orig_solution.put(catalog_proc, catalog_param);
            }
        }

        // -------------------------------
        // Calculate the number of backtracks and the local search time
        // we want to allow in this round.
        // -------------------------------
        if (hints.enable_local_search_increase) {
            if (this.last_halt_reason == HaltReason.BACKTRACK_LIMIT && this.last_backtrack_limit != null) {
                // Give them more backtracks
                this.last_backtrack_limit = this.last_backtrack_limit * hints.back_tracks_multiplier;
                LOG.info(String.format("Increasing BackTrack limit from %d to %.02f", hints.limit_back_tracks, this.last_backtrack_limit));
                hints.limit_back_tracks = (int) Math.round(this.last_backtrack_limit);
            } else if (this.last_halt_reason == HaltReason.LOCAL_TIME_LIMIT && this.last_localtime_limit != null) {
                // Give them more time
                this.last_localtime_limit = this.last_localtime_limit * hints.local_time_multiplier;
                LOG.info(String.format("Increasing LocalTime limit from %d to %.02f", hints.limit_local_time, this.last_localtime_limit));
                hints.limit_local_time = (int) Math.round(this.last_localtime_limit);
            }
        }

        // -------------------------------
        // GO GO LOCAL SEARCH!!
        // -------------------------------
        Pair<PartitionPlan, BranchAndBoundPartitioner.StateVertex> pair = this.executeLocalSearch(hints, this.agraph, table_attributes, proc_attributes);
        assert (pair != null);
        PartitionPlan result = pair.getFirst();
        BranchAndBoundPartitioner.StateVertex state = pair.getSecond();

        // -------------------------------
        // Validation
        // -------------------------------
        for (Table catalog_tbl : info.catalogContext.database.getTables()) {
            if (catalog_tbl.getSystable() == false && orig_solution.containsKey(catalog_tbl)) {
                assert (orig_solution.get(catalog_tbl).equals(catalog_tbl.getPartitioncolumn())) : String.format("%s got changed: %s => %s", catalog_tbl, orig_solution.get(catalog_tbl),
                        catalog_tbl.getPartitioncolumn());
            }
        } // FOR
        for (Procedure catalog_proc : info.catalogContext.database.getProcedures()) {
            if (orig_solution.containsKey(catalog_proc)) {
                ProcParameter catalog_param = catalog_proc.getParameters().get(catalog_proc.getPartitionparameter());
                if (catalog_param == null) {
                    assert (orig_solution.get(catalog_proc) == null) : catalog_proc + " got changed: " + orig_solution.get(catalog_proc) + " => " + catalog_param + "\n" + result;
                } else {
                    assert (catalog_param.equals(orig_solution.get(catalog_proc))) : catalog_proc + " got changed: " + orig_solution.get(catalog_proc) + " => " + catalog_param + "\n" + result;
                }
            }
        } // FOR

        // -------------------------------
View Full Code Here

        for (Procedure catalog_proc : procs) {
            if (catalog_proc.getSystemproc() || catalog_proc.getParameters().size() == 0)
                continue;
            // If we get back a null ProcParameter, then just the Procedure
            // alone
            ProcParameter catalog_proc_param = this.findBestProcParameter(hints, catalog_proc);
            if (catalog_proc_param != null)
                new_procparams.put(catalog_proc, catalog_proc_param.getIndex());
        } // FOR
        this.applyProcParameterSwap(hints, new_procparams);
    }
View Full Code Here

        // Find all the ProcParameter correlations that map to the target column
        // in the Procedure
        // ParameterCorrelations correlations = info.getCorrelations();
        // assert(correlations != null);

        ProcParameter default_param = catalog_proc.getParameters().get(0);
        ObjectHistogram<Column> col_access_histogram = this.proc_column_histogram.get(catalog_proc);
        if (col_access_histogram == null) {
            if (debug.val)
                LOG.warn("No column access histogram for " + catalog_proc + ". Setting to default");
            return (default_param);
        }
        if (debug.val)
            LOG.debug(catalog_proc + " Column Histogram:\n" + col_access_histogram);

        // Loop through each Table and check whether its partitioning column is
        // referenced in this procedure
        Map<ProcParameter, List<Double>> param_weights = new HashMap<ProcParameter, List<Double>>();
        for (Table catalog_tbl : info.catalogContext.database.getTables()) {
            if (catalog_tbl.getIsreplicated())
                continue;
            Column catalog_col = catalog_tbl.getPartitioncolumn();
            if (!col_access_histogram.contains(catalog_col))
                continue;
            long col_access_cnt = col_access_histogram.get(catalog_col);

            if (debug.val)
                LOG.debug(CatalogUtil.getDisplayName(catalog_col));
            // Now loop through the ProcParameters and figure out which ones are
            // correlated to the Column
            for (ProcParameter catalog_proc_param : catalog_proc.getParameters()) {
                // Skip if this is an array
                if (hints.enable_array_procparameter_candidates == false && catalog_proc_param.getIsarray())
                    continue;

                if (!param_weights.containsKey(catalog_proc_param)) {
                    param_weights.put(catalog_proc_param, new ArrayList<Double>());
                }
                List<Double> weights_list = param_weights.get(catalog_proc_param);
                Collection<ParameterMapping> pms = mappings.get(catalog_proc_param, catalog_col);
                if (pms != null) {
                    for (ParameterMapping c : pms) {
                        weights_list.add(c.getCoefficient() * col_access_cnt);
                    } // FOR
                }
                if (debug.val)
                    LOG.debug("  " + catalog_proc_param + ": " + weights_list);
            } // FOR
            if (debug.val)
                LOG.debug("");
        } // FOR (Table)

        final Map<ProcParameter, Double> final_param_weights = new HashMap<ProcParameter, Double>();
        for (Entry<ProcParameter, List<Double>> e : param_weights.entrySet()) {
            // The weights for each ProcParameter will be the geometric mean of
            // the correlation coefficients
            if (!e.getValue().isEmpty()) {
                double weights[] = new double[e.getValue().size()];
                for (int i = 0; i < weights.length; i++)
                    weights[i] = e.getValue().get(i);
                final_param_weights.put(e.getKey(), MathUtil.geometricMean(weights, MathUtil.GEOMETRIC_MEAN_ZERO));
            }
        } // FOR
        if (final_param_weights.isEmpty()) {
            if (debug.val)
                LOG.warn("Failed to find any ProcParameters for " + catalog_proc.getName() + " that map to partition columns");
            return (default_param);
        }
        Map<ProcParameter, Double> sorted = CollectionUtil.sortByValues(final_param_weights, true);
        assert (sorted != null);
        ProcParameter best_param = CollectionUtil.first(sorted.keySet());
        if (debug.val)
            LOG.debug("Best Param: " + best_param + " " + sorted);
        return (best_param);
    }
View Full Code Here

        for (ProcParameter catalog_param : params) {
            param_map.put(catalog_param, new HashSet<MultiProcParameter>());
        } // FOR

        for (int i = 0, cnt = params.size(); i < cnt; i++) {
            ProcParameter param0 = params.get(i);
            assert (param0 != null);
            if (param0 instanceof MultiProcParameter || param0.getIsarray())
                continue;

            for (int ii = i + 1; ii < cnt; ii++) {
                ProcParameter param1 = params.get(ii);
                assert (param1 != null);
                if (param1 instanceof MultiProcParameter || param1.getIsarray())
                    continue;

                // This will automatically update the Procedure, so there isn't
                // anything more
                // we need to do here...
View Full Code Here

        for (Procedure catalog_proc : catalog_db.getProcedures()) {
            Procedure clone_proc = clone_db.getProcedures().get(catalog_proc.getName());
            for (ProcParameter catalog_param : catalog_proc.getParameters()) {
                if (catalog_param instanceof MultiProcParameter) {
                    MultiProcParameter mpp = (MultiProcParameter) catalog_param;
                    ProcParameter clone_params[] = new ProcParameter[mpp.size()];
                    for (int i = 0; i < clone_params.length; i++) {
                        clone_params[i] = clone_proc.getParameters().get(mpp.get(i).getIndex());
                    } // FOR

                    // This will automatically add our guy into clone_tbl
View Full Code Here

            StmtParameter src_stmt_param = (StmtParameter) src_item;
            StmtParameter dest_stmt_param = (StmtParameter) clone;

            if (src_stmt_param.getProcparameter() != null) {
                Procedure dest_proc = (Procedure) dest_stmt_param.getParent().getParent();
                ProcParameter src_proc_param = src_stmt_param.getProcparameter();
                ProcParameter dest_proc_param = dest_proc.getParameters().get(src_proc_param.getName());
                if (dest_proc_param == null) {
                    LOG.warn("dest_proc:      " + dest_proc);
                    LOG.warn("dest_stmt:      " + dest_stmt_param.getParent());
                    LOG.warn("src_proc_param: " + src_proc_param);
                    LOG.warn("dest_proc.getParameters(): " + CatalogUtil.debug(dest_proc.getParameters()));
View Full Code Here

        } // FOR
    }
   
    @Override
    public Object calculate(String key, Object params[]) throws Exception {
        ProcParameter catalog_param = this.getProcParameter(key);
        Object inner_params[] = (Object[])params[catalog_param.getIndex()];
        return (this.calculate(inner_params));
    }
View Full Code Here

        } // FOR
    }
   
    @Override
    public Object calculate(String key, Object params[]) throws Exception {
        ProcParameter catalog_param = this.getProcParameter(key);
        Object inner_params[] = (Object[])params[catalog_param.getIndex()];
        return (this.calculate(inner_params));
    }
View Full Code Here

        } // FOR
    }
   
    @Override
    public Object calculate(String key, Object params[]) throws Exception {
        ProcParameter catalog_param = this.getProcParameter(key);
        assert(catalog_param.getIsarray()) : "Invalid: " + catalog_param;
        Object inner_params[] = (Object[])params[catalog_param.getIndex()];
        return (inner_params.length);
    }
View Full Code Here

TOP

Related Classes of org.voltdb.catalog.ProcParameter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.