| 45 | import java.util.TreeMap; |
| 46 | |
| 47 | public class PhysicalFsWriter implements PhysicalWriter { |
| 48 | private static final Logger LOG = LoggerFactory.getLogger(PhysicalFsWriter.class); |
| 49 | |
| 50 | private static final int HDFS_BUFFER_SIZE = 256 * 1024; |
| 51 | |
| 52 | private FSDataOutputStream rawWriter; |
| 53 | private final DirectStream rawStream; |
| 54 | |
| 55 | // the compressed metadata information outStream |
| 56 | private OutStream compressStream; |
| 57 | // a protobuf outStream around streamFactory |
| 58 | private CodedOutputStream codedCompressStream; |
| 59 | |
| 60 | private Path path; |
| 61 | private final HadoopShims shims; |
| 62 | private final long blockSize; |
| 63 | private final int maxPadding; |
| 64 | private final StreamOptions compress; |
| 65 | private final OrcFile.CompressionStrategy compressionStrategy; |
| 66 | private final boolean addBlockPadding; |
| 67 | private final boolean writeVariableLengthBlocks; |
| 68 | private final VariantTracker unencrypted; |
| 69 | |
| 70 | private long headerLength; |
| 71 | private long stripeStart; |
| 72 | // The position of the last time we wrote a short block, which becomes the |
| 73 | // natural blocks |
| 74 | private long blockOffset; |
| 75 | private int metadataLength; |
| 76 | private int stripeStatisticsLength = 0; |
| 77 | private int footerLength; |
| 78 | private int stripeNumber = 0; |
| 79 | |
| 80 | private final Map<WriterEncryptionVariant, VariantTracker> variants = new TreeMap<>(); |
| 81 | |
| 82 | public PhysicalFsWriter(FileSystem fs, |
| 83 | Path path, |
| 84 | OrcFile.WriterOptions opts |
| 85 | ) throws IOException { |
| 86 | this(fs, path, opts, new WriterEncryptionVariant[0]); |
| 87 | } |
| 88 | |
| 89 | public PhysicalFsWriter(FileSystem fs, |
| 90 | Path path, |
| 91 | OrcFile.WriterOptions opts, |
| 92 | WriterEncryptionVariant[] encryption |
| 93 | ) throws IOException { |
| 94 | this(fs.create(path, opts.getOverwrite(), HDFS_BUFFER_SIZE, |
| 95 | fs.getDefaultReplication(path), opts.getBlockSize()), opts, encryption); |
| 96 | this.path = path; |
| 97 | LOG.debug("ORC writer created for path: {} with stripeSize: {} blockSize: {}" + |
| 98 | " compression: {}", path, opts.getStripeSize(), blockSize, compress); |
| 99 | } |
| 100 | |
| 101 | public PhysicalFsWriter(FSDataOutputStream outputStream, |
| 102 | OrcFile.WriterOptions opts, |
| 103 | WriterEncryptionVariant[] encryption |
| 104 | ) throws IOException { |
nothing calls this directly
no outgoing calls
no test coverage detected