Examples of GenericData


Examples of org.apache.avro.generic.GenericData

  @Test public void testUnionWithFixed() {
    Schema s = new Schema.Parser().parse
        ("[\"null\", {\"type\":\"fixed\",\"name\":\"f\",\"size\":1}]");
    Schema f = new Schema.Parser().parse("{\"type\":\"fixed\",\"name\":\"f\",\"size\":1}");
    GenericData data = ReflectData.get();
    assertEquals(1, data.resolveUnion(s, new GenericData.Fixed(f)));
  }
View Full Code Here

Examples of org.apache.avro.generic.GenericData

  @Test public void testUnionWithEnum() {
    Schema s = new Schema.Parser().parse
        ("[\"null\", {\"type\":\"enum\",\"name\":\"E\",\"namespace\":" +
            "\"org.apache.avro.reflect.TestReflect$\",\"symbols\":[\"A\",\"B\"]}]");
    GenericData data = ReflectData.get();
    assertEquals(1, data.resolveUnion(s, E.A));
  }
View Full Code Here

Examples of org.apache.avro.generic.GenericData

    assertEquals(1, data.resolveUnion(s, E.A));
  }

  @Test public void testUnionWithBytes() {
    Schema s = new Schema.Parser().parse ("[\"null\", \"bytes\"]");
    GenericData data = ReflectData.get();
    assertEquals(1, data.resolveUnion(s, ByteBuffer.wrap(new byte[]{1})));
  }
View Full Code Here

Examples of org.apache.avro.generic.GenericData

public class TestAvroKeyRecordWriter {
  @Test
  public void testWrite() throws IOException {
    Schema writerSchema = Schema.create(Schema.Type.INT);
    GenericData dataModel = new ReflectData();
    CodecFactory compressionCodec = CodecFactory.nullCodec();
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    TaskAttemptContext context = createMock(TaskAttemptContext.class);

    replay(context);
View Full Code Here

Examples of org.apache.avro.generic.GenericData

  }
 
  @Test
  public void testSycnableWrite() throws IOException {
    Schema writerSchema = Schema.create(Schema.Type.INT);
    GenericData dataModel = new ReflectData();
    CodecFactory compressionCodec = CodecFactory.nullCodec();
    FileOutputStream outputStream = new FileOutputStream(new File("target/temp.avro"));
    TaskAttemptContext context = createMock(TaskAttemptContext.class);

    replay(context);
View Full Code Here

Examples of org.apache.avro.generic.GenericData

    AvroDatumConverter<K, ?> keyConverter = converterFactory.create(
        (Class<K>) context.getOutputKeyClass());
    AvroDatumConverter<V, ?> valueConverter = converterFactory.create(
        (Class<V>) context.getOutputValueClass());

    GenericData dataModel = AvroSerialization.createDataModel(conf);

    return new AvroKeyValueRecordWriter<K, V>(keyConverter, valueConverter,
        dataModel, getCompressionCodec(context), getAvroFileOutputStream(context),
        getSyncInterval(context));
  }
View Full Code Here

Examples of org.apache.avro.generic.GenericData

    if (null == writerSchema) {
      throw new IOException(
          "AvroKeyOutputFormat requires an output schema. Use AvroJob.setOutputKeySchema().");
    }

    GenericData dataModel = AvroSerialization.createDataModel(conf);

    return mRecordWriterFactory.create
      (writerSchema, dataModel, getCompressionCodec(context),
       getAvroFileOutputStream(context), getSyncInterval(context));
  }
View Full Code Here

Examples of org.apache.avro.generic.GenericData

  }

  @Test public void testUnionWithCollection() {
    Schema s = Schema.parse
      ("[\"null\", {\"type\":\"array\",\"items\":\"float\"}]");
    GenericData data = ReflectData.get();
    assertEquals(1, data.resolveUnion(s, new ArrayList<Float>()));
  }
View Full Code Here

Examples of org.apache.avro.generic.GenericData

  }

  @Test public void testUnionWithMap() {
    Schema s = Schema.parse
      ("[\"null\", {\"type\":\"map\",\"values\":\"float\"}]");
    GenericData data = ReflectData.get();
    assertEquals(1, data.resolveUnion(s, new HashMap<String,Float>()));
  }
View Full Code Here

Examples of org.apache.avro.generic.GenericData

    assertEquals(1, data.resolveUnion(s, new HashMap<String,Float>()));
  }

  @Test public void testUnionWithBytes() {
    Schema s = Schema.parse ("[\"null\", \"bytes\"]");
    GenericData data = ReflectData.get();
    assertEquals(1, data.resolveUnion(s, ByteBuffer.wrap(new byte[]{1})));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.