Examples of VoltType


Examples of org.voltdb.VoltType

       
        assertFalse(xact.hasOutput());
        xact.setOutput(vt);
        assert(xact.hasOutput());
       
        VoltType types[] = xact.getOutputTypes(0);
        assertNotNull(types);
        Object output[][] = xact.getOutput(0);
        assertNotNull(output);
        for (int j = 0; j < num_cols; j++) {
            assertEquals(vt.getColumnName(j), vt.getColumnType(j), types[j]);
View Full Code Here

Examples of org.voltdb.VoltType

                assertEquals(String.format("[%d, %d]", i, j), orig_row[j].toString(), copy_row[j].toString());
            } // FOR
        } // FOR
       
        // OUTPUT TYPES
        VoltType expected_types[] = xact.getOutputTypes(0);
        assertNotNull(expected_types);
        VoltType actual_types[] = xact.getOutputTypes(0);
        assertNotNull(actual_types);
        assertEquals(expected_types.length, actual_types.length);
        for (int i = 0; i < expected_types.length; i++) {
            assertEquals(Integer.toString(i), expected_types[i], actual_types[i]);
        } // FOR
View Full Code Here

Examples of org.voltdb.VoltType

        for (int i = 0, cnt = params.length; i < cnt; i++) {
            ProcParameter catalog_param = catalog_proc.getParameters().get(i);
            assertNotNull(catalog_param);

            try {
                VoltType expected_type = VoltType.get((byte) catalog_param.getType());
                if (catalog_param.getIsarray()) {
                    int j = 0;
                    for (Object inner : (Object[]) params[i]) {
                        System.err.print("[" + i + "][" + j++ + "]: " + expected_type + " --> " + inner + " [class=" + inner.getClass() + ",");
                        VoltType param_type = VoltType.typeFromClass(inner.getClass());
                        System.err.println("type=" + param_type + "]");
                        assertEquals(expected_type, param_type);
                    } // FOR
                } else {
                    System.err.print("[" + i + "]: " + expected_type + " --> " + params[i] + " [class=" + params[i].getClass() + ",");
                    VoltType param_type = VoltType.typeFromClass(params[i].getClass());
                    System.err.println("type=" + param_type + "]");
                    assertEquals(expected_type, param_type);
                }
            } catch (NullPointerException ex) {
                System.err.println("Null parameter at index " + i + " for " + catalog_proc);
View Full Code Here

Examples of org.voltdb.VoltType

                table.resetRowPosition();
                while (table.advanceRow()) {
                    int row = table.getActiveRowIndex();
                    for (Column catalog_col : catalog_tbl.getColumns()) {
                        int index = catalog_col.getIndex();
                        VoltType col_type = VoltType.get(catalog_col.getType());
                        switch (col_type) {
                            case TINYINT:
                            case SMALLINT:
                            case INTEGER: {
                                // TODO
View Full Code Here

Examples of org.voltdb.VoltType

                table.resetRowPosition();
                while (table.advanceRow()) {
                    int row = table.getActiveRowIndex();
                    for (Column catalog_col : catalog_tbl.getColumns()) {
                        int index = catalog_col.getIndex();
                        VoltType col_type = VoltType.get(catalog_col.getType());
                        switch (col_type) {
                            case TINYINT:
                            case SMALLINT:
                            case INTEGER: {
                                // TODO
View Full Code Here

Examples of org.voltdb.VoltType

     * This method only looks at a single node and will not recursively walk through the tree
     *
     * @param exp
     */
    public static Pair<VoltType,Integer> calculateOutputValueTypes(AbstractExpression exp) {
        VoltType retType = VoltType.INVALID;
        int retSize = 0;
        //
        // First get the value types for the left and right children
        //
        ExpressionType exp_type = exp.getExpressionType();
        AbstractExpression left_exp = exp.getLeft();
        AbstractExpression right_exp = exp.getRight();

        // -------------------------------
        // CONSTANT/NULL/PARAMETER/TUPLE VALUES
        // If our current expression is a Value node, then the QueryPlanner should have
        // already figured out our types and there is nothing we need to do here
        // -------------------------------
        if (exp instanceof ConstantValueExpression ||
            exp instanceof NullValueExpression ||
            exp instanceof ParameterValueExpression ||
            exp instanceof TupleValueExpression) {
            //
            // Nothing to do...
            // We have to return what we already have to keep the QueryPlanner happy
            //
            retType = exp.getValueType();
            retSize = exp.getValueSize();
        // -------------------------------
        // CONJUNCTION & COMPARISON
        // If it is an Comparison or Conjunction node, then the output is always
        // going to be either true or false
        // -------------------------------
        } else if (exp instanceof ComparisonExpression ||
                   exp instanceof ConjunctionExpression) {
            //
            // Make sure that they have the same number of output values
            // NOTE: We do not need to do this check for COMPARE_IN
            //
            if (exp_type != ExpressionType.COMPARE_IN) {
                //
                // IMPORTANT:
                // We are not handling the case where one of types is NULL. That is because we
                // are only dealing with what the *output* type should be, not what the actual
                // value is at execution time. There will need to be special handling code
                // over on the ExecutionEngine to handle special cases for conjunctions with NULLs
                // Therefore, it is safe to assume that the output is always going to be an
                // integer (for booleans)
                //
                retType = VoltType.BIGINT;
                retSize = retType.getLengthInBytesForFixedTypes();
            //
            // Everything else...
            //
            } else {
                //
                // TODO: Need to figure out how COMPARE_IN is going to work
                //
                throw new NotImplementedException("The '" + exp_type + "' Expression is not yet supported");
            }
        // -------------------------------
        // AGGREGATES
        // -------------------------------
        } else if (exp instanceof AggregateExpression) {
            switch (exp_type) {
                case AGGREGATE_COUNT:
                case AGGREGATE_COUNT_STAR:
                    //
                    // Always an integer
                    //
                    retType = VoltType.BIGINT;
                    retSize = retType.getLengthInBytesForFixedTypes();
                    break;
                case AGGREGATE_AVG:
                case AGGREGATE_MAX:
                case AGGREGATE_MIN:
                    //
                    // It's always whatever the base type is
                    //
                    retType = left_exp.getValueType();
                    retSize = left_exp.getValueSize();
                    break;
                case AGGREGATE_SUM:
                    if (left_exp.getValueType() == VoltType.TINYINT ||
                            left_exp.getValueType() == VoltType.SMALLINT ||
                            left_exp.getValueType() == VoltType.INTEGER) {
                        retType = VoltType.BIGINT;
                        retSize = retType.getLengthInBytesForFixedTypes();
                    } else {
                        retType = left_exp.getValueType();
                        retSize = left_exp.getValueSize();
                    }
                    break;
                default:
                    throw new RuntimeException("ERROR: Invalid Expression type '" + exp_type + "' for Expression '" + exp + "'");
            } // SWITCH
        // -------------------------------
        // EVERYTHING ELSE
        // We need to look at our children and iterate through their
        // output value types. We will match up the left and right output types
        // at each position and call the method to figure out the cast type
        // -------------------------------
        } else {
            VoltType left_type = left_exp.getValueType();
            VoltType right_type = right_exp.getValueType();
            VoltType cast_type = VoltType.INVALID;
            //
            // If there doesn't need to be a a right expression, then the type will always be a integer (for booleans)
            //
            if (!ExpressionUtil.needsRightExpression(exp)) {
                //
                // Make sure that they can cast the left-side expression with integer
                // This is just a simple check to make sure that it is a numeric value
                //
                try {
                    // NOTE: in some brave new Decimal world, this check will be
                    // unnecessary.  This code path is currently extremely unlikely
                    // anyway since we don't support any of the ways to get here
                    cast_type = VoltType.DECIMAL;
                    if (left_type != VoltType.DECIMAL)
                    {
                        VoltTypeUtil.determineImplicitCasting(left_type, VoltType.BIGINT);
                        cast_type = VoltType.BIGINT;
                    }
                } catch (Exception ex) {
                    throw new RuntimeException("ERROR: Invalid type '" + left_type + "' used in a '" + exp_type + "' Expression");
                }
            //
            // Otherwise, use VoltTypeUtil to figure out what to case the value to
            //
            } else {
                cast_type = VoltTypeUtil.determineImplicitCasting(left_type, right_type);
            }
            if (cast_type == VoltType.INVALID) {
                throw new RuntimeException("ERROR: Invalid output value type for Expression '" + exp + "'");
            }
            retType = cast_type;
            // this may not always be safe
            retSize = cast_type.getLengthInBytesForFixedTypes();
        }
        return new Pair<VoltType, Integer>(retType, retSize);
    }
View Full Code Here

Examples of org.voltdb.VoltType

     */
    AbstractExpression parseValueExpression(Node exprNode, NamedNodeMap attrs) {
        String type = attrs.getNamedItem("type").getNodeValue();
        Node isParam = attrs.getNamedItem("isparam");

        VoltType vt = VoltType.typeFromString(type);
        int size = VoltType.MAX_VALUE_LENGTH;
        assert(vt != VoltType.VOLTTABLE);
        if (vt != VoltType.STRING) {
            size = vt.getLengthInBytesForFixedTypes();
        }
        if ((isParam != null) && (isParam.getNodeValue().equalsIgnoreCase("true"))) {
            ParameterValueExpression expr = new ParameterValueExpression();
            long id = Long.parseLong(attrs.getNamedItem("id").getNodeValue());
            ParameterInfo param = paramsById.get(id);
View Full Code Here

Examples of org.voltdb.VoltType

    public static Boolean needsConversion(VoltTable inputTable,
                                          Table outputTableSchema) {
        for (int ii = 0; ii < inputTable.getColumnCount(); ii++) {
            final String name = inputTable.getColumnName(ii);
            final VoltType type = inputTable.getColumnType(ii);
            final Column column = outputTableSchema.getColumns().get(name);

            if (column == null) {
                return true;
            }

            if (column.getIndex() != ii) {
                return true;
            }

            if (column.getType() != type.getValue()) {
                return true;
            }
        }
        return false;
    }
View Full Code Here

Examples of org.voltdb.VoltType

                {
                    // otherwise if it's nullable, insert null,
                    Column catalog_column =
                        outputTableSchema.getColumns().
                        get(new_table.getColumnName(i));
                    VoltType default_type =
                        VoltType.get((byte)catalog_column.getDefaulttype());
                    if (default_type != VoltType.INVALID)
                    {
                        // if there is a default value for this table/column
                        // insert the default value
                        try
                        {
                            coerced_values[i] =
                                VoltTypeUtil.
                                getObjectFromString(default_type,
                                                    catalog_column.
                                                    getDefaultvalue());
                        }
                        catch (ParseException e)
                        {
                            String message = "Column: ";
                            message += new_table.getColumnName(i);
                            message += " has an unparseable default: ";
                            message += catalog_column.getDefaultvalue();
                            message += " for VoltType: ";
                            message += default_type.toString();
                            throw new VoltTypeException(message);
                        }
                    }
                    else if (catalog_column.getNullable())
                    {
View Full Code Here

Examples of org.voltdb.VoltType

        /*
         * Validate that the total size
         */
        int maxRowSize = 0;
        for (Column c : columnMap.values()) {
            VoltType t = VoltType.get((byte)c.getType());
            if (t == VoltType.STRING) {
                if (c.getSize() > 1024 * 1024) {
                    throw m_compiler.new VoltCompilerException("Table name " + name + " column " + c.getName() +
                            " has a maximum size of " + c.getSize() + " bytes" +
                            " but the maximum supported size is " + VoltType.MAX_VALUE_LENGTH_STR);
                }
                maxRowSize += 4 + c.getSize();
            } else {
                maxRowSize += t.getLengthInBytesForFixedTypes();
            }
        }
        if (maxRowSize > MAX_ROW_SIZE) {
            throw m_compiler.new VoltCompilerException("Table name " + name + " has a maximum row size of " + maxRowSize +
                    " but the maximum supported row size is " + MAX_ROW_SIZE);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.