Package org.voltdb.catalog

Examples of org.voltdb.catalog.StmtParameter


        Map<Statement, Object[]> stmt_params = new HashMap<Statement, Object[]>();
        for (Statement catalog_stmt : vpc.getOptimizedQueries()) {
            // We first need to generate random input parameters
            Object params[] = new Object[catalog_stmt.getParameters().size()];
            for (int i = 0; i < params.length; i++) {
                StmtParameter catalog_param = catalog_stmt.getParameters().get(i);
                VoltType vtype = VoltType.get(catalog_param.getJavatype());
                params[i] = VoltTypeUtil.getRandomValue(vtype);
            } // FOR
            stmt_params.put(catalog_stmt, params);
           
            // Then get the list of partitions that it will access
View Full Code Here


                }
                continue;
            }
           
            // Go through the StmtParameters and map values from ProcParameters
            StmtParameter stmt_params[] = catalog_stmt.getParameters().values();
            Object stmt_args[] = new Object[stmt_params.length]; // this.getStatementParamsArray(catalog_stmt);
            boolean stmt_args_set = false;
           
            // XXX: This method may return null because it's being used for other
            // purposes in the BatchPlanner.
            int stmt_args_offsets[] = this.p_estimator.getStatementEstimationParameters(catalog_stmt);
            if (stmt_args_offsets == null) {
                stmt_args_offsets = new int[stmt_args.length];
                for (int i = 0; i < stmt_args.length; i++)
                    stmt_args_offsets[i] = i;
            }
            assert(stmt_args_offsets != null) :
                "Unexpected null StmtParameter offsets for " + catalog_stmt.fullName();
            for (int offset : stmt_args_offsets) {
                StmtParameter catalog_stmt_param = stmt_params[offset];
                assert(catalog_stmt_param != null);
                if (trace.val)
                    LOG.trace("Retrieving ParameterMappings for " + catalog_stmt_param.fullName());
               
                Collection<ParameterMapping> mappings = stmtMappings.get(catalog_stmt_param);
                if (mappings == null || mappings.isEmpty()) {
                    if (trace.val)
                        LOG.trace("No parameter mappings exists for " + catalog_stmt_param.fullName());
                    continue;
                }
                if (debug.val)
                    LOG.debug("Found " + mappings.size() + " mapping(s) for " + catalog_stmt_param.fullName());
       
                // Special Case:
                // If the number of possible Statements we could execute next is greater than one,
                // then we need to prune our list by removing those Statements who have a StmtParameter
                // that are correlated to a ProcParameter that doesn't exist (such as referencing an
                // array element that is greater than the size of that current array)
                // TODO: For now we are just going always pick the first mapping
                // that comes back. Is there any choice that we would need to make in order
                // to have a better prediction about what the transaction might do?
                if (debug.val && mappings.size() > 1) {
                    LOG.warn("Multiple parameter mappings for " + catalog_stmt_param.fullName());
                    if (trace.val) {
                        int ctr = 0;
                        for (ParameterMapping m : mappings) {
                            LOG.trace("[" + (ctr++) + "] Mapping: " + m);
                        } // FOR
View Full Code Here

        assertFalse(cols.isEmpty());
        // System.err.println(stmt.fullName() + " -> " + cols + "\n" + StringUtil.formatMaps(cache.colParams));
       
        Set<StmtParameter> seenParams = new HashSet<StmtParameter>();
        for (Column col : cols) {
            StmtParameter param = cache.colParams.get(col);
            assertNotNull(col.fullName(), param);
            assertFalse(param.fullName(), seenParams.contains(param));
            seenParams.add(param);
        } // FOR
        assertEquals(cols.size(), seenParams.size());
    }
View Full Code Here

     */
    public void testEqualParameters() throws Exception {
        Procedure catalog_proc = this.getProcedure(neworder.class);
        Statement catalog_stmt = CollectionUtil.first(catalog_proc.getStatements());
        assertNotNull(catalog_stmt);
        StmtParameter catalog_stmt_param = CollectionUtil.first(catalog_stmt.getParameters());
        assertNotNull(catalog_stmt_param);
       
        TransactionTrace txn_trace = CollectionUtil.first(workload.getTraces(catalog_proc));
        assertNotNull(txn_trace);
       
View Full Code Here

        // Input Parameters
        // We will need to update the system catalogs with this new information
        // If this is an adhoc query then there won't be any parameters
        for (ParameterInfo param : plan.parameters) {
            StmtParameter catalogParam = catalogStmt.getParameters().add(String.valueOf(param.index));
            catalogParam.setJavatype(param.type.getValue());
            catalogParam.setIndex(param.index);
        }

        // Output Columns
        int index = 0;
        for (Integer plancol : plan.columns) {
View Full Code Here

            }

        // StmtParameter
        } else if (src_item instanceof StmtParameter) {
            // We need to fix the reference to the ProcParameter (if one exists)
            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()));
                    CatalogUtil.saveCatalog(dest_catalog, CatalogUtil.CATALOG_FILENAME);
                }

                assert (dest_proc_param != null);
                dest_stmt_param.setProcparameter(dest_proc_param);
            }
        }
        return (clone);
    }
View Full Code Here

        // The input parameters to the MapInputQuery are the input parameters
        // for the Procedure
        else {
            paramTypes = new Class<?>[mapStatement.getParameters().size()];
            for (int i = 0; i < paramTypes.length; i++) {
                StmtParameter catalog_stmt_param = mapStatement.getParameters().get(i);
                assert (catalog_stmt_param != null);
                VoltType vtype = VoltType.get(catalog_stmt_param.getJavatype());
                paramTypes[i] = vtype.classFromType();

                ProcParameter catalog_proc_param = procedure.getParameters().add(catalog_stmt_param.getName());
                catalog_proc_param.setIndex(i);
                catalog_proc_param.setIsarray(false); // One day...
                catalog_proc_param.setType(vtype.getValue());
            } // FOR
        }
View Full Code Here

            QueryInstance query_instance = correlation.getQueryInstance(catalog_stmt);
            Object query_params[] = query_trace.getParams();
           
            // For each of the StmtParameter, update the correlation information for each of the ProcParameters
            for (int i = 0; i < query_params.length; i++) {
                StmtParameter catalog_stmt_param = catalog_stmt.getParameters().get(i);
                assert(catalog_stmt_param != null);
                VoltType stmt_param_type = VoltType.get(catalog_stmt_param.getJavatype());
                assert(stmt_param_type != VoltType.INVALID);
                Number stmt_param_val = this.getParamAsNumber(stmt_param_type, query_params[i]);

                for (int ii = 0; ii < xact_params.length; ii++) {
                    ProcParameter catalog_proc_param = catalog_proc.getParameters().get(ii);
View Full Code Here

                if (catalog_stmt == null) {
                    throw new RuntimeException("Unknown Statement name '" + stmt_name + "' in ParameterMapping");
                }

                for (Integer stmt_param : map.get(stmt_name).keySet()) {
                    StmtParameter catalog_stmt_param = catalog_stmt.getParameters().get(stmt_param);

                    Integer proc_param = map.get(stmt_name).get(stmt_param);
                    ProcParameter catalog_proc_param = catalog_proc.getParameters().get(proc_param);

                    // Skip if it already has the proper ProcParameter set
                    if (!force && catalog_stmt_param.getProcparameter() != null && catalog_stmt_param.getProcparameter().equals(catalog_proc_param)) {
                        if (debug.val) LOG.debug("Skipping parameter mapping in " + catalog_stmt + " because it is already set");
                    } else {
                        catalog_stmt_param.setProcparameter(catalog_proc_param);
                        if (debug.val) LOG.debug("Added parameter mapping in Statement '" + stmt_name + "' from StmtParameter '" + catalog_stmt_param.getName() + "' to '" + catalog_proc_param.getName() + "'");
                    }
                } // FOR
            } // FOR
        } // FOR
        return;
View Full Code Here

    @Override
    public boolean add(ParameterMapping c) {
        assert(c != null);
        Statement catalog_stmt = c.getStatement();
        assert(catalog_stmt != null);
        StmtParameter catalog_stmt_param = c.getStmtParameter();
        assert(catalog_stmt_param != null);
        Procedure catalog_proc = catalog_stmt.getParent();
        assert(catalog_proc != null);
        ProcParameter catalog_proc_param = c.getProcParameter();
        Column catalog_col = c.getColumn();
View Full Code Here

TOP

Related Classes of org.voltdb.catalog.StmtParameter

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.