Package elki.persistent
Class DefaultPageHeader
- java.lang.Object
-
- elki.persistent.DefaultPageHeader
-
- All Implemented Interfaces:
PageHeader
- Direct Known Subclasses:
TreeIndexHeader
public class DefaultPageHeader extends java.lang.Object implements PageHeader
Default implementation of a page header.- Since:
- 0.1
- Author:
- Elke Achtert
-
-
Field Summary
Fields Modifier and Type Field Description private static intFILE_VERSIONVersion number of this header (magic number).private intpageSizeThe size of a page in bytes.private static intSIZEThe size of this header in Bytes, which is 8 Bytes ( 4 Bytes forFILE_VERSIONand 4 Bytes forpageSize).
-
Constructor Summary
Constructors Constructor Description DefaultPageHeader()Empty constructor for serialization.DefaultPageHeader(int pageSize)Creates a new header with the specified parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetPageSize()Returns the size of a page in Bytes.intgetReservedPages()Returns the number of pages necessary for the headervoidreadHeader(java.nio.ByteBuffer data)Initializes this header from the given Byte array.intsize()Returns the size of this header in Bytes.voidwriteHeader(java.nio.ByteBuffer buffer)Writes this header to the specified file.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface elki.persistent.PageHeader
readHeader, writeHeader
-
-
-
-
Field Detail
-
SIZE
private static final int SIZE
The size of this header in Bytes, which is 8 Bytes ( 4 Bytes forFILE_VERSIONand 4 Bytes forpageSize).- See Also:
- Constant Field Values
-
FILE_VERSION
private static final int FILE_VERSION
Version number of this header (magic number).- See Also:
- Constant Field Values
-
pageSize
private int pageSize
The size of a page in bytes.
-
-
Method Detail
-
size
public int size()
Description copied from interface:PageHeaderReturns the size of this header in Bytes.- Specified by:
sizein interfacePageHeader- Returns:
- the size of this header in Bytes
-
readHeader
public void readHeader(java.nio.ByteBuffer data)
Initializes this header from the given Byte array. Looks for the right version and reads the integer value ofpageSizefrom the file.- Specified by:
readHeaderin interfacePageHeader- Parameters:
data- byte array with the page data.
-
writeHeader
public void writeHeader(java.nio.ByteBuffer buffer)
Writes this header to the specified file. Writes theversionof this header and the integer value ofpageSizeto the file.- Specified by:
writeHeaderin interfacePageHeader- Parameters:
buffer- Buffer to write to
-
getPageSize
public int getPageSize()
Returns the size of a page in Bytes.- Specified by:
getPageSizein interfacePageHeader- Returns:
- the size of a page in Bytes
-
getReservedPages
public int getReservedPages()
Returns the number of pages necessary for the header- Specified by:
getReservedPagesin interfacePageHeader- Returns:
- the number of pages
-
-