use of com.hazelcast.nio.ObjectDataInput 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);
}
}
use of com.hazelcast.nio.ObjectDataInput 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);
}
}
use of com.hazelcast.nio.ObjectDataInput in project hazelcast by hazelcast.
the class CompactInternalGenericRecord method getArrayOfNullableBoolean.
@Nullable
@Override
public Boolean[] getArrayOfNullableBoolean(@Nonnull String fieldName) {
FieldDescriptor fd = getFieldDefinition(fieldName);
FieldKind fieldKind = fd.getKind();
switch(fieldKind) {
case ARRAY_OF_BOOLEAN:
return getVariableSize(fieldName, ARRAY_OF_BOOLEAN, CompactInternalGenericRecord::readBooleanBitsAsNullables);
case ARRAY_OF_NULLABLE_BOOLEAN:
return getArrayOfVariableSize(fieldName, ARRAY_OF_NULLABLE_BOOLEAN, Boolean[]::new, ObjectDataInput::readBoolean);
default:
throw unexpectedFieldKind(fieldKind, fieldName);
}
}
use of com.hazelcast.nio.ObjectDataInput in project hazelcast by hazelcast.
the class CachePartitionLostListenerTest method test_cachePartitionEventData_deserialization.
@Test
public void test_cachePartitionEventData_deserialization() throws IOException {
CachePartitionEventData cachePartitionEventData = new CachePartitionEventData("", 0, null);
ObjectDataInput input = mock(ObjectDataInput.class, withSettings().extraInterfaces(DataReader.class));
when(input.readString()).thenReturn("cacheName");
when(input.readInt()).thenReturn(1);
cachePartitionEventData.readData(input);
assertEquals("cacheName", cachePartitionEventData.getName());
assertEquals(1, cachePartitionEventData.getPartitionId());
}
use of com.hazelcast.nio.ObjectDataInput in project hazelcast by hazelcast.
the class AbstractDataStreamIntegrationTest method testLong.
@Test
public void testLong() throws IOException {
out.writeLong(Long.MIN_VALUE);
out.writeLong(-1);
out.writeLong(Long.MAX_VALUE);
ObjectDataInput in = getDataInputFromOutput();
assertEquals(Long.MIN_VALUE, in.readLong());
assertEquals(-1, in.readLong());
assertEquals(Long.MAX_VALUE, in.readLong());
}
Aggregations