Package org.voltdb

Examples of org.voltdb.VoltType


        boolean needConstant = (needParameter == false) ||
            ((isPlannerGenerated != null) && (isPlannerGenerated.equalsIgnoreCase("true")));

        if (needConstant) {
            String type = exprNode.attributes.get("valuetype");
            VoltType vt = VoltType.typeFromString(type);
            int size = VoltType.MAX_VALUE_LENGTH;
            assert(vt != VoltType.VOLTTABLE);

            if ((vt != VoltType.STRING) && (vt != VoltType.VARBINARY)) {
                if (vt == VoltType.NULL) size = 0;
                else size = vt.getLengthInBytesForFixedTypes();
            }
            cve = new ConstantValueExpression();
            cve.setValueType(vt);
            cve.setValueSize(size);
            if ( ! needParameter && vt != VoltType.NULL) {
View Full Code Here


        } else {
            assert(rightExprNode == null);
            if (exprType == ExpressionType.OPERATOR_CAST) {
                String valuetype = exprNode.attributes.get("valuetype");
                assert(valuetype != null);
                VoltType voltType = VoltType.typeFromString(valuetype);
                expr.setValueType(voltType);
                // We don't support parameterized casting, such as specifically to "VARCHAR(3)" vs. VARCHAR,
                // so assume max length for variable-length types (VARCHAR and VARBINARY).
                expr.setValueSize(voltType.getMaxLengthInBytes());
            }
        }

        return expr;
    }
View Full Code Here

        String disabled = exprNode.attributes.get("disabled");
        if (disabled != null) {
            throw new PlanningErrorException("Function '" + name + "' is not supported in VoltDB: " + disabled);
        }
        String value_type_name = exprNode.attributes.get("valuetype");
        VoltType value_type = VoltType.typeFromString(value_type_name);
        String id = exprNode.attributes.get("function_id");
        assert(id != null);
        int idArg = 0;
        try {
            idArg = Integer.parseInt(id);
        } catch (NumberFormatException nfe) {}
        assert(idArg > 0);
        String parameter = exprNode.attributes.get("parameter");
        String volt_alias = exprNode.attributes.get("volt_alias");
        if (volt_alias == null) {
            volt_alias = name; // volt shares the function name with HSQL
        }

        ArrayList<AbstractExpression> args = new ArrayList<AbstractExpression>();
        for (VoltXMLElement argNode : exprNode.children) {
            assert(argNode != null);
            // recursively parse each argument subtree (could be any kind of expression).
            AbstractExpression argExpr = parseExpressionTree(argNode);
            assert(argExpr != null);
            args.add(argExpr);
        }

        FunctionExpression expr = new FunctionExpression();
        expr.setAttributes(name, volt_alias, idArg);
        expr.setArgs(args);
        if (value_type != null) {
            expr.setValueType(value_type);
            expr.setValueSize(value_type.getMaxLengthInBytes());
        }

        if (parameter != null) {
            int parameter_idx = -1; // invalid argument index
            try {
View Full Code Here

            if (node.name.equalsIgnoreCase("parameter")) {
                long id = Long.parseLong(node.attributes.get("id"));
                int index = Integer.parseInt(node.attributes.get("index"));
                String typeName = node.attributes.get("valuetype");
                String isVectorParam = node.attributes.get("isvector");
                VoltType type = VoltType.typeFromString(typeName);
                ParameterValueExpression pve = new ParameterValueExpression();
                pve.setParameterIndex(index);
                pve.setValueType(type);
                if (isVectorParam != null && isVectorParam.equalsIgnoreCase("true")) {
                    pve.setParamIsVector();
View Full Code Here

        ImmutableSortedMap.Builder<String, Integer> byNameBuilder =
                ImmutableSortedMap.naturalOrder();

        for (int c = 0; c < byIndex.length; ++c) {
            VoltType cType = table.getColumnType(c);
            StringBuilder cName = new StringBuilder(table.getColumnName(c));

            byIndex[c] = cType;

            boolean upperCaseIt = false;
View Full Code Here

        AbstractExpression indexableExpr, AbstractExpression otherExpr,
        AbstractExpression coveringExpr, int coveringColId)
    {
        // Do some preliminary disqualifications.

        VoltType keyType = indexableExpr.getValueType();
        VoltType otherType = otherExpr.getValueType();
        // EE index key comparator should not lose precision when casting keys to the indexed type.
        // Do not choose an index that requires such a cast.
        if ( ! keyType.canExactlyRepresentAnyValueOf(otherType)) {
            // Except the EE DOES contain the necessary logic to avoid loss of SCALE
            // when the indexed type is just a narrower integer type.
            // This is very important, since the typing for integer constants
            // MAY not pay that much attention to minimizing scale.
            // This was behind issue ENG-4606 -- failure to index on constant equality.
            // So, accept any pair of integer types.
            if ( ! (keyType.isInteger() && otherType.isInteger()))  {
                return null;
            }
        }
        // Left and right operands must not be from the same table,
        // e.g. where t.a = t.b is not indexable with the current technology.
View Full Code Here

    private static CatalogItemSizeBase getColumnsSize(List<Column> columns, boolean forIndex) {
        // See http://voltdb.com/docs/PlanningGuide/ChapMemoryRecs.php
        CatalogItemSizeBase csize = new CatalogItemSizeBase();
        for (Column column: columns) {
            VoltType ctype = VoltType.get((byte)column.getType());
            switch(ctype) {
            case STRING: {
                boolean inBytes = column.getInbytes();
                int capacity = column.getSize();
                if (!inBytes) capacity *= MAX_BYTES_PER_UTF8_CHARACTER;

                csize.widthMin += getVariableColumnSize(capacity, 0, forIndex);
                csize.widthMax += getVariableColumnSize(capacity, capacity, forIndex);
                break;
            }
            case VARBINARY: {
                int capacity = column.getSize();
                csize.widthMin += getVariableColumnSize(capacity, 0, forIndex);
                csize.widthMax += getVariableColumnSize(capacity, capacity, forIndex);
                break;
            }
            default: {
                // Fixed type - use the fixed size.
                csize.widthMin += ctype.getLengthInBytesForFixedTypes();
                csize.widthMax += ctype.getLengthInBytesForFixedTypes();
            }
            }
        }
        return csize;
    }
View Full Code Here

            return;
        }
        m_left.refineOperandType(columnType);
        //XXX Not sure how unary minus (and unary plus?) are handled (possibly via an implicit zero left argument?)
        m_right.refineOperandType(columnType);
        VoltType cast_type = VoltTypeUtil.determineImplicitCasting(m_left.getValueType(), m_right.getValueType());
        if (cast_type == VoltType.INVALID) {
            throw new RuntimeException("ERROR: Invalid output value type for Expression '" + this + "'");
        }
        m_valueType = cast_type;
        m_valueSize = cast_type.getLengthInBytesForFixedTypes();
    }
View Full Code Here

        // float. If any of the lhs, rhs, or target result type are float, then any ambiguity
        // in the remaining arguments (such as parameters) should be resolved in favor of
        // float. Otherwise, if any are decimal, then decimal should be favored. Otherwise,
        // the broadest integer type is preferable, even if the target is of a more limited
        // integer type -- math has a way of scaling values up AND down.
        VoltType operandType = neededType;
        if (operandType.isInteger()) {
            operandType = VoltType.BIGINT;
        }
        VoltType leftType = m_left.getValueType();
        VoltType rightType = m_right.getValueType();
        if (leftType == VoltType.FLOAT || rightType == VoltType.FLOAT) {
            operandType = VoltType.FLOAT;
        }
        else if (operandType != VoltType.FLOAT) {
            if (leftType == VoltType.DECIMAL || rightType == VoltType.DECIMAL) {
                operandType = VoltType.DECIMAL;
            }
        }
        m_left.refineOperandType(operandType);
        m_right.refineOperandType(operandType);
        //XXX Not sure how unary minus (and unary plus?) are handled (possibly via an implicit zero left argument?)
        VoltType cast_type = VoltTypeUtil.determineImplicitCasting(m_left.getValueType(), m_right.getValueType());
        if (cast_type == VoltType.INVALID) {
            throw new RuntimeException("ERROR: Invalid output value type for Expression '" + this + "'");
        }
        m_valueType = cast_type;
        m_valueSize = cast_type.getLengthInBytesForFixedTypes();
    }
View Full Code Here

        if (type == ExpressionType.OPERATOR_CASE_WHEN || type == ExpressionType.OPERATOR_ALTERNATIVE) {
            assert(m_valueType != null);
            m_valueSize = m_valueType.getMaxLengthInBytes();
            return;
        }
        VoltType left_type = m_left.getValueType();
        //XXX Not sure how unary minus (and unary plus?) are handled (possibly via an implicit zero left argument?)
        VoltType right_type = m_right.getValueType();
        VoltType cast_type = VoltTypeUtil.determineImplicitCasting(left_type, right_type);
        if (cast_type == VoltType.INVALID) {
            throw new RuntimeException("ERROR: Invalid output value type for Expression '" + this + "'");
        }
        m_valueType = cast_type;
        // this may not always be safe
        m_valueSize = cast_type.getLengthInBytesForFixedTypes();
    }
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.