Package org.voltdb.planner

Examples of org.voltdb.planner.PlanningErrorException


            if (columns.size() != outputColumns.size()) {
                throw new RuntimeException("Column number mismatch detected in rows of UNION");
            }
            for (int j = 0; j < outputColumns.size(); ++j) {
                if (outputColumns.get(j).getType() != columns.get(j).getType()) {
                    throw new PlanningErrorException("Incompatible data types in UNION");
                }
            }
        }
        m_outputSchema = m_children.get(0).getOutputSchema();
        m_hasSignificantOutputSchema = false; // It's just the first child's
View Full Code Here


                return;
            }
            // Variably sized types need to fit within the target width.
            if (neededType == VoltType.VARBINARY) {
                if ( ! Encoder.isHexEncodedString(getValue())) {
                    throw new PlanningErrorException("Value (" + getValue() +
                                                     ") has an invalid format for a constant " +
                                                     neededType.toSQLString() + " value");
                }
                size_unit = 2;
            }
            else {
                assert neededType == VoltType.STRING;
            }

            if (getValue().length() > size_unit*neededSize ) {
                throw new PlanningErrorException("Value (" + getValue() +
                                                 ") is too wide for a constant " +
                                                 neededType.toSQLString() +
                                                 " value of size " + neededSize);
            }
            setValueSize(neededSize);
            return;
        }

        if (m_isNull) {
            setValueType(neededType);
            setValueSize(neededSize);
            return;
        }

        // Constant's apparent type may not exactly match the target type needed.
        if (neededType == VoltType.VARBINARY &&
                (m_valueType == VoltType.STRING || m_valueType == null)) {
            if ( ! Encoder.isHexEncodedString(getValue())) {
                throw new PlanningErrorException("Value (" + getValue() +
                                                 ") has an invalid format for a constant " +
                                                 neededType.toSQLString() + " value");
            }
            size_unit = 2;
            if (getValue().length() > size_unit*neededSize ) {
                throw new PlanningErrorException("Value (" + getValue() +
                                                 ") is too wide for a constant " +
                                                 neededType.toSQLString() +
                                                 " value of size " + neededSize);
            }
            setValueType(neededType);
            setValueSize(neededSize);
            return;
        }

        if (neededType == VoltType.STRING && m_valueType == null) {
            if (getValue().length() > size_unit*neededSize ) {
                throw new PlanningErrorException("Value (" + getValue() +
                                                 ") is too wide for a constant " +
                                                 neededType.toSQLString() +
                                                 " value of size " + neededSize);
            }
            setValueType(neededType);
            setValueSize(neededSize);
            return;
        }

        if (neededType == VoltType.TIMESTAMP) {
            if (m_valueType == VoltType.STRING) {
                try {
                    // Convert date value in whatever format is supported by TimeStampType
                    // into VoltDB native microsecond count.
                    TimestampType ts = new TimestampType(m_value);
                    m_value = String.valueOf(ts.getTime());
                }
                // It couldn't be converted to timestamp.
                catch (IllegalArgumentException e) {
                    throw new PlanningErrorException("Value (" + getValue() +
                                                     ") has an invalid format for a constant " +
                                                     neededType.toSQLString() + " value");

                }
                setValueType(neededType);
                setValueSize(neededSize);
                return;
            }
        }

        if ((neededType == VoltType.FLOAT) || (neededType == VoltType.DECIMAL)) {
            if (m_valueType == null ||
                    (m_valueType != VoltType.NUMERIC && ! m_valueType.isExactNumeric())) {
                try {
                    Double.parseDouble(getValue());
                } catch (NumberFormatException nfe) {
                    throw new PlanningErrorException("Value (" + getValue() +
                                                     ") has an invalid format for a constant " +
                                                     neededType.toSQLString() + " value");
                }
            }
            setValueType(neededType);
            setValueSize(neededSize);
            return;
        }

        if (neededType.isInteger()) {
            long value = 0;
            try {
                value = Long.parseLong(getValue());
            } catch (NumberFormatException nfe) {
                throw new PlanningErrorException("Value (" + getValue() +
                                                 ") has an invalid format for a constant " +
                                                 neededType.toSQLString() + " value");
            }
            checkIntegerValueRange(value, neededType);
            m_valueType = neededType;
            m_valueSize = neededType.getLengthInBytesForFixedTypes();
            return;
        }

        // That's it for known type conversions.
        throw new PlanningErrorException("Value (" + getValue() +
                ") has an invalid format for a constant " +
                neededType.toSQLString() + " value");
    }
View Full Code Here

        // to use the literal NULL. Thus the NULL values for each of the 4 integer types are considered
        // an underflow exception for the type.

        if (integerType == VoltType.BIGINT || integerType == VoltType.TIMESTAMP) {
            if (value == VoltType.NULL_BIGINT)
                throw new PlanningErrorException("Constant value underflows BIGINT type.");
        }
        if (integerType == VoltType.INTEGER) {
            if ((value > Integer.MAX_VALUE) || (value <= VoltType.NULL_INTEGER))
                throw new PlanningErrorException("Constant value overflows/underflows INTEGER type.");
        }
        if (integerType == VoltType.SMALLINT) {
            if ((value > Short.MAX_VALUE) || (value <= VoltType.NULL_SMALLINT))
                throw new PlanningErrorException("Constant value overflows/underflows SMALLINT type.");
        }
        if (integerType == VoltType.TINYINT) {
            if ((value > Byte.MAX_VALUE) || (value <= VoltType.NULL_TINYINT))
                throw new PlanningErrorException("Constant value overflows/underflows TINYINT type.");
        }
    }
View Full Code Here

    @Override
    public void processTVE(TupleValueExpression expr, String columnName) {
        Integer idx = m_outputColumnIndexMap.get(columnName);
        if (idx == null) {
            throw new PlanningErrorException("Mismatched columns " + columnName + " in subquery");
        }
        SchemaColumn schemaCol = m_outputColumnList.get(idx.intValue());

        expr.setColumnIndex(idx.intValue());
        expr.setTypeSizeBytes(schemaCol.getType(), schemaCol.getSize(),
View Full Code Here

TOP

Related Classes of org.voltdb.planner.PlanningErrorException

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.