Class IndexImpl

  • All Implemented Interfaces:
    Index

    public class IndexImpl
    extends Object
    implements Index
    Access table (logical) index. Logical indexes are backed for IndexData, where one or more logical indexes could be backed by the same data.
    Author:
    Tim McCune
    • Field Detail

      • PRIMARY_KEY_INDEX_TYPE

        public static final byte PRIMARY_KEY_INDEX_TYPE
        index type for primary key indexes
        See Also:
        Constant Field Values
      • FOREIGN_KEY_INDEX_TYPE

        public static final byte FOREIGN_KEY_INDEX_TYPE
        index type for foreign key indexes
        See Also:
        Constant Field Values
    • Method Detail

      • getIndexData

        public IndexData getIndexData()
      • getIndexNumber

        public int getIndexNumber()
      • getIndexFlags

        public byte getIndexFlags()
      • getUniqueEntryCount

        public int getUniqueEntryCount()
      • getUniqueEntryCountOffset

        public int getUniqueEntryCountOffset()
      • getProperties

        public PropertyMap getProperties()
                                  throws IOException
        Description copied from interface: Index
        Returns the properties for this index. An index has a property block of its own, separate from the block of the column it is named after.
        Specified by:
        getProperties in interface Index
        Throws:
        IOException
      • isPrimaryKey

        public boolean isPrimaryKey()
        Specified by:
        isPrimaryKey in interface Index
      • isForeignKey

        public boolean isForeignKey()
        Specified by:
        isForeignKey in interface Index
      • shouldIgnoreNulls

        public boolean shouldIgnoreNulls()
        Description copied from interface: Index
        Whether or not null values are actually recorded in the index.
        Specified by:
        shouldIgnoreNulls in interface Index
      • isUnique

        public boolean isUnique()
        Description copied from interface: Index
        Whether or not index entries must be unique.

        Some notes about uniqueness:

        • Access does not seem to consider multiple null entries invalid for a unique index
        • text indexes collapse case, and Access seems to compare only the index entry bytes, therefore two strings which differ only in case will violate the unique constraint
        Specified by:
        isUnique in interface Index
      • isRequired

        public boolean isRequired()
        Description copied from interface: Index
        Whether or not values are required for index columns.
        Specified by:
        isRequired in interface Index
      • getColumnCount

        public int getColumnCount()
        Specified by:
        getColumnCount in interface Index
      • newCursor

        public CursorBuilder newCursor()
        Description copied from interface: Index
        Convenience method for constructing a new CursorBuilder for this Index.
        Specified by:
        newCursor in interface Index
      • isInitialized

        public boolean isInitialized()
        Whether or not the complete index state has been read.
      • initialize

        public void initialize()
                        throws IOException
        Forces initialization of this index (actual parsing of index pages). normally, the index will not be initialized until the entries are actually needed.
        Throws:
        IOException
      • cursor

        public IndexData.EntryCursor cursor​(Object[] startRow,
                                            boolean startInclusive,
                                            Object[] endRow,
                                            boolean endInclusive)
                                     throws IOException
        Gets a new cursor for this index, narrowed to the range defined by the given startRow and endRow.

        Forces index initialization.

        Parameters:
        startRow - the first row of data for the cursor, or null for the first entry
        startInclusive - whether or not startRow is inclusive or exclusive
        endRow - the last row of data for the cursor, or null for the last entry
        endInclusive - whether or not endRow is inclusive or exclusive
        Throws:
        IOException
      • constructIndexRowFromEntry

        public Object[] constructIndexRowFromEntry​(Object... values)
        Constructs an array of values appropriate for this index from the given column values, expected to match the columns for this index.
        Returns:
        the appropriate sparse array of data
        Throws:
        IllegalArgumentException - if the wrong number of values are provided
      • constructPartialIndexRowFromEntry

        public Object[] constructPartialIndexRowFromEntry​(Object filler,
                                                          Object... values)
        Constructs an array of values appropriate for this index from the given column values, possibly only providing a prefix subset of the index columns (at least one value must be provided). If a prefix entry is provided, any missing, trailing index entry values will use the given filler value.
        Returns:
        the appropriate sparse array of data
        Throws:
        IllegalArgumentException - if at least one value is not provided
      • constructIndexRow

        public Object[] constructIndexRow​(String colName,
                                          Object value)
        Constructs an array of values appropriate for this index from the given column value.
        Returns:
        the appropriate sparse array of data or null if not all columns for this index were provided
      • constructPartialIndexRow

        public Object[] constructPartialIndexRow​(Object filler,
                                                 String colName,
                                                 Object value)
        Constructs an array of values appropriate for this index from the given column value, which must be the first column of the index. Any missing, trailing index entry values will use the given filler value.
        Returns:
        the appropriate sparse array of data or null if no prefix list of columns for this index were provided
      • constructIndexRow

        public Object[] constructIndexRow​(Map<String,​?> row)
        Constructs an array of values appropriate for this index from the given column values.
        Returns:
        the appropriate sparse array of data or null if not all columns for this index were provided
      • constructPartialIndexRow

        public Object[] constructPartialIndexRow​(Object filler,
                                                 Map<String,​?> row)
        Constructs an array of values appropriate for this index from the given column values, possibly only using a subset of the given values. A partial row can be created if one or more prefix column values are provided. If a prefix can be found, any missing, trailing index entry values will use the given filler value.
        Returns:
        the appropriate sparse array of data or null if no prefix list of columns for this index were provided