use of com.hazelcast.nio.serialization.FieldDefinition in project hazelcast by hazelcast.
the class MorphingPortableReader method readChar.
@Override
public char readChar(String fieldName) throws IOException {
FieldDefinition fd = cd.getField(fieldName);
if (fd == null) {
return 0;
}
validateTypeCompatibility(fd, CHAR);
return super.readChar(fieldName);
}
use of com.hazelcast.nio.serialization.FieldDefinition in project hazelcast by hazelcast.
the class MorphingPortableReader method readFloatArray.
@Override
public float[] readFloatArray(String fieldName) throws IOException {
FieldDefinition fd = cd.getField(fieldName);
if (fd == null) {
return null;
}
validateTypeCompatibility(fd, FLOAT_ARRAY);
return super.readFloatArray(fieldName);
}
use of com.hazelcast.nio.serialization.FieldDefinition in project hazelcast by hazelcast.
the class MorphingPortableReader method readShortArray.
@Override
public short[] readShortArray(String fieldName) throws IOException {
FieldDefinition fd = cd.getField(fieldName);
if (fd == null) {
return null;
}
validateTypeCompatibility(fd, SHORT_ARRAY);
return super.readShortArray(fieldName);
}
use of com.hazelcast.nio.serialization.FieldDefinition in project hazelcast by hazelcast.
the class DefaultPortableWriter method writePortable.
@Override
public void writePortable(String fieldName, Portable portable) throws IOException {
FieldDefinition fd = setPosition(fieldName, FieldType.PORTABLE);
final boolean isNull = portable == null;
out.writeBoolean(isNull);
out.writeInt(fd.getFactoryId());
out.writeInt(fd.getClassId());
if (!isNull) {
checkPortableAttributes(fd, portable);
serializer.writeInternal(out, portable);
}
}
use of com.hazelcast.nio.serialization.FieldDefinition in project hazelcast by hazelcast.
the class DefaultPortableWriter method setPosition.
private FieldDefinition setPosition(String fieldName, FieldType fieldType) throws IOException {
if (raw) {
throw new HazelcastSerializationException("Cannot write Portable fields after getRawDataOutput() is called!");
}
FieldDefinition fd = cd.getField(fieldName);
if (fd == null) {
throw new HazelcastSerializationException("Invalid field name: '" + fieldName + "' for ClassDefinition {id: " + cd.getClassId() + ", version: " + cd.getVersion() + "}");
}
if (writtenFields.add(fieldName)) {
int pos = out.position();
int index = fd.getIndex();
out.writeInt(offset + index * INT_SIZE_IN_BYTES, pos);
out.writeShort(fieldName.length());
out.writeBytes(fieldName);
out.writeByte(fieldType.getId());
} else {
throw new HazelcastSerializationException("Field '" + fieldName + "' has already been written!");
}
return fd;
}
Aggregations