public final class ResizeableMappedStore extends Object
Modifier and Type | Field and Description |
---|---|
protected net.openhft.lang.io.AbstractMappedStore.MmapInfoHolder |
mmapInfoHolder |
Constructor and Description |
---|
ResizeableMappedStore(File file,
FileChannel.MapMode mode,
long size) |
ResizeableMappedStore(File file,
FileChannel.MapMode mode,
long size,
ObjectSerializer objectSerializer) |
Modifier and Type | Method and Description |
---|---|
long |
address() |
DirectBytes |
bytes()
Create a bytes whose content is the whole bytes store.
|
DirectBytes |
bytes(long offset,
long length)
|
void |
close() |
File |
file() |
void |
free() |
protected void |
map(long startInFile) |
ObjectSerializer |
objectSerializer() |
void |
resize(long newSize)
Resizes the underlying file and re-maps it.
|
protected void |
resizeIfNeeded(long startInFile,
long newSize) |
long |
size() |
void |
syncToDisk() |
protected void |
unmapAndSyncToDisk() |
protected static void |
validateSize(long size) |
protected final net.openhft.lang.io.AbstractMappedStore.MmapInfoHolder mmapInfoHolder
public ResizeableMappedStore(File file, FileChannel.MapMode mode, long size) throws IOException
IOException
public ResizeableMappedStore(File file, FileChannel.MapMode mode, long size, ObjectSerializer objectSerializer) throws IOException
IOException
public void resize(long newSize) throws IOException
Bytes
obtained through bytes()
or
bytes(long, long)
are invalid and using them can lead to reading
arbitrary data or JVM crash! It is the callers responsibility to ensure
that these instances are not used after the method call.newSize
- IOException
protected static void validateSize(long size)
protected final void resizeIfNeeded(long startInFile, long newSize) throws IOException
IOException
protected final void map(long startInFile) throws IOException
IOException
protected final void unmapAndSyncToDisk() throws IOException
IOException
public final void syncToDisk() throws IOException
IOException
public final ObjectSerializer objectSerializer()
objectSerializer
in interface BytesStore
public final long address()
address
in interface BytesStore
public final long size()
size
in interface BytesStore
public final void free()
free
in interface BytesStore
public final void close()
close
in interface Closeable
close
in interface AutoCloseable
@NotNull public final DirectBytes bytes()
BytesStore
bytes(0, size())
call.bytes
in interface BytesStore
BytesStore.bytes(long, long)
@NotNull public final DirectBytes bytes(long offset, long length)
BytesStore
Bytes
object with start address of
address
+ offset
and capacity of length
.
If this BytesStore
is Bytes
itself rather than natural
BytesStore
object, this method will offset the new bytes from the
bytes' start, not from bytes' position like
BytesCommon.slice(long, long)
.
offset
should be non-negative, length
should be positive,
offset + length
should be less or equal to size
.
bytes
in interface BytesStore
offset
- offset of the new bytes from the bytes store addresslength
- capacity and limit of the new bytesBytes
BytesStore.bytes()
public final File file()
file
in interface BytesStore
Copyright © 2019. All rights reserved.