Search in sources :

Example 1 with BinaryMode

use of org.apache.ignite.internal.schema.marshaller.BinaryMode in project ignite-3 by apache.

the class ColumnBinding method createIdentityBinding.

/**
 * Binds a column with an object of given type.
 *
 * @param col       Column.
 * @param type      Object type.
 * @param converter Type converter or {@code null}.
 * @return Column to object binding.
 */
@NotNull
static ColumnBinding createIdentityBinding(Column col, Class<?> type, @Nullable TypeConverter<?, ?> converter) {
    final BinaryMode mode = MarshallerUtil.mode(type);
    if (mode.typeSpec() != col.type().spec()) {
        throw new SchemaMismatchException(String.format("Object can't be mapped to a column of incompatible type: columnType=%s, mappedType=%s", col.type().spec(), type.getName()));
    }
    final MethodHandle identityHandle = MethodHandles.identity(type);
    return create(col, type, identityHandle, identityHandle, converter);
}
Also used : BinaryMode(org.apache.ignite.internal.schema.marshaller.BinaryMode) SchemaMismatchException(org.apache.ignite.internal.schema.SchemaMismatchException) MethodHandle(java.lang.invoke.MethodHandle) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

MethodHandle (java.lang.invoke.MethodHandle)1 SchemaMismatchException (org.apache.ignite.internal.schema.SchemaMismatchException)1 BinaryMode (org.apache.ignite.internal.schema.marshaller.BinaryMode)1 NotNull (org.jetbrains.annotations.NotNull)1