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

Class TestJsonFileDump

java/tools/src/test/org/apache/orc/tools/TestJsonFileDump.java:45–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43import static org.junit.jupiter.api.Assertions.assertEquals;
44
45public class TestJsonFileDump implements TestConf {
46
47 public static String getFileFromClasspath(String name) {
48 URL url = ClassLoader.getSystemResource(name);
49 if (url == null) {
50 throw new IllegalArgumentException("Could not find " + name);
51 }
52 return url.getPath();
53 }
54
55 Path workDir = new Path(System.getProperty("test.tmp.dir"));
56 FileSystem fs;
57 Path testFilePath;
58
59 @BeforeEach
60 public void openFileSystem () throws Exception {
61 fs = FileSystem.getLocal(conf);
62 testFilePath = new Path(workDir + File.separator + "TestFileDump.testDump.orc");
63 fs.delete(testFilePath, false);
64 }
65
66 @Test
67 public void testJsonDump() throws Exception {
68 TypeDescription schema =
69 TypeDescription.fromString("struct<i:int,l:bigint,s:string>");
70 schema.findSubtype("l")
71 .setAttribute("test1", "value1")
72 .setAttribute("test2","value2");
73 conf.set(OrcConf.ENCODING_STRATEGY.getAttribute(), "COMPRESSION");
74 conf.set(OrcConf.DICTIONARY_IMPL.getAttribute(), "rbtree");
75 OrcFile.WriterOptions options = OrcFile.writerOptions(conf)
76 .fileSystem(fs)
77 .setSchema(schema)
78 .stripeSize(100000)
79 .compress(CompressionKind.ZLIB)
80 .bufferSize(10000)
81 .rowIndexStride(1000)
82 .bloomFilterColumns("s");
83 Writer writer = OrcFile.createWriter(testFilePath, options);
84 Random r1 = new Random(1);
85 String[] words = new String[]{"It", "was", "the", "best", "of", "times,",
86 "it", "was", "the", "worst", "of", "times,", "it", "was", "the", "age",
87 "of", "wisdom,", "it", "was", "the", "age", "of", "foolishness,", "it",
88 "was", "the", "epoch", "of", "belief,", "it", "was", "the", "epoch",
89 "of", "incredulity,", "it", "was", "the", "season", "of", "Light,",
90 "it", "was", "the", "season", "of", "Darkness,", "it", "was", "the",
91 "spring", "of", "hope,", "it", "was", "the", "winter", "of", "despair,",
92 "we", "had", "everything", "before", "us,", "we", "had", "nothing",
93 "before", "us,", "we", "were", "all", "going", "direct", "to",
94 "Heaven,", "we", "were", "all", "going", "direct", "the", "other",
95 "way"};
96 VectorizedRowBatch batch = schema.createRowBatch(1000);
97 for(int i=0; i < 21000; ++i) {
98 ((LongColumnVector) batch.cols[0]).vector[batch.size] = r1.nextInt();
99 ((LongColumnVector) batch.cols[1]).vector[batch.size] = r1.nextLong();
100 if (i % 100 == 0) {
101 batch.cols[2].noNulls = false;
102 batch.cols[2].isNull[batch.size] = true;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected