Package org.voltdb

Examples of org.voltdb.VoltType


                endType == IndexLookupType.EQ &&
                endKeys.size() > 0 &&
                endKeys.size() == indexSize - 1 &&
                isp.getSearchKeyExpressions().size() == indexSize) {

            VoltType missingKeyType = VoltType.INVALID;
            boolean canPadding = true;

            // need to check the filter we are missing is the last indexable expr
            // and find out the missing key
            if (jsonstring.isEmpty()) {
                int lastIndex = indexedColRefs.get(indexSize - 1).getColumn().getIndex();
                for (AbstractExpression expr : endComparisons) {
                    if (((TupleValueExpression)(expr.getLeft())).getColumnIndex() == lastIndex) {
                        canPadding = false;
                        break;
                    }
                }
                if (canPadding) {
                    missingKeyType = VoltType.get((byte)(indexedColRefs.get(indexSize - 1).getColumn().getType()));
                }
            } else {
                AbstractExpression lastIndexableExpr = indexedExprs.get(indexSize - 1);
                for (AbstractExpression expr : endComparisons) {
                    if (expr.getLeft().bindingToIndexedExpression(lastIndexableExpr) != null) {
                        canPadding = false;
                        break;
                    }
                }
                if (canPadding) {
                    missingKeyType = lastIndexableExpr.getValueType();
                }
            }
            if (canPadding && missingKeyType.isMaxValuePaddable()) {
                ConstantValueExpression missingKey = new ConstantValueExpression();
                missingKey.setValueType(missingKeyType);
                missingKey.setValue(String.valueOf(VoltType.getPaddedMaxTypeValue(missingKeyType)));
                missingKey.setValueSize(missingKeyType.getLengthInBytesForFixedTypes());
                endType = IndexLookupType.LTE;
                endKeys.add(missingKey);
            } else {
                return null;
            }
View Full Code Here


        /*
         * Validate that the total size
         */
        int maxRowSize = 0;
        for (Column c : columnMap.values()) {
            VoltType t = VoltType.get((byte)c.getType());
            if ((t == VoltType.STRING && c.getInbytes()) || (t == VoltType.VARBINARY)) {
                if (c.getSize() > VoltType.MAX_VALUE_LENGTH) {
                    throw m_compiler.new VoltCompilerException("Column " + name + "." + c.getName() +
                            " specifies a maximum size of " + c.getSize() + " bytes" +
                            " but the maximum supported size is " + VoltType.humanReadableSize(VoltType.MAX_VALUE_LENGTH));
                }
                maxRowSize += 4 + c.getSize();
            }
            else if (t == VoltType.STRING) {
                if (c.getSize() * MAX_BYTES_PER_UTF8_CHARACTER > VoltType.MAX_VALUE_LENGTH) {
                    throw m_compiler.new VoltCompilerException("Column " + name + "." + c.getName() +
                            " specifies a maximum size of " + c.getSize() + " characters" +
                            " but the maximum supported size is " +
                            VoltType.humanReadableSize(VoltType.MAX_VALUE_LENGTH / MAX_BYTES_PER_UTF8_CHARACTER) +
                            " characters or " + VoltType.humanReadableSize(VoltType.MAX_VALUE_LENGTH) + " bytes");
                }
                maxRowSize += 4 + c.getSize() * MAX_BYTES_PER_UTF8_CHARACTER;
            } else {
                maxRowSize += t.getLengthInBytesForFixedTypes();
            }
        }
        // Temporarily assign the view Query to the annotation so we can use when we build
        // the DDL statement for the VIEW
        if (query != null) {
View Full Code Here

            defaultvalue = defaultvalue.replace('\n', ' ');
            defaultvalue = defaultvalue.replace('\r', ' ');
        }

        // fyi: Historically, VoltType class initialization errors get reported on this line (?).
        VoltType type = VoltType.typeFromString(typename);
        columnTypes.put(index, type);
        if (defaultFuncID == -1) {
            if (defaultvalue != null && (type == VoltType.DECIMAL || type == VoltType.NUMERIC)) {
                // Until we support deserializing scientific notation in the EE, we'll
                // coerce default values to plain notation here.  See ENG-952 for more info.
                BigDecimal temp = new BigDecimal(defaultvalue);
                defaultvalue = temp.toPlainString();
            }
        } else {
            // Concat function name and function id, format: NAME:ID
            // Used by PlanAssembler:getNextInsertPlan().
            defaultvalue = defaultvalue + ":" + String.valueOf(defaultFuncID);
        }

        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(Boolean.valueOf(nullable));
        int size = type.getMaxLengthInBytes();

        boolean inBytes = false;
        if (node.attributes.containsKey("bytes")) {
            inBytes = Boolean.valueOf(node.attributes.get("bytes"));
        }

        // Require a valid length if variable length is supported for a type
        if (type == VoltType.STRING || type == VoltType.VARBINARY) {
            if (sizeString == null) {
                // An unspecified size for a VARCHAR/VARBINARY column should be
                // for a materialized view column whose type is derived from a
                // function or expression of variable-length type.
                // Defaulting these to MAX_VALUE_LENGTH tends to cause them to overflow the
                // allowed MAX_ROW_SIZE when there are more than one in a view.
                // It's not clear what benefit, if any, we derive from limiting MAX_ROW_SIZE
                // based on worst-case length for variable fields, but we comply for now by
                // arbitrarily limiting these matview column sizes such that
                // the max number of columns of this size would still fit.
                size = MAX_ROW_SIZE / MAX_COLUMNS;
            } else {
                int userSpecifiedSize = Integer.parseInt(sizeString);
                if (userSpecifiedSize < 0 || (inBytes && userSpecifiedSize > VoltType.MAX_VALUE_LENGTH)) {
                    String msg = type.toSQLString() + " column " + name +
                        " in table " + table.getTypeName() + " has unsupported length " + sizeString;
                    throw m_compiler.new VoltCompilerException(msg);
                }
                if (!inBytes && type == VoltType.STRING) {
                    if (userSpecifiedSize > VoltType.MAX_VALUE_LENGTH_IN_CHARACTERS) {
View Full Code Here

            }
        }

        if (exprs == null) {
            for (int i = 0; i < colNames.length; i++) {
                VoltType colType = VoltType.get((byte)columns[i].getType());
                if (colType == VoltType.DECIMAL || colType == VoltType.FLOAT || colType == VoltType.STRING) {
                    has_nonint_col = true;
                    nonint_col_name = colNames[i];
                }
                // disallow columns from VARBINARYs
                if (colType == VoltType.VARBINARY) {
                    String msg = "VARBINARY values are not currently supported as index keys: '" + colNames[i] + "'";
                    throw this.m_compiler.new VoltCompilerException(msg);
                }
            }
        } else {
            for (AbstractExpression expression : exprs) {
                VoltType colType = expression.getValueType();
                if (colType == VoltType.DECIMAL || colType == VoltType.FLOAT || colType == VoltType.STRING) {
                    has_nonint_col = true;
                    nonint_col_name = "<expression>";
                }
                // disallow expressions of type VARBINARY
View Full Code Here

    static boolean isArray = false;
    static final byte ARRAY_BEGIN = 126;
    static final byte ARRAY_END = 127;

    static void echo(byte[] t, byte[] buffer, int length) {
        VoltType type = null;
        ByteBuffer buf;

        if (t[0] == ARRAY_BEGIN) {
            isArray = true;
            return;
        } else if (t[0] == ARRAY_END) {
            isArray = false;
            return;
        } else {
            type = VoltType.get(t[0]);
        }

        FastDeserializer fds = new FastDeserializer(buffer);
        int count = 1;
        try {
            fs.writeInt(length);
            fs.writeByte(type.getValue());

            if (isArray) {
                if (type == VoltType.TINYINT) {
                    count = fds.readInt();
                    fs.writeInt(count);
View Full Code Here

        final PlannerTool ptool = context.m_ptool;

        List<String> errorMsgs = new ArrayList<String>();
        List<AdHocPlannedStatement> stmts = new ArrayList<AdHocPlannedStatement>();
        int partitionParamIndex = -1;
        VoltType partitionParamType = null;
        Object partitionParamValue = null;
        assert(work.sqlStatements != null);
        // Take advantage of the planner optimization for inferring single partition work
        // when the batch has one statement.
        StatementPartitioning partitioning = null;
View Full Code Here

                int oldTypeInt = (Integer) prevType.getField("type");
                int newTypeInt = (Integer) suspect.getField("type");
                int oldSize = (Integer) prevType.getField("size");
                int newSize = (Integer) suspect.getField("size");

                VoltType oldType = VoltType.get((byte) oldTypeInt);
                VoltType newType = VoltType.get((byte) newTypeInt);

                boolean oldInBytes = false, newInBytes = false;
                if (oldType == VoltType.STRING) {
                    oldInBytes = (Boolean) prevType.getField("inbytes");
                }
                if (newType == VoltType.STRING) {
                    newInBytes = (Boolean) suspect.getField("inbytes");
                }

                if (checkIfColumnTypeChangeIsSupported(oldType, oldSize, newType, newSize,
                        oldInBytes, newInBytes)) {
                    return null;
                }
                if (oldTypeInt == newTypeInt) {
                    if (oldType == VoltType.STRING && oldInBytes == false && newInBytes == true) {
                        restrictionQualifier = "narrowing from " + oldSize + "CHARACTERS to "
                    + newSize * CatalogSizing.MAX_BYTES_PER_UTF8_CHARACTER + " BYTES";
                    } else {
                        restrictionQualifier = "narrowing from " + oldSize + " to " + newSize;
                    }
                }
                else {
                    restrictionQualifier = "from " + oldType.toSQLString() +
                                           " to " + newType.toSQLString();
                }
            }
        }

        else if (suspect instanceof MaterializedViewInfo) {
View Full Code Here

                extractedValues == null ? ParameterSet.emptyParameterSet() :
                                          ParameterSet.fromArrayNoCopy(extractedValues),
                null);
        List<AdHocPlannedStatement> stmts = new ArrayList<AdHocPlannedStatement>();
        stmts.add(s);
        VoltType partitionParamType = null;
        Object partitionParamValue = null;
        if (work.userPartitionKey != null) {
            partitionParamValue = work.userPartitionKey[0];
        }
        else if (partitionParamIndex > -1) {
View Full Code Here

                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) {
            parsePartitionInfo(compiler, db, procedure, info.partitionInfo);
            if (procedure.getPartitionparameter() >= paramTypes.length) {
                String msg = "PartitionInfo parameter not a valid parameter for procedure: " + procedure.getClassname();
                throw compiler.new VoltCompilerException(msg);
            }

            // check the type of partition parameter meets our high standards
            Class<?> partitionType = paramTypes[procedure.getPartitionparameter()];
            Class<?>[] validPartitionClzzes = {
                    Long.class, Integer.class, Short.class, Byte.class,
                    long.class, int.class, short.class, byte.class,
                    String.class, byte[].class
            };
            boolean found = false;
            for (Class<?> candidate : validPartitionClzzes) {
                if (partitionType == candidate)
                    found = true;
            }
            if (!found) {
                String msg = "PartitionInfo parameter must be a String or Number for procedure: " + procedure.getClassname();
                throw compiler.new VoltCompilerException(msg);
            }

            VoltType columnType = VoltType.get((byte)procedure.getPartitioncolumn().getType());
            VoltType paramType = VoltType.typeFromClass(partitionType);
            if ( ! columnType.canExactlyRepresentAnyValueOf(paramType)) {
                String msg = "Type mismatch between partition column and partition parameter for procedure " +
                    procedure.getClassname() + " may cause overflow or loss of precision.\nPartition column is type " + columnType +
                    " and partition parameter is type " + paramType;
                throw compiler.new VoltCompilerException(msg);
            } else if ( ! paramType.canExactlyRepresentAnyValueOf(columnType)) {
                String msg = "Type mismatch between partition column and partition parameter for procedure " +
                        procedure.getClassname() + " does not allow the full range of partition key values.\nPartition column is type " + columnType +
                        " and partition parameter is type " + paramType;
                compiler.addWarn(msg);
            }
View Full Code Here

            for (Set<AbstractExpression> partitioningValues : eqSets) {
                for (AbstractExpression constExpr : partitioningValues) {
                    if (constExpr instanceof TupleValueExpression) {
                        continue;
                    }
                    VoltType valueType = tokenPartitionKey.getValueType();
                    addPartitioningExpression(tokenPartitionKey.getTableName() +
                            '.' + tokenPartitionKey.getColumnName(), constExpr, valueType);
                    // Only need one constant value.
                    break;
                }
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.