Search in sources :

Example 56 with ObjectDataInput

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

the class CompactInternalGenericRecord method getInt32.

@Override
public int getInt32(@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 getVariableSizeAsNonNull(fd, ObjectDataInput::readInt, "Int32");
        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 57 with ObjectDataInput

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

the class CompactInternalGenericRecord method getInt8.

@Override
public byte getInt8(@Nonnull String fieldName) {
    FieldDescriptor fd = getFieldDefinition(fieldName);
    FieldKind fieldKind = fd.getKind();
    switch(fieldKind) {
        case INT8:
            try {
                return in.readByte(readFixedSizePosition(fd));
            } catch (IOException e) {
                throw illegalStateException(e);
            }
        case NULLABLE_INT8:
            return getVariableSizeAsNonNull(fd, ObjectDataInput::readByte, "Int8");
        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 58 with ObjectDataInput

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

the class DataSerializableImplementsVersionedTest method isGetVersionCalledOnRead.

private boolean isGetVersionCalledOnRead(DataSerializable dataSerializable) throws IOException {
    ObjectDataInput in = getObjectDataInput();
    when(in.getVersion()).thenReturn(Versions.V4_0);
    try {
        dataSerializable.readData(in);
    } catch (NullPointerException | UnsupportedOperationException | IllegalArgumentException | ArithmeticException ignored) {
    }
    return isGetVersionCalled(in);
}
Also used : ObjectDataInput(com.hazelcast.nio.ObjectDataInput)

Example 59 with ObjectDataInput

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

the class DataSerializableImplementsVersionedTest method getObjectDataInput.

// overridden in EE
protected ObjectDataInput getObjectDataInput() {
    ObjectDataInput input = mock(ObjectDataInput.class, withSettings().extraInterfaces(SerializationServiceSupport.class, DataReader.class));
    when(((SerializationServiceSupport) input).getSerializationService()).thenReturn(serializationService);
    return input;
}
Also used : DataReader(com.hazelcast.internal.nio.DataReader) SerializationServiceSupport(com.hazelcast.spi.impl.SerializationServiceSupport) ObjectDataInput(com.hazelcast.nio.ObjectDataInput)

Example 60 with ObjectDataInput

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

the class AbstractDataStreamIntegrationTest method testByteArray.

@Test
public void testByteArray() throws IOException {
    byte[] arr = new byte[] { Byte.MIN_VALUE, Byte.MAX_VALUE, 0 };
    out.writeByteArray(arr);
    ObjectDataInput in = getDataInputFromOutput();
    assertArrayEquals(arr, in.readByteArray());
}
Also used : ObjectDataInput(com.hazelcast.nio.ObjectDataInput) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

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