org.helidb.util.bplus
Class NumberOfRecordsNodeSizeStrategy

java.lang.Object
  extended by org.helidb.util.bplus.NumberOfRecordsNodeSizeStrategy
All Implemented Interfaces:
NodeSizeStrategy

public class NumberOfRecordsNodeSizeStrategy
extends Object
implements NodeSizeStrategy

This NodeSizeStrategy uses a fixed number of records per node.

Since:
1.0
Author:
Karl Gustafsson
In_jar:
helidb-core

Constructor Summary
NumberOfRecordsNodeSizeStrategy(int noOfRecords)
          Constructor.
 
Method Summary
 int getMaxNumberOfRecordsPerNode(int headerSize, int recordSize, long pos)
          Given the supplied size of the node header and records, how many records will fit in a node?
 int getNodeSize(int headerSize, int recordSize, long pos)
          Given the supplied size of the node header and records, how many bytes will a node occupy?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NumberOfRecordsNodeSizeStrategy

public NumberOfRecordsNodeSizeStrategy(int noOfRecords)
                                throws IllegalArgumentException
Constructor.

Parameters:
noOfRecords - The number of records to store in a node.
Throws:
IllegalArgumentException - If the number of records is less than two.
Method Detail

getMaxNumberOfRecordsPerNode

public int getMaxNumberOfRecordsPerNode(int headerSize,
                                        int recordSize,
                                        long pos)
Description copied from interface: NodeSizeStrategy
Given the supplied size of the node header and records, how many records will fit in a node?

Specified by:
getMaxNumberOfRecordsPerNode in interface NodeSizeStrategy
Parameters:
headerSize - The size of the node header.
recordSize - The size of a record.
pos - The position of the node in the file.
Returns:
The number of records that fit in a node.

getNodeSize

public int getNodeSize(int headerSize,
                       int recordSize,
                       long pos)
Description copied from interface: NodeSizeStrategy
Given the supplied size of the node header and records, how many bytes will a node occupy?

Specified by:
getNodeSize in interface NodeSizeStrategy
Parameters:
headerSize - The size of the node header.
recordSize - The size of a record.
pos - The position of the node in the file.
Returns:
The size of a node, in bytes.