MCPcopy Create free account
hub / github.com/apache/orc / main

Method main

java/examples/src/java/org/apache/orc/examples/CoreWriter.java:34–57  ·  view source on GitHub ↗
(Configuration conf, String[] args)

Source from the content-addressed store, hash-verified

32
33public class CoreWriter {
34 public static void main(Configuration conf, String[] args) throws IOException {
35 TypeDescription schema = TypeDescription.fromString("struct<x:int,y:string>");
36 Writer writer = OrcFile.createWriter(new Path("my-file.orc"),
37 OrcFile.writerOptions(conf)
38 .setSchema(schema));
39 VectorizedRowBatch batch = schema.createRowBatch();
40 LongColumnVector x = (LongColumnVector) batch.cols[0];
41 BytesColumnVector y = (BytesColumnVector) batch.cols[1];
42 for(int r=0; r < 10000; ++r) {
43 int row = batch.size++;
44 x.vector[row] = r;
45 byte[] buffer = ("Last-" + (r * 3)).getBytes(StandardCharsets.UTF_8);
46 y.setRef(row, buffer, 0, buffer.length);
47 // If the batch is full, write it out and start over.
48 if (batch.size == batch.getMaxSize()) {
49 writer.addRowBatch(batch);
50 batch.reset();
51 }
52 }
53 if (batch.size != 0) {
54 writer.addRowBatch(batch);
55 }
56 writer.close();
57 }
58
59 public static void main(String[] args) throws IOException {
60 main(new Configuration(), args);

Callers 1

mainMethod · 0.95

Calls 9

fromStringMethod · 0.95
createWriterMethod · 0.95
writerOptionsMethod · 0.95
createRowBatchMethod · 0.95
addRowBatchMethod · 0.95
closeMethod · 0.95
setSchemaMethod · 0.80
getBytesMethod · 0.80
resetMethod · 0.65

Tested by

no test coverage detected