Search in sources :

Example 16 with FieldKind

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

the class CompactStreamSerializer method writeGenericRecord.

void writeGenericRecord(BufferObjectDataOutput output, CompactGenericRecord record, boolean includeSchemaOnBinary) throws IOException {
    Schema schema = record.getSchema();
    putToSchemaService(includeSchemaOnBinary, schema);
    writeSchema(output, includeSchemaOnBinary, schema);
    DefaultCompactWriter writer = new DefaultCompactWriter(this, output, schema, includeSchemaOnBinary);
    Collection<FieldDescriptor> fields = schema.getFields();
    for (FieldDescriptor fieldDescriptor : fields) {
        String fieldName = fieldDescriptor.getFieldName();
        FieldKind fieldKind = fieldDescriptor.getKind();
        fieldOperations(fieldKind).writeFieldFromRecordToWriter(writer, record, fieldName);
    }
    writer.end();
}
Also used : FieldKind(com.hazelcast.nio.serialization.FieldKind)

Example 17 with FieldKind

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

the class CompactInternalGenericRecord method getNullableInt64.

@Nullable
@Override
public Long getNullableInt64(@Nonnull String fieldName) {
    FieldDescriptor fd = getFieldDefinition(fieldName);
    FieldKind fieldKind = fd.getKind();
    switch(fieldKind) {
        case INT64:
            try {
                return in.readLong(readFixedSizePosition(fd));
            } catch (IOException e) {
                throw illegalStateException(e);
            }
        case NULLABLE_INT64:
            return getVariableSize(fd, ObjectDataInput::readLong);
        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)

Example 18 with FieldKind

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

the class CompactInternalGenericRecord method getFloat32.

@Override
public float getFloat32(@Nonnull String fieldName) {
    FieldDescriptor fd = getFieldDefinition(fieldName);
    FieldKind fieldKind = fd.getKind();
    switch(fieldKind) {
        case FLOAT32:
            try {
                return in.readFloat(readFixedSizePosition(fd));
            } catch (IOException e) {
                throw illegalStateException(e);
            }
        case NULLABLE_FLOAT32:
            return getVariableSizeAsNonNull(fd, ObjectDataInput::readFloat, "Float32");
        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)

Example 19 with FieldKind

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

the class CompactInternalGenericRecord method getNullableInt32.

@Nullable
@Override
public Integer getNullableInt32(@Nonnull String fieldName) {
    FieldDescriptor fd = getFieldDefinition(fieldName);
    FieldKind fieldKind = fd.getKind();
    switch(fieldKind) {
        case INT32:
            try {
                return in.readInt(readFixedSizePosition(fd));
            } catch (IOException e) {
                throw illegalStateException(e);
            }
        case NULLABLE_INT32:
            return getVariableSize(fd, ObjectDataInput::readInt);
        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)

Example 20 with FieldKind

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

the class CompactInternalGenericRecord method getArrayOfPrimitive.

private <T> T getArrayOfPrimitive(@Nonnull String fieldName, Reader<T> reader, FieldKind primitiveKind, FieldKind nullableKind, String methodSuffix) {
    FieldDescriptor fd = getFieldDefinition(fieldName);
    FieldKind fieldKind = fd.getKind();
    if (fieldKind == primitiveKind) {
        return getVariableSize(fd, reader);
    } else if (fieldKind == nullableKind) {
        return getNullableArrayAsPrimitiveArray(fd, reader, methodSuffix);
    }
    throw unexpectedFieldKind(fieldKind, fieldName);
}
Also used : FieldKind(com.hazelcast.nio.serialization.FieldKind)

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