Interface Tuple

  • All Superinterfaces:
    Pinnable
    All Known Implementing Classes:
    HeapFilePageTuple, PageTuple, TupleLiteral

    public interface Tuple
    extends Pinnable
    This interface provides the operations that can be performed with a tuple. In relational database theory, a tuple is an ordered set of attribute-value pairs, but in this implementation the tuple's data and its schema are kept completely separate. This tuple interface simply provides an index-accessed collection of values; the schema would be represented separately using the Schema class.

    Different implementations of this interface store their data in different places. Some tuple implementations (e.g. subclasses of PageTuple) load and store values straight out of a tuple file, and thus their data is backed by a buffer page that can be written back to the filesystem. Other tuples may exist entirely in memory, with no corresponding back-end storage.

    SQL data types are mapped to/from Java data types as follows:

    • TINYINT - byte (8 bit signed integer)
    • SMALLINT - short (16 bit signed integer)
    • INTEGER (INT) - int (32 bit signed integer)
    • BIGINT - long (64 bit signed integer)
    • CHAR and VARCHAR - java.lang.String
    • NUMERIC - java.math.BigDecimal
    See Also:
    Schema
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      int getColumnCount()
      Returns a count of the number of columns in the tuple.
      java.lang.Object getColumnValue​(int colIndex)
      Returns the value of a column, or null if the column's SQL value is NULL.
      FilePointer getExternalReference()
      This method returns an external reference to the tuple, which can be stored and used to look up this tuple.
      boolean isDiskBacked()
      Returns true if this tuple is backed by a disk page that must be kept in memory as long as the tuple is in use.
      boolean isNullValue​(int colIndex)
      Returns true if the specified column's value is NULL.
      void setColumnValue​(int colIndex, java.lang.Object value)
      Sets the value of a column.
    • Method Detail

      • isDiskBacked

        boolean isDiskBacked()
        Returns true if this tuple is backed by a disk page that must be kept in memory as long as the tuple is in use. Some tuple implementations allocate memory to store their values, and are therefore not affected if disk pages are evicted from the Buffer Manager. Others are backed by disk pages, and the disk page cannot be evicted until the tuple is no longer being used. In cases where a plan-node needs to hold onto a tuple for a long time (e.g. for sorting or grouping), the plan node should probably make a copy of disk-backed tuples, or materialize the results, etc.
        Returns:
        true if the tuple is backed by a disk page, or false if the tuple's data is allocated in the memory heap.
      • getColumnCount

        int getColumnCount()
        Returns a count of the number of columns in the tuple.
        Returns:
        a count of the number of columns in the tuple.
      • isNullValue

        boolean isNullValue​(int colIndex)
        Returns true if the specified column's value is NULL.
        Parameters:
        colIndex - the index of the column to check for NULLness.
        Returns:
        true if the specified column is NULL, false otherwise.
      • getColumnValue

        java.lang.Object getColumnValue​(int colIndex)
        Returns the value of a column, or null if the column's SQL value is NULL.
        Parameters:
        colIndex - the index of the column to retrieve the value for
        Returns:
        the value of the column, or null if the column is NULL.
      • setColumnValue

        void setColumnValue​(int colIndex,
                            java.lang.Object value)
        Sets the value of a column. If null is passed, the column is set to the SQL NULL value.
        Parameters:
        colIndex - the index of the column to set the value for
        value - the value to store for the column, or null if the column should be set to NULL.
      • getExternalReference

        FilePointer getExternalReference()
        This method returns an external reference to the tuple, which can be stored and used to look up this tuple. The external reference is represented as a file-pointer. Implementations can throw an UnsupportedOperationException if the kind of tuple doesn't support an external reference.
        Returns:
        a file-pointer that can be used to look up this tuple
        Throws:
        java.lang.UnsupportedOperationException - if this operation is unsupported