Package org.kairosdb.bigqueue.page
Class MappedPageImpl
- java.lang.Object
-
- org.kairosdb.bigqueue.page.MappedPageImpl
-
- All Implemented Interfaces:
Closeable,AutoCloseable,IMappedPage
public class MappedPageImpl extends Object implements IMappedPage, Closeable
-
-
Constructor Summary
Constructors Constructor Description MappedPageImpl(MappedByteBuffer mbb, String pageFile, long index)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidflush()Persist any changes to diskByteBuffergetLocal(int position)Get a thread local copy of the mapped page bufferbyte[]getLocal(int position, int length)Get data from a thread local copy of the mapped page bufferStringgetPageFile()The back page file name of the mapped pagelonggetPageIndex()The index of the mapped pagebooleanisClosed()Check if this mapped page has been closed or notbooleanisNew()Is the mapped page new or was it read from diskvoidsetDirty(boolean dirty)Set if the mapped page has been changed or notvoidsetNew(boolean isNew)StringtoString()
-
-
-
Constructor Detail
-
MappedPageImpl
public MappedPageImpl(MappedByteBuffer mbb, String pageFile, long index)
-
-
Method Detail
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
setNew
public void setNew(boolean isNew)
-
isNew
public boolean isNew()
Description copied from interface:IMappedPageIs the mapped page new or was it read from disk- Specified by:
isNewin interfaceIMappedPage- Returns:
- true if no file on disk existed
-
setDirty
public void setDirty(boolean dirty)
Description copied from interface:IMappedPageSet if the mapped page has been changed or not- Specified by:
setDirtyin interfaceIMappedPage- Parameters:
dirty- dirty flag to set
-
flush
public void flush()
Description copied from interface:IMappedPagePersist any changes to disk- Specified by:
flushin interfaceIMappedPage
-
getLocal
public byte[] getLocal(int position, int length)Description copied from interface:IMappedPageGet data from a thread local copy of the mapped page buffer- Specified by:
getLocalin interfaceIMappedPage- Parameters:
position- start position(relative to the start position of source mapped page buffer) of the thread local bufferlength- the length to fetch- Returns:
- byte data
-
getLocal
public ByteBuffer getLocal(int position)
Description copied from interface:IMappedPageGet a thread local copy of the mapped page buffer- Specified by:
getLocalin interfaceIMappedPage- Parameters:
position- start position(relative to the start position of source mapped page buffer) of the thread local buffer- Returns:
- a byte buffer with specific position as start position.
-
isClosed
public boolean isClosed()
Description copied from interface:IMappedPageCheck if this mapped page has been closed or not- Specified by:
isClosedin interfaceIMappedPage- Returns:
- returns true if closed
-
getPageFile
public String getPageFile()
Description copied from interface:IMappedPageThe back page file name of the mapped page- Specified by:
getPageFilein interfaceIMappedPage- Returns:
- name of page file
-
getPageIndex
public long getPageIndex()
Description copied from interface:IMappedPageThe index of the mapped page- Specified by:
getPageIndexin interfaceIMappedPage- Returns:
- the index
-
-