本文整理了Java中org.apache.avro.io.Encoder.init()
方法的一些代码示例,展示了Encoder.init()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Encoder.init()
方法的具体详情如下:
包路径:org.apache.avro.io.Encoder
类名称:Encoder
方法名:init
[英]Redirect output (and reset the parser state if we're checking).
[中]重定向输出(如果我们正在检查,则重置解析器状态)。
代码示例来源:origin: org.apache.cassandra.deps/avro
@Override
public void init(OutputStream out) throws IOException {
flush();
parser.reset();
this.out.init(out);
}
代码示例来源:origin: org.apache.hadoop/avro
@Override
public void init(OutputStream out) throws IOException {
flush();
parser.reset();
this.out.init(out);
}
代码示例来源:origin: org.apache.hadoop/avro
@Override
public int run(InputStream stdin, PrintStream out, PrintStream err,
List<String> args) throws Exception {
if (args.size() != 1) {
// Unlike other commands, "-" can't be used for stdin, because
// we can only use seekable files.
err.println("Expected 1 argument: input_file.");
return 1;
}
GenericDatumReader<Object> reader = new GenericDatumReader<Object>();
DataFileReader<Object> fileReader =
new DataFileReader<Object>(new File(args.get(0)), reader);
try {
Schema schema = fileReader.getSchema();
DatumWriter<Object> writer = new GenericDatumWriter<Object>(schema);
Encoder encoder = new JsonEncoder(schema, (JsonGenerator)null);
for (Object datum : fileReader) {
// init() recreates the internal Jackson JsonGenerator
encoder.init(out);
writer.write(datum, encoder);
encoder.flush();
out.println();
}
out.flush();
} finally {
fileReader.close();
}
return 0;
}
代码示例来源:origin: org.apache.cassandra.deps/avro
@Override
public int run(InputStream stdin, PrintStream out, PrintStream err,
List<String> args) throws Exception {
if (args.size() != 1) {
// Unlike other commands, "-" can't be used for stdin, because
// we can only use seekable files.
err.println("Expected 1 argument: input_file.");
return 1;
}
GenericDatumReader<Object> reader = new GenericDatumReader<Object>();
DataFileReader<Object> fileReader =
new DataFileReader<Object>(new File(args.get(0)), reader);
try {
Schema schema = fileReader.getSchema();
DatumWriter<Object> writer = new GenericDatumWriter<Object>(schema);
Encoder encoder = new JsonEncoder(schema, (JsonGenerator)null);
for (Object datum : fileReader) {
// init() recreates the internal Jackson JsonGenerator
encoder.init(out);
writer.write(datum, encoder);
encoder.flush();
out.println();
}
out.flush();
} finally {
fileReader.close();
}
return 0;
}
内容来源于网络,如有侵权,请联系作者删除!