()
| 59 | private static final int scale = 3; |
| 60 | |
| 61 | @BeforeAll |
| 62 | public static void setup() throws IOException { |
| 63 | fs = FileSystem.get(conf); |
| 64 | |
| 65 | LOG.info("Creating file {} with schema {}", filePath, schema); |
| 66 | try (Writer writer = OrcFile.createWriter(filePath, |
| 67 | OrcFile.writerOptions(conf) |
| 68 | .fileSystem(fs) |
| 69 | .overwrite(true) |
| 70 | .rowIndexStride(8192) |
| 71 | .setSchema(schema))) { |
| 72 | Random rnd = new Random(1024); |
| 73 | VectorizedRowBatch b = schema.createRowBatch(); |
| 74 | for (int rowIdx = 0; rowIdx < RowCount; rowIdx++) { |
| 75 | long v = rnd.nextLong(); |
| 76 | for (int colIdx = 0; colIdx < schema.getChildren().size() - 1; colIdx++) { |
| 77 | switch (schema.getChildren().get(colIdx).getCategory()) { |
| 78 | case LONG: |
| 79 | ((LongColumnVector) b.cols[colIdx]).vector[b.size] = v; |
| 80 | break; |
| 81 | case DECIMAL: |
| 82 | HiveDecimalWritable d = new HiveDecimalWritable(); |
| 83 | d.setFromLongAndScale(v, scale); |
| 84 | ((DecimalColumnVector) b.cols[colIdx]).vector[b.size] = d; |
| 85 | break; |
| 86 | case STRING: |
| 87 | ((BytesColumnVector) b.cols[colIdx]).setVal(b.size, |
| 88 | String.valueOf(v) |
| 89 | .getBytes(StandardCharsets.UTF_8)); |
| 90 | break; |
| 91 | default: |
| 92 | throw new IllegalArgumentException(); |
| 93 | } |
| 94 | } |
| 95 | // Populate the rowIdx |
| 96 | ((LongColumnVector) b.cols[4]).vector[b.size] = rowIdx; |
| 97 | |
| 98 | b.size += 1; |
| 99 | if (b.size == b.getMaxSize()) { |
| 100 | writer.addRowBatch(b); |
| 101 | b.reset(); |
| 102 | } |
| 103 | } |
| 104 | if (b.size > 0) { |
| 105 | writer.addRowBatch(b); |
| 106 | b.reset(); |
| 107 | } |
| 108 | } |
| 109 | LOG.info("Created file {}", filePath); |
| 110 | } |
| 111 | |
| 112 | @Test |
| 113 | public void writeIsSuccessful() throws IOException { |
nothing calls this directly
no test coverage detected