Class ReadOnlySparseVector.ReadOnlySparseVectorBinding

  • All Implemented Interfaces:
    com.qfs.vector.IVectorBinding
    Enclosing class:
    ReadOnlySparseVector

    public static class ReadOnlySparseVector.ReadOnlySparseVectorBinding
    extends com.qfs.vector.binding.impl.GenericVectorBinding
    Custom binding to use more efficient custom ReadOnlySparseVector methods for aggregation methods: plus, minus and copyFrom. We are trying to avoid calling getDouble() for every index in the vector which ultimately calls getExplicitValueIndex() which takes O(N). This leads to a total time complexity of O(N2) for operations that use loops to call getDouble() for each element in a ReadOnlySparseVector - such as the aggregation functions. Instead of retrieving each double from the ReadOnlySparseVector to perform an operation, we can instead perform the operation in the ReadOnlySparseVector its-self. This allows us to keep track of where the Explicit values are located in the compressed representation of the vector rather than searching for a specific index for every Explicit value. This allows us to perform the aggregation operations in O(N) time and O(1) space.
    • Field Summary

      • Fields inherited from class com.qfs.vector.binding.impl.GenericVectorBinding

        INSTANCE
      • Fields inherited from class com.qfs.vector.binding.impl.AVectorBinding

        UNSAFE
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void copyFrom​(com.qfs.vector.IVector source, com.qfs.vector.IVector destination)  
      void minus​(com.qfs.vector.IVector source, com.qfs.vector.IVector destination)  
      void plus​(com.qfs.vector.IVector source, com.qfs.vector.IVector destination)  
      • Methods inherited from class com.qfs.vector.binding.impl.GenericVectorBinding

        applyAsDouble, applyAsFloat, applyAsInt, applyAsLong, checkIndex, equals, getInstance, minusNegativeValues, minusPositiveValues, plusNegativeValues, plusPositiveValues
      • Methods inherited from class com.qfs.vector.binding.impl.AVectorBinding

        acquireFence, getMaxPos, getMaxUnroll, getPos, releaseFence
    • Constructor Detail

      • ReadOnlySparseVectorBinding

        public ReadOnlySparseVectorBinding()
    • Method Detail

      • plus

        public final void plus​(com.qfs.vector.IVector source,
                               com.qfs.vector.IVector destination)
        Specified by:
        plus in interface com.qfs.vector.IVectorBinding
        Overrides:
        plus in class com.qfs.vector.binding.impl.GenericVectorBinding
      • minus

        public final void minus​(com.qfs.vector.IVector source,
                                com.qfs.vector.IVector destination)
        Specified by:
        minus in interface com.qfs.vector.IVectorBinding
        Overrides:
        minus in class com.qfs.vector.binding.impl.GenericVectorBinding
      • copyFrom

        public final void copyFrom​(com.qfs.vector.IVector source,
                                   com.qfs.vector.IVector destination)
        Specified by:
        copyFrom in interface com.qfs.vector.IVectorBinding
        Overrides:
        copyFrom in class com.qfs.vector.binding.impl.GenericVectorBinding