当前位置: 首页>>代码示例>>Java>>正文


Java VoltTypeException类代码示例

本文整理汇总了Java中org.voltdb.VoltTypeException的典型用法代码示例。如果您正苦于以下问题:Java VoltTypeException类的具体用法?Java VoltTypeException怎么用?Java VoltTypeException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


VoltTypeException类属于org.voltdb包,在下文中一共展示了VoltTypeException类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildTable

import org.voltdb.VoltTypeException; //导入依赖的package包/类
private PartitionProcedureCallback buildTable() {
    ArrayList<VoltBulkLoaderRow> buf = new ArrayList<VoltBulkLoaderRow>(m_minBatchTriggerSize);
    m_partitionRowQueue.drainTo(buf, m_minBatchTriggerSize);
    ListIterator<VoltBulkLoaderRow> it = buf.listIterator();
    while (it.hasNext()) {
        VoltBulkLoaderRow currRow = it.next();
        VoltBulkLoader loader = currRow.m_loader;
        Object row_args[];
        row_args = new Object[currRow.m_rowData.length];
        try {
            for (int i = 0; i < row_args.length; i++) {
                final VoltType type = m_columnTypes[i];
                row_args[i] = ParameterConverter.tryToMakeCompatible(type.classFromType(),
                        currRow.m_rowData[i]);
            }
        } catch (VoltTypeException e) {
            loader.generateError(currRow.m_rowHandle, currRow.m_rowData, e.getMessage());
            loader.m_outstandingRowCount.decrementAndGet();
            it.remove();
            continue;
        }
        table.addRow(row_args);
    }

    return new PartitionProcedureCallback(buf);
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:27,代码来源:PerPartitionTable.java

示例2: testDecimalMixedTypes

import org.voltdb.VoltTypeException; //导入依赖的package包/类
public void testDecimalMixedTypes()
    {
        // only exact types can cast to decimal.
        boolean caught = false;
        try
        {
            VoltTypeUtil.determineImplicitCasting(VoltType.DECIMAL,
                                                  VoltType.FLOAT);
        }
        catch (VoltTypeException e)
        {
            caught = true;
        }

        assertTrue("VoltType.DECIMAL and VoltType.FLOAT threw" +
                   "exception", caught);

        // Check that DECIMAL + DECIMAL -> DECIMAL
        assertEquals(VoltTypeUtil.determineImplicitCasting(VoltType.DECIMAL,
                                                           VoltType.DECIMAL),
                                                           VoltType.DECIMAL);

        // D + SMALLINT = D
        assertEquals(VoltTypeUtil.determineImplicitCasting(VoltType.DECIMAL,
                                                           VoltType.SMALLINT),
                                                           VoltType.DECIMAL);
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:28,代码来源:TestVoltTypeUtil.java

示例3: reinsertFailed

import org.voltdb.VoltTypeException; //导入依赖的package包/类
private void reinsertFailed(List<VoltBulkLoaderRow> rows) throws Exception {
    VoltTable tmpTable = new VoltTable(m_columnInfo);
    for (final VoltBulkLoaderRow row : rows) {
        // No need to check error here if a correctedLine has come here it was
        // previously successful.
        try {
            Object row_args[] = new Object[row.m_rowData.length];
            for (int i = 0; i < row_args.length; i++) {
                final VoltType type = m_columnTypes[i];
                row_args[i] = ParameterConverter.tryToMakeCompatible(type.classFromType(),
                        row.m_rowData[i]);
            }
            tmpTable.addRow(row_args);
        } catch (VoltTypeException ex) {
            // Should never happened because the bulk conversion in PerPartitionProcessor
            // should have caught this
            continue;
        }

        ProcedureCallback callback = new ProcedureCallback() {
            @Override
            public void clientCallback(ClientResponse response) throws Exception {
                row.m_loader.m_outstandingRowCount.decrementAndGet();
                row.m_loader.m_loaderCompletedCnt.incrementAndGet();

                //one insert at a time callback
                if (response.getStatus() != ClientResponse.SUCCESS) {
                    row.m_loader.m_notificationCallBack.failureCallback(row.m_rowHandle, row.m_rowData, response);
                }
            }
        };

        loadTable(callback, tmpTable);
    }
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:36,代码来源:PerPartitionTable.java

示例4: getHashedPartitionForParameter

import org.voltdb.VoltTypeException; //导入依赖的package包/类
/**
 * Given the type of the targeting partition parameter and an object,
 * coerce the object to the correct type and hash it.
 * NOTE NOTE NOTE NOTE! THIS SHOULD BE THE ONLY WAY THAT YOU FIGURE OUT
 * THE PARTITIONING FOR A PARAMETER! THIS IS SHARED BY SERVER AND CLIENT
 * CLIENT USES direct instance method as it initializes its own per connection
 * Hashinator.
 *
 * @return The partition best set up to execute the procedure.
 * @throws VoltTypeException
 */
public int getHashedPartitionForParameter(int partitionValueType, Object partitionValue)
        throws VoltTypeException {
    final VoltType partitionParamType = VoltType.get((byte) partitionValueType);

    // Special cases:
    // 1) if the user supplied a string for a number column,
    // try to do the conversion. This makes it substantially easier to
    // load CSV data or other untyped inputs that match DDL without
    // requiring the loader to know precise the schema.
    // 2) For legacy hashinators, if we have a numeric column but the param is in a byte
    // array, convert the byte array back to the numeric value
    if (partitionValue != null && partitionParamType.isPartitionableNumber()) {
        if (partitionValue.getClass() == String.class) {
            {
                Object tempParam = ParameterConverter.stringToLong(
                        partitionValue,
                        partitionParamType.classFromType());
                // Just in case someone managed to feed us a non integer
                if (tempParam != null) {
                    partitionValue = tempParam;
                }
            }
        }
        else if (partitionValue.getClass() == byte[].class) {
            partitionValue = bytesToValue(partitionParamType, (byte[]) partitionValue);
        }
    }

    return hashToPartition(partitionParamType, partitionValue);
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:42,代码来源:HashinatorLite.java

示例5: _put

import org.voltdb.VoltTypeException; //导入依赖的package包/类
/**
 * The main method that updates a value in the histogram with a given sample count
 * This should be called by one of the public interface methods that are synchronized
 * This method is not synchronized on purpose for performance
 * @param value
 * @param count
 * @return Return the new count for the given key
 */
private long _put(X value, long count) {
    // If we're giving a null value, then the count will always be zero
    if (value == null) return (0);
    
    // HACK: Try to infer the internal type if we don't have it already
    if (this.value_type == VoltType.INVALID) {
        try {
            this.value_type = VoltType.typeFromClass(value.getClass());
        } catch (VoltTypeException ex) {
            this.value_type = VoltType.NULL;
        }
    }

    this.num_samples += count;
    
    // If we already have this value in our histogram, then add the new
    // count to its existing total
    Long existing = this.histogram.get(value);
    if (existing != null) {
        count += existing.longValue();
    }
    
    // We can't have a negative value
    if (count < 0) {
        String msg = String.format("Invalid negative count for key '%s' [count=%d]", value, count);
        throw new IllegalArgumentException(msg);
    }
    // If the new count is zero, then completely remove it if we're not
    // allowed to have zero entries
    else if (count == 0 && this.keep_zero_entries == false) {
        this.histogram.remove(value);
    }
    // Otherwise throw it into our map
    else {
        this.histogram.put(value, Long.valueOf(count));
    }
    // Mark ourselves as dirty so that we will always recompute
    // internal values (min/max) when they ask for them
    this.dirty = true;
    return (count);
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:50,代码来源:ObjectHistogram.java

示例6: convertTable

import org.voltdb.VoltTypeException; //导入依赖的package包/类
public static VoltTable convertTable(VoltTable inputTable,
                                     Table outputTableSchema)
throws VoltTypeException
{
    VoltTable new_table =
        CatalogUtil.getVoltTable(outputTableSchema);

    Map<Integer, Integer> column_copy_index_map =
        computeColumnCopyIndexMap(inputTable, new_table);

    // Copy all the old tuples into the new table
    while (inputTable.advanceRow())
    {
        Object[] coerced_values =
            new Object[new_table.getColumnCount()];

        for (int i = 0; i < new_table.getColumnCount(); i++)
        {
            if (column_copy_index_map.containsKey(i))
            {
                int orig_column_index = column_copy_index_map.get(i);
                coerced_values[i] =
                    inputTable.get(orig_column_index,
                            inputTable.getColumnType(orig_column_index));
            }
            else
            {
                // 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())
                {
                    coerced_values[i] = null;
                }
                else
                {
                    throw new VoltTypeException("Column: " +
                                                new_table.getColumnName(i) +
                                                " has no default " +
                                                "and null is not permitted");
                }
            }
        }

        new_table.addRow(coerced_values);
    }

    return new_table;
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:76,代码来源:SavedTableConverter.java

示例7: determineImplicitCasting

import org.voltdb.VoltTypeException; //导入依赖的package包/类
public static VoltType determineImplicitCasting(VoltType left, VoltType right) {
    //
    // Make sure both are valid
    //
    if (left == VoltType.INVALID || right == VoltType.INVALID) {
        throw new VoltTypeException("ERROR: Unable to determine cast type for '" + left + "' and '" + right + "' types");
    }
    // Check for NULL first, if either type is NULL the output is always NULL
    // XXX do we need to actually check for all NULL_foo types here?
    else if (left == VoltType.NULL || right == VoltType.NULL)
    {
        return VoltType.NULL;
    }
    //
    // No mixing of strings and numbers
    //
    else if ((left == VoltType.STRING && right != VoltType.STRING) ||
            (left != VoltType.STRING && right == VoltType.STRING))
    {
        throw new VoltTypeException("ERROR: Unable to determine cast type for '" +
                                    left + "' and '" + right + "' types");
    }

    // Allow promoting INTEGER types to DECIMAL.
    else if ((left == VoltType.DECIMAL || right == VoltType.DECIMAL) &&
            !(left.isExactNumeric() && right.isExactNumeric()))
    {
        throw new VoltTypeException("ERROR: Unable to determine cast type for '" +
                                    left + "' and '" + right + "' types");
    }
    //
    // The following list contains the rules that use for casting:
    //
    //    (1) If both types are a STRING, the output is always a STRING
    //        Note that up above we made sure that they do not mix strings and numbers
    //            Example: STRING + STRING -> STRING
    //    (2) If one type is a DECIMAL, the output is always a DECIMAL
    //        Note that above we made sure that DECIMAL only mixes with
    //        allowed types
    //    (3) Floating-point types take precedence over integers
    //            Example: FLOAT + INTEGER -> FLOAT
    //    (4) Specific types for floating-point and integer types take precedence
    //        over the more general types
    //            Example: MONEY + FLOAT -> MONEY
    //            Example: TIMESTAMP + INTEGER -> TIMESTAMP
    VoltType cast_order[] = { VoltType.STRING,
                              VoltType.DECIMAL,
                              VoltType.FLOAT,
                              VoltType.TIMESTAMP,
                              VoltType.BIGINT };
    for (VoltType cast_type : cast_order) {
        //
        // If any one of the types is the current cast type, we'll use that
        //
        if (left == cast_type || right == cast_type)
        {
            return cast_type;
        }
    }

    // If we have INT types smaller than BIGINT
    // promote the output up to BIGINT
    if ((left == VoltType.INTEGER || left == VoltType.SMALLINT || left == VoltType.TINYINT) &&
            (right == VoltType.INTEGER || right == VoltType.SMALLINT || right == VoltType.TINYINT))
    {
        return VoltType.BIGINT;
    }

    // If we get here, we couldn't figure out what to do
    throw new VoltTypeException("ERROR: Unable to determine cast type for '" +
                                left + "' and '" + right + "' types");
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:73,代码来源:VoltTypeUtil.java

示例8: convertTable

import org.voltdb.VoltTypeException; //导入依赖的package包/类
public static VoltTable convertTable(VoltTable inputTable,
                                     Table outputTableSchema)
throws VoltTypeException
{
    VoltTable new_table =
        CatalogUtil.getVoltTable(outputTableSchema);

    Map<Integer, Integer> column_copy_index_map =
        computeColumnCopyIndexMap(inputTable, new_table);

    // Copy all the old tuples into the new table
    while (inputTable.advanceRow())
    {
        Object[] coerced_values =
            new Object[new_table.getColumnCount()];

        for (int i = 0; i < new_table.getColumnCount(); i++)
        {
            if (column_copy_index_map.containsKey(i))
            {
                int orig_column_index = column_copy_index_map.get(i);
                // For column we have in new table convert and make compatible value.
                coerced_values[i] = ParameterConverter.tryToMakeCompatible(
                        new_table.getColumnType(i).classFromType(),
                        inputTable.get(orig_column_index,
                                inputTable.getColumnType(orig_column_index)));
            }
            else
            {
                // 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())
                {
                    coerced_values[i] = null;
                }
                else
                {
                    throw new VoltTypeException("Column: " +
                                                new_table.getColumnName(i) +
                                                " has no default " +
                                                "and null is not permitted");
                }
            }
        }

        new_table.addRow(coerced_values);
    }

    return new_table;
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:78,代码来源:SavedTableConverter.java

示例9: determineImplicitCasting

import org.voltdb.VoltTypeException; //导入依赖的package包/类
public static VoltType determineImplicitCasting(VoltType left, VoltType right) {
    //
    // Make sure both are valid
    //
    if (left == VoltType.INVALID || right == VoltType.INVALID) {
        throw new VoltTypeException("ERROR: Unable to determine cast type for '" + left + "' and '" + right + "' types");
    }
    // Check for NULL first, if either type is NULL the output is always NULL
    // XXX do we need to actually check for all NULL_foo types here?
    else if (left == VoltType.NULL || right == VoltType.NULL)
    {
        return VoltType.NULL;
    }
    //
    // No mixing of strings and numbers
    //
    else if ((left == VoltType.STRING && right != VoltType.STRING) ||
            (left != VoltType.STRING && right == VoltType.STRING))
    {
        throw new VoltTypeException("ERROR: Unable to determine cast type for '" +
                                    left + "' and '" + right + "' types");
    }

    // Allow promoting INTEGER types to DECIMAL.
    else if ((left == VoltType.DECIMAL || right == VoltType.DECIMAL) &&
            !(left.isExactNumeric() && right.isExactNumeric()))
    {
        throw new VoltTypeException("ERROR: Unable to determine cast type for '" +
                                    left + "' and '" + right + "' types");
    }
    //
    // The following list contains the rules that use for casting:
    //
    //    (1) If both types are a STRING, the output is always a STRING
    //        Note that up above we made sure that they do not mix strings and numbers
    //            Example: STRING + STRING -> STRING
    //    (2) If one type is a DECIMAL, the output is always a DECIMAL
    //        Note that above we made sure that DECIMAL only mixes with
    //        allowed types
    //    (3) Floating-point types take precedence over integers
    //            Example: FLOAT + INTEGER -> FLOAT
    //    (4) Specific types for floating-point and integer types take precedence
    //        over the more general types
    //            Example: MONEY + FLOAT -> MONEY
    //            Example: TIMESTAMP + INTEGER -> TIMESTAMP
    for (VoltType cast_type : CAST_ORDER) {
        //
        // If any one of the types is the current cast type, we'll use that
        //
        if (left == cast_type || right == cast_type)
        {
            return cast_type;
        }
    }

    // If we have INT types smaller than BIGINT
    // promote the output up to BIGINT
    if ((left == VoltType.INTEGER || left == VoltType.SMALLINT || left == VoltType.TINYINT) &&
            (right == VoltType.INTEGER || right == VoltType.SMALLINT || right == VoltType.TINYINT))
    {
        return VoltType.BIGINT;
    }

    // If we get here, we couldn't figure out what to do
    throw new VoltTypeException("ERROR: Unable to determine cast type for '" +
                                left + "' and '" + right + "' types");
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:68,代码来源:VoltTypeUtil.java


注:本文中的org.voltdb.VoltTypeException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。