Package org.apache.trevni

Examples of org.apache.trevni.ColumnFileMetaData


    checkRead(s);
  }

  private void checkWrite(Schema schema) throws IOException {
    AvroColumnWriter<Object> writer =
      new AvroColumnWriter<Object>(schema, new ColumnFileMetaData());
    int count = 0;
    for (Object datum : new RandomData(schema, COUNT)) {
      //System.out.println("datum="+datum);
      writer.write(datum);
    }
View Full Code Here


    job.set(AvroTrevniOutputFormat.META_PREFIX + "test2", "2");
    job.set("test3", "3");
    job.set(AvroJob.TEXT_PREFIX + "test4", "4");
    job.set(AvroTrevniOutputFormat.META_PREFIX + "test5", "5");
   
    ColumnFileMetaData metadata = AvroTrevniOutputFormat.filterMetadata(job);
   
    assertTrue(metadata.get("test1") != null);
    assertTrue(new String(metadata.get("test1")).equals("1"));
    assertTrue(metadata.get("test2") != null);
    assertTrue(new String(metadata.get("test2")).equals("2"));
    assertTrue(metadata.get("test5") != null);
    assertTrue(new String(metadata.get("test5")).equals("5"));
    assertTrue(metadata.get("test3") == null);
    assertTrue(metadata.get("test4") == null);
   
  }
View Full Code Here

    Schema schema = Schema.parse(new File(dir, "input.avsc"));
    List<Object> data = fromJson(schema, new File(dir, "input.json"));

    // write full data
    AvroColumnWriter<Object> writer =
      new AvroColumnWriter<Object>(schema, new ColumnFileMetaData());
    for (Object datum : data)
      writer.write(datum);
    writer.writeTo(FILE);

    // test that the full schema reads correctly
View Full Code Here

  }

  @Test
    public void testTrevniEvolvedRead() throws IOException {
    AvroColumnWriter<GenericRecord> acw =
      new AvroColumnWriter<GenericRecord>(writer, new ColumnFileMetaData());
    acw.write(writtenRecord);
    File serializedTrevni = File.createTempFile("trevni", null);
    acw.writeTo(serializedTrevni);

    AvroColumnReader.Params params = new Params(serializedTrevni);
View Full Code Here

    super.init();
  }

  private ColumnFileMetaData createFileMeta() {
    return new ColumnFileMetaData()
        .setCodec("null")
        .setChecksum("null");
  }
View Full Code Here

    checkRead(s);
  }

  private void checkWrite(Schema schema) throws IOException {
    AvroColumnWriter<Object> writer =
      new AvroColumnWriter<Object>(schema, new ColumnFileMetaData());
    int count = 0;
    for (Object datum : new RandomData(schema, COUNT)) {
      //System.out.println("datum="+datum);
      writer.write(datum);
    }
View Full Code Here

    boolean isMapOnly = job.getNumReduceTasks() == 0;
    final Schema schema = isMapOnly
      ? AvroJob.getMapOutputSchema(job)
      : AvroJob.getOutputSchema(job);

    final ColumnFileMetaData meta = new ColumnFileMetaData();
    for (Map.Entry<String,String> e : job)
      if (e.getKey().startsWith(META_PREFIX))
        meta.put(e.getKey().substring(AvroJob.TEXT_PREFIX.length()),
                 e.getValue().getBytes(MetaData.UTF8));

    final Path dir = FileOutputFormat.getTaskOutputPath(job, name);
    final FileSystem fs = dir.getFileSystem(job);
    if (!fs.mkdirs(dir))
View Full Code Here

          if (schema == null) {
            throw new IOException("Null output schema");
          }
        }

        final ColumnFileMetaData meta = new ColumnFileMetaData();

        for (Entry<String, String> e : tc.getConfiguration()) {
          if (e.getKey().startsWith(
              org.apache.trevni.avro.AvroTrevniOutputFormat.META_PREFIX)) {
            meta.put(e.getKey().substring(AvroJob.TEXT_PREFIX.length()),
                e.getValue().getBytes(MetaData.UTF8));
          }
        }
       
        final Path dir = getOutputPath(tc);
        final FileSystem fs = FileSystem.get(tc.getConfiguration());
        final long blockSize = fs.getDefaultBlockSize();

        if (!fs.mkdirs(dir)) {
          throw new IOException("Failed to create directory: " + dir);
        }

        meta.setCodec("deflate");

        return new AvroRecordWriter(dir, tc.getConfiguration()) {
          private int part = 0;
          private Schema avroRecordWriterSchema;
          private AvroColumnWriter<GenericData.Record> writer;
View Full Code Here

          if (schema == null) {
            throw new IOException("Null output schema");
          }
        }

        final ColumnFileMetaData meta = new ColumnFileMetaData();

        for (Entry<String, String> e : tc.getConfiguration()) {
          if (e.getKey().startsWith(
              org.apache.trevni.avro.AvroTrevniOutputFormat.META_PREFIX)) {
            meta.put(e.getKey().substring(AvroJob.TEXT_PREFIX.length()),
                e.getValue().getBytes(MetaData.UTF8));
          }
        }
       
        final Path dir = getOutputPath(tc);
        final FileSystem fs = FileSystem.get(tc.getConfiguration());
        final long blockSize = fs.getDefaultBlockSize();

        if (!fs.mkdirs(dir)) {
          throw new IOException("Failed to create directory: " + dir);
        }

        meta.setCodec("deflate");

        return new AvroRecordWriter(dir, tc.getConfiguration()) {
          private int part = 0;
          private Schema avroRecordWriterSchema;
          private AvroColumnWriter<GenericData.Record> writer;
View Full Code Here

  public void setUp() throws IOException {
    avroFile = tmpDir.getFile("test.avro.trevni");
  }

  private void populateGenericFile(List<GenericRecord> genericRecords, Schema schema) throws IOException {
    ColumnFileMetaData cfmd = new ColumnFileMetaData();
    AvroColumnWriter writer = new AvroColumnWriter(schema, cfmd);

    for (GenericRecord record : genericRecords) {
      writer.write(record);
    }
View Full Code Here

TOP

Related Classes of org.apache.trevni.ColumnFileMetaData

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.