Interface TupleFile

  • All Known Subinterfaces:
    HashedTupleFile, SequentialTupleFile
    All Known Implementing Classes:
    HeapTupleFile

    public interface TupleFile
    This interface defines the most basic operations that all files storing tuples must support. The operations include the ability to scan through all tuples in the file, and to add, modify and delete tuples.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      Tuple addTuple​(Tuple tuple)
      Adds the specified tuple into the table file, returning a new object corresponding to the actual tuple added to the table.
      void analyze()
      Analyzes the tuple data in the file, updating the file's statistics.
      void deleteTuple​(Tuple tuple)
      Deletes the specified tuple from the table.
      DBFile getDBFile()
      Returns the DBFile object that this tuple file is stored in.
      Tuple getFirstTuple()
      Returns the first tuple in this table file, or null if there are no tuples in the file.
      TupleFileManager getManager()
      Returns the manager class for this kind of tuple file.
      Tuple getNextTuple​(Tuple tuple)
      Returns the tuple that follows the specified tuple, or null if there are no more tuples in the file.
      Schema getSchema()
      Returns the schema of tuples stored in this tuple file.
      TableStats getStats()
      Returns statistics describing the data in this tuple file.
      Tuple getTuple​(FilePointer fptr)
      Returns the tuple corresponding to the specified file pointer.
      void optimize()
      Optimizes the tuple file's layout or other characteristics to ensure optimal performance and space usage.
      void updateTuple​(Tuple tuple, java.util.Map<java.lang.String,​java.lang.Object> newValues)
      Modifies the values in the specified tuple.
      java.util.List<java.lang.String> verify()
      Verifies the tuple file's internal storage format, identifying any potential structural errors in the file.
    • Method Detail

      • getManager

        TupleFileManager getManager()
        Returns the manager class for this kind of tuple file.
        Returns:
        the manager class for this kind of tuple file.
      • getDBFile

        DBFile getDBFile()
        Returns the DBFile object that this tuple file is stored in.
        Returns:
        the DBFile object that this tuple file is stored in.
        Design Note:
        (donnie) For tuple files that are comprised of multiple physical files, this file will be the top-level file that records details such as all the other files necessary for that storage format.
      • getSchema

        Schema getSchema()
        Returns the schema of tuples stored in this tuple file.
        Returns:
        the schema of tuples stored in this tuple file.
      • getStats

        TableStats getStats()
        Returns statistics describing the data in this tuple file. Note that there is no corresponding "set-stats" method, because the analyze() method is the intended way of updating a tuple file's statistics.
        Returns:
        statistics describing the data in this tuple file.
      • getFirstTuple

        Tuple getFirstTuple()
        Returns the first tuple in this table file, or null if there are no tuples in the file.
        Returns:
        the first tuple, or null if the table is empty
      • getNextTuple

        Tuple getNextTuple​(Tuple tuple)
        Returns the tuple that follows the specified tuple, or null if there are no more tuples in the file. The implementation must operate correctly regardless of whether the input tuple is pinned or unpinned.
        Parameters:
        tuple - the "previous" tuple in the table. This tuple may be pinned or unpinned.
        Returns:
        the tuple following the previous tuple, or null if the previous tuple is the last one in the table
      • getTuple

        Tuple getTuple​(FilePointer fptr)
                throws InvalidFilePointerException
        Returns the tuple corresponding to the specified file pointer. This method is used by other features in the database, such as indexes.
        Parameters:
        fptr - a file-pointer specifying the tuple to retrieve
        Returns:
        the tuple referenced by fptr
        Throws:
        InvalidFilePointerException - if the specified file-pointer doesn't actually point to a real tuple.
      • addTuple

        Tuple addTuple​(Tuple tuple)
        Adds the specified tuple into the table file, returning a new object corresponding to the actual tuple added to the table.
        Parameters:
        tuple - a tuple object containing the values to add to the table
        Returns:
        a tuple object actually backed by this table
      • updateTuple

        void updateTuple​(Tuple tuple,
                         java.util.Map<java.lang.String,​java.lang.Object> newValues)
        Modifies the values in the specified tuple.
        Parameters:
        tuple - the tuple to modify in the table
        newValues - a map containing the name/value pairs to use to update the tuple. Values in this map will be coerced to the column-type of the specified columns. Only the columns being modified need to be specified in this collection.
      • deleteTuple

        void deleteTuple​(Tuple tuple)
        Deletes the specified tuple from the table.
        Parameters:
        tuple - the tuple to delete from the table
      • analyze

        void analyze()
        Analyzes the tuple data in the file, updating the file's statistics.
      • verify

        java.util.List<java.lang.String> verify()
        Verifies the tuple file's internal storage format, identifying any potential structural errors in the file. Errors are returned as a list of error-message strings, each one reporting some error that was found.
        Returns:
        a list of error-message strings describing issues identified during verification. The list will be empty if the file has no identifiable errors.
      • optimize

        void optimize()
        Optimizes the tuple file's layout or other characteristics to ensure optimal performance and space usage. Tuple file formats that don't provide any optimization capabilities can simply return when this is called.