public Portable[] readPortableArray(String fieldName) throws IOException {
   FieldDefinition fd = cd.getField(fieldName);
   if (fd == null) {
     throw throwUnknownFieldException(fieldName);
   }
   if (fd.getType() != FieldType.PORTABLE_ARRAY) {
     throw new HazelcastSerializationException("Not a Portable array field: " + fieldName);
   }
   final int currentPos = in.position();
   try {
     int pos = readPosition(fd);
     in.position(pos);
     final int len = in.readInt();
     final Portable[] portables = new Portable[len];
     if (len > 0) {
       final int offset = in.position();
       for (int i = 0; i < len; i++) {
         final int start = in.readInt(offset + i * 4);
         in.position(start);
         portables[i] =
             serializer.readAndInitialize(in, fd.getFactoryId(), fd.getClassId(), fd.getVersion());
       }
     }
     return portables;
   } finally {
     in.position(currentPos);
   }
 }
 private int readPosition(String fieldName, FieldType type) throws IOException {
   if (raw) {
     throw new HazelcastSerializationException(
         "Cannot read Portable fields after getRawDataInput() is called!");
   }
   FieldDefinition fd = cd.getField(fieldName);
   if (fd == null) {
     return readNestedPosition(fieldName, type);
   }
   if (fd.getType() != type) {
     throw new HazelcastSerializationException("Not a '" + type + "' field: " + fieldName);
   }
   return readPosition(fd);
 }
 public Portable readPortable(String fieldName) throws IOException {
   FieldDefinition fd = cd.getField(fieldName);
   if (fd == null) {
     throw throwUnknownFieldException(fieldName);
   }
   if (fd.getType() != FieldType.PORTABLE) {
     throw new HazelcastSerializationException("Not a Portable field: " + fieldName);
   }
   final int currentPos = in.position();
   try {
     int pos = readPosition(fd);
     in.position(pos);
     final boolean isNull = in.readBoolean();
     if (!isNull) {
       return serializer.readAndInitialize(
           in, fd.getFactoryId(), fd.getClassId(), fd.getVersion());
     }
     return null;
   } finally {
     in.position(currentPos);
   }
 }