Package co.cask.cdap.internal.io

Examples of co.cask.cdap.internal.io.SchemaHash


   * @return A {@link StreamEvent} reconstructed from payload.
   */
  public StreamEvent decodePayload(byte[] payload) {
    ByteBuffer buffer = ByteBuffer.wrap(payload);

    SchemaHash schemaHash = new SchemaHash(buffer);
    Preconditions.checkArgument(schemaHash.equals(STREAM_EVENT_SCHEMA.getSchemaHash()),
                                "Schema from payload not matching StreamEvent schema.");

    Decoder decoder = new BinaryDecoder(new ByteBufferInputStream(buffer));

    try {
View Full Code Here


      try {
        builder.add(STREAM_EVENT_CODEC.decodePayload(content));
      } catch (Throwable t) {
        // If failed to decode, it maybe using old (pre 2.1) stream codec. Try to decode with old one.
        ByteBuffer buffer = ByteBuffer.wrap(content);
        SchemaHash schemaHash = new SchemaHash(buffer);
        Preconditions.checkArgument(schemaHash.equals(StreamEventDataCodec.STREAM_DATA_SCHEMA.getSchemaHash()),
                                    "Schema from payload not matching with StreamEventData schema.");

        Decoder decoder = new BinaryDecoder(new ByteBufferInputStream(buffer));
        // In old schema, timestamp is not recorded.
        builder.add(new DefaultStreamEvent(StreamEventDataCodec.decode(decoder), 0));
View Full Code Here

   *
   * @param buffer {@link ByteBuffer} for reading in schema hash
   * @return A {@link Schema} or {@code null} if the schema is not found.
   */
  public Schema get(ByteBuffer buffer) {
    return get(new SchemaHash(buffer));
  }
View Full Code Here

TOP

Related Classes of co.cask.cdap.internal.io.SchemaHash

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.