Top Description Constructors Methods
org.eclipse.jgit.internal.storage.dfs

public abstract Class DfsOutputStream

extends OutputStream
Class Inheritance
Known Direct Subclasses
org.eclipse.jgit.internal.storage.dfs.InMemoryRepository.Out
Imports
java.io.IOException, .OutputStream, java.nio.ByteBuffer, org.eclipse.jgit.internal.storage.pack.PackExt

Output stream to create a file on the DFS.
See Also
DfsObjDatabase#writeFile(DfsPackDescription, PackExt)

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

recommended alignment size for randomly positioned reads. Does not need to be a power of 2.
blockSize
()

Get the recommended alignment for writing.

public abstract int

Returns:

number of bytes actually read.
read
(long
offset to read from.
position
,
ByteBuffer
buffer to populate. Up to buf.remaining() bytes will be read from position.
buf
)

Read back a portion of already written data.

public void
write(int
the byte.
b
)

Implements abstract java.io.OutputStream.write.

Writes the specified byte to this output stream.

public abstract void
write(byte[]
the data.
buf
,
int
the start offset in the data.
off
,
int
the number of bytes to write.
len
)

Overrides java.io.OutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream.

Inherited from java.io.OutputStream:
closeflushnullOutputStreamwrite

Constructor Detail

DfsOutputStreamback to summary
public DfsOutputStream()

Method Detail

blockSizeback to summary
public int blockSize()

Get the recommended alignment for writing.

Starting a write at multiples of the blockSize is more efficient than starting a write at any other position. If 0 or -1 the channel does not have any specific block size recommendation.

Channels should not recommend large block sizes. Sizes up to 1-4 MiB may be reasonable, but sizes above that may be horribly inefficient.

Returns:int

recommended alignment size for randomly positioned reads. Does not need to be a power of 2.

readback to summary
public abstract int read(long position, ByteBuffer buf) throws IOException

Read back a portion of already written data.

The writing position of the output stream is not affected by a read.

Parameters
position:long

offset to read from.

buf:ByteBuffer

buffer to populate. Up to buf.remaining() bytes will be read from position.

Returns:int

number of bytes actually read.

Exceptions
IOException:
reading is not supported, or the read cannot be performed due to DFS errors.
writeback to summary
public void write(int b) throws IOException

Implements abstract java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes the specified byte to this output stream. The general contract for write is that one byte is written to the output stream. The byte to be written is the eight low-order bits of the argument b. The 24 high-order bits of b are ignored.

Parameters
b:int

the byte.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.
writeback to summary
public abstract void write(byte[] buf, int off, int len) throws IOException

Overrides java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream. The general contract for write(b, off, len) is that some of the bytes in the array b are written to the output stream in order; element b[off] is the first byte written and b[off+len-1] is the last byte written by this operation.

If b is null, a NullPointerException is thrown.

If off is negative, or len is negative, or off+len is greater than the length of the array b, then an IndexOutOfBoundsException is thrown.

Parameters
buf:byte[]

the data.

off:int

the start offset in the data.

len:int

the number of bytes to write.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs. In particular, an IOException is thrown if the output stream is closed.