Package org.voltdb

Examples of org.voltdb.VoltType


        }

        // Columns
        String add = "\n";
        for (Column catalog_col : CatalogUtil.getSortedCatalogItems(catalog_tbl.getColumns(), "index")) {
            VoltType col_type = VoltType.get((byte)catalog_col.getType());

            // this next assert would be great if we dealt with default values well
            //assert(! ((catalog_col.getDefaultvalue() == null) && (catalog_col.getNullable() == false) ) );

            if (tableIsView) {
                sb.append(add + spacer + catalog_col.getTypeName());
                add = ",\n";
                continue;
            }

            sb.append(add + spacer + catalog_col.getTypeName() + " " + col_type.toSQLString() +
                    ((col_type == VoltType.STRING || col_type == VoltType.VARBINARY) &&
                    catalog_col.getSize() > 0 ? "(" + catalog_col.getSize() +
                    (catalog_col.getInbytes() ? " BYTES" : "") + ")" : "") );

            // Default value
View Full Code Here


    // ResultSet object as an Object in the Java programming language.
    @Override
    public Object getObject(int columnIndex) throws SQLException {
        checkColumnBounds(columnIndex);
        try {
            VoltType type = table.getColumnType(columnIndex - 1);
            if (type == VoltType.TIMESTAMP)
                return getTimestamp(columnIndex);
            else
                return table.get(columnIndex - 1, type);
        } catch (Exception x) {
View Full Code Here

        // There will be a "finalize" pass over the completed expression tree to finish specifying any remaining "generics".

        // DO use the type chosen by HSQL for the parameterized function as a specific type hint
        // for numeric constant arguments that could either go decimal or float.
        AbstractExpression param_arg = m_args.get(m_parameterArg);
        VoltType param_type = param_arg.getValueType();
        VoltType value_type = getValueType();
        // The heuristic for which type to change is that any type (parameter type or return type) specified so far,
        // including NUMERIC is better than nothing. And that anything else is better than NUMERIC.
        if (value_type != param_type) {
            if (value_type == null) {
                value_type = param_type;
            } else if (value_type == VoltType.NUMERIC) {
                if (param_type != null) {
                    value_type = param_type;
                }
                // Pushing a type DOWN to the argument is a lot like work, and not worth it just to
                // propagate down a known NUMERIC return type,
                // since it will just have to be re-specialized when a more specific type is inferred from
                // the context or finalized when the expression is complete.
            } else if ((param_type == null) || (param_type == VoltType.NUMERIC)) {
                // The only purpose of refining the parameter argument's type is to force a more specific
                // refinement than NUMERIC as implied by HSQL, in case that might be more specific than
                // what can be be inferred later from the function call context.
                param_arg.refineValueType(value_type, value_type.getMaxLengthInBytes());
            }
        }
        if (value_type != null) {
            setValueType(value_type);
            setValueSize(value_type.getMaxLengthInBytes());
        }
    }
View Full Code Here

        // and have that change propagate up to its return type.
        if (m_valueType != null && m_valueType != VoltType.NUMERIC) {
            return;
        }
        AbstractExpression arg = m_args.get(m_parameterArg);
        VoltType valueType = arg.getValueType();
        if (valueType != null && valueType != VoltType.NUMERIC) {
            return;
        }
        arg.refineOperandType(columnType);
        m_valueType = arg.getValueType();
View Full Code Here

        // and have that change propagate up to its return type.
        if (m_valueType != null && m_valueType != VoltType.NUMERIC) {
            return;
        }
        AbstractExpression arg = m_args.get(m_parameterArg);
        VoltType valueType = arg.getValueType();
        if (valueType != null && valueType != VoltType.NUMERIC) {
            return;
        }
        // No assumption is made that functions that are parameterized by
        // variably-sized types are size-preserving, so allow any size
View Full Code Here

    public static void toCSVWriter(CSVWriter csv, VoltTable vt, List<VoltType> columnTypes) throws IOException {
        final SimpleDateFormat sdf = m_sdf.get();
        String[] fields = new String[vt.getColumnCount()];
        while (vt.advanceRow()) {
            for (int ii = 0; ii < vt.getColumnCount(); ii++) {
                final VoltType type = columnTypes.get(ii);
                if (type == VoltType.BIGINT
                        || type == VoltType.INTEGER
                        || type == VoltType.SMALLINT
                        || type == VoltType.TINYINT) {
                    final long value = vt.getLong(ii);
View Full Code Here

    public void refineValueType(VoltType neededType, int neededSize) {
        if (m_originalValue != null) {
            // Do not push down a target type that contradicts the original constant value
            // of a generated parameter.
            m_originalValue.refineValueType(neededType, neededSize);
            VoltType fallbackType = m_originalValue.getValueType();
            if (fallbackType != neededType) {
                setValueType(fallbackType);
                setValueSize(fallbackType.getLengthInBytesForFixedTypes());
                return;
            }
        }
        // Otherwise, target knows best?
        setValueType(neededType);
View Full Code Here

        // There IS (or was?) at least one case of type-checking in the code that considers
        // indexed access paths, but it might not be critical (i.e. might be obsolete).
        if (m_valueType != null && m_valueType != VoltType.NUMERIC) {
            return;
        }
        VoltType fallbackType = VoltType.FLOAT;
        if (m_originalValue != null) {
            m_originalValue.refineOperandType(VoltType.BIGINT);
            fallbackType = m_originalValue.getValueType(); // Typically BIGINT or FLOAT.
        }
        m_valueType = fallbackType;
View Full Code Here

            } else {
                if (isHSQL()) {
                    // Hsql return 0 for NULL
                    assertEquals(0, actual);
                } else {
                    VoltType type = vt.getColumnType(i);
                    assertEquals(Long.parseLong(type.getNullValue().toString()), actual);
                }
            }
        }
    }
View Full Code Here

            assertTrue(prefix + "too few actual rows; expected more than " + (i + 1), actualRows.advanceRow());

            for (int j = 0; j < actualRows.getColumnCount(); j++) {
                String columnName = actualRows.getColumnName(j);
                String colPrefix = prefix + "row " + i + ": column: " + columnName + ": ";
                VoltType actualTy = actualRows.getColumnType(j);
                VoltType expectedTy = expectedRows.getColumnType(j);
                assertEquals(colPrefix + "type mismatch", expectedTy, actualTy);

                Object expectedObj = expectedRows.get(j,  expectedTy);
                Object actualObj = expectedRows.get(j,  actualTy);
                assertEquals(colPrefix + "values not equal: expected: " + expectedObj + ", actual: " + actualObj,
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.