use of com.hazelcast.nio.ObjectDataInput in project hazelcast-jet by hazelcast.
the class HashSetHook method createSerializer.
@Override
@SuppressWarnings("checkstyle:anoninnerlength")
public Serializer createSerializer() {
return new StreamSerializer<HashSet>() {
@Override
public int getTypeId() {
return SerializerHookConstants.HASH_SET;
}
@Override
public void destroy() {
}
@Override
@SuppressWarnings("checkstyle:illegaltype")
public void write(ObjectDataOutput out, HashSet set) throws IOException {
out.writeInt(set.size());
for (Object o : set) {
out.writeObject(o);
}
}
@Override
@SuppressWarnings("checkstyle:illegaltype")
public HashSet read(ObjectDataInput in) throws IOException {
int length = in.readInt();
HashSet set = new HashSet();
for (int i = 0; i < length; i++) {
// noinspection unchecked
set.add(in.readObject());
}
return set;
}
};
}
use of com.hazelcast.nio.ObjectDataInput in project hazelcast by hazelcast.
the class Employee method readPortable.
public void readPortable(PortableReader reader) throws IOException {
name = reader.readString("n");
age = reader.readInt("a");
by = reader.readByte("b");
c = reader.readChar("c");
bool = reader.readBoolean("bo");
s = reader.readShort("s");
i = reader.readInt("i");
l = reader.readLong("l");
f = reader.readFloat("f");
d = reader.readDouble("d");
str = reader.readString("str");
utfStr = reader.readString("utfstr");
byteArray = reader.readByteArray("bb");
charArray = reader.readCharArray("cc");
boolArray = reader.readBooleanArray("ba");
shortArray = reader.readShortArray("ss");
integerArray = reader.readIntArray("ii");
floatArray = reader.readFloatArray("ff");
doubleArray = reader.readDoubleArray("dd");
ObjectDataInput in = reader.getRawDataInput();
by = (Byte) in.readObject();
c = (Character) in.readObject();
bool = (Boolean) in.readObject();
s = (Short) in.readObject();
i = (Integer) in.readObject();
f = (Float) in.readObject();
d = (Double) in.readObject();
str = (String) in.readObject();
utfStr = (String) in.readObject();
}
use of com.hazelcast.nio.ObjectDataInput in project hazelcast by hazelcast.
the class CompactInternalGenericRecord method getNullableInt16.
@Nullable
@Override
public Short getNullableInt16(@Nonnull String fieldName) {
FieldDescriptor fd = getFieldDefinition(fieldName);
FieldKind fieldKind = fd.getKind();
switch(fieldKind) {
case INT16:
try {
return in.readShort(readFixedSizePosition(fd));
} catch (IOException e) {
throw illegalStateException(e);
}
case NULLABLE_INT16:
return getVariableSize(fd, ObjectDataInput::readShort);
default:
throw unexpectedFieldKind(fieldKind, fieldName);
}
}
use of com.hazelcast.nio.ObjectDataInput in project hazelcast by hazelcast.
the class CompactInternalGenericRecord method getInt64.
@Override
public long getInt64(@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 getVariableSizeAsNonNull(fd, ObjectDataInput::readLong, "Int64");
default:
throw unexpectedFieldKind(fieldKind, fieldName);
}
}
use of com.hazelcast.nio.ObjectDataInput in project hazelcast by hazelcast.
the class CompactInternalGenericRecord method getInt16.
@Override
public short getInt16(@Nonnull String fieldName) {
FieldDescriptor fd = getFieldDefinition(fieldName);
FieldKind fieldKind = fd.getKind();
switch(fieldKind) {
case INT16:
try {
return in.readShort(readFixedSizePosition(fd));
} catch (IOException e) {
throw illegalStateException(e);
}
case NULLABLE_INT16:
return getVariableSizeAsNonNull(fd, ObjectDataInput::readShort, "Int16");
default:
throw unexpectedFieldKind(fieldKind, fieldName);
}
}
Aggregations