Examples of GenericData


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

Examples of org.apache.avro.generic.GenericData

    Configuration conf = getConf();
    boolean isKey = AvroKey.class.isAssignableFrom(c);
    Schema schema = isKey
      ? Pair.getKeySchema(AvroJob.getMapOutputSchema(conf))
      : Pair.getValueSchema(AvroJob.getMapOutputSchema(conf));
    GenericData dataModel = AvroJob.createMapOutputDataModel(conf);
    DatumReader<T> datumReader = dataModel.createDatumReader(schema);
    return new AvroWrapperDeserializer(datumReader, isKey);
  }
View Full Code Here

Examples of org.apache.avro.generic.GenericData

    SeekableInput seekableFileInput
        = createSeekableInput(context.getConfiguration(), fileSplit.getPath());

    // Wrap the seekable input stream in an Avro DataFileReader.
    Configuration conf = context.getConfiguration();
    GenericData dataModel = AvroSerialization.createDataModel(conf);
    DatumReader<T> datumReader = dataModel.createDatumReader(mReaderSchema);
    mAvroFileReader = createAvroFileReader(seekableFileInput, datumReader);

    // Initialize the start and end offsets into the file based on the boundaries of the
    // input split we're responsible for.  We will read the first block that begins
    // after the input split start boundary.  We will read up to but not including the
View Full Code Here

Examples of org.apache.avro.generic.GenericData

    Schema schema = isFinalOutput
      ? AvroJob.getOutputSchema(conf)
      : (AvroKey.class.isAssignableFrom(c)
         ? Pair.getKeySchema(AvroJob.getMapOutputSchema(conf))
         : Pair.getValueSchema(AvroJob.getMapOutputSchema(conf)));
    GenericData dataModel = AvroJob.createDataModel(conf);
    return new AvroWrapperSerializer(dataModel.createDatumWriter(schema));
  }
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));
  }
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));
  }
View Full Code Here

Examples of org.apache.avro.generic.GenericData

    return (Class<? extends GenericData>) conf.getClass(
        CONF_DATA_MODEL, ReflectData.class, GenericData.class);
  }

  private static GenericData newDataModelInstance(Class<? extends GenericData> modelClass, Configuration conf) {
    GenericData dataModel;
    try {
      Constructor<? extends GenericData> ctor = modelClass.getDeclaredConstructor(ClassLoader.class);
      ctor.setAccessible(true);
      dataModel = ctor.newInstance(conf.getClassLoader());
    } catch (Exception e) {
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.