Top Description Inners Fields Constructors Methods
com.jogamp.common.nio

public Class MappedByteBufferInputStream

extends InputStream
Class Inheritance
Imports
java.io.IOException, .InputStream, .OutputStream, .PrintStream, .RandomAccessFile, java.lang.ref.WeakReference, java.lang.reflect.Method, java.nio.ByteBuffer, .MappedByteBuffer, java.nio.channels.FileChannel, .FileChannel.MapMode, java.security.AccessController, .PrivilegedAction, jogamp.common.Debug, com.jogamp.common.os.Platform

An InputStream implementation based on an underlying FileChannel's memory mapped ByteBuffer, supporting mark and reset().

Implementation allows full memory mapped ByteBuffer coverage via FileChannel beyond its size limitation of Integer#MAX_VALUE utilizing an array of ByteBuffer slices.

Implementation further allows full random access via position() and position(long) and accessing the memory mapped ByteBuffer slices directly via currentSlice() and nextSlice().

Since
2.3.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
public static interface
MappedByteBufferInputStream.FileResizeOp

File resize interface allowing a file to change its size, e.g. via RandomAccessFile#setLength(long).

Field Summary

Modifier and TypeField and Description
private Method
private boolean
private MappedByteBufferInputStream.CacheMode
pack-priv static final boolean
public static final int
DEFAULT_SLICE_SHIFT

Default slice shift, i.e. 1L << shift, denoting slice size in MiB:

private final FileChannel
private MappedByteBufferInputStream.FileResizeOp
private boolean
private long
private Method
private final FileChannel.MapMode
private static final MappedByteBufferInputStream.FileResizeOp
private int
private int
private int
private ByteBuffer[]
private WeakReference<ByteBuffer>[]
private int
private int
private final int
private boolean
private long

Constructor Summary

AccessConstructor and Description
pack-priv
MappedByteBufferInputStream(final FileChannel fc, final FileChannel.MapMode mmode, final MappedByteBufferInputStream.CacheMode cmode, final int sliceShift, final long totalSize, final int currSliceIdx)

public
MappedByteBufferInputStream(final FileChannel
the file channel to be mapped lazily.
fileChannel
,
final FileChannel.MapMode
the map mode, default is FileChannel.MapMode#READ_ONLY.
mmode
,
final MappedByteBufferInputStream.CacheMode
the caching mode, default is CacheMode#FLUSH_PRE_HARD.
cmode
,
final int
the pow2 slice size, default is DEFAULT_SLICE_SHIFT.
sliceShift
)

Creates a new instance using the given FileChannel.

public
MappedByteBufferInputStream(final FileChannel
the file channel to be used.
fileChannel
,
final FileChannel.MapMode
the map mode, default is FileChannel.MapMode#READ_ONLY.
mmode
,
final MappedByteBufferInputStream.CacheMode
the caching mode, default is CacheMode#FLUSH_PRE_HARD.
cmode
)

Creates a new instance using the given FileChannel, given mapping-mode, given cache-mode and the DEFAULT_SLICE_SHIFT.

public
MappedByteBufferInputStream(final FileChannel
the file channel to be used.
fileChannel
)

Creates a new instance using the given FileChannel, read-only mapping mode, CacheMode#FLUSH_PRE_HARD and the DEFAULT_SLICE_SHIFT.

Method Summary

Modifier and TypeMethod and Description
public final synchronized int
available()

Overrides java.io.InputStream.available.

See remaining() for an accurate variant.
pack-priv final synchronized void
private synchronized void
cleanAllSlices(final boolean syncBuffers)

private synchronized boolean
cleanBuffer(final ByteBuffer mbb, final boolean syncBuffer)

private synchronized void
cleanSlice(final int i, final boolean syncBuffer)

public final synchronized void
close()

Overrides java.io.InputStream.close.

Implements java.io.Closeable.close.

Closes this input stream and releases any system resources associated with the stream.
public final synchronized ByteBuffer
currentSlice()

Return the mapped ByteBuffer slice at the current position().

pack-priv final void
dbgDump(final String prefix, final PrintStream out)

public final synchronized void
flush(final boolean
TODO
metaData
)

Similar to OutputStream#flush(), synchronizes all mapped buffers from local storage via MappedByteBuffer#force() as well as the FileChannel#force(boolean) w/o metaData.

private final synchronized void
flushImpl(final boolean metaData, final boolean syncBuffer)

private synchronized void
flushSlice(final int i, final boolean syncBuffer)

public final synchronized MappedByteBufferInputStream.CacheMode
getCacheMode()

Return the used CacheMode.

pack-priv final FileChannel.MapMode
public final synchronized MappedByteBufferOutputStream
getOutputStream(final MappedByteBufferInputStream.FileResizeOp fileResizeOp)

Returns a new MappedByteBufferOutputStream instance sharing all resources of this input stream, including all buffer slices.

public final synchronized boolean
private synchronized void
public final synchronized long
length()

Returns the total size in bytes of the InputStream

  0 <= position() <= length()
public final synchronized void
mark(final int
the maximum limit of bytes that can be read before the mark position becomes invalid.
readlimit
)

Overrides java.io.InputStream.mark.

Marks the current position in this input stream.
public final boolean
markSupported()

Overrides java.io.InputStream.markSupported.

Tests if this input stream supports the mark and reset methods.
public final synchronized ByteBuffer
nextSlice()

Return the next mapped ByteBuffer slice from the current position(), implicitly setting position(long) to the start of the returned next slice, see currentSlice().

public final synchronized void
notifyLengthChange(final long
the new total size
newTotalSize
)

Notify this instance that the underlying FileChannel's size has been changed and adjusting this instances buffer slices and states accordingly.

private final synchronized void
notifyLengthChangeImpl(final long newTotalSize, final long currentPosition)

public final synchronized long
position()

Returns the absolute position of the InputStream.

public final synchronized MappedByteBufferInputStream

Returns:

this instance
position
(final long
The new position, which must be non-negative and ≤ length().
newPosition
)

Sets the absolute position of the InputStream to newPosition.

private final synchronized void
position2(final long newPosition)

public final synchronized int
read()

Implements abstract java.io.InputStream.read.

Reads the next byte of data from the input stream.
public final synchronized int
read(final byte[]
the buffer into which the data is read.
b
,
final int
the start offset in array b at which the data is written.
off
,
final int
the maximum number of bytes to read.
len
)

Overrides java.io.InputStream.read.

Reads up to len bytes of data from the input stream into an array of bytes.
public final synchronized int

Returns:

the number of bytes read, -1 for EOS
read
(final ByteBuffer
the ByteBuffer sink, data is written at current ByteBuffer#position()
b
,
final int
the number of bytes to read
len
)

Perform similar to read(byte[], int, int) with ByteBuffer instead of byte array.

public final synchronized long
remaining()

Returns the number of remaining available bytes of the InputStream, i.e. length() - position().

public final synchronized void
reset()

Overrides java.io.InputStream.reset.

Repositions this stream to the position at the time the mark method was last called on this input stream.
public final synchronized void
public final synchronized void
setLength(final long
the new total size
newTotalSize
)

Resize the underlying FileChannel's size and adjusting this instance via accordingly.

public final synchronized void
setSynchronous(final boolean
true to enable synchronous mode
s
)

Enable or disable synchronous mode.

public final synchronized long
skip(final long
the number of bytes to be skipped.
n
)

Overrides java.io.InputStream.skip.

Skips over and discards n bytes of data from this input stream.
pack-priv synchronized void
pack-priv synchronized void
syncSlice(final ByteBuffer s, final boolean syncBuffer)

Inherited from java.io.InputStream:
nullInputStreamreadreadAllBytesreadNBytesreadNBytesskipNBytestransferTo

Field Detail

cCleanback to summary
private Method cClean
cleanerInitback to summary
private boolean cleanerInit
cmodeback to summary
private MappedByteBufferInputStream.CacheMode cmode
DEBUGback to summary
pack-priv static final boolean DEBUG
DEFAULT_SLICE_SHIFTback to summary
public static final int DEFAULT_SLICE_SHIFT

Default slice shift, i.e. 1L << shift, denoting slice size in MiB:

In case the default is too much of-used up address-space, one may choose other values:

  • 29 -> 512 MiB
  • 28 -> 256 MiB
  • 27 -> 128 MiB
  • 26 -> 64 MiB

fcback to summary
private final FileChannel fc
fileResizeOpback to summary
private MappedByteBufferInputStream.FileResizeOp fileResizeOp
hasCleanerback to summary
private boolean hasCleaner
markback to summary
private long mark
mbbCleanerback to summary
private Method mbbCleaner
mmodeback to summary
private final FileChannel.MapMode mmode
NoFileResizeback to summary
private static final MappedByteBufferInputStream.FileResizeOp NoFileResize
refCountback to summary
private int refCount
sliceCountback to summary
private int sliceCount
sliceIdxback to summary
private int sliceIdx
slicesback to summary
private ByteBuffer[] slices
slices2GCback to summary
private WeakReference<ByteBuffer>[] slices2GC
slices2GCEntriesback to summary
private int slices2GCEntries
slicesEntriesback to summary
private int slicesEntries
sliceShiftback to summary
private final int sliceShift
synchronousback to summary
private boolean synchronous
totalSizeback to summary
private long totalSize

Constructor Detail

MappedByteBufferInputStreamback to summary
pack-priv MappedByteBufferInputStream(final FileChannel fc, final FileChannel.MapMode mmode, final MappedByteBufferInputStream.CacheMode cmode, final int sliceShift, final long totalSize, final int currSliceIdx) throws IOException
MappedByteBufferInputStreamback to summary
public MappedByteBufferInputStream(final FileChannel fileChannel, final FileChannel.MapMode mmode, final MappedByteBufferInputStream.CacheMode cmode, final int sliceShift) throws IOException

Creates a new instance using the given FileChannel.

The ByteBuffer slices will be mapped lazily at first usage.

Parameters
fileChannel:FileChannel

the file channel to be mapped lazily.

mmode:FileChannel.MapMode

the map mode, default is FileChannel.MapMode#READ_ONLY.

cmode:MappedByteBufferInputStream.CacheMode

the caching mode, default is CacheMode#FLUSH_PRE_HARD.

sliceShift:int

the pow2 slice size, default is DEFAULT_SLICE_SHIFT.

MappedByteBufferInputStreamback to summary
public MappedByteBufferInputStream(final FileChannel fileChannel, final FileChannel.MapMode mmode, final MappedByteBufferInputStream.CacheMode cmode) throws IOException

Creates a new instance using the given FileChannel, given mapping-mode, given cache-mode and the DEFAULT_SLICE_SHIFT.

The ByteBuffer slices will be mapped lazily at first usage.

Parameters
fileChannel:FileChannel

the file channel to be used.

mmode:FileChannel.MapMode

the map mode, default is FileChannel.MapMode#READ_ONLY.

cmode:MappedByteBufferInputStream.CacheMode

the caching mode, default is CacheMode#FLUSH_PRE_HARD.

MappedByteBufferInputStreamback to summary
public MappedByteBufferInputStream(final FileChannel fileChannel) throws IOException

Creates a new instance using the given FileChannel, read-only mapping mode, CacheMode#FLUSH_PRE_HARD and the DEFAULT_SLICE_SHIFT.

The ByteBuffer slices will be mapped FileChannel.MapMode#READ_ONLY lazily at first usage.

Parameters
fileChannel:FileChannel

the file channel to be used.

Method Detail

availableback to summary
public final synchronized int available() throws IOException

Overrides java.io.InputStream.available.

Doc from java.io.InputStream.available.

See remaining() for an accurate variant.

Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected. The read might be on the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes.

Note that while some implementations of InputStream will return the total number of bytes in the stream, many will not. It is never correct to use the return value of this method to allocate a buffer intended to hold all data in this stream.

A subclass's implementation of this method may choose to throw an IOException if this input stream has been closed by invoking the close() method.

Returns:int

an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking or 0 when it reaches the end of the input stream.

Annotations
@Override
Exceptions
IOException:
if a buffer slice operation failed.
checkOpenback to summary
pack-priv final synchronized void checkOpen() throws IOException
cleanAllSlicesback to summary
private synchronized void cleanAllSlices(final boolean syncBuffers) throws IOException
cleanBufferback to summary
private synchronized boolean cleanBuffer(final ByteBuffer mbb, final boolean syncBuffer) throws IOException
cleanSliceback to summary
private synchronized void cleanSlice(final int i, final boolean syncBuffer) throws IOException
closeback to summary
public final synchronized void close() throws IOException

Overrides java.io.InputStream.close.

Implements java.io.Closeable.close.

Doc from java.io.InputStream.close.

Closes this input stream and releases any system resources associated with the stream.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
currentSliceback to summary
public final synchronized ByteBuffer currentSlice() throws IOException

Return the mapped ByteBuffer slice at the current position().

Due to the nature of using sliced buffers mapping the whole region, user has to determine whether the returned buffer covers the desired region and may fetch the nextSlice() until satisfied.
It is also possible to repeat this operation after reposition the stream via position(long) or skip(long) to a position within the next block, similar to nextSlice().

Exceptions
IOException:
if a buffer slice operation failed.
dbgDumpback to summary
pack-priv final void dbgDump(final String prefix, final PrintStream out)
flushback to summary
public final synchronized void flush(final boolean metaData) throws IOException

Similar to OutputStream#flush(), synchronizes all mapped buffers from local storage via MappedByteBuffer#force() as well as the FileChannel#force(boolean) w/o metaData.

Parameters
metaData:boolean

TODO

Exceptions
IOException:
if this stream has been closed.
flushImplback to summary
private final synchronized void flushImpl(final boolean metaData, final boolean syncBuffer) throws IOException
flushSliceback to summary
private synchronized void flushSlice(final int i, final boolean syncBuffer) throws IOException
getCacheModeback to summary
public final synchronized MappedByteBufferInputStream.CacheMode getCacheMode()

Return the used CacheMode.

If a desired CacheMode is not available, it may fall back to an available one at runtime, see CacheMode#FLUSH_PRE_HARD.
This evaluation only happens if the CacheMode != CacheMode#FLUSH_NONE and while attempting to flush an unused buffer slice.

getMapModeback to summary
pack-priv final FileChannel.MapMode getMapMode()
getOutputStreamback to summary
public final synchronized MappedByteBufferOutputStream getOutputStream(final MappedByteBufferInputStream.FileResizeOp fileResizeOp) throws IllegalStateException, IOException

Returns a new MappedByteBufferOutputStream instance sharing all resources of this input stream, including all buffer slices.

Exceptions
IllegalStateException:
if attempting to set the FileResizeOp to a different value than before
IOException:
if this instance was opened w/ FileChannel.MapMode#READ_ONLY or if this stream has been closed.
getSynchronousback to summary
public final synchronized boolean getSynchronous()

Return synchronous mode.

initCleanerback to summary
private synchronized void initCleaner(final ByteBuffer bb)
lengthback to summary
public final synchronized long length()

Returns the total size in bytes of the InputStream

  0 <= position() <= length()
markback to summary
public final synchronized void mark(final int readlimit)

Overrides java.io.InputStream.mark.

Doc from java.io.InputStream.mark.

Marks the current position in this input stream. A subsequent call to the reset method repositions this stream at the last marked position so that subsequent reads re-read the same bytes.

The readlimit arguments tells this input stream to allow that many bytes to be read before the mark position gets invalidated.

The general contract of mark is that, if the method markSupported returns true, the stream somehow remembers all the bytes read after the call to mark and stands ready to supply those same bytes again if and whenever the method reset is called. However, the stream is not required to remember any data at all if more than readlimit bytes are read from the stream before reset is called.

Marking a closed stream should not have any effect on the stream.

Parameter readLimit is not used in this implementation, since the whole file is memory mapped and no read limitation occurs.

Parameters
readlimit:int

the maximum limit of bytes that can be read before the mark position becomes invalid.

Annotations
@Override
markSupportedback to summary
public final boolean markSupported()

Overrides java.io.InputStream.markSupported.

Doc from java.io.InputStream.markSupported.

Tests if this input stream supports the mark and reset methods. Whether or not mark and reset are supported is an invariant property of a particular input stream instance.

Returns:boolean

true if this stream instance supports the mark and reset methods; false otherwise.

Annotations
@Override
nextSliceback to summary
public final synchronized ByteBuffer nextSlice() throws IOException

Return the next mapped ByteBuffer slice from the current position(), implicitly setting position(long) to the start of the returned next slice, see currentSlice().

If no subsequent slice is available, null is being returned.

Exceptions
IOException:
if a buffer slice operation failed.
notifyLengthChangeback to summary
public final synchronized void notifyLengthChange(final long newTotalSize) throws IOException

Notify this instance that the underlying FileChannel's size has been changed and adjusting this instances buffer slices and states accordingly.

Should be called by user API when aware of such event.

Parameters
newTotalSize:long

the new total size

Exceptions
IOException:
if a buffer slice operation failed
notifyLengthChangeImplback to summary
private final synchronized void notifyLengthChangeImpl(final long newTotalSize, final long currentPosition) throws IOException
positionback to summary
public final synchronized long position() throws IOException

Returns the absolute position of the InputStream.

  0 <= position() <= length()
Exceptions
IOException:
if a buffer slice operation failed.
positionback to summary
public final synchronized MappedByteBufferInputStream position(final long newPosition) throws IOException

Sets the absolute position of the InputStream to newPosition.

  0 <= position() <= length()
Parameters
newPosition:long

The new position, which must be non-negative and ≤ length().

Returns:MappedByteBufferInputStream

this instance

Exceptions
IOException:
if a buffer slice operation failed or stream is closed.
position2back to summary
private final synchronized void position2(final long newPosition) throws IOException
readback to summary
public final synchronized int read() throws IOException

Implements abstract java.io.InputStream.read.

Doc from java.io.InputStream.read.

Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

Returns:int

the next byte of data, or -1 if the end of the stream is reached.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
readback to summary
public final synchronized int read(final byte[] b, final int off, final int len) throws IOException

Overrides java.io.InputStream.read.

Doc from java.io.InputStream.read.

Reads up to len bytes of data from the input stream into an array of bytes. An attempt is made to read as many as len bytes, but a smaller number may be read. The number of bytes actually read is returned as an integer.

This method blocks until input data is available, end of file is detected, or an exception is thrown.

If len is zero, then no bytes are read and 0 is returned; otherwise, there is an attempt to read at least one byte. If no byte is available because the stream is at end of file, the value -1 is returned; otherwise, at least one byte is read and stored into b.

The first byte read is stored into element b[off], the next one into b[off+1], and so on. The number of bytes read is, at most, equal to len. Let k be the number of bytes actually read; these bytes will be stored in elements b[off] through b[off+k-1], leaving elements b[off+k] through b[off+len-1] unaffected.

In every case, elements b[0] through b[off-1] and elements b[off+len] through b[b.length-1] are unaffected.

Parameters
b:byte[]

the buffer into which the data is read.

off:int

the start offset in array b at which the data is written.

len:int

the maximum number of bytes to read.

Returns:int

the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.

Annotations
@Override
Exceptions
IOException:
If the first byte cannot be read for any reason other than end of file, or if the input stream has been closed, or if some other I/O error occurs.
readback to summary
public final synchronized int read(final ByteBuffer b, final int len) throws IOException

Perform similar to read(byte[], int, int) with ByteBuffer instead of byte array.

Parameters
b:ByteBuffer

the ByteBuffer sink, data is written at current ByteBuffer#position()

len:int

the number of bytes to read

Returns:int

the number of bytes read, -1 for EOS

Exceptions
IOException:
if a buffer slice operation failed or stream has been closed.
remainingback to summary
public final synchronized long remaining() throws IOException

Returns the number of remaining available bytes of the InputStream, i.e. length() - position().

  0 <= position() <= length()

In contrast to InputStream's available() method, this method returns the proper return type long.

Exceptions
IOException:
if a buffer slice operation failed.
resetback to summary
public final synchronized void reset() throws IOException

Overrides java.io.InputStream.reset.

Doc from java.io.InputStream.reset.

Repositions this stream to the position at the time the mark method was last called on this input stream.

The general contract of reset is:

  • If the method markSupported returns true, then:
    • If the method mark has not been called since the stream was created, or the number of bytes read from the stream since mark was last called is larger than the argument to mark at that last call, then an IOException might be thrown.
    • If such an IOException is not thrown, then the stream is reset to a state such that all the bytes read since the most recent call to mark (or since the start of the file, if mark has not been called) will be resupplied to subsequent callers of the read method, followed by any bytes that otherwise would have been the next input data as of the time of the call to reset.
  • If the method markSupported returns false, then:
    • The call to reset may throw an IOException.
    • If an IOException is not thrown, then the stream is reset to a fixed state that depends on the particular type of the input stream and how it was created. The bytes that will be supplied to subsequent callers of the read method depend on the particular type of the input stream.
Annotations
@Override
Exceptions
IOException:
if this stream has not been marked, a buffer slice operation failed or stream has been closed.
setFileResizeOpback to summary
public final synchronized void setFileResizeOp(final MappedByteBufferInputStream.FileResizeOp fileResizeOp) throws IllegalStateException
Parameters
fileResizeOp:MappedByteBufferInputStream.FileResizeOp

the new FileResizeOp.

Exceptions
IllegalStateException:
if attempting to set the FileResizeOp to a different value than before
setLengthback to summary
public final synchronized void setLength(final long newTotalSize) throws IOException

Resize the underlying FileChannel's size and adjusting this instance via accordingly.

User must have a FileResizeOp registered before.

Implementation calls notifyLengthChange(long) after FileResizeOp#setLength(long).

Parameters
newTotalSize:long

the new total size

Exceptions
IOException:
if no FileResizeOp has been registered or if a buffer slice operation failed
setSynchronousback to summary
public final synchronized void setSynchronous(final boolean s)

Enable or disable synchronous mode.

If synchronous mode is enabled, mapped buffers will be flushed if resized, written to or closing in read-write mapping mode.

If synchronous mode is enabled, FileChannel#force(boolean) is issued if resizing or closing and not in read-only mapping mode.

Parameters
s:boolean

true to enable synchronous mode

skipback to summary
public final synchronized long skip(final long n) throws IOException

Overrides java.io.InputStream.skip.

Doc from java.io.InputStream.skip.

Skips over and discards n bytes of data from this input stream. The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. This may result from any of a number of conditions; reaching end of file before n bytes have been skipped is only one possibility. The actual number of bytes skipped is returned. If n is negative, the skip method for class InputStream always returns 0, and no bytes are skipped. Subclasses may handle the negative value differently.

Parameters
n:long

the number of bytes to be skipped.

Returns:long

the actual number of bytes skipped which might be zero.

Annotations
@Override
Exceptions
IOException:
if a buffer slice operation failed or stream is closed.
syncSliceback to summary
pack-priv synchronized void syncSlice(final ByteBuffer s) throws IOException
syncSliceback to summary
pack-priv synchronized void syncSlice(final ByteBuffer s, final boolean syncBuffer) throws IOException
com.jogamp.common.nio back to summary

public final Enum MappedByteBufferInputStream.CacheMode

extends Enum<MappedByteBufferInputStream.CacheMode>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final MappedByteBufferInputStream.CacheMode
FLUSH_NONE

Keep all previous lazily cached buffer slices alive, useful for hopping readers, i.e. random access via position(p) or reset().

public static final MappedByteBufferInputStream.CacheMode
FLUSH_PRE_HARD

Hard flush the previous lazily cached buffer slice when caching the next buffer slice, useful for sequential forward readers.

public static final MappedByteBufferInputStream.CacheMode
FLUSH_PRE_SOFT

Soft flush the previous lazily cached buffer slice when caching the next buffer slice, useful for sequential forward readers, as well as for hopping readers like FLUSH_NONE in case of relatively short periods between hopping across slices.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static MappedByteBufferInputStream.CacheMode
public static MappedByteBufferInputStream.CacheMode[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

FLUSH_NONEback to summary
public static final MappedByteBufferInputStream.CacheMode FLUSH_NONE

Keep all previous lazily cached buffer slices alive, useful for hopping readers, i.e. random access via position(p) or reset().

Note that without flushing, the platform may fail memory mapping due to virtual address space exhaustion.
In such case an OutOfMemoryError may be thrown directly, or encapsulated as the the cause of a thrown IOException.

FLUSH_PRE_HARDback to summary
public static final MappedByteBufferInputStream.CacheMode FLUSH_PRE_HARD

Hard flush the previous lazily cached buffer slice when caching the next buffer slice, useful for sequential forward readers.

Besides clearing the buffer slice reference, implementation attempts to hard flush the mapped buffer using a sun.misc.Cleaner by reflection. In case such method does not exist nor works, implementation falls back to FLUSH_PRE_SOFT.

This is the default.

FLUSH_PRE_SOFTback to summary
public static final MappedByteBufferInputStream.CacheMode FLUSH_PRE_SOFT

Soft flush the previous lazily cached buffer slice when caching the next buffer slice, useful for sequential forward readers, as well as for hopping readers like FLUSH_NONE in case of relatively short periods between hopping across slices.

Implementation clears the buffer slice reference while preserving a WeakReference to allow its resurrection if not yet garbage collected.

Constructor Detail

CacheModeback to summary
private CacheMode()

Method Detail

valueOfback to summary
public static MappedByteBufferInputStream.CacheMode valueOf(String name)
valuesback to summary
public static MappedByteBufferInputStream.CacheMode[] values()
com.jogamp.common.nio back to summary

public Interface MappedByteBufferInputStream.FileResizeOp


File resize interface allowing a file to change its size, e.g. via RandomAccessFile#setLength(long).

Method Summary

Modifier and TypeMethod and Description
public void
setLength(final long
the new file size
newSize
)

Method Detail

setLengthback to summary
public void setLength(final long newSize) throws IOException
Parameters
newSize:long

the new file size

Exceptions
IOException:
if file size change is not supported or any other I/O error occurs