Package org.apache.avro.generic

Examples of org.apache.avro.generic.GenericRecordBuilder.build()


        int level = rand.nextInt(LOG_LEVELS.length);
        builder.set("level", LOG_LEVELS[level]);
        builder.set("message", LOG_MESSAGES[level]);

        writer.write(builder.build());
      }

      writer.flush();
    } finally {
      if (writer != null) {
View Full Code Here


    // access the partition strategy, which produces keys from records
    final PartitionStrategy partitioner = data.getDescriptor()
        .getPartitionStrategy();

    return partitioner.partitionKeyForEntity(builder.build());
  }

  @Override
  public int run(String[] args) throws Exception {
    // open the repository
View Full Code Here

        int level = rand.nextInt(LOG_LEVELS.length);
        builder.set("level", LOG_LEVELS[level]);
        builder.set("message", LOG_MESSAGES[level]);

        writer.write(builder.build());
      }
    } finally {
      writer.flush();
      writer.close();
    }
View Full Code Here

   private byte[] encodeMessage (Schema headerSchema, Schema bodySchema) {
     
      GenericRecord bodyRecord = new GenericData.Record(bodySchema);
      GenericRecordBuilder builder = new GenericRecordBuilder(headerSchema);

      GenericRecord headerRecord = builder.build();
      bodyRecord.put("header", headerRecord)
     
      ByteArrayOutputStream out = new ByteArrayOutputStream();
     
      DatumWriter<GenericRecord> writer = new GenericDatumWriter<GenericRecord>(bodySchema);
View Full Code Here

   public ByteArrayOutputStream getHello(ByteArrayOutputStream out) {
     
      GenericRecord ofpHelloRecord = new GenericData.Record(ofpHelloSchema);
      GenericRecordBuilder builder = new GenericRecordBuilder(helloHeaderSchema);

      GenericRecord ofpHelloHeaderRecord = builder.build();
      ofpHelloRecord.put("header", ofpHelloHeaderRecord)
     
      DatumWriter<GenericRecord> writer = new GenericDatumWriter<GenericRecord>(ofpHelloSchema);
      Encoder encoder = EncoderFactory.get().binaryNonEncoder(out, null);
     
View Full Code Here

   public ByteArrayOutputStream getSwitchFeaturesRequest(ByteArrayOutputStream out) {
     
      GenericRecord ofpSwitchFeaturesRequestRecord = new GenericData.Record(ofpSwitchFeaturesRequestSchema);
      GenericRecordBuilder builder = new GenericRecordBuilder(switchFeaturesRequestHeaderSchema);

      GenericRecord ofpSwitchFeaturesRequestHeaderRecord = builder.build();
      ofpSwitchFeaturesRequestRecord.put("header", ofpSwitchFeaturesRequestHeaderRecord)
     
      DatumWriter<GenericRecord> writer = new GenericDatumWriter<GenericRecord>(ofpSwitchFeaturesRequestSchema);
      Encoder encoder = EncoderFactory.get().binaryNonEncoder(out, null);
     
View Full Code Here

   public ByteArrayOutputStream getSwitchFeaturesReply(ByteArrayOutputStream out) {
     
      GenericRecord ofpSwitchFeaturesReplyRecord = new GenericData.Record(ofpSwitchFeaturesSchema);
      GenericRecordBuilder builder = new GenericRecordBuilder(switchFeaturesHeaderSchema);
     
      GenericRecord ofpSwitchFeaturesReplyHeaderRecord = builder.build();
      ofpSwitchFeaturesReplyRecord.put("header", ofpSwitchFeaturesReplyHeaderRecord)
     
      DatumWriter<GenericRecord> writer = new GenericDatumWriter<GenericRecord>(ofpSwitchFeaturesSchema);
      Encoder encoder = EncoderFactory.get().binaryNonEncoder(out, null);
     
View Full Code Here

   public ByteArrayOutputStream getSetSwitchConfig(ByteArrayOutputStream out) {
     
      GenericRecord ofpSetSwitchConfigRecord = new GenericData.Record(ofpSetSwitchConfigSchema);
     
      GenericRecordBuilder builder = new GenericRecordBuilder(ofpSetSwitchConfigHeaderSchema);
      GenericRecord ofpSetSwitchConfigHeaderRecord = builder.build();
     
      ofpSetSwitchConfigRecord.put("header", ofpSetSwitchConfigHeaderRecord);
     
      byte[] fl = {0,0};
      GenericData.Fixed flags = new GenericData.Fixed(ofpSetSwitchConfigSchema, fl);
View Full Code Here

   public ByteArrayOutputStream getSwitchConfigRequest(ByteArrayOutputStream out) {
     
      GenericRecord ofpGetConfigRequestRecord = new GenericData.Record(ofpGetConfigRequestSchema);
      GenericRecordBuilder builder = new GenericRecordBuilder(getConfigRequestHeaderSchema);
     
      GenericRecord ofpGetConfigRequestHeaderRecord = builder.build();
      ofpGetConfigRequestRecord.put("header", ofpGetConfigRequestHeaderRecord)
     
      DatumWriter<GenericRecord> writer = new GenericDatumWriter<GenericRecord>(ofpGetConfigRequestSchema);
      Encoder encoder = EncoderFactory.get().binaryNonEncoder(out, null);
     
View Full Code Here

   public byte[] encodeSwitchConfigRequest () {
     
      GenericRecord ofpGetConfigRequestRecord = new GenericData.Record(ofpGetConfigRequestSchema);
      GenericRecordBuilder builder = new GenericRecordBuilder(getConfigRequestHeaderSchema);
     
      GenericRecord ofpGetConfigRequestHeaderRecord = builder.build();
      ofpGetConfigRequestRecord.put("header", ofpGetConfigRequestHeaderRecord)
     
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      DatumWriter<GenericRecord> writer = new GenericDatumWriter<GenericRecord>(ofpGetConfigRequestSchema);
      Encoder encoder = EncoderFactory.get().binaryNonEncoder(out, null);
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.