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

## Class DenseVectorStorage

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

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

      public class DenseVectorStorage
      extends Object
      implements VectorStorage

  Array based `VectorStorage` implementation.
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DenseVectorStorage()` IMPL NOTE required by `Externalizable`.
    `DenseVectorStorage(double[] data)`
    `DenseVectorStorage(int size)`
    `DenseVectorStorage(Serializable[] data)`

  - ### 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()`
    `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`

- - ### Constructor Detail

    - #### DenseVectorStorage

          public DenseVectorStorage()

      IMPL NOTE required by `Externalizable`.

    - #### DenseVectorStorage

          public DenseVectorStorage(int size)

      Parameters:
        `size` - Vector size.

    - #### DenseVectorStorage

          public DenseVectorStorage(double[] data)

      Parameters:
        `data` - Backing data array.

    - #### DenseVectorStorage

          public DenseVectorStorage(Serializable[] data)

      Parameters:
        `data` - Backing data array.

  - ### 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.

    - #### isArrayBased

          public boolean isArrayBased()

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

    - #### 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.

    - #### 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`

    - #### isNumeric

          public boolean isNumeric()

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

    - #### 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`

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

2021 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.10.0
Release Date | : March 10 2021