Package org.voltdb.catalog

Examples of org.voltdb.catalog.ProcParameter


                        LOG.error(msg, ex);
                        throw new ServerFaultException(msg, ex, ts.getTransactionId());
                    }
                }
                else {
                    ProcParameter catalog_proc_param = pm.procedure_parameter;
                    assert(catalog_proc_param != null) :
                        "Missing mapping from " + catalog_param.fullName() + " to ProcParameter";
                    stmt_params[catalog_param.getIndex()] = proc_params[catalog_proc_param.getIndex()];
                }
            } // FOR (StmtParameter)
            prefetchParams[i] = new ParameterSet(stmt_params);
            prefetchCounters[i] = counted_stmt.counter;
View Full Code Here


   
    protected final ProcParameter getProcParameter(Database catalog_db, Procedure catalog_proc, int idx) {
        assertNotNull(catalog_db);
        assert(idx >= 0) : "Invalid ProcParameter index for " + catalog_proc + ": " + idx;
        assert(idx < catalog_proc.getParameters().size()) : "Invalid ProcParameter index for " + catalog_proc + ": " + idx;
        ProcParameter catalog_param = catalog_proc.getParameters().get(idx);
        assertNotNull("Null ProcParameter index for " + catalog_proc + ": " + idx, catalog_param);
        return (catalog_param);
    }
View Full Code Here

        Column catalog_col = PlanNodeUtil.getColumnForStmtParameter(catalog_param);
        assertNotNull(catalog_col);
        Collection<Column> columns = CollectionUtil.addAll(new HashSet<Column>(), catalog_col);
        summarizer = new WorkloadSummarizer(catalog_db, p_estimator, mappings, catalog_db.getProcedures(), columns);
       
        ProcParameter expected = this.getProcParameter(catalog_proc, 1);
        List<ProcParameter> proc_params = summarizer.getTargetParameters(catalog_proc);
        assertNotNull(proc_params);
        assertEquals(1, proc_params.size());
        assert(proc_params.contains(expected)) : proc_params;
    }
View Full Code Here

        System.err.println(StringUtil.DOUBLE_LINE);
        System.err.println(catalog_proc);

        assertEquals(catalog_proc.getParameters().size(), params.length);
        for (int i = 0, cnt = params.length; i < cnt; i++) {
            ProcParameter catalog_param = catalog_proc.getParameters().get(i);
            assertNotNull(catalog_param);

            try {
                VoltType expected_type = VoltType.get((byte) catalog_param.getType());
                if (catalog_param.getIsarray()) {
                    int j = 0;
                    for (Object inner : (Object[]) params[i]) {
                        System.err.print("[" + i + "][" + j++ + "]: " + expected_type + " --> " + inner + " [class=" + inner.getClass() + ",");
                        VoltType param_type = VoltType.typeFromClass(inner.getClass());
                        System.err.println("type=" + param_type + "]");
View Full Code Here

    /**
     * testMultiProcParameter
     */
    public void testMultiProcParameter() throws Exception {
        Procedure catalog_proc = this.getProcedure(UpdateSubscriberData.class);
        ProcParameter params[] = { catalog_proc.getParameters().get(0), catalog_proc.getParameters().get(1), };
        MultiProcParameter item0 = MultiProcParameter.get(params);
        assertNotNull(item0);

        String key = CatalogKey.createKey(item0);
        assertNotNull(key);
View Full Code Here

        // We want to make sure that it clones MultiProcParameters too!
        Procedure target_proc = this.getProcedure(neworder.class);
        List<MultiProcParameter> expected = new ArrayList<MultiProcParameter>();
        int cnt = 3;
        for (int i = 0; i < cnt; i++) {
            ProcParameter col0 = target_proc.getParameters().get(i);
            for (int ii = i + 1; ii < cnt; ii++) {
                ProcParameter col1 = target_proc.getParameters().get(ii);
                MultiProcParameter mpp = MultiProcParameter.get(col0, col1);
                assertNotNull(mpp);
                expected.add(mpp);
            } // FOR
        } // FOR
        assertFalse(expected.isEmpty());
       
        Database clone_db = CatalogCloner.cloneDatabase(catalog_db);
        assertNotNull(clone_db);

        Cluster catalog_cluster = CatalogUtil.getCluster(catalog_db);
        assertNotNull(catalog_cluster);
        Cluster clone_cluster = CatalogUtil.getCluster(clone_db);
        assertNotNull(clone_cluster);
        for (Host catalog_host : catalog_cluster.getHosts()) {
            Host clone_host = clone_cluster.getHosts().get(catalog_host.getName());
            assertNotNull(clone_host);
            checkFields(Host.class, catalog_host, clone_host);
        } // FOR

        for (Site catalog_site : catalog_cluster.getSites()) {
            Site clone_site = clone_cluster.getSites().get(catalog_site.getName());
            assertNotNull(clone_site);
            checkFields(Site.class, catalog_site, clone_site);
        }

        assertEquals(NUM_PARTITIONS, CatalogUtil.getNumberOfPartitions(clone_db));
        Collection<Integer> clone_partitions = CatalogUtil.getAllPartitionIds(clone_db);
        assertNotNull(clone_partitions);
        assertEquals(all_partitions.size(), clone_partitions.size());
        assert (all_partitions.containsAll(clone_partitions));

        for (Table catalog_tbl : catalog_db.getTables()) {
            Table clone_tbl = clone_db.getTables().get(catalog_tbl.getName());
            assertNotNull(catalog_tbl.toString(), clone_tbl);
            checkFields(Table.class, catalog_tbl, clone_tbl);

            for (Column catalog_col : catalog_tbl.getColumns()) {
                Column clone_col = clone_tbl.getColumns().get(catalog_col.getName());
                assertNotNull(CatalogUtil.getDisplayName(catalog_col), clone_col);
                assertEquals(CatalogUtil.getDisplayName(clone_col), clone_tbl, (Table) clone_col.getParent());
                assertEquals(CatalogUtil.getDisplayName(clone_col), clone_tbl.hashCode(), clone_col.getParent().hashCode());
            } // FOR
            for (MaterializedViewInfo catalog_view : catalog_tbl.getViews()) {
                assert (catalog_view.getGroupbycols().size() > 0);
                MaterializedViewInfo clone_view = clone_tbl.getViews().get(catalog_view.getName());
                checkFields(MaterializedViewInfo.class, catalog_view, clone_view);
            } // FOR

        } // FOR

        for (Procedure catalog_proc : catalog_db.getProcedures()) {
            Procedure clone_proc = clone_db.getProcedures().get(catalog_proc.getName());
            assertNotNull(catalog_proc.toString(), clone_proc);
            assertEquals(clone_proc.getParameters().toString(), catalog_proc.getParameters().size(), clone_proc.getParameters().size());

            // Procedure Conflicts
            this.checkProcedureConflicts(catalog_proc, catalog_proc.getConflicts(), clone_proc.getConflicts());
            this.checkProcedureConflicts(catalog_proc, catalog_proc.getConflicts(), clone_proc.getConflicts());
           
            for (ProcParameter catalog_param : catalog_proc.getParameters()) {
                ProcParameter clone_param = clone_proc.getParameters().get(catalog_param.getIndex());
                assertNotNull(CatalogUtil.getDisplayName(catalog_param), clone_param);
                assertEquals(CatalogUtil.getDisplayName(clone_param), clone_proc, (Procedure) clone_param.getParent());
                assertEquals(CatalogUtil.getDisplayName(clone_param), clone_proc.hashCode(), clone_param.getParent().hashCode());
            } // FOR
        }
    }
View Full Code Here

            for (String procName : m_paramMappings.keySet()) {
                Procedure catalog_proc = catalog_db.getProcedures().getIgnoreCase(procName);
                assert(catalog_proc != null) :
                    "Invalid Procedure name for ParameterMappings '" + procName + "'";
                for (Integer procParamIdx : m_paramMappings.get(procName).keySet()) {
                    ProcParameter catalog_procParam = catalog_proc.getParameters().get(procParamIdx.intValue());
                    assert(catalog_procParam != null) :
                        "Invalid ProcParameter for '" + procName + "' at offset " + procParamIdx;
                    Pair<String, Integer> stmtPair = m_paramMappings.get(procName).get(procParamIdx);
                    assert(stmtPair != null);
                   
View Full Code Here

                        tempParamTypeIsPrimitive = new boolean[tempParamTypesLength];
                        tempParamTypeIsArray = new boolean[tempParamTypesLength];
                        tempParamTypeComponentType = new Class<?>[tempParamTypesLength];

                        for (int i = 0; i < tempParamTypesLength; i++) {
                            ProcParameter catalog_param = params.get(i);
                            VoltType vtype = VoltType.get(catalog_param.getType());
                            assert(vtype != null);
                            tempParamTypes[i] = vtype.classFromType();
                        } // FOR
                       
                        // We'll try to cast everything as a primitive
View Full Code Here

        correlation.start();
       
        // Cast all the ProcParameters once in the beginning
        Number xact_params[][] = new Number[xact_trace.getParams().length][];
        for (int i = 0; i < xact_params.length; i++) {
            ProcParameter catalog_proc_param = catalog_proc.getParameters().get("index", i);
            assert(catalog_proc_param != null);
            VoltType proc_param_type = VoltType.get(catalog_proc_param.getType());
           
            try {
                // Arrays
                if (catalog_proc_param.getIsarray()) {
                    Object param_arr[] = xact_trace.getParam(i);
                    xact_params[i] = new Number[param_arr.length];
                    for (int ii = 0; ii < param_arr.length; ii++) {
                        xact_params[i][ii] = this.getParamAsNumber(proc_param_type, param_arr[ii]);
                    } // FOR
                   
                // Scalars (just store in the first element of the array
                } else {
                    xact_params[i] = new Number[] {
                        this.getParamAsNumber(proc_param_type, xact_trace.getParam(i))
                    };
                }
            } catch (Exception ex) {
                LOG.error("Failed to process " + CatalogUtil.getDisplayName(catalog_proc_param));
                throw ex;
            }
        } // FOR
       
        // Now run through all of the queries and calculate the correlation between StmtParameters and ProcParameters
        for (QueryTrace query_trace : xact_trace.getQueries()) {
            Statement catalog_stmt = query_trace.getCatalogItem(this.catalog_db);
            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);
                    assert(catalog_proc_param != null) : "Missing ProcParameter in " + catalog_proc + " at index " + ii;
                    VoltType proc_param_type = VoltType.get(catalog_proc_param.getType());
                    assert(proc_param_type != VoltType.INVALID);
                   
                    ProcParameterCorrelation ppc = query_instance.getProcParameterCorrelation(catalog_stmt_param, catalog_proc_param);
                    for (int iii = 0; iii < xact_params[ii].length; iii++) {
                        ppc.getAbstractCorrelation(iii).addOccurrence(stmt_param_val, xact_params[ii][iii]);
View Full Code Here

        // set procedure parameter types
        CatalogMap<ProcParameter> params = procedure.getParameters();
        Class<?>[] paramTypes = lang.accept(procedureEntryPointParametersTypeExtractor, fields);
        for (int i = 0; i < paramTypes.length; i++) {
            Class<?> cls = paramTypes[i];
            ProcParameter param = params.add(String.valueOf(i));
            param.setIndex(i);

            // handle the case where the param is an array
            if (cls.isArray()) {
                param.setIsarray(true);
                cls = cls.getComponentType();
            }
            else
                param.setIsarray(false);

            // boxed types are not supported parameters at this time
            if ((cls == Long.class) || (cls == Integer.class) || (cls == Short.class) ||
                (cls == Byte.class) || (cls == Double.class) ||
                (cls == Character.class) || (cls == Boolean.class))
            {
                String msg = "Procedure: " + shortName + " has a parameter with a boxed type: ";
                msg += cls.getSimpleName();
                msg += ". Replace this parameter with the corresponding primitive type and the procedure may compile.";
                throw compiler.new VoltCompilerException(msg);
            } else if ((cls == Float.class) || (cls == float.class)) {
                String msg = "Procedure: " + shortName + " has a parameter with type: ";
                msg += cls.getSimpleName();
                msg += ". Replace this parameter type with double and the procedure may compile.";
                throw compiler.new VoltCompilerException(msg);

            }

            VoltType type;
            try {
                type = VoltType.typeFromClass(cls);
            }
            catch (VoltTypeException e) {
                // handle the case where the type is invalid
                String msg = "Procedure: " + shortName + " has a parameter with invalid type: ";
                msg += cls.getSimpleName();
                throw compiler.new VoltCompilerException(msg);
            }
            catch (RuntimeException e) {
                String msg = "Procedure: " + shortName + " unexpectedly failed a check on a parameter of type: ";
                msg += cls.getSimpleName();
                msg += " with error: ";
                msg += e.toString();
                throw compiler.new VoltCompilerException(msg);
            }

            param.setType(type.getValue());
        }

        // parse the procinfo
        procedure.setSinglepartition(info.singlePartition);
        if (info.singlePartition) {
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.