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

Class TestRLEv2

java/tools/src/test/org/apache/orc/impl/TestRLEv2.java:54–433  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52import static org.junit.jupiter.api.Assertions.assertTrue;
53
54public class TestRLEv2 implements TestConf {
55 Path workDir = new Path(System.getProperty("test.tmp.dir",
56 "target" + File.separator + "test" + File.separator + "tmp"));
57 Path testFilePath;
58 FileSystem fs;
59
60 @BeforeEach
61 public void openFileSystem (TestInfo testInfo) throws Exception {
62 fs = FileSystem.getLocal(conf);
63 testFilePath = new Path(workDir, "TestRLEv2." +
64 testInfo.getTestMethod().get().getName() + ".orc");
65 fs.delete(testFilePath, false);
66 }
67
68 private void appendInt(VectorizedRowBatch batch, long i) {
69 ((LongColumnVector) batch.cols[0]).vector[batch.size++] = i;
70 }
71
72 @Test
73 public void testFixedDeltaZero() throws Exception {
74 TypeDescription schema = TypeDescription.createInt();
75 Writer w = OrcFile.createWriter(testFilePath,
76 OrcFile.writerOptions(conf)
77 .compress(CompressionKind.NONE)
78 .setSchema(schema)
79 .rowIndexStride(0)
80 .encodingStrategy(OrcFile.EncodingStrategy.COMPRESSION)
81 .version(OrcFile.Version.V_0_12)
82 );
83 VectorizedRowBatch batch = schema.createRowBatch(5120);
84 for (int i = 0; i < 5120; ++i) {
85 appendInt(batch, 123);
86 }
87 w.addRowBatch(batch);
88 w.close();
89
90 PrintStream origOut = System.out;
91 ByteArrayOutputStream myOut = new ByteArrayOutputStream();
92 System.setOut(new PrintStream(myOut, false, StandardCharsets.UTF_8.toString()));
93 FileDump.main(new String[]{testFilePath.toUri().toString()});
94 System.out.flush();
95 String outDump = new String(myOut.toByteArray(), StandardCharsets.UTF_8);
96 // 10 runs of 512 elements. Each run has 2 bytes header, 2 bytes base (base = 123,
97 // zigzag encoded varint) and 1 byte delta (delta = 0). In total, 5 bytes per run.
98 assertTrue(outDump.contains("Stream: column 0 section DATA start: 3 length 50"));
99 System.setOut(origOut);
100 }
101
102 @Test
103 public void testFixedDeltaOne() throws Exception {
104 TypeDescription schema = TypeDescription.createInt();
105 Writer w = OrcFile.createWriter(testFilePath,
106 OrcFile.writerOptions(conf)
107 .compress(CompressionKind.NONE)
108 .setSchema(schema)
109 .rowIndexStride(0)
110 .encodingStrategy(OrcFile.EncodingStrategy.COMPRESSION)
111 .version(OrcFile.Version.V_0_12)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected