@Override public synchronized void write(final byte[] b, final int off, final int len) throws IOException { super.write(b, off, len); } }
@Override public synchronized void write(final int b) throws IOException { super.write(b); }
@Override public void write(byte[] b) throws IOException { write(b, 0, b.length); }
@Override public synchronized void write(final byte[] b) throws IOException { super.write(b); }
@Override public synchronized void write(final byte[] b, final int off, final int len) throws IOException { if (closed) { throw new IOException("Stream is closed"); } try { bcos.write(b, off, len); } catch (final IOException ioe) { recycle = false; throw new IOException("Failed to write to " + this, ioe); } bytesWritten += len; scc.setLength(bytesWritten + initialLength); }
@Override public synchronized void write(final int b) throws IOException { if (closed) { throw new IOException("Stream is closed"); } try { bcos.write(b); } catch (final IOException ioe) { recycle = false; throw new IOException("Failed to write to " + this, ioe); } bytesWritten++; scc.setLength(bytesWritten + initialLength); }
@Override public synchronized void write(final byte[] b) throws IOException { if (closed) { throw new IOException("Stream is closed"); } try { bcos.write(b); } catch (final IOException ioe) { recycle = false; throw new IOException("Failed to write to " + this, ioe); } bytesWritten += b.length; scc.setLength(bytesWritten + initialLength); }
@Override public long merge(final Collection<ContentClaim> claims, final ContentClaim destination, final byte[] header, final byte[] footer, final byte[] demarcator) throws IOException { if (claims.contains(destination)) { throw new IllegalArgumentException("destination cannot be within claims"); } try (final ByteCountingOutputStream out = new ByteCountingOutputStream(write(destination))) { if (header != null) { out.write(header); } int i = 0; for (final ContentClaim claim : claims) { try (final InputStream in = read(claim)) { StreamUtils.copy(in, out); } if (++i < claims.size() && demarcator != null) { out.write(demarcator); } } if (footer != null) { out.write(footer); } return out.getBytesWritten(); } }
@Override public void write(final byte[] b) throws IOException { try { countingOut.write(b); } catch (final IOException ioe) { LOG.error("Failed to write content to " + sourceFlowFile + "; rolling back session", ioe); rollback(true); close(); throw new FlowFileAccessException("Failed to write to Content Repository for " + sourceFlowFile, ioe); } }
@Override public void write(final int b) throws IOException { try { countingOut.write(b); } catch (final IOException ioe) { LOG.error("Failed to write content to " + sourceFlowFile + "; rolling back session", ioe); rollback(true); close(); throw new FlowFileAccessException("Failed to write to Content Repository for " + sourceFlowFile, ioe); } }
@Override public void write(final byte[] b, final int off, final int len) throws IOException { try { countingOut.write(b, off, len); } catch (final IOException ioe) { LOG.error("Failed to write content to " + sourceFlowFile + "; rolling back session", ioe); rollback(true); close(); throw new FlowFileAccessException("Failed to write to Content Repository for " + sourceFlowFile, ioe); } }
@VisibleForTesting public OutputStream getStream() throws IOException { if (rawWriter == null) { rawWriter = new ByteCountingOutputStream(flowFileOutputStream); rawWriter.write(OrcFile.MAGIC.getBytes()); headerLength = rawWriter.getBytesWritten(); writer = new OutStream("metadata", bufferSize, codec, new DirectStream(rawWriter)); protobufWriter = CodedOutputStream.newInstance(writer); } return rawWriter; }
@Override public long writeIntermediateFooter() throws IOException { // flush any buffered rows flushStripe(); // write a footer if (stripesAtLastFlush != stripes.size()) { if (callback != null) { callback.preFooterWrite(callbackContext); } int metaLength = writeMetadata(); int footLength = writeFooter(rawWriter.getBytesWritten() - metaLength); rawWriter.write(writePostScript(footLength, metaLength)); stripesAtLastFlush = stripes.size(); rawWriter.flush(); } return rawWriter.getBytesWritten(); }
@Override public void close() throws IOException { if (callback != null) { callback.preFooterWrite(callbackContext); } // remove us from the memory manager so that we don't get any callbacks memoryManager.removeWriter(path); // actually close the file flushStripe(); int metadataLength = writeMetadata(); int footerLength = writeFooter(rawWriter.getBytesWritten() - metadataLength); rawWriter.write(writePostScript(footerLength, metadataLength)); rawWriter.close(); }
while (padding > 0) { int writeLen = (int) Math.min(padding, pad.length); rawWriter.write(pad, 0, writeLen); padding -= writeLen;
@Override public void write(byte[] b) throws IOException { write(b, 0, b.length); }
@Override public synchronized void write(final byte[] b) throws IOException { super.write(b); }
@Override public synchronized void write(final int b) throws IOException { super.write(b); }
@VisibleForTesting public OutputStream getStream() throws IOException { if (rawWriter == null) { rawWriter = new ByteCountingOutputStream(flowFileOutputStream); rawWriter.write(OrcFile.MAGIC.getBytes()); headerLength = rawWriter.getBytesWritten(); writer = new OutStream("metadata", bufferSize, codec, new DirectStream(rawWriter)); protobufWriter = CodedOutputStream.newInstance(writer); } return rawWriter; }