Search in sources :

Example 26 with Value

use of org.h2.value.Value in project ignite by apache.

the class GridH2KeyValueRowOnheap method getValue0.

/**
 * Get real column value.
 *
 * @param col Adjusted column index (without default columns).
 * @return Value.
 */
private Value getValue0(int col) {
    Value v = getCached(col);
    if (v != null)
        return v;
    Object res = desc.columnValue(key.getObject(), val.getObject(), col);
    if (res == null)
        v = ValueNull.INSTANCE;
    else {
        try {
            v = desc.wrap(res, desc.fieldType(col));
        } catch (IgniteCheckedException e) {
            throw DbException.convert(e);
        }
    }
    setCached(col, v);
    return v;
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) Value(org.h2.value.Value)

Example 27 with Value

use of org.h2.value.Value in project ignite by apache.

the class InlineIndexHelperTest method getResBytes.

/**
 */
private boolean getResBytes(InlineIndexHelper ha, byte[] b1, byte[] b2) {
    Value v1 = b1 == null ? ValueNull.INSTANCE : ValueBytes.get(b1);
    Value v2 = b2 == null ? ValueNull.INSTANCE : ValueBytes.get(b2);
    int c = v1.compareTypeSafe(v2, CompareMode.getInstance(null, 0));
    return ha.canRelyOnCompare(c, v1, v2);
}
Also used : Value(org.h2.value.Value)

Example 28 with Value

use of org.h2.value.Value in project ignite by apache.

the class InlineIndexHelperTest method getRes.

/**
 */
private boolean getRes(InlineIndexHelper ha, String s1, String s2) {
    Value v1 = s1 == null ? ValueNull.INSTANCE : ValueString.get(s1);
    Value v2 = s2 == null ? ValueNull.INSTANCE : ValueString.get(s2);
    int c = v1.compareTypeSafe(v2, CompareMode.getInstance(null, 0));
    return ha.canRelyOnCompare(c, v1, v2);
}
Also used : Value(org.h2.value.Value)

Example 29 with Value

use of org.h2.value.Value in project ignite by apache.

the class H2Utils method convert.

/**
 * Convert value to column's expected type by means of H2.
 *
 * @param val Source value.
 * @param desc Row descriptor.
 * @param type Expected column type to convert to.
 * @return Converted object.
 * @throws IgniteCheckedException if failed.
 */
public static Object convert(Object val, GridH2RowDescriptor desc, int type) throws IgniteCheckedException {
    if (val == null)
        return null;
    int objType = DataType.getTypeFromClass(val.getClass());
    if (objType == type)
        return val;
    Value h2Val = desc.wrap(val, objType);
    return h2Val.convertTo(type).getObject();
}
Also used : Value(org.h2.value.Value)

Example 30 with Value

use of org.h2.value.Value in project h2database by h2database.

the class Parser method readParameterIndex.

private void readParameterIndex() {
    int i = parseIndex;
    char[] chars = sqlCommandChars;
    char c = chars[i++];
    long number = c - '0';
    while (true) {
        c = chars[i];
        if (c < '0' || c > '9') {
            currentValue = ValueInt.get((int) number);
            currentTokenType = VALUE;
            currentToken = "0";
            parseIndex = i;
            break;
        }
        number = number * 10 + (c - '0');
        if (number > Integer.MAX_VALUE) {
            throw DbException.getInvalidValueException("parameter index", number);
        }
        i++;
    }
}
Also used : AlterTableRenameConstraint(org.h2.command.ddl.AlterTableRenameConstraint) AlterTableAddConstraint(org.h2.command.ddl.AlterTableAddConstraint) AlterTableDropConstraint(org.h2.command.ddl.AlterTableDropConstraint)

Aggregations

Value (org.h2.value.Value)291 SQLException (java.sql.SQLException)94 DbException (org.h2.message.DbException)91 ResultSet (java.sql.ResultSet)69 PreparedStatement (java.sql.PreparedStatement)61 Statement (java.sql.Statement)53 Column (org.h2.table.Column)44 ValueString (org.h2.value.ValueString)44 JdbcStatement (org.h2.jdbc.JdbcStatement)42 JdbcPreparedStatement (org.h2.jdbc.JdbcPreparedStatement)36 SimpleResultSet (org.h2.tools.SimpleResultSet)31 StatementBuilder (org.h2.util.StatementBuilder)28 IndexColumn (org.h2.table.IndexColumn)23 Expression (org.h2.expression.Expression)22 IOException (java.io.IOException)21 Row (org.h2.result.Row)19 SearchRow (org.h2.result.SearchRow)18 Connection (java.sql.Connection)17 ValueArray (org.h2.value.ValueArray)17 ValueTimestamp (org.h2.value.ValueTimestamp)17