org.apache.avro.io.JsonDecoder类的使用及代码示例

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

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

JsonDecoder介绍

[英]A Decoder for Avro's JSON data encoding.

Construct using DecoderFactory.

JsonDecoder is not thread-safe.
[中]用于Avro的JSON数据编码的解码器。
使用DecoderFactory构造。
JsonDecoder不是线程安全的。

代码示例

代码示例来源: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

@Override
public long readArrayStart() throws IOException {
 advance(Symbol.ARRAY_START);
 if (in.getCurrentToken() == JsonToken.START_ARRAY) {
  in.nextToken();
  return doArrayNext();
 } else {
  throw error("array-start");
 }
}

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

@Override
public void readFixed(byte[] bytes, int start, int len) throws IOException {
 checkFixed(len);
 if (in.getCurrentToken() == JsonToken.VALUE_STRING) {
  byte[] result = readByteArray();
  in.nextToken();
  if (result.length != len) {
   throw new AvroTypeException("Expected fixed length " + len
     + ", but got" + result.length);
  }
  System.arraycopy(result, 0, bytes, start, len);
 } else {
  throw error("fixed");
 }
}

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

@Override
public void skipFixed(int length) throws IOException {
 checkFixed(length);
 doSkipFixed(length);
}

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

@Override
public long mapNext() throws IOException {
 advance(Symbol.ITEM_END);
 return doMapNext();
}

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

@Override
public long arrayNext() throws IOException {
 advance(Symbol.ITEM_END);
 return doArrayNext();
}

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

@Override
public ByteBuffer readBytes(ByteBuffer old) throws IOException {
 advance(Symbol.BYTES);
 if (in.getCurrentToken() == JsonToken.VALUE_STRING) {
  byte[] result = readByteArray();
  in.nextToken();
  return ByteBuffer.wrap(result);
 } else {
  throw error("bytes");
 }
}

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

@Override
public long readMapStart() throws IOException {
 advance(Symbol.MAP_START);
 if (in.getCurrentToken() == JsonToken.START_OBJECT) {
  in.nextToken();
  return doMapNext();
 } else {
  throw error("map-start");
 }
}

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

@Override
public void skipBytes() throws IOException {
 advance(Symbol.BYTES);
 if (in.getCurrentToken() == JsonToken.VALUE_STRING) {
  in.nextToken();
 } else {
  throw error("bytes");
 }
}

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

private void doSkipFixed(int length) throws IOException {
 if (in.getCurrentToken() == JsonToken.VALUE_STRING) {
  byte[] result = readByteArray();
  in.nextToken();
  if (result.length != length) {
   throw new AvroTypeException("Expected fixed length " + length
     + ", but got" + result.length);
  }
 } else {
  throw error("fixed");
 }
}

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

@Override
protected void skipFixed() throws IOException {
 advance(Symbol.FIXED);
 Symbol.IntCheckAction top = (Symbol.IntCheckAction) parser.popSymbol();
 doSkipFixed(top.size);
}

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

private JsonDecoder(Symbol root, InputStream in) throws IOException {
 super(root);
 configure(in);
}

代码示例来源: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: apache/avro

private void checkFixed(int size) throws IOException {
 advance(Symbol.FIXED);
 Symbol.IntCheckAction top = (Symbol.IntCheckAction) parser.popSymbol();
 if (size != top.size) {
  throw new AvroTypeException(
   "Incorrect length for fixed binary: expected " +
   top.size + " but received " + size + " bytes.");
 }
}

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

@Override
public ByteBuffer readBytes(ByteBuffer old) throws IOException {
 advance(Symbol.BYTES);
 if (in.getCurrentToken() == JsonToken.VALUE_STRING) {
  byte[] result = readByteArray();
  in.nextToken();
  return ByteBuffer.wrap(result);
 } else {
  throw error("bytes");
 }
}

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

@Override
public long readMapStart() throws IOException {
 advance(Symbol.MAP_START);
 if (in.getCurrentToken() == JsonToken.START_OBJECT) {
  in.nextToken();
  return doMapNext();
 } else {
  throw error("map-start");
 }
}

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

@Override
public boolean readBoolean() throws IOException {
 advance(Symbol.BOOLEAN);
 JsonToken t = in.getCurrentToken();
 if (t == JsonToken.VALUE_TRUE || t == JsonToken.VALUE_FALSE) {
  in.nextToken();
  return t == JsonToken.VALUE_TRUE;
 } else {
  throw error("boolean");
 }
}

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

private void doSkipFixed(int length) throws IOException {
 if (in.getCurrentToken() == JsonToken.VALUE_STRING) {
  byte[] result = readByteArray();
  in.nextToken();
  if (result.length != length) {
   throw new AvroTypeException("Expected fixed length " + length
     + ", but got" + result.length);
  }
 } else {
  throw error("fixed");
 }
}

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

@Override
public void skipFixed(int length) throws IOException {
 checkFixed(length);
 doSkipFixed(length);
}

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

@Override
public long mapNext() throws IOException {
 advance(Symbol.ITEM_END);
 return doMapNext();
}

相关文章