Search in sources :

Example 31 with FieldKind

use of com.hazelcast.nio.serialization.FieldKind in project hazelcast by hazelcast.

the class DeserializedGenericRecord method getArrayOfBoolean.

@Override
@Nullable
public boolean[] getArrayOfBoolean(@Nonnull String fieldName) {
    FieldKind fieldKind = check(fieldName, ARRAY_OF_BOOLEAN, ARRAY_OF_NULLABLE_BOOLEAN);
    if (fieldKind == ARRAY_OF_NULLABLE_BOOLEAN) {
        Boolean[] array = (Boolean[]) objects.get(fieldName);
        boolean[] result = new boolean[array.length];
        for (int i = 0; i < array.length; i++) {
            if (array[i] == null) {
                throw exceptionForUnexpectedNullValueInArray(fieldName, "Boolean");
            }
            result[i] = array[i];
        }
        return result;
    }
    return (boolean[]) objects.get(fieldName);
}
Also used : FieldKind(com.hazelcast.nio.serialization.FieldKind) Nullable(javax.annotation.Nullable)

Example 32 with FieldKind

use of com.hazelcast.nio.serialization.FieldKind in project hazelcast by hazelcast.

the class DeserializedGenericRecord method getArrayOfNullableFloat32.

@Nullable
@Override
public Float[] getArrayOfNullableFloat32(@Nonnull String fieldName) {
    FieldKind fieldKind = check(fieldName, ARRAY_OF_FLOAT32, ARRAY_OF_NULLABLE_FLOAT32);
    if (fieldKind == ARRAY_OF_FLOAT32) {
        float[] array = (float[]) objects.get(fieldName);
        Float[] result = new Float[array.length];
        Arrays.setAll(result, i -> array[i]);
        return result;
    }
    return (Float[]) objects.get(fieldName);
}
Also used : FieldKind(com.hazelcast.nio.serialization.FieldKind) Nullable(javax.annotation.Nullable)

Example 33 with FieldKind

use of com.hazelcast.nio.serialization.FieldKind in project hazelcast by hazelcast.

the class DeserializedGenericRecord method getArrayOfInt8.

@Override
@Nullable
public byte[] getArrayOfInt8(@Nonnull String fieldName) {
    FieldKind fieldKind = check(fieldName, ARRAY_OF_INT8, ARRAY_OF_NULLABLE_INT8);
    if (fieldKind == ARRAY_OF_NULLABLE_INT8) {
        Byte[] array = (Byte[]) objects.get(fieldName);
        byte[] result = new byte[array.length];
        for (int i = 0; i < array.length; i++) {
            if (array[i] == null) {
                throw exceptionForUnexpectedNullValueInArray(fieldName, "Int8");
            }
            result[i] = array[i];
        }
        return result;
    }
    return (byte[]) objects.get(fieldName);
}
Also used : FieldKind(com.hazelcast.nio.serialization.FieldKind) Nullable(javax.annotation.Nullable)

Example 34 with FieldKind

use of com.hazelcast.nio.serialization.FieldKind in project hazelcast by hazelcast.

the class CompactInternalGenericRecord method getArrayOfBoolean.

@Override
@Nullable
public boolean[] getArrayOfBoolean(@Nonnull String fieldName) {
    FieldDescriptor fd = getFieldDefinition(fieldName);
    FieldKind fieldKind = fd.getKind();
    switch(fieldKind) {
        case ARRAY_OF_BOOLEAN:
            return getVariableSize(fd, CompactInternalGenericRecord::readBooleanBits);
        case ARRAY_OF_NULLABLE_BOOLEAN:
            return getNullableArrayAsPrimitiveArray(fd, ObjectDataInput::readBooleanArray, "Boolean");
        default:
            throw unexpectedFieldKind(fieldKind, fieldName);
    }
}
Also used : FieldKind(com.hazelcast.nio.serialization.FieldKind) BufferObjectDataInput(com.hazelcast.internal.nio.BufferObjectDataInput) ObjectDataInput(com.hazelcast.nio.ObjectDataInput) Nullable(javax.annotation.Nullable)

Example 35 with FieldKind

use of com.hazelcast.nio.serialization.FieldKind in project hazelcast by hazelcast.

the class CompactInternalGenericRecord method getNullableFloat64.

@Nullable
@Override
public Double getNullableFloat64(@Nonnull String fieldName) {
    FieldDescriptor fd = getFieldDefinition(fieldName);
    FieldKind fieldKind = fd.getKind();
    switch(fieldKind) {
        case FLOAT64:
            try {
                return in.readDouble(readFixedSizePosition(fd));
            } catch (IOException e) {
                throw illegalStateException(e);
            }
        case NULLABLE_FLOAT64:
            return getVariableSize(fd, ObjectDataInput::readDouble);
        default:
            throw unexpectedFieldKind(fieldKind, fieldName);
    }
}
Also used : FieldKind(com.hazelcast.nio.serialization.FieldKind) IOException(java.io.IOException) BufferObjectDataInput(com.hazelcast.internal.nio.BufferObjectDataInput) ObjectDataInput(com.hazelcast.nio.ObjectDataInput) Nullable(javax.annotation.Nullable)

Aggregations

FieldKind (com.hazelcast.nio.serialization.FieldKind)40 Nullable (javax.annotation.Nullable)24 BufferObjectDataInput (com.hazelcast.internal.nio.BufferObjectDataInput)17 ObjectDataInput (com.hazelcast.nio.ObjectDataInput)16 IOException (java.io.IOException)14 Nonnull (javax.annotation.Nonnull)3 HazelcastSerializationException (com.hazelcast.nio.serialization.HazelcastSerializationException)2 QueryDataType (com.hazelcast.sql.impl.type.QueryDataType)2 DeserializedSchemaBoundGenericRecordBuilder (com.hazelcast.internal.serialization.impl.compact.DeserializedSchemaBoundGenericRecordBuilder)1 Schema (com.hazelcast.internal.serialization.impl.compact.Schema)1 FieldTypeToFieldKind (com.hazelcast.internal.serialization.impl.portable.FieldTypeToFieldKind)1 FAILING_TOP_LEVEL_INJECTOR (com.hazelcast.jet.sql.impl.inject.UpsertInjector.FAILING_TOP_LEVEL_INJECTOR)1 GenericRecord (com.hazelcast.nio.serialization.GenericRecord)1 GenericRecordBuilder (com.hazelcast.nio.serialization.GenericRecordBuilder)1 QueryException (com.hazelcast.sql.impl.QueryException)1 BigDecimal (java.math.BigDecimal)1 LocalDate (java.time.LocalDate)1 LocalDateTime (java.time.LocalDateTime)1 LocalTime (java.time.LocalTime)1 OffsetDateTime (java.time.OffsetDateTime)1