Package org.voltdb

Examples of org.voltdb.VoltType


        if (defaultvalue != null && defaultvalue.equals("NULL"))
            defaultvalue = null;
        if (defaulttype != null)
            defaulttype = Integer.toString(VoltType.typeFromString(defaulttype).getValue());

        VoltType type = VoltType.typeFromString(typename);
        int size = Integer.parseInt(sizeString);
        // check valid length if varchar
        if (type == VoltType.STRING) {
            if ((size == 0) || (size > VoltType.MAX_VALUE_LENGTH)) {
                String msg = "VARCHAR Column " + name + " in table " + table.getTypeName() + " has unsupported length " + sizeString;
                throw m_compiler.new VoltCompilerException(msg);
            }
        }

        Column column = table.getColumns().add(name);
        // need to set other column data here (default, nullable, etc)
        // column.setName(name);
        column.setIndex(index);

        column.setType(type.getValue());
        column.setNullable(nullable.toLowerCase().startsWith("t") ? true : false);
        column.setSize(size);

        column.setDefaultvalue(defaultvalue);
        if (defaulttype != null)
View Full Code Here


        // 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

        Table catalog_table = catalogContext.database.getTables().getIgnoreCase(tableName);
        assert (!catalog_table.getIsreplicated());
        // XXX blatantly stolen from LoadMultipartitionTable
        // find the index and type of the partitioning attribute
        int partition_col = catalog_table.getPartitioncolumn().getIndex();
        VoltType partition_type = VoltType.get((byte) catalog_table.getPartitioncolumn().getType());

        // create a table for each partition
        VoltTable[] partitioned_tables = new VoltTable[number_of_partitions];
        for (int i = 0; i < partitioned_tables.length; i++) {
            partitioned_tables[i] = loadedTable.clone(loadedTable.getUnderlyingBufferSize() / number_of_partitions);
View Full Code Here

            final VoltTable[] inner_results = voltExecuteSQL();
            assert (inner_results.length == 0);
            while (inner_results[0].advanceRow()) {
                for (int i = 0, cnt = inner_results[0].getColumnCount(); i < cnt; i++) {
                    VoltType col_type = inner_results[0].getColumnType(i);
                    System.err.print(add + col_type.name() + "[");
                    System.err.print(inner_results[0].get(i, col_type));
                    System.err.print("]");
                    add = ", ";
                } // FOR
            } // WHILE
View Full Code Here

        while (d_results[0].advanceRow()) {
            System.err.print("RESULT (");
            String add = "";
            for (int i = 0, cnt = d_results[0].getColumnCount(); i < cnt; i++) {
                VoltType col_type = d_results[0].getColumnType(i);
                System.err.print(add + col_type.name() + "[");
                System.err.print(d_results[0].get(i, col_type));
                System.err.print("]");
                add = ", ";
            } // FOR
            System.err.println(")");
View Full Code Here

        assertNotNull(vt);
        int num_rows = 50;
        for (int i = 0; i < num_rows; i++) {
            Object row[] = new Object[catalog_tbl.getColumns().size()];
            for (int j = 0; j < row.length; j++) {
                VoltType vtype = VoltType.get(catalog_tbl.getColumns().get(j).getType());
                row[j] = VoltTypeUtil.getRandomValue(vtype, rand);
            } // FOR
            vt.addRow(row);
        } // FOR
       
View Full Code Here

     * @return The partition best set up to execute the procedure.
     * @throws VoltTypeException
     */
    public int getHashedPartitionForParameter(int partitionValueType, Object partitionValue)
            throws VoltTypeException {
        final VoltType partitionParamType = VoltType.get((byte) partitionValueType);

        // Special cases:
        // 1) if the user supplied a string for a number column,
        // try to do the conversion. This makes it substantially easier to
        // load CSV data or other untyped inputs that match DDL without
        // requiring the loader to know precise the schema.
        // 2) For legacy hashinators, if we have a numeric column but the param is in a byte
        // array, convert the byte array back to the numeric value
        if (partitionValue != null && partitionParamType.isPartitionableNumber()) {
            if (partitionValue.getClass() == String.class) {
                {
                    Object tempParam = ParameterConverter.stringToLong(
                            partitionValue,
                            partitionParamType.classFromType());
                    // Just in case someone managed to feed us a non integer
                    if (tempParam != null) {
                        partitionValue = tempParam;
                    }
                }
View Full Code Here

            // No need to check error here if a correctedLine has come here it was
            // previously successful.
            try {
                Object row_args[] = new Object[row.m_rowData.length];
                for (int i = 0; i < row_args.length; i++) {
                    final VoltType type = m_columnTypes[i];
                    row_args[i] = ParameterConverter.tryToMakeCompatible(type.classFromType(),
                            row.m_rowData[i]);
                }
                tmpTable.addRow(row_args);
            } catch (VoltTypeException ex) {
                // Should never happened because the bulk conversion in PerPartitionProcessor
View Full Code Here

            VoltBulkLoader loader = currRow.m_loader;
            Object row_args[];
            row_args = new Object[currRow.m_rowData.length];
            try {
                for (int i = 0; i < row_args.length; i++) {
                    final VoltType type = m_columnTypes[i];
                    row_args[i] = ParameterConverter.tryToMakeCompatible(type.classFromType(),
                            currRow.m_rowData[i]);
                }
            } catch (VoltTypeException e) {
                loader.generateError(currRow.m_rowHandle, currRow.m_rowData, e.getMessage());
                loader.m_outstandingRowCount.decrementAndGet();
View Full Code Here

        }

        while (procInfo.advanceRow()) {
            String table = procInfo.getString("TABLE_NAME");
            if (tableName.equalsIgnoreCase(table)) {
                VoltType vtype = VoltType.typeFromString(procInfo.getString("TYPE_NAME"));
                int idx = (int) procInfo.getLong("ORDINAL_POSITION") - 1;
                m_mappedColumnTypes.put(idx, vtype);
                m_colNames.put(idx, procInfo.getString("COLUMN_NAME"));
                String remarks = procInfo.getString("REMARKS");
                if (remarks != null && remarks.equalsIgnoreCase("PARTITION_COLUMN")) {
                    m_partitionColumnType = vtype;
                    m_partitionedColumnIndex = idx;
                }
            }
        }
        m_columnCnt = m_mappedColumnTypes.size();

        if (m_columnCnt == 0) {
            //VoltBulkLoader will exit.
            throw new IllegalArgumentException("Table Name parameter does not match any known table.");
        }
        m_columnTypes = getColumnTypes();

        //Build column info so we can build VoltTable
        m_colInfo = new VoltTable.ColumnInfo[m_columnCnt];
        for (int i = 0; i < m_columnCnt; i++) {
            VoltType type = m_columnTypes[i];
            String cname = m_colNames.get(i);
            VoltTable.ColumnInfo ci = new VoltTable.ColumnInfo(cname, type);
            m_colInfo[i] = ci;
        }
View Full Code Here

TOP

Related Classes of org.voltdb.VoltType

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.