Search in sources :

Example 51 with ObjectDataInput

use of com.hazelcast.nio.ObjectDataInput in project hazelcast by hazelcast.

the class ObjectCarryingPortable method readPortable.

@Override
public void readPortable(PortableReader reader) throws IOException {
    ObjectDataInput input = reader.getRawDataInput();
    object = input.readObject();
}
Also used : ObjectDataInput(com.hazelcast.nio.ObjectDataInput)

Example 52 with ObjectDataInput

use of com.hazelcast.nio.ObjectDataInput in project hazelcast by hazelcast.

the class SerializationServiceV1 method initDataSerializableInputAndSkipTheHeader.

/**
 * Init the ObjectDataInput for the given Data skipping the serialization header-bytes and navigating to the position
 * from where the readData() starts reading the object fields.
 *
 * @param data data to initialize the ObjectDataInput with.
 * @return the initialized ObjectDataInput without the header.
 * @throws IOException
 */
public ObjectDataInput initDataSerializableInputAndSkipTheHeader(Data data) throws IOException {
    ObjectDataInput input = createObjectDataInput(data);
    byte header = input.readByte();
    if (isFlagSet(header, IDS_FLAG)) {
        skipBytesSafely(input, FACTORY_AND_CLASS_ID_BYTE_LENGTH);
    } else {
        input.readString();
    }
    if (isFlagSet(header, EE_FLAG)) {
        skipBytesSafely(input, EE_BYTE_LENGTH);
    }
    return input;
}
Also used : BufferObjectDataInput(com.hazelcast.internal.nio.BufferObjectDataInput) ObjectDataInput(com.hazelcast.nio.ObjectDataInput)

Example 53 with ObjectDataInput

use of com.hazelcast.nio.ObjectDataInput 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 54 with ObjectDataInput

use of com.hazelcast.nio.ObjectDataInput 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)

Example 55 with ObjectDataInput

use of com.hazelcast.nio.ObjectDataInput in project hazelcast by hazelcast.

the class CompactInternalGenericRecord method getBoolean.

@Override
public boolean getBoolean(@Nonnull String fieldName) {
    FieldDescriptor fd = getFieldDefinition(fieldName);
    FieldKind fieldKind = fd.getKind();
    switch(fieldKind) {
        case BOOLEAN:
            return getBoolean(fd);
        case NULLABLE_BOOLEAN:
            return getVariableSizeAsNonNull(fd, ObjectDataInput::readBoolean, "Boolean");
        default:
            throw unexpectedFieldKind(BOOLEAN, fieldName);
    }
}
Also used : FieldKind(com.hazelcast.nio.serialization.FieldKind) BufferObjectDataInput(com.hazelcast.internal.nio.BufferObjectDataInput) ObjectDataInput(com.hazelcast.nio.ObjectDataInput)

Aggregations

ObjectDataInput (com.hazelcast.nio.ObjectDataInput)81 Test (org.junit.Test)35 QuickTest (com.hazelcast.test.annotation.QuickTest)32 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)24 BufferObjectDataInput (com.hazelcast.internal.nio.BufferObjectDataInput)17 FieldKind (com.hazelcast.nio.serialization.FieldKind)16 IOException (java.io.IOException)13 ObjectDataOutput (com.hazelcast.nio.ObjectDataOutput)12 Nullable (javax.annotation.Nullable)9 GlobalSerializerConfig (com.hazelcast.config.GlobalSerializerConfig)7 SerializationConfig (com.hazelcast.config.SerializationConfig)6 StreamSerializer (com.hazelcast.nio.serialization.StreamSerializer)6 Data (com.hazelcast.nio.serialization.Data)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 Data (com.hazelcast.internal.serialization.Data)3 SerializationService (com.hazelcast.internal.serialization.SerializationService)3 DefaultSerializationServiceBuilder (com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder)3 HeapData (com.hazelcast.internal.serialization.impl.HeapData)3 SerializationService (com.hazelcast.spi.serialization.SerializationService)3 SerializerConfig (com.hazelcast.config.SerializerConfig)2