Class LeafNode

java.lang.Object
org.grp1.index.Node
org.grp1.index.LeafNode
All Implemented Interfaces:
NodeChild

public class LeafNode extends Node
  • Field Details

    • maxNumOfKeys

      private final int maxNumOfKeys
      Represents the maximum number of keys
    • keys

      private List<Integer> keys
      Represents the keys of the node
    • buckets

      private List<Bucket> buckets
      Represents the buckets of the node
    • parent

      private InternalNode parent
      Represents the node that points to this node
    • previous

      private LeafNode previous
      Represents the previous node
    • next

      private LeafNode next
      Represents the next node
  • Constructor Details

    • LeafNode

      public LeafNode(LeafNode previous, LeafNode next, InternalNode parent, int maxNumOfKeys)
      Constructor to instantiate the leaf node
      Parameters:
      previous - The previous node
      next - The next node
      parent - The parent node
      maxNumOfKeys - The maximum number of keys
    • LeafNode

      public LeafNode(LeafNode previous, LeafNode next, InternalNode parent, List<Integer> keys, List<Bucket> buckets, int maxNumOfKeys)
      Constructor to instantiate the leaf node
      Parameters:
      previous - The previous node
      next - The next node
      parent - The parent node
      keys - The keys of the node
      buckets - The buckets of the node
      maxNumOfKeys - The maximum number of keys
  • Method Details

    • isFull

      public boolean isFull()
      The function to return the status of the node
      Specified by:
      isFull in class Node
      Returns:
      The status of the node whether it is full or not
    • size

      public int size()
      The function to return the size of the node
      Specified by:
      size in class Node
      Returns:
      The number of keys contained in this node
    • setPrevious

      public void setPrevious(LeafNode previous)
      The function to set the previous node
      Parameters:
      previous - The previous node
    • setParent

      public void setParent(InternalNode parent)
      The function to set the parent of the node
      Specified by:
      setParent in class Node
      Parameters:
      parent - The parent of the node
    • setRecords

      public void setRecords(ArrayList<Integer> keys, ArrayList<Bucket> buckets)
      The function to set the records to the node using the address
      Parameters:
      keys - The keys of the node
      buckets - The buckets that will contain an address pointing to the record
    • insertAddress

      public void insertAddress(Address newAddress, int key)
      The function to insert the address corresponding to the Record
      Parameters:
      newAddress - The address of the record
      key - The key of the record
    • insert

      public void insert(NodeChild newChild) throws LeafFullException
      The function to insert the new child
      Specified by:
      insert in class Node
      Parameters:
      newChild - The new child to be inserted
      Throws:
      LeafFullException
    • getKey

      public int getKey()
      The function to return the minimum key
      Returns:
      The minimum key
    • getKeyByIndex

      public int getKeyByIndex(int index)
      The function to return the key by index
      Specified by:
      getKeyByIndex in class Node
      Parameters:
      index - The index of the key
      Returns:
      The corresponding index
    • getRecordIndex

      public int getRecordIndex(int key)
    • getRecordIndexLowerBound

      public int getRecordIndexLowerBound(int key)
      The function to return the lower bound index of the node
      Parameters:
      key - The key of the record
      Returns:
      The index lower bound corresponding to the key
    • clear

      public void clear()
      The function to clear the content of the node
    • getKeys

      public List<Integer> getKeys()
      The function to return the list of keys of the node
      Returns:
      The keys of the node
    • getBuckets

      public List<Bucket> getBuckets()
      The function to return the buckets of the node
      Returns:
      The buckets of the node
    • delete

      public void delete(int index)
      The function that deletes an entry based on the index
      Specified by:
      delete in class Node
      Parameters:
      index - The index of the entry to be deleted
    • getBucket

      public Bucket getBucket(int key)
      The function to return the bucket based on the key
      Parameters:
      key - The key of the bucket
      Returns:
      The bucket corresponding to the key
    • getBucketByIndex

      public Bucket getBucketByIndex(int index)
      The function to return the bucket by index
      Parameters:
      index - The index of the bucket
      Returns:
      The bucket corresponding to the index
    • getChildAsNodeChild

      public NodeChild getChildAsNodeChild(int index)
      The function to return the child node as ChildNode
      Specified by:
      getChildAsNodeChild in class Node
      Parameters:
      index - The index of the child node
      Returns:
      The corresponding child node
    • getNext

      public LeafNode getNext()
      The function to return the next ndoe
      Returns:
      The next child ndoe
    • setNext

      public void setNext(LeafNode next)
      The function to set the next node
      Parameters:
      next - The next node
    • splitBucketList

      public List<Bucket> splitBucketList(int x)
      The function to split the bucket list
      Parameters:
      x - The boundary between the left and right list
      Returns:
      The split list of nodes
    • splitKeyList

      public List<Integer> splitKeyList(int x)
      The function to split the key list
      Parameters:
      x - The boundary between the left and right ist
      Returns:
      The split list of nodes
    • getMaxNumOfKeys

      public int getMaxNumOfKeys()
      The function to return the maximum number of keys
      Returns:
      The maximum number of keys
    • getMinNumOfKeys

      public int getMinNumOfKeys()
      The function to return the minimum number of keys
      Returns:
      The minimum number of keys