Interface IndexManager

  • All Known Implementing Classes:
    BasicIndexManager

    public interface IndexManager
    This interface specifies all operations that are necessary for supporting indexes in NanoDB. Indexes are implemented as tuple files with a schema containing the indexed columns, as well as a tuple-pointer column that references the indexed tuples. Therefore, many of the specific lookup operations are provided directly by the underlying TupleFile implementation that exposes these operations.
    • Field Detail

      • COLNAME_TUPLEPTR

        static final java.lang.String COLNAME_TUPLEPTR
        A constant specifying the name of the column that will hold the table's tuple pointer in an index file.
        See Also:
        Constant Field Values
    • Method Detail

      • indexExists

        boolean indexExists​(java.lang.String tableName,
                            java.lang.String indexName)
      • createIndex

        void createIndex​(IndexInfo indexInfo,
                         java.lang.String indexName)
      • createUnnamedIndex

        void createUnnamedIndex​(IndexInfo indexInfo)
      • openIndex

        IndexInfo openIndex​(TableInfo tableInfo,
                            java.lang.String indexName)
        This method opens the data file corresponding to the specified index name and reads in the index's details. If the index is already open then the cached data is simply returned.
        Parameters:
        tableInfo - the table that the index is defined on
        indexName - the name of the index to open. Indexes are not referenced directly except by CREATE/ALTER/DROP INDEX statements, so these index names are stored in the table schema files, and are generally opened when the optimizer needs to know what indexes are available.
        Returns:
        an object representing the details of the open index
        Throws:
        java.io.FileNotFoundException - if no index-file exists for the index; in other words, it doesn't yet exist.
        java.io.IOException - if an IO error occurs when attempting to open the index.
      • loadIndexInfo

        void loadIndexInfo​(IndexInfo indexInfo)
        This method loads the details for the specified index.
        Parameters:
        indexInfo - the index information object to populate. When this is passed in, it only contains the index's name, the name of the table the index is specified on, and the opened database file to read the data from.
        Throws:
        java.io.IOException - if an IO error occurs when attempting to load the index's details.
      • saveIndexInfo

        void saveIndexInfo​(IndexInfo indexInfo)
        This method initializes a newly created index file, using the details specified in the passed-in IndexInfo object.
        Parameters:
        indexInfo - This object is an in/out parameter. It is used to specify the name and details of the new index being created. When the index is successfully created, the object is updated with the actual file that the index's data is stored in.
        Throws:
        java.io.IOException - if the file cannot be created, or if an error occurs while storing the initial index data.
      • verifyIndex

        java.util.List<java.lang.String> verifyIndex​(IndexInfo indexInfo)
        This function allows an index to be verified for proper structure and contents.
        Parameters:
        indexInfo - the index to verify
        Throws:
        java.io.IOException - if an IO error occurs while verifying the index
        To Do:
        Should this be in this interface?
      • analyzeIndex

        void analyzeIndex​(IndexInfo indexInfo)
      • optimizeIndex

        void optimizeIndex​(IndexInfo indexInfo)
        This method performs whatever optimization is suitable for the specific kind of index that is implemented. For example, if the logical and physical ordering of pages is widely different, this method can resolve that kind of issue.
        Parameters:
        indexInfo - the index to optimize
        Throws:
        java.io.IOException - if an IO error occurs while optimizing the index
        To Do:
        Should this be in this interface?
      • closeIndex

        void closeIndex​(IndexInfo indexInfo)
      • dropIndex

        void dropIndex​(TableInfo tableInfo,
                       java.lang.String indexName)