Class Block

java.lang.Object
org.grp1.storage.Block

public class Block extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private int
    Represents the number of records inside of this block
    private final Record[]
    Represents the records inside of this block
  • Constructor Summary

    Constructors
    Constructor
    Description
    Block(int size)
    The constructor to instantiate a block
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    deleteRecord(int index)
    The function to delete a record in a disk
    int
    The function to get the number of records inside of this block
    getRecord(int index)
    The function to get the record based on the index / offset
    The function to return all of the records inside of a block
    void
    The function to insert the record
    boolean
    The function to return whether the block is empty or not
    boolean
    The function to return whether the block is full or not
    protected boolean
    isInvalidIndex(int index)
    The function to check whether the index is a valid index

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • records

      private final Record[] records
      Represents the records inside of this block
    • numOfRecord

      private int numOfRecord
      Represents 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

      public Record getRecord(int index) throws InvalidIndexException
      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

      public Record[] getRecords()
      The function to return all of the records inside of a block
      Returns:
    • insertRecord

      public void insertRecord(Record obj) throws BlockFullException
      The function to insert the record
      Parameters:
      obj - The record to be inserted
      Throws:
      BlockFullException
    • deleteRecord

      public void deleteRecord(int index) throws InvalidIndexException
      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