Package org.apache.avro.file

Examples of org.apache.avro.file.SeekableFileInput


    write(writer, new BarRecord("Two beers please"), check);
    write(writer, new FooRecord(20), check);
    writer.close();

    ReflectDatumReader<Object> din = new ReflectDatumReader<Object>();
    SeekableFileInput sin = new SeekableFileInput(FILE);
    DataFileReader<Object> reader = new DataFileReader<Object>(sin, din);
    int count = 0;
    for (Object datum : reader)
      check.assertEquals(datum, count++);
    Assert.assertEquals(count, check.size());
View Full Code Here


    write(writer, new BarRecord(), check);
    write(writer, new BarRecord("Two beers please"), check);
    writer.close();

    ReflectDatumReader<BarRecord> din = new ReflectDatumReader<BarRecord>();
    SeekableFileInput sin = new SeekableFileInput(FILE);
    DataFileReader<BarRecord> reader = new DataFileReader<BarRecord>(sin, din);
    int count = 0;
    for (BarRecord datum : reader)
      check.assertEquals(datum, count++);
    Assert.assertEquals(count, check.size());
View Full Code Here

    write(writer, new BazRecord(10), check);
    write(writer, new BazRecord(20), check);
    writer.close();

    ReflectDatumReader<BazRecord> din = new ReflectDatumReader<BazRecord>();
    SeekableFileInput sin = new SeekableFileInput(FILE);
    DataFileReader<BazRecord> reader = new DataFileReader<BazRecord>(sin, din);
    int count = 0;
    for (BazRecord datum : reader)
      check.assertEquals(datum, count++);
    Assert.assertEquals(count, check.size());
View Full Code Here

    DataFileReader<Object> reader =
      new DataFileReader<Object>(file, new GenericDatumReader<Object>());
    // get a header for this file
    DataFileStream.Header header = reader.getHeader();
    // re-open to an arbitrary position near the middle, with sync == true
    SeekableFileInput sin = new SeekableFileInput(file);
    sin.seek(sin.length() / 2);
    reader = DataFileReader.<Object>openReader(sin, new GenericDatumReader<Object>(),
        header, true);
    assertNotNull("Should be able to reopen from arbitrary point", reader.next());
    long validPos = reader.previousSync();
    // post sync, we know of a valid sync point: re-open with seek (sync == false)
    sin.seek(validPos);
    reader = DataFileReader.<Object>openReader(sin, new GenericDatumReader<Object>(),
        header, false);
    assertEquals("Should not move from sync point on reopen", validPos, sin.tell());
    assertNotNull("Should be able to reopen at sync point", reader.next());
  }
View Full Code Here

    write(writer, new BarRecord("Two beers please"), check);
    write(writer, new FooRecord(20), check);
    writer.close();

    ReflectDatumReader din = new ReflectDatumReader();
    SeekableFileInput sin = new SeekableFileInput(FILE);
    DataFileReader<Object> reader = new DataFileReader<Object>(sin, din);
    Object datum = null;
    long count = reader.getMetaLong("count");
    for (int i = 0; i < count; i++) {
      datum = reader.next(datum);
View Full Code Here

    write(writer, new BarRecord("Many beers please"), check);

    writer.close();

    ReflectDatumReader din = new ReflectDatumReader();
    SeekableFileInput sin = new SeekableFileInput(FILE);
    DataFileReader<Object> reader = new DataFileReader<Object>(sin, din);
    Object datum = null;
    long count = reader.getMetaLong("count");
    for (int i = 0; i < count; i++) {
      datum = reader.next(datum);
View Full Code Here

    write(writer, new BarRecord(), check);
    write(writer, new BarRecord("Two beers please"), check);
    writer.close();

    ReflectDatumReader din = new ReflectDatumReader();
    SeekableFileInput sin = new SeekableFileInput(FILE);
    DataFileReader<Object> reader = new DataFileReader<Object>(sin, din);
    Object datum = null;
    long count = reader.getMetaLong("count");
    for (int i = 0; i < count; i++) {
      datum = reader.next(datum);
View Full Code Here

    write(writer, new BazRecord(10), check);
    write(writer, new BazRecord(20), check);
    writer.close();

    ReflectDatumReader din = new ReflectDatumReader();
    SeekableFileInput sin = new SeekableFileInput(FILE);
    DataFileReader<Object> reader = new DataFileReader<Object>(sin, din);
    Object datum = null;
    long count = reader.getMetaLong("count");
    for (int i = 0; i < count; i++) {
      datum = reader.next(datum);
View Full Code Here

  }

  @Test
  public void testGenericRead() throws IOException {
    DataFileReader<Object> reader =
      new DataFileReader<Object>(new SeekableFileInput(FILE),
                                 new GenericDatumReader<Object>());
    try {
      Object datum = null;
      if (VALIDATE) {
        for (Object expected : new RandomData(SCHEMA, COUNT, SEED)) {
View Full Code Here

  protected void readFile(File f,
      DatumReader<Object> datumReader, boolean reuse)
    throws IOException {
    System.out.println("Reading "+ f.getName());
    DataFileReader<Object> reader =
      new DataFileReader<Object>(new SeekableFileInput(f), datumReader);
    Object datum = null;
    long count = reader.getMetaLong("count");
    for (int i = 0; i < count; i++) {
      datum = reader.next(reuse ? datum : null);
      assertNotNull(datum);
View Full Code Here

TOP

Related Classes of org.apache.avro.file.SeekableFileInput

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.