Class RIDList


  • final class RIDList
    extends java.lang.Object
    This is an optimization to help sorting over a column in a table. It is an aid for sorting rows in a query without having to resort to cell lookup. It uses memory to speed up sorting.

    Sorting data is a central part of any database system. This object maintains a list of values that represent each cell in a column relationally.

    For example, consider the following data in a column:

    { 'a', 'g', 'i', 'b', 'a' }

    A RID list is a set of integer values that represents a column relationally. So the above column data could be represented in a RID list as:

    { 1, 3, 4, 2, 1 }

    If 'c' is inserted into the above list, there is not an integer value that we can use to represent this cell. In this case, the RID list is renumbered to make room for the insertion.

    • Field Detail

      • table_name

        private TableName table_name
        The TableName of the table.
      • column_name

        private java.lang.String column_name
        The name of the column of this rid list.
      • column

        private int column
        The column in the master table.
      • set_list

        private BlockIntegerList set_list
        The sorted list of rows in this set. This is sorted from min to max (not sorted by row number - sorted by entity row value).
      • rid_list

        private IntegerVector rid_list
        The contents of our list.
      • hash_rid_difference

        private int hash_rid_difference
        The difference between each hash when the uid_list was last created or rehashed.
      • set_comparator

        private IndexComparator set_comparator
        The IndexComparator that we use to refer elements in the set to actual data objects.
      • is_built

        private boolean is_built
        Set to true if this list has been fully built.
      • build_state

        private int build_state
        The RID list build state. 0 - list not built. 1 - stage 1 (set_list being built). 2 - state 2 (rid_list being built). 3 - pending modifications. 4 - finished
      • concurrent_modification_info

        private IntegerVector concurrent_modification_info
        A list of modifications made to the index while it is being built.
      • concurrent_modification_data

        private java.util.ArrayList concurrent_modification_data
      • modification_lock

        private java.lang.Object modification_lock
      • request_processing

        private boolean request_processing
        Set to true if a request to build the rid list is on the event dispatcher.
    • Method Detail

      • Debug

        public final DebugLogger Debug()
        Returns a DebugLogger object that we can use to log debug messages.
      • setupComparator

        private void setupComparator()
        Sets the internal comparator that enables us to sort and lookup on the data in this column.
      • getCellContents

        private TObject getCellContents​(int row)
        Gets the cell at the given row in the column of the master table.
      • calcHashRIDDifference

        private void calcHashRIDDifference​(int size)
        Calculates the 'hash_rid_difference' variable. This dictates the difference between hashing entries.
      • rehashRIDList

        private int rehashRIDList​(int old_rid_place)
        Rehashes the entire rid list. This goes through the entire list from first sorted entry to last and spaces out each rid so that there's 16 numbers between each entry.
      • insertRID

        void insertRID​(TObject cell,
                       int row)
        Algorithm for inserting a new row into the rid table. For most cases this should be a very fast method.

        NOTE: This must never be called from anywhere except inside MasterTableDataStore.

        Parameters:
        cell - the cell to insert into the list.
        row - the row number.
      • removeRID

        void removeRID​(int row)
        Removes a RID entry from the given row. This MUST only be called when the row is perminantly removed from the table (eg. by the row garbage collector).

        NOTE: This must never be called from anywhere except inside MasterTableDataStore.

      • requestBuildRIDList

        void requestBuildRIDList()
        Requests that a rid_list should be built for this column. The list will be built on the database dispatcher thread.
      • createRIDCache

        private void createRIDCache()
        If rid_list is null then create it now.

        NOTE: This must never be called from anywhere except inside MasterTableDataStore.

      • isBuilt

        boolean isBuilt()
        Quick way of determining if the RID list has been built.
      • sortedSet

        BlockIntegerList sortedSet​(IntegerVector row_set)
        Given an unsorted set of rows in this table, this will return the row list sorted in descending order. This only uses the information from within this list to make up the sorted result, and does not reference any data in the master table.

        SYNCHRONIZATION: This does not lock the master_table because it doesn't use any information in it.