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

Method main

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

Source from the content-addressed store, hash-verified

32
33public class CoreReader {
34 public static void main(Configuration conf, String[] args) throws IOException {
35 // Get the information from the file footer
36 Reader reader = OrcFile.createReader(new Path("my-file.orc"),
37 OrcFile.readerOptions(conf));
38 System.out.println("File schema: " + reader.getSchema());
39 System.out.println("Row count: " + reader.getNumberOfRows());
40
41 // Pick the schema we want to read using schema evolution
42 TypeDescription readSchema =
43 TypeDescription.fromString("struct<z:int,y:string,x:bigint>");
44 // Read the row data
45 VectorizedRowBatch batch = readSchema.createRowBatch();
46 RecordReader rowIterator = reader.rows(reader.options()
47 .schema(readSchema));
48 LongColumnVector z = (LongColumnVector) batch.cols[0];
49 BytesColumnVector y = (BytesColumnVector) batch.cols[1];
50 LongColumnVector x = (LongColumnVector) batch.cols[2];
51 while (rowIterator.nextBatch(batch)) {
52 for(int row=0; row < batch.size; ++row) {
53 int zRow = z.isRepeating ? 0: row;
54 int xRow = x.isRepeating ? 0: row;
55 System.out.println("z: " +
56 (z.noNulls || !z.isNull[zRow] ? z.vector[zRow] : null));
57 System.out.println("y: " + y.toString(row));
58 System.out.println("x: " +
59 (x.noNulls || !x.isNull[xRow] ? x.vector[xRow] : null));
60 }
61 }
62 rowIterator.close();
63 reader.close();
64 }
65
66 public static void main(String[] args) throws IOException {
67 main(new Configuration(), args);

Callers 1

mainMethod · 0.95

Calls 13

createReaderMethod · 0.95
readerOptionsMethod · 0.95
getSchemaMethod · 0.95
getNumberOfRowsMethod · 0.95
fromStringMethod · 0.95
createRowBatchMethod · 0.95
rowsMethod · 0.95
optionsMethod · 0.95
nextBatchMethod · 0.95
closeMethod · 0.95
schemaMethod · 0.80
closeMethod · 0.65

Tested by

no test coverage detected