Class SparseVectorCommitTimeUpdater


  • public class SparseVectorCommitTimeUpdater
    extends Object
    Listen for changes to a specified datastore and it's field. Once a commit has been performed then a ReadOnlySparseVector object is wrapped around the IVector. This step is necessary when using ReadOnlySparseVector type for fields the default AP IVector that an array is wrapped around does not know how to properly decode the "crunched" down array implementation used in the sparse array.
    Author:
    ActiveViam
    • Constructor Detail

      • SparseVectorCommitTimeUpdater

        public SparseVectorCommitTimeUpdater​(com.qfs.store.IDatastore datastore,
                                             double densityProperty,
                                             double defaultValue)
        Will generate sparse vectors
        Parameters:
        datastore - The datastore
        densityProperty - The density threshold that triggers the sparse representation bellows
        defaultValue - The sparse default value (should be 0)
    • Method Detail

      • register

        public void register​(String storeName,
                             List<String> fields)
        Listen for changes to the specified datastore and it's field. Once a commit has been performed then a ReadOnlySparseVector object is wrapped around the IVector.
        Parameters:
        storeName - the store which we will listen to
        fields - the fields of the store we will listen to.
      • createSparseVector

        protected double[] createSparseVector​(int[] scenarioIds,
                                              double[] pnls,
                                              Integer vectorLength)
        This is intended to be used in order to avoid the expansion and re-compaction effect. If the data is already represented as sparse (scenarios + values), the source can directly send it as is, and the commit handle will take care of it.
        Parameters:
        scenarioIds - The list of non sparse scenarios
        pnls - The list of values corresponding to the scenarios
        vectorLength - The size of the original vector
        Returns:
        A buffer that is compacted or not depending on the sparse value density