Deserialize a {@link GenericRecord} from a byte array. This method is not intended for high performance.
335548
public static GenericRecord slowDeserializeGenericRecord(byte[] serializedRecord, Schema schema) throws IOException {
    Decoder decoder = DecoderFactory.get().binaryDecoder(serializedRecord, null);
    GenericDatumReader<GenericRecord> reader = new GenericDatumReader<>(schema);
    return reader.read(null, decoder);
  }
368720
public void fieldsToData(Rec record) throws DBException
    {
        try   {
            int iFieldTypes = BaseBuffer.PHYSICAL_FIELDS;
            if (!((Record)record).isAllSelected())
                iFieldTypes = BaseBuffer.DATA_FIELDS;   //SELECTED_FIELDS; (Selected and physical)
            m_dataSource = new VectorBuffer(null, iFieldTypes);   //x new StringBuff();
            ((BaseBuffer)m_dataSource).fieldsToBuffer((FieldList)record);
        } catch (Exception ex) {
            throw DatabaseException.toDatabaseException(ex);
        }
    }
843518
public Serializable deserializeFromBytes(final byte[] bytes) {
        Serializable o = null;
        try (final ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
            final ObjectInputStream ois = new RestrictedObjectInputStream(bais, this.trustedPackages, this.trustedClasses)) {
            o = (Serializable) ois.readObject();
        } catch (final IOException | ClassNotFoundException e) {
            logger.warn("cannot Java deserialize object", e);
        }
        return o;
    }
1098789
private ApacheHttpRequest<GenericRecord> buildWriteRequest(BufferedRecord<GenericRecord> record) {
    if (record == null) {
      return null;
    }

    ApacheHttpRequest<GenericRecord> request = new ApacheHttpRequest<>();
    HttpOperation httpOperation = HttpUtils.toHttpOperation(record.getRecord());

    // Set uri
    URI uri = HttpUtils.buildURI(urlTemplate, httpOperation.getKeys(), httpOperation.getQueryParams());
    if (uri == null) {
      return null;
    }

    RequestBuilder builder = RequestBuilder.create(verb.toUpperCase());
    builder.setUri(uri);

    // Set headers
    Map<String, String> headers = httpOperation.getHeaders();
    if (headers != null && headers.size() != 0) {
      for (Map.Entry<String, String> header : headers.entrySet()) {
        builder.setHeader(header.getKey(), header.getValue());
      }
    }

    // Add payload
    int bytesWritten = addPayload(builder, httpOperation.getBody());
    if (bytesWritten == -1) {
      throw new RuntimeException("Fail to write payload into request");
    }

    request.setRawRequest(build(builder));
    request.markRecord(record, bytesWritten);
    return request;
  }
494432
@SuppressWarnings("unchecked")
  @Override
  public D readRecordImpl(D reuse) throws DataRecordException, IOException {
    if (this.shutdownRequested.get()) {
      return null;
    }

    long readStartTime = System.nanoTime();

    while (!allPartitionsFinished()) {
      if (currentPartitionFinished()) {
        moveToNextPartition();
        continue;
      }
      if (this.messageIterator == null || !this.messageIterator.hasNext()) {
        try {
          long fetchStartTime = System.nanoTime();
          this.messageIterator = fetchNextMessageBuffer();
          this.currentPartitionFetchMessageBufferTime += System.nanoTime() - fetchStartTime;
        } catch (Exception e) {
          LOG.error(String.format("Failed to fetch next message buffer for partition %s. Will skip this partition.",
              getCurrentPartition()), e);
          moveToNextPartition();
          continue;
        }
        if (this.messageIterator == null || !this.messageIterator.hasNext()) {
          moveToNextPartition();
          continue;
        }
      }
      while (!currentPartitionFinished()) {
        if (!this.messageIterator.hasNext()) {
          break;
        }

        KafkaConsumerRecord nextValidMessage = this.messageIterator.next();

        // Even though we ask Kafka to give us a message buffer starting from offset x, it may
        // return a buffer that starts from offset smaller than x, so we need to skip messages
        // until we get to x.
        if (nextValidMessage.getOffset() < this.nextWatermark.get(this.currentPartitionIdx)) {
          continue;
        }

        this.nextWatermark.set(this.currentPartitionIdx, nextValidMessage.getNextOffset());
        try {
          // track time for decode/convert depending on the record type
          long decodeStartTime = System.nanoTime();

          D record = decodeKafkaMessage(nextValidMessage);

          this.currentPartitionDecodeRecordTime += System.nanoTime() - decodeStartTime;
          this.currentPartitionRecordCount++;
          this.currentPartitionTotalSize += nextValidMessage.getValueSizeInBytes();
          this.currentPartitionReadRecordTime += System.nanoTime() - readStartTime;
          this.currentPartitionLastSuccessfulRecord = record;
          return record;
        } catch (Throwable t) {
          this.errorPartitions.add(this.currentPartitionIdx);
          this.undecodableMessageCount++;
          if (shouldLogError()) {
            LOG.error(String.format("A record from partition %s cannot be decoded.", getCurrentPartition()), t);
          }
          incrementErrorCount();
        }
      }
    }
    LOG.info("Finished pulling topic " + this.topicName);

    this.currentPartitionReadRecordTime += System.nanoTime() - readStartTime;
    return null;
  }
33809
private Serializable deserializeObject(byte[] buffer) throws IOException, ClassNotFoundException {

		Serializable theObject = null;
		ObjectInputStream objectIn = null;

		if (buffer != null) {
			objectIn = new ObjectInputStream(new ByteArrayInputStream(buffer));
			theObject = (Serializable)objectIn.readObject();
			objectIn.close();
		}
		return theObject;
	}
554735
public byte[] getRecord(final long iPosition) throws IOException {
    if (iPosition == -1)
      return null;

    acquireSharedLock();
    try {

      final long[] pos = getRelativePosition(iPosition);
      final OFile file = files[(int) pos[0]];

      final int recordSize = file.readInt(pos[1]);
      if (recordSize <= 0)
        // RECORD DELETED
        return null;

      if (pos[1] + RECORD_FIX_SIZE + recordSize > file.getFilledUpTo())
        throw new OStorageException(
            "Error on reading record from file '"
                + file.getName()
                + "', position "
                + iPosition
                + ", size "
                + OFileUtils.getSizeAsString(recordSize)
                + ": the record size is bigger then the file itself ("
                + OFileUtils.getSizeAsString(getFilledUpTo())
                + "). Probably the record is dirty due to a previous crash. It is strongly suggested to restore the database or export and reimport this one.");

      final byte[] content = new byte[recordSize];
      file.read(pos[1] + RECORD_FIX_SIZE, content, recordSize);
      return content;

    } finally {
      releaseSharedLock();
    }
  }
1207470
public byte[] readRecord() throws IOException {
        if (this.debug) {
            System.err.println("ReadRecord: recIdx = " + this.currRecIdx + " blkIdx = " + this.currBlkIdx);
        }

        if (this.inStream == null) {
            throw new IOException("reading from an output buffer");
        }

        if (this.currRecIdx >= this.recsPerBlock) {
            if (!this.readBlock()) {
                return null;
            }
        }

        byte[] result = new byte[this.recordSize];

        System.arraycopy(this.blockBuffer, (this.currRecIdx * this.recordSize), result, 0, this.recordSize);

        this.currRecIdx++;

        return result;
    }
759641
protected P upConvertPayload(GenericRecord inputRecord) throws DataConversionException {
    try {
      Schema payloadSchema = getPayloadSchema(inputRecord);
      // Set writer schema
      latestPayloadReader.setSchema(payloadSchema);

      byte[] payloadBytes = getPayloadBytes(inputRecord);
      Decoder decoder = DecoderFactory.get().binaryDecoder(payloadBytes, null);

      // 'latestPayloadReader.read' will convert the record from 'payloadSchema' to the latest payload schema
      return latestPayloadReader.read(null, decoder);
    } catch (Exception e) {
      throw new DataConversionException(e);
    }
  }
393859
public static <T> T fromByteArrayKryo(byte[] data, Class<T> clazz) {
        return fromByteArrayKryo(data, clazz, null);
    }
49366
@FFDCIgnore({ClassNotFoundException.class })
	public static final Serializable deserialize(byte[] array, String cacheName) throws IOException, ClassNotFoundException {

		if (array == null) {
			return null;
		}
		
		Serializable object = null;

		try {
			if (null != _instance) {
				SerializationService ss = _instance.serializationServiceRef.getService();
				if (null != ss) {
					try {
						ClassLoader tccl = getContextClassLoader();
						ObjectInputStream objectInputStream = ss.createObjectInputStream(new ByteArrayInputStream(array), tccl);
						object = (Serializable) objectInputStream.readObject();
					}catch (ClassNotFoundException e){
						if (null != cacheName){
							Library sharedLib = getSharedLibrary(cacheName);
							if (null != sharedLib){
								ObjectInputStream objectInputStream = new DeserializationObjectInputStream(new ByteArrayInputStream(array), sharedLib.getClassLoader());
								object = (Serializable) objectInputStream.readObject();
							}
						}
					}
				}
			}

			if (null == object) {
				object = deserializeUsingTCCL(array, 0, array.length, getContextClassLoader());
			}
		} catch (ClassNotFoundException e) {
			try {
				object = deserialize(array, 0, array.length);
			} catch (ClassNotFoundException e1) {
				throw e1;
			}
		}
		return object;
	}
79332
public static <S extends Serializable> S deserialize(byte[] bytes) throws IOException {
    if (bytes == null) {
      return null;
    }
    return deserialize(new ByteArrayInputStream(bytes));
  }
1104163
public static <T extends Serializable> T deserialize(byte[] bytes, boolean compressed) throws IOException, ClassNotFoundException {
        requireNonNull(bytes);

        try (ByteArrayInputStream i = new ByteArrayInputStream(bytes);
             ObjectInputStream ois = new ObjectInputStream(compressed ? new GZIPInputStream(i) : i)) {
            return (T) ois.readObject();
        }
    }
987971
protected Object deserialize(byte[] in) {
    Object rv=null;
    ByteArrayInputStream bis = null;
    ObjectInputStream is = null;
    try {
      if(in != null) {
        bis=new ByteArrayInputStream(in);
        is=new ObjectInputStream(bis);
        rv=is.readObject();
        is.close();
        bis.close();
      }
    } catch (IOException e) {
      getLogger().warn("Caught IOException decoding %d bytes of data",
          in == null ? 0 : in.length, e);
    } catch (ClassNotFoundException e) {
      getLogger().warn("Caught CNFE decoding %d bytes of data",
          in == null ? 0 : in.length, e);
    } finally {
      CloseUtil.close(is);
      CloseUtil.close(bis);
    }
    return rv;
  }
846336
private static byte[] extractBytes(byte[] scanRecord, int start, int length) {
        byte[] bytes = new byte[length];
        System.arraycopy(scanRecord, start, bytes, 0, length);
        return bytes;
    }
1181520
protected Object deserialize(final byte[] in) {
        Object o = null;
        ByteArrayInputStream bis = null;
        ConfigurableObjectInputStream is = null;

        try {
            if (in != null) {
                bis = new ByteArrayInputStream(in);
                is = new ConfigurableObjectInputStream(bis, Thread.currentThread().getContextClassLoader());
                o = is.readObject();
                is.close();
                bis.close();
            }
        } catch (IOException e) {
            LOGGER.warn(String.format("Caught IOException decoding %d bytes of data", in.length), e);
        } catch (ClassNotFoundException e) {
            LOGGER.warn(String.format("Caught CNFE decoding %d bytes of data", in.length), e);
        } finally {
            close(is);
            close(bis);
        }

        return o;
    }
872802
@NotNull
    public static <T> T deserialize(@NotNull final DeserializerRegistry registry, @NotNull final SerializedData data) {
        Contract.requireArgNotNull("registry", registry);
        Contract.requireArgNotNull("data", data);
        final Deserializer deserializer = registry.getDeserializer(data.getType(), data.getMimeType());
        return deserializer.unmarshal(data.getRaw(), data.getType(), data.getMimeType());

    }