Package org.aksw.commons.io.block.impl
Class PageManagerForFileChannel
java.lang.Object
org.aksw.commons.io.block.impl.PageManagerForFileChannel
- All Implemented Interfaces:
BlockSource,PageManager
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected FileChannelprotected longWe rely on the channel's size being constant.static final intThe cache is crucial to the implementation.protected int -
Constructor Summary
ConstructorsConstructorDescriptionPageManagerForFileChannel(FileChannel channel, long channelSize, int pageSize) -
Method Summary
Modifier and TypeMethodDescriptionstatic PageManagerForFileChannelcreate(FileChannel channel) static PageManagerForFileChannelcreate(FileChannel channel, int pageSize) longThe maximum position in the underlying bufferintThe pageSize.org.aksw.commons.util.ref.Ref<Page> getRefForPage(long page) static ByteBuffermap(FileChannel channel, FileChannel.MapMode mapMode, long start, long length) org.aksw.commons.util.ref.Ref<Page> requestBufferForPage(long page) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.aksw.commons.io.block.api.PageManager
contentAtOrAfter, contentAtOrBefore, getSizeOfBlock, hasBlockAfter, hasBlockBefore, size
-
Field Details
-
DEFAULT_PAGE_SIZE
public static final int DEFAULT_PAGE_SIZE- See Also:
-
pageCache
The cache is crucial to the implementation. Setting its size to 0 will cause excessive allocation of pages and thus a timely OutOfMemory error. -
channel
-
channelSize
protected long channelSizeWe rely on the channel's size being constant. A growing size should work, a shrinking one will cause exceptions. -
pageSize
protected int pageSize
-
-
Constructor Details
-
PageManagerForFileChannel
-
-
Method Details
-
create
- Throws:
IOException
-
create
public static PageManagerForFileChannel create(FileChannel channel, int pageSize) throws IOException - Throws:
IOException
-
getPageSize
public int getPageSize()Description copied from interface:PageManagerThe pageSize. Must never change during the life time of a page manager.- Specified by:
getPageSizein interfacePageManager- Returns:
-
requestBufferForPage
- Specified by:
requestBufferForPagein interfacePageManager
-
map
public static ByteBuffer map(FileChannel channel, FileChannel.MapMode mapMode, long start, long length) throws IOException - Throws:
IOException
-
getRefForPage
- Throws:
IOException
-
getEndPos
public long getEndPos()Description copied from interface:PageManagerThe maximum position in the underlying buffer- Specified by:
getEndPosin interfacePageManager- Returns:
-