当前位置: 首页>>代码示例>>Java>>正文


Java GenericContainer.getSchema方法代码示例

本文整理汇总了Java中org.apache.avro.generic.GenericContainer.getSchema方法的典型用法代码示例。如果您正苦于以下问题:Java GenericContainer.getSchema方法的具体用法?Java GenericContainer.getSchema怎么用?Java GenericContainer.getSchema使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.avro.generic.GenericContainer的用法示例。


在下文中一共展示了GenericContainer.getSchema方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: decodeFromTransport

import org.apache.avro.generic.GenericContainer; //导入方法依赖的package包/类
/**
 * Decode the message from the transport.
 * 
 * @param input The FinancialForce Orizuru Avro Transport message from which to decode the message.
 * @throws OrizuruConsumerException Exception thrown if decoding the message fails.
 */
public void decodeFromTransport(Transport input) throws OrizuruConsumerException {

	try {

		String messageSchemaName = input.getMessageSchemaName().toString();

		Class<?> avroClass = Class.forName(messageSchemaName);
		Constructor<?> constructor = avroClass.getConstructor();
		GenericContainer container = (GenericContainer) constructor.newInstance();
		this.schema = container.getSchema();

		ByteBuffer messageBuffer = input.getMessageBuffer();
		this.data = messageBuffer.array();

	} catch (Exception ex) {
		throw new DecodeMessageException(ex);
	}

}
 
开发者ID:financialforcedev,项目名称:orizuru-java,代码行数:26,代码来源:Message.java

示例2: objectToByteBuffer

import org.apache.avro.generic.GenericContainer; //导入方法依赖的package包/类
@Override
public byte[] objectToByteBuffer(Object o) throws IOException{
   ByteArrayOutputStream baos = new ByteArrayOutputStream();
   ObjectOutputStream oos = new ObjectOutputStream(baos);
   if (o instanceof GenericContainer) {
      oos.write(RECORD);
      GenericContainer container = (GenericContainer) o;
      oos.writeObject((container.getSchema().getFullName()));
      DatumWriter<GenericContainer> datumWriter = new GenericDatumWriter<>(container.getSchema());
      BinaryEncoder encoder = EncoderFactory.get().directBinaryEncoder(baos, null);
      datumWriter.write(container,encoder);
      encoder.flush();
   } else if (o instanceof Schema) {
      oos.write(SCHEMA);
      oos.writeObject(o.toString());
   } else {
      oos.write(OTHER);
      oos.writeObject(o);
   }
   return baos.toByteArray();
}
 
开发者ID:leads-project,项目名称:infinispan-avro,代码行数:22,代码来源:AbstractMarshaller.java

示例3: serialize

import org.apache.avro.generic.GenericContainer; //导入方法依赖的package包/类
/**
 * Serializes the record as an in-memory representation of a standard Avro file.
 *
 * <p>That is, the returned bytes include a standard Avro header that contains a magic byte, the
 * record's Avro schema (and so on), followed by the byte representation of the record.
 *
 * <p>Implementation detail:  This method uses Avro's {@code DataFileWriter}.
 *
 * @return Avro-encoded record (bytes) that includes the Avro schema
 */
public byte[] serialize(GenericContainer record) throws IOException {
  if (record != null) {
    DatumWriter<GenericContainer> datumWriter = new GenericDatumWriter<>(record.getSchema());
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    DataFileWriter<GenericContainer> writer = new DataFileWriter<>(datumWriter);
    writer.create(record.getSchema(), out);
    writer.append(record);
    writer.close();
    out.close();
    return out.toByteArray();
  } else {
    return null;
  }
}
 
开发者ID:confluentinc,项目名称:support-metrics-client,代码行数:25,代码来源:AvroSerializer.java

示例4: from

import org.apache.avro.generic.GenericContainer; //导入方法依赖的package包/类
@Override
public org.infinispan.query.dsl.QueryBuilder from(Class entityType) {
   if (!GenericContainer.class.isAssignableFrom(entityType))
      throw new CacheException();
   try {
      GenericContainer container = (GenericContainer) entityType.newInstance();
      Schema schema = container.getSchema();
      return new QueryBuilder(cache,this,schema);
   } catch (InstantiationException | IllegalAccessException e) {
      e.printStackTrace();
   }
   throw new CacheException();
}
 
开发者ID:leads-project,项目名称:infinispan-avro,代码行数:14,代码来源:QueryFactory.java

示例5: getSchema

import org.apache.avro.generic.GenericContainer; //导入方法依赖的package包/类
private Schema getSchema(GenericContainer datum, Schema lastSchema) {
  Schema schema = datum.getSchema();
  if (lastSchema != null && lastSchema != schema) {
    throw new MorphlineRuntimeException("Schemas must be identical: " + schema + ", lastSchema: " + lastSchema);
  }
  return schema;
}
 
开发者ID:cloudera,项目名称:cdk,代码行数:8,代码来源:WriteAvroToByteArrayBuilder.java

示例6: write

import org.apache.avro.generic.GenericContainer; //导入方法依赖的package包/类
public void write(Kryo kryo, Output output, GenericContainer record) {

        String fingerPrint = this.getFingerprint(record.getSchema());
        output.writeString(fingerPrint);
        GenericDatumWriter<GenericContainer> writer = new GenericDatumWriter<>(record.getSchema());

        BinaryEncoder encoder = EncoderFactory
                .get()
                .directBinaryEncoder(output, null);
        try {
            writer.write(record, encoder);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
 
开发者ID:alibaba,项目名称:jstorm,代码行数:16,代码来源:AbstractAvroSerializer.java


注:本文中的org.apache.avro.generic.GenericContainer.getSchema方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。