Class ShortComparator

    • Constructor Detail

      • ShortComparator

        public ShortComparator​(boolean ascending)
    • Method Detail

      • supportsNormalizedKey

        public boolean supportsNormalizedKey()
        Description copied from class: TypeComparator
        Checks whether the data type supports the creation of a normalized key for comparison.
        Specified by:
        supportsNormalizedKey in class TypeComparator<Short>
        Returns:
        True, if the data type supports the creation of a normalized key for comparison, false otherwise.
      • getNormalizeKeyLen

        public int getNormalizeKeyLen()
        Description copied from class: TypeComparator
        Gets the number of bytes that the normalized key would maximally take. A value of Integer.MAX_VALUE is interpreted as infinite.
        Specified by:
        getNormalizeKeyLen in class TypeComparator<Short>
        Returns:
        The number of bytes that the normalized key would maximally take.
      • isNormalizedKeyPrefixOnly

        public boolean isNormalizedKeyPrefixOnly​(int keyBytes)
        Description copied from class: TypeComparator
        Checks, whether the given number of bytes for a normalized is only a prefix to determine the order of elements of the data type for which this comparator provides the comparison methods. For example, if the data type is ordered with respect to an integer value it contains, then this method would return true, if the number of key bytes is smaller than four.
        Specified by:
        isNormalizedKeyPrefixOnly in class TypeComparator<Short>
        Returns:
        True, if the given number of bytes is only a prefix, false otherwise.
      • putNormalizedKey

        public void putNormalizedKey​(Short value,
                                     MemorySegment target,
                                     int offset,
                                     int numBytes)
        Description copied from class: TypeComparator
        Writes a normalized key for the given record into the target byte array, starting at the specified position and writing exactly the given number of bytes. Note that the comparison of the bytes is treating the bytes as unsigned bytes: int byteI = bytes[i] & 0xFF;

        If the meaningful part of the normalized key takes less than the given number of bytes, then it must be padded. Padding is typically required for variable length data types, such as strings. The padding uses a special character, either 0 or 0xff, depending on whether shorter values are sorted to the beginning or the end.

        This method is similar to NormalizableKey.copyNormalizedKey(MemorySegment, int, int). In the case that multiple fields of a record contribute to the normalized key, it is crucial that the fields align on the byte field, i.e. that every field always takes up the exact same number of bytes.

        Specified by:
        putNormalizedKey in class TypeComparator<Short>
        Parameters:
        value - The record for which to create the normalized key.
        target - The byte array into which to write the normalized key bytes.
        offset - The offset in the byte array, where to start writing the normalized key bytes.
        numBytes - The number of bytes to be written exactly.
        See Also:
        NormalizableKey.copyNormalizedKey(MemorySegment, int, int)
      • duplicate

        public ShortComparator duplicate()
        Description copied from class: TypeComparator
        Creates a copy of this class. The copy must be deep such that no state set in the copy affects this instance of the comparator class.
        Specified by:
        duplicate in class TypeComparator<Short>
        Returns:
        A deep copy of this comparator instance.