Package org.grp1.storage
Class Block
java.lang.Object
org.grp1.storage.Block
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intRepresents the number of records inside of this blockprivate final Record[]Represents the records inside of this block -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteRecord(int index) The function to delete a record in a diskintThe function to get the number of records inside of this blockgetRecord(int index) The function to get the record based on the index / offsetRecord[]The function to return all of the records inside of a blockvoidinsertRecord(Record obj) The function to insert the recordbooleanisEmpty()The function to return whether the block is empty or notbooleanisFull()The function to return whether the block is full or notprotected booleanisInvalidIndex(int index) The function to check whether the index is a valid index
-
Field Details
-
records
Represents the records inside of this block -
numOfRecord
private int numOfRecordRepresents the number of records inside of this block
-
-
Constructor Details
-
Block
public Block(int size) The constructor to instantiate a block- Parameters:
size-
-
-
Method Details
-
getNumberOfRecords
public int getNumberOfRecords()The function to get the number of records inside of this block- Returns:
- The number of records inside of the block
-
isEmpty
public boolean isEmpty()The function to return whether the block is empty or not- Returns:
- The status of the block whether it is empty or not
-
isFull
public boolean isFull()The function to return whether the block is full or not- Returns:
- The status of the block whether it is full or not
-
getRecord
The function to get the record based on the index / offset- Parameters:
index- The index of the block- Returns:
- The corresponding record based on the index
- Throws:
InvalidIndexException
-
getRecords
The function to return all of the records inside of a block- Returns:
-
insertRecord
The function to insert the record- Parameters:
obj- The record to be inserted- Throws:
BlockFullException
-
deleteRecord
The function to delete a record in a disk- Parameters:
index- The index of a record to be deleted- Throws:
InvalidIndexException
-
isInvalidIndex
protected boolean isInvalidIndex(int index) The function to check whether the index is a valid index- Parameters:
index- The index of the record- Returns:
- The status of the index whether it is valid or not
-