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 int
FILE_VERSION
Version number of this header (magic number).private int
pageSize
The size of a page in bytes.private static int
SIZE
The size of this header in Bytes, which is 8 Bytes ( 4 Bytes forFILE_VERSION
and 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 int
getPageSize()
Returns the size of a page in Bytes.int
getReservedPages()
Returns the number of pages necessary for the headervoid
readHeader(java.nio.ByteBuffer data)
Initializes this header from the given Byte array.int
size()
Returns the size of this header in Bytes.void
writeHeader(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_VERSION
and 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:PageHeader
Returns the size of this header in Bytes.- Specified by:
size
in 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 ofpageSize
from the file.- Specified by:
readHeader
in 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 theversion
of this header and the integer value ofpageSize
to the file.- Specified by:
writeHeader
in interfacePageHeader
- Parameters:
buffer
- Buffer to write to
-
getPageSize
public int getPageSize()
Returns the size of a page in Bytes.- Specified by:
getPageSize
in interfacePageHeader
- Returns:
- the size of a page in Bytes
-
getReservedPages
public int getReservedPages()
Returns the number of pages necessary for the header- Specified by:
getReservedPages
in interfacePageHeader
- Returns:
- the number of pages
-
-