(FileSystem fs,
Path path,
OrcFile.WriterOptions opts)
| 146 | private boolean isClose = false; |
| 147 | |
| 148 | public WriterImpl(FileSystem fs, |
| 149 | Path path, |
| 150 | OrcFile.WriterOptions opts) throws IOException { |
| 151 | this.path = path; |
| 152 | this.conf = opts.getConfiguration(); |
| 153 | // clone it so that we can annotate it with encryption |
| 154 | this.schema = opts.getSchema().clone(); |
| 155 | int numColumns = schema.getMaximumId() + 1; |
| 156 | if (!opts.isEnforceBufferSize()) { |
| 157 | opts.bufferSize(getEstimatedBufferSize(opts.getStripeSize(), numColumns, |
| 158 | opts.getBufferSize())); |
| 159 | } |
| 160 | |
| 161 | // Annotate the schema with the column encryption |
| 162 | schema.annotateEncryption(opts.getEncryption(), opts.getMasks()); |
| 163 | columnEncryption = new WriterEncryptionVariant[numColumns]; |
| 164 | columnMaskDescriptions = new MaskDescriptionImpl[numColumns]; |
| 165 | encryption = setupEncryption(opts.getKeyProvider(), schema, |
| 166 | opts.getKeyOverrides()); |
| 167 | needKeyFlush = encryption.length > 0; |
| 168 | |
| 169 | this.directEncodingColumns = OrcUtils.includeColumns( |
| 170 | opts.getDirectEncodingColumns(), opts.getSchema()); |
| 171 | dictionaryKeySizeThreshold = |
| 172 | OrcConf.DICTIONARY_KEY_SIZE_THRESHOLD.getDouble(conf); |
| 173 | |
| 174 | this.callback = opts.getCallback(); |
| 175 | if (callback != null) { |
| 176 | callbackContext = () -> WriterImpl.this; |
| 177 | } else { |
| 178 | callbackContext = null; |
| 179 | } |
| 180 | |
| 181 | this.useProlepticGregorian = opts.getProlepticGregorian(); |
| 182 | this.writeTimeZone = hasTimestamp(schema); |
| 183 | this.useUTCTimeZone = opts.getUseUTCTimestamp(); |
| 184 | |
| 185 | this.encodingStrategy = opts.getEncodingStrategy(); |
| 186 | this.compressionStrategy = opts.getCompressionStrategy(); |
| 187 | |
| 188 | // ORC-1362: if isBuildIndex=false, then rowIndexStride will be set to 0. |
| 189 | if (opts.getRowIndexStride() >= 0 && opts.isBuildIndex()) { |
| 190 | this.rowIndexStride = opts.getRowIndexStride(); |
| 191 | } else { |
| 192 | this.rowIndexStride = 0; |
| 193 | } |
| 194 | |
| 195 | this.buildIndex = rowIndexStride > 0; |
| 196 | |
| 197 | if (buildIndex && rowIndexStride < MIN_ROW_INDEX_STRIDE) { |
| 198 | throw new IllegalArgumentException("Row stride must be at least " + |
| 199 | MIN_ROW_INDEX_STRIDE); |
| 200 | } |
| 201 | |
| 202 | this.writerVersion = opts.getWriterVersion(); |
| 203 | this.version = opts.getVersion(); |
| 204 | if (version == OrcFile.Version.FUTURE) { |
| 205 | throw new IllegalArgumentException("Can not write in a unknown version."); |
nothing calls this directly
no test coverage detected