Package elki.persistent
Class DefaultPageHeader
- java.lang.Object
-
- elki.persistent.DefaultPageHeader
-
- All Implemented Interfaces:
elki.persistent.PageHeader
- Direct Known Subclasses:
TreeIndexHeader
public class DefaultPageHeader extends java.lang.Object implements elki.persistent.PageHeaderDefault 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()voidwriteHeader(java.nio.ByteBuffer buffer)Writes this header to the specified file.
-
-
-
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()
- Specified by:
sizein interfaceelki.persistent.PageHeader
-
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 interfaceelki.persistent.PageHeader
-
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 interfaceelki.persistent.PageHeader
-
getPageSize
public int getPageSize()
Returns the size of a page in Bytes.- Specified by:
getPageSizein interfaceelki.persistent.PageHeader- Returns:
- the size of a page in Bytes
-
getReservedPages
public int getReservedPages()
Returns the number of pages necessary for the header- Specified by:
getReservedPagesin interfaceelki.persistent.PageHeader- Returns:
- the number of pages
-
-