MCPcopy Index your code
hub / github.com/apache/orc / TestCheckTool

Class TestCheckTool

java/tools/src/test/org/apache/orc/tools/TestCheckTool.java:42–210  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40import static org.junit.jupiter.api.Assertions.assertTrue;
41
42public class TestCheckTool implements TestConf {
43 private Path workDir = new Path(System.getProperty("test.tmp.dir"));
44 private FileSystem fs;
45 private Path testFilePath;
46
47 @BeforeEach
48 public void openFileSystem() throws Exception {
49 fs = FileSystem.getLocal(conf);
50 testFilePath = new Path(workDir + File.separator + "TestCheckTool.testCheckTool.orc");
51 fs.delete(testFilePath, false);
52 createFile();
53 }
54
55 private void createFile() throws IOException {
56 TypeDescription schema = TypeDescription.fromString("struct<x:int,y:string,z:string>");
57 Writer writer = OrcFile.createWriter(testFilePath,
58 OrcFile.writerOptions(conf)
59 .bloomFilterColumns("x,y")
60 .rowIndexStride(5000)
61 .setSchema(schema));
62 VectorizedRowBatch batch = schema.createRowBatch();
63 LongColumnVector x = (LongColumnVector) batch.cols[0];
64 BytesColumnVector y = (BytesColumnVector) batch.cols[1];
65 BytesColumnVector z = (BytesColumnVector) batch.cols[2];
66 for (int r = 0; r < 10000; ++r) {
67 int row = batch.size++;
68 x.vector[row] = r;
69 byte[] yBuffer = ("y-byte-" + r).getBytes();
70 byte[] zBuffer = ("z-byte-" + r).getBytes();
71 y.setRef(row, yBuffer, 0, yBuffer.length);
72 z.setRef(row, zBuffer, 0, zBuffer.length);
73 if (batch.size == batch.getMaxSize()) {
74 writer.addRowBatch(batch);
75 batch.reset();
76 }
77 }
78 if (batch.size != 0) {
79 writer.addRowBatch(batch);
80 }
81 writer.close();
82 }
83
84 @Test
85 public void testPredicate() throws Exception {
86 PrintStream origOut = System.out;
87 ByteArrayOutputStream myOut = new ByteArrayOutputStream();
88 System.setOut(new PrintStream(myOut, false, StandardCharsets.UTF_8));
89
90 CheckTool.main(conf, new String[]{
91 "--type", "predicate",
92 "--values", "0", "--values", "5566",
93 "--column", "x",
94 testFilePath.toString()});
95
96 CheckTool.main(conf, new String[]{
97 "--type", "predicate",
98 "--values", "y-byte-1234", "--values", "y-byte-5566",
99 "--column", "y",

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected