Package org.apache.avro.io

Examples of org.apache.avro.io.DecoderFactory


  public AvroEventWrapper(Schema inputSchema) {
    this(inputSchema, inputSchema);
  }

  public AvroEventWrapper(Schema inputSchema, Schema outputSchema) {
    mDecoderFactory = new DecoderFactory();
    mRecord = new GenericData.Record(inputSchema);
    mGenericReader = new GenericDatumReader<GenericData.Record>(inputSchema, outputSchema);
  }
View Full Code Here


      }
   }

   @Override
   public Object objectFromByteBuffer(byte[] buf, int offset, int length) throws IOException {
      DecoderFactory factory = new DecoderFactory(); // TODO: Could this be cached?
      InputStream is = new ByteArrayInputStream(buf, offset, length);
      Decoder decoder = factory.createBinaryDecoder(is, null);
      return objectFromByteBuffer(decoder);
   }
View Full Code Here

     * supplies an input stream that is only valid until the end of one
     * record serialization. Each time deserialize() is called, the IS
     * is advanced to point to the right location, so we should not
     * buffer the whole input stream at once.
     */
    decoder = new DecoderFactory().configureDirectDecoder(true)
      .createBinaryDecoder(in, decoder);
  }
View Full Code Here

    if (null != schemaStr) {
      // If schemaStr is null, validate() will fail, so we won't
      // need these things that we can't initialize.
      try {
        mSchema = Schema.parse(schemaStr);
        mDecoderFactory = new DecoderFactory();
        mRecord = new GenericData.Record(mSchema);
        mDatumReader = new GenericDatumReader<GenericData.Record>(mSchema);
      } catch (RuntimeException re) {
        // Couldn't parse schema. Ok, we'll get this in the validate() method.
      }
View Full Code Here

      }
   }

   @Override
   public Object objectFromByteBuffer(byte[] buf, int offset, int length) throws IOException {
      DecoderFactory factory = new DecoderFactory(); // TODO: Could this be cached?
      InputStream is = new ByteArrayInputStream(buf, offset, length);
      Decoder decoder = factory.createBinaryDecoder(is, null);
      return objectFromByteBuffer(decoder);
   }
View Full Code Here

     * supplies an input stream that is only valid until the end of one
     * record serialization. Each time deserialize() is called, the IS
     * is advanced to point to the right location, so we should not
     * buffer the whole input stream at once.
     */
    decoder = new DecoderFactory().configureDirectDecoder(true)
      .createBinaryDecoder(in, decoder);
  }
View Full Code Here

    dump(bs);
    Assert.assertEquals(12, bs.length);

    ByteArrayInputStream bais = new ByteArrayInputStream(bs);
    ReflectDatumReader<A> reader = new ReflectDatumReader<A>(schm);
    BinaryDecoder dec = (new DecoderFactory()).createBinaryDecoder(bais, null);
    A decoded = reader.read(null, dec);
    LOG.info(decoded);
  }
View Full Code Here

    Assert.assertEquals(60, bs.length);

    ByteArrayInputStream bais = new ByteArrayInputStream(bs);
    ReflectDatumReader<EventImpl> reader = new ReflectDatumReader<EventImpl>(
        schm);
    BinaryDecoder dec = (new DecoderFactory()).createBinaryDecoder(bais, null);
    EventImpl decoded = reader.read(null, dec);
    // EventImpl decoded = reader.read(null, new BinaryDecoder(bais));
    LOG.info(decoded);
  }
View Full Code Here

      }
   }

   @Override
   public Object objectFromByteBuffer(byte[] buf, int offset, int length) throws IOException {
      DecoderFactory factory = new DecoderFactory(); // TODO: Could this be cached?
      InputStream is = new ByteArrayInputStream(buf, offset, length);
      Decoder decoder = factory.createBinaryDecoder(is, null);
      return objectFromByteBuffer(decoder);
   }
View Full Code Here

        Result schemaRow = schemaTable.get(new Get(schemaKey));
        actual = Schema.parse(Bytes.toString(schemaRow.getValue(Bytes.toBytes("avro"), Bytes.toBytes("s"))));
      } finally {
        pool.putTable(schemaTable);
      }
      DecoderFactory decoderFactory = new DecoderFactory();
      JsonDecoder jd = decoderFactory.jsonDecoder(actual, Bytes.toString(userRow.getValue(COLUMN_FAMILY, Bytes.toBytes("d"))));

      // Read it as a slightly different schema lacking a field
      InputStream stream = getClass().getResourceAsStream("/src/test/avro/User2.avsc");
      Schema expected = Schema.parse(stream);
View Full Code Here

TOP

Related Classes of org.apache.avro.io.DecoderFactory

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.