org.apache.ignite.ml.math.primitives.vector.storage

## Class SparseVectorStorage

- java.lang.Object
- - org.apache.ignite.ml.math.primitives.vector.storage.SparseVectorStorage

- All Implemented Interfaces:
    Externalizable, Serializable, Destroyable, VectorStorage, StorageConstants, StorageOpsMetrics

      public class SparseVectorStorage
      extends Object
      implements VectorStorage, StorageConstants

  Sparse, local, on-heap vector storage.
  See Also:
    Serialized Form

- - ### Field Summary

    - ### Fields inherited from interface org.apache.ignite.ml.math.StorageConstants

      `COLUMN_STORAGE_MODE, RANDOM_ACCESS_MODE, ROW_STORAGE_MODE, SEQUENTIAL_ACCESS_MODE, UNKNOWN_STORAGE_MODE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SparseVectorStorage()`
    `SparseVectorStorage(int size)`
    `SparseVectorStorage(Map<Integer,? extends Serializable> map, boolean cp)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `double[]` | `data()` Gets underlying array if `StorageOpsMetrics.isArrayBased()` returns `true` and all values in vector are Numbers.
    `boolean` | `equals(Object o)`
    `double` | `get(int i)` Gets element from vector by index and cast it to double.
    `<T extends Serializable> T` | `getRaw(int i)`
    `int` | `hashCode()`
    `it.unimi.dsi.fastutil.ints.IntSet` | `indexes()`
    `boolean` | `isArrayBased()` Checks if implementation is based on Java arrays.
    `boolean` | `isDense()` Checks if this implementation should be considered dense so that it explicitly represents every value.
    `boolean` | `isNumeric()`
    `Serializable[]` | `rawData()`
    `void` | `readExternal(ObjectInput in)`
    `void` | `set(int i, double v)`
    `void` | `setRaw(int i, Serializable v)`
    `int` | `size()`
    `void` | `writeExternal(ObjectOutput out)`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.apache.ignite.ml.math.Destroyable

      `destroy`

    - ### Methods inherited from interface org.apache.ignite.ml.math.StorageConstants

      `assertAccessMode, assertStorageMode`

- - ### Constructor Detail

    - #### SparseVectorStorage

          public SparseVectorStorage()

    - #### SparseVectorStorage

          public SparseVectorStorage(Map<Integer,? extends Serializable> map,
                                     boolean cp)

    - #### SparseVectorStorage

          public SparseVectorStorage(int size)

      Parameters:
        `size` - Vector size.

  - ### Method Detail

    - #### size

          public int size()

      Specified by:
        `size` in interface `VectorStorage`

    - #### get

          public double get(int i)

      Gets element from vector by index and cast it to double.
      Specified by:
        `get` in interface `VectorStorage`
      Parameters:
        `i` - Vector element index.
      Returns:
        Value obtained for given element index.

    - #### getRaw

          public <T extends Serializable> T getRaw(int i)

      Specified by:
        `getRaw` in interface `VectorStorage`
      Type Parameters:
        `T` - Type of stored element in vector.
      Parameters:
        `i` - Vector element index.
      Returns:
        Value obtained for given element index.

    - #### set

          public void set(int i,
                          double v)

      Specified by:
        `set` in interface `VectorStorage`
      Parameters:
        `i` - Vector element index.
        `v` - Value to set at given index.

    - #### setRaw

          public void setRaw(int i,
                             Serializable v)

      Specified by:
        `setRaw` in interface `VectorStorage`
      Parameters:
        `i` - Vector element index.
        `v` - Value to set at given index.

    - #### writeExternal

          public void writeExternal(ObjectOutput out)
                             throws IOException

      Specified by:
        `writeExternal` in interface `Externalizable`
      Throws:
        `IOException`

    - #### readExternal

          public void readExternal(ObjectInput in)
                            throws IOException,
                                   ClassNotFoundException

      Specified by:
        `readExternal` in interface `Externalizable`
      Throws:
        `IOException`
        `ClassNotFoundException`

    - #### isDense

          public boolean isDense()

      Checks if this implementation should be considered dense so that it explicitly represents every value.
      Specified by:
        `isDense` in interface `StorageOpsMetrics`

    - #### isArrayBased

          public boolean isArrayBased()

      Checks if implementation is based on Java arrays.
      Specified by:
        `isArrayBased` in interface `StorageOpsMetrics`

    - #### isNumeric

          public boolean isNumeric()

      Specified by:
        `isNumeric` in interface `StorageOpsMetrics`
      Returns:
        true if all stored data are values of Number class.

    - #### data

          public double[] data()

      Gets underlying array if `StorageOpsMetrics.isArrayBased()` returns `true` and all values in vector are Numbers. Returns `null` if in other cases.
      Specified by:
        `data` in interface `VectorStorage`
      See Also:
        `StorageOpsMetrics.isArrayBased()`

    - #### rawData

          public Serializable[] rawData()

      Specified by:
        `rawData` in interface `VectorStorage`
      Returns:
        Underlying array of serializable objects `StorageOpsMetrics.isArrayBased()` returns `true`. Returns `null` if in other cases.

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### indexes

          public it.unimi.dsi.fastutil.ints.IntSet indexes()

2021 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.11.0
Release Date | : September 11 2021