org.apache.avro.io.JsonDecoder.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(105)

本文整理了Java中org.apache.avro.io.JsonDecoder.<init>()方法的一些代码示例,展示了JsonDecoder.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonDecoder.<init>()方法的具体详情如下:
包路径:org.apache.avro.io.JsonDecoder
类名称:JsonDecoder
方法名:<init>

JsonDecoder.<init>介绍

[英]Creates a new JsonDecoder based on an InputStream.
[中]基于InputStream创建新的JsonDecoder。

代码示例

代码示例来源:origin: org.apache.avro/avro

/**
 * Creates a {@link JsonDecoder} using the InputStrim provided for reading
 * data that conforms to the Schema provided.
 * <p/>
 *
 * @param schema
 *          The Schema for data read from this JsonEncoder. Cannot be null.
 * @param input
 *          The InputStream to read from. Cannot be null.
 * @return A JsonEncoder configured with <i>input</i> and <i>schema</i>
 * @throws IOException
 */
public JsonDecoder jsonDecoder(Schema schema, InputStream input)
  throws IOException {
 return new JsonDecoder(schema, input);
}

代码示例来源:origin: apache/avro

/**
 * Creates a {@link JsonDecoder} using the InputStrim provided for reading
 * data that conforms to the Schema provided.
 * <p/>
 *
 * @param schema
 *          The Schema for data read from this JsonEncoder. Cannot be null.
 * @param input
 *          The InputStream to read from. Cannot be null.
 * @return A JsonEncoder configured with <i>input</i> and <i>schema</i>
 * @throws IOException
 */
public JsonDecoder jsonDecoder(Schema schema, InputStream input)
  throws IOException {
 return new JsonDecoder(schema, input);
}

代码示例来源:origin: apache/avro

/**
 * Creates a {@link JsonDecoder} using the String provided for reading data
 * that conforms to the Schema provided.
 * <p/>
 *
 * @param schema
 *          The Schema for data read from this JsonEncoder. Cannot be null.
 * @param input
 *          The String to read from. Cannot be null.
 * @return A JsonEncoder configured with <i>input</i> and <i>schema</i>
 * @throws IOException
 */
public JsonDecoder jsonDecoder(Schema schema, String input)
  throws IOException {
 return new JsonDecoder(schema, input);
}

代码示例来源:origin: org.apache.avro/avro

/**
 * Creates a {@link JsonDecoder} using the String provided for reading data
 * that conforms to the Schema provided.
 * <p/>
 *
 * @param schema
 *          The Schema for data read from this JsonEncoder. Cannot be null.
 * @param input
 *          The String to read from. Cannot be null.
 * @return A JsonEncoder configured with <i>input</i> and <i>schema</i>
 * @throws IOException
 */
public JsonDecoder jsonDecoder(Schema schema, String input)
  throws IOException {
 return new JsonDecoder(schema, input);
}

代码示例来源:origin: voldemort/voldemort

/**
 * Parses a string that contains single fat client config string in avro
 * format
 * 
 * @param configAvro Input string of avro format, that contains config for
 *        multiple stores
 * @return Properties of single fat client config
 */
@SuppressWarnings("unchecked")
public static Properties readSingleClientConfigAvro(String configAvro) {
  Properties props = new Properties();
  try {
    JsonDecoder decoder = new JsonDecoder(CLIENT_CONFIG_AVRO_SCHEMA, configAvro);
    GenericDatumReader<Object> datumReader = new GenericDatumReader<Object>(CLIENT_CONFIG_AVRO_SCHEMA);
    Map<Utf8, Utf8> flowMap = (Map<Utf8, Utf8>) datumReader.read(null, decoder);
    for(Utf8 key: flowMap.keySet()) {
      props.put(key.toString(), flowMap.get(key).toString());
    }
  } catch(Exception e) {
    e.printStackTrace();
  }
  return props;
}

代码示例来源:origin: voldemort/voldemort

Map<String, Properties> mapStoreToProps = Maps.newHashMap();
try {
  JsonDecoder decoder = new JsonDecoder(CLIENT_CONFIGS_AVRO_SCHEMA, configAvro);
  GenericDatumReader<Object> datumReader = new GenericDatumReader<Object>(CLIENT_CONFIGS_AVRO_SCHEMA);

代码示例来源:origin: voldemort/voldemort

line = reader.readLine();
JsonDecoder decoder = new JsonDecoder(keySchema, line);
GenericDatumReader<Object> datumReader = null;
Object key = null;
valueString = line;
JsonDecoder keyDecoder = new JsonDecoder(keySchema, keyString);
JsonDecoder valueDecoder = new JsonDecoder(valueSchema, valueString);

代码示例来源:origin: voldemort/voldemort

JsonDecoder decoder = new JsonDecoder(latestSchema, avroString);
GenericDatumReader<Object> datumReader = new GenericDatumReader<Object>(latestSchema);
obj = datumReader.read(null, decoder);

代码示例来源:origin: voldemort/voldemort

if(isAvroSchema(keySerializerName)) {
  Schema keySchema = Schema.parse(keySerializerDef.getCurrentSchemaInfo());
  JsonDecoder decoder = new JsonDecoder(keySchema, keyString);
  GenericDatumReader<Object> datumReader = new GenericDatumReader<Object>(keySchema);
  keyObject = datumReader.read(null, decoder);

代码示例来源:origin: apache/avro

private static void check(Schema sc, byte[] bytes, String calls,
  Object[] values, final int skipLevel, Encoding encoding)
 throws IOException {
 // dump(bytes);
 // System.out.println(new String(bytes, "UTF-8"));
 Decoder bvi = null;
 switch (encoding) {
 case BINARY:
 case BLOCKING_BINARY:
  bvi = DecoderFactory.get().binaryDecoder(bytes, null);
  break;
 case JSON:
  InputStream in = new ByteArrayInputStream(bytes);
  bvi = new JsonDecoder(sc, in);
 }
 Decoder vi = new ValidatingDecoder(sc, bvi);
 check(vi, calls, values, skipLevel);
}

代码示例来源:origin: voldemort/voldemort

if(isAvroSchema(keySerializerName)) {
  Schema keySchema = Schema.parse(keySerializerDef.getCurrentSchemaInfo());
  JsonDecoder decoder = new JsonDecoder(keySchema, keyString);
  GenericDatumReader<Object> datumReader = new GenericDatumReader<Object>(keySchema);
  keyObject = datumReader.read(null, decoder);

代码示例来源:origin: apache/avro

static void check(Schema wsc, Schema rsc, byte[] bytes,
  String calls, Object[] values, Encoding encoding,
  int skipLevel)
  throws IOException {
 // TestValidatingIO.dump(bytes);
 // System.out.println(new String(bytes, "UTF-8"));
 Decoder bvi = null;
 switch (encoding) {
 case BINARY:
 case BLOCKING_BINARY:
  bvi = DecoderFactory.get().binaryDecoder(bytes, null);
  break;
 case JSON:
  InputStream in = new ByteArrayInputStream(bytes);
  bvi = new JsonDecoder(wsc, in);
  break;
 }
 Decoder vi = new ResolvingDecoder(wsc, rsc, bvi);
 TestValidatingIO.check(vi, calls, values, skipLevel);
}

代码示例来源:origin: stackoverflow.com

byte[] bytes = encoder.toBytes(map);
    KeyedMessage<String, byte[]> message =new KeyedMessage<String, byte[]>(this.topic, bytes);

JsonDecoder decoder = new JsonDecoder(null);
Map map = (Map) decoder.fromBytes(it.next().message());

代码示例来源:origin: com.linkedin.pegasus/data-avro

@Override
public Decoder createJsonDecoder(Schema schema, String json) throws IOException
{
 Decoder jsonDecoder = new JsonDecoder(schema, json);
 return jsonDecoder;
}

代码示例来源:origin: com.facebook.presto.hive/hive-apache

/**
 * Creates a {@link JsonDecoder} using the String provided for reading data
 * that conforms to the Schema provided.
 * <p/>
 * 
 * @param schema
 *          The Schema for data read from this JsonEncoder. Cannot be null.
 * @param input
 *          The String to read from. Cannot be null.
 * @return A JsonEncoder configured with <i>input</i> and <i>schema</i>
 * @throws IOException
 */
public JsonDecoder jsonDecoder(Schema schema, String input)
  throws IOException {
 return new JsonDecoder(schema, input);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.avro

/**
 * Creates a {@link JsonDecoder} using the InputStrim provided for reading
 * data that conforms to the Schema provided.
 * <p/>
 *
 * @param schema
 *          The Schema for data read from this JsonEncoder. Cannot be null.
 * @param input
 *          The InputStream to read from. Cannot be null.
 * @return A JsonEncoder configured with <i>input</i> and <i>schema</i>
 * @throws IOException
 */
public JsonDecoder jsonDecoder(Schema schema, InputStream input)
  throws IOException {
 return new JsonDecoder(schema, input);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.avro

/**
 * Creates a {@link JsonDecoder} using the String provided for reading data
 * that conforms to the Schema provided.
 * <p/>
 *
 * @param schema
 *          The Schema for data read from this JsonEncoder. Cannot be null.
 * @param input
 *          The String to read from. Cannot be null.
 * @return A JsonEncoder configured with <i>input</i> and <i>schema</i>
 * @throws IOException
 */
public JsonDecoder jsonDecoder(Schema schema, String input)
  throws IOException {
 return new JsonDecoder(schema, input);
}

代码示例来源:origin: org.apache.cassandra.deps/avro

/** 
 * Converts a String JSON object into a generic datum.
 * 
 * This is inefficient (creates extra objects), so should be used 
 * sparingly.
 */
static Object jsonToGenericDatum(Schema schema, String jsonData) throws IOException {
 GenericDatumReader<Object> reader = 
  new GenericDatumReader<Object>(schema);
 Object datum = reader.read(null, new JsonDecoder(schema, jsonData));
 return datum;
}

代码示例来源:origin: org.apache.hadoop/avro

/** 
 * Converts a String JSON object into a generic datum.
 * 
 * This is inefficient (creates extra objects), so should be used 
 * sparingly.
 */
static Object jsonToGenericDatum(Schema schema, String jsonData) throws IOException {
 GenericDatumReader<Object> reader = 
  new GenericDatumReader<Object>(schema);
 Object datum = reader.read(null, new JsonDecoder(schema, jsonData));
 return datum;
}

代码示例来源:origin: stackoverflow.com

private static GenericData.Record parseJson(String json, String schema)
  throws IOException {
 Schema parsedSchema = Schema.parse(schema);
 Decoder decoder = new JsonDecoder(parsedSchema, json);

 DatumReader<GenericData.Record> reader =
   new GenericDatumReader<>(parsedSchema);
 return reader.read(null, decoder);
}

相关文章