Class FSIndexComparatorImpl

  • All Implemented Interfaces:
    java.lang.Comparable<FSIndexComparator>, FSIndexComparator

    public class FSIndexComparatorImpl
    extends java.lang.Object
    implements FSIndexComparator
    Specifies the comparison to be used for an index, in terms of - the keys and the typeorder, in an order - the standard/reverse ordering
    • Field Detail

      • type

        private Type type
      • keySpecs

        private final java.util.List<java.lang.Object> keySpecs
      • directions

        private final IntVector directions
    • Constructor Detail

      • FSIndexComparatorImpl

        public FSIndexComparatorImpl()
      • FSIndexComparatorImpl

        private FSIndexComparatorImpl​(Type type,
                                      java.util.List<java.lang.Object> keySpecs,
                                      IntVector directions)
    • Method Detail

      • checkType

        private boolean checkType​(Type t)
      • setType

        public void setType​(Type type)
        Description copied from interface: FSIndexComparator
        Set the type of this comparator. Note that you can use this method more than once, in case you need to generate indexes that are identical except for the type.
        Specified by:
        setType in interface FSIndexComparator
        Parameters:
        type - The type of the index.
      • getTypeCode

        int getTypeCode()
      • addKey

        public int addKey​(Feature feat,
                          int compareKey)
        Description copied from interface: FSIndexComparator
        Add a new key.
        Specified by:
        addKey in interface FSIndexComparator
        Parameters:
        feat - The key feature.
        compareKey - The way to compare the key values.
        Returns:
        The number of the key.
      • addKey

        public int addKey​(LinearTypeOrder typeOrder,
                          int compareKey)
        Specified by:
        addKey in interface FSIndexComparator
        Parameters:
        typeOrder - the type order
        compareKey - the direction
        Returns:
        the number of the key
      • getKeyFeature

        public FeatureImpl getKeyFeature​(int key)
        Description copied from interface: FSIndexComparator
        Get the feature for this key.
        Specified by:
        getKeyFeature in interface FSIndexComparator
        Parameters:
        key - The number of the key.
        Returns:
        The corresponding feature, if it exists; null, else.
      • getKeyComparator

        public int getKeyComparator​(int key)
        Description copied from interface: FSIndexComparator
        Get the comparator for this key.
        Specified by:
        getKeyComparator in interface FSIndexComparator
        Parameters:
        key - The number of the key.
        Returns:
        The corresponding comparator, if it exists; -1, else.
      • equals

        public boolean equals​(java.lang.Object o)
        Equals including the type of the comparator
        Specified by:
        equals in interface FSIndexComparator
        Overrides:
        equals in class java.lang.Object
      • equalsWithoutType

        boolean equalsWithoutType​(FSIndexComparatorImpl comp)
        Compare two comparators, ignoring the type
        Parameters:
        comp - the other comparator to compare to
        Returns:
        true if they're the same comparator
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • isValid

        public boolean isValid()
        Description copied from interface: FSIndexComparator
        Validate that this comparator is valid with respect to the type system. Note that all types and features used to define this comparator must come from the same type system. Note that this method only returns true or false. It doesn't tell you what's actually wrong. Maybe we need to change that?
        Specified by:
        isValid in interface FSIndexComparator
        Returns:
        true iff all key features are appropriate for the type of this comparator.
      • compareTo

        public int compareTo​(FSIndexComparator o)
        Compares two FSIndexComparator instances. The code to compare two FSs is in the compare method of FsIndex_singletype.
        Specified by:
        compareTo in interface java.lang.Comparable<FSIndexComparator>
        See Also:
        Comparable.compareTo(Object)