org.apache.ignite.ml.util

## Class Utils

- java.lang.Object
- - org.apache.ignite.ml.util.Utils

-     public final class Utils
      extends Object

  Class with various utility methods.

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <T> Stream<T>` | `asStream(Iterator<T> iter)` Convert given iterator to a stream.
    `static <T> Stream<T>` | `asStream(Iterator<T> iter, long cnt)` Convert given iterator to a stream with known count of entries.
    `static <T> T` | `copy(T orig)` Perform deep copy of an object.
    `static <T extends Serializable> T` | `deserialize(byte[] o)` Deserialized object represented as a byte array.
    `static int[]` | `selectKDistinct(int n, int k)` Select k distinct integers from range [0, n) with reservoir sampling: https://en.wikipedia.org/wiki/Reservoir_sampling.
    `static int[]` | `selectKDistinct(int n, int k, Random rand)` Select k distinct integers from range [0, n) with reservoir sampling: https://en.wikipedia.org/wiki/Reservoir_sampling.
    `static <T extends Serializable> byte[]` | `serialize(T o)` Serialized the specified object.

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

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

- - ### Method Detail

    - #### copy

          public static <T> T copy(T orig)

      Perform deep copy of an object.
      Type Parameters:
        `T` - Class of original object;
      Parameters:
        `orig` - Original object.
      Returns:
        Deep copy of original object.

    - #### selectKDistinct

          public static int[] selectKDistinct(int n,
                                              int k,
                                              Random rand)

      Select k distinct integers from range [0, n) with reservoir sampling: https://en.wikipedia.org/wiki/Reservoir_sampling.
      Parameters:
        `n` - Number specifying left end of range of integers to pick values from.
        `k` - Count specifying how many integers should be picked.
        `rand` - RNG.
      Returns:
        Array containing k distinct integers from range [0, n);

    - #### selectKDistinct

          public static int[] selectKDistinct(int n,
                                              int k)

      Select k distinct integers from range [0, n) with reservoir sampling: https://en.wikipedia.org/wiki/Reservoir_sampling. Equivalent to `selectKDistinct(n, k, new Random())`.
      Parameters:
        `n` - Number specifying left end of range of integers to pick values from.
        `k` - Count specifying how many integers should be picked.
      Returns:
        Array containing k distinct integers from range [0, n);

    - #### asStream

          public static <T> Stream<T> asStream(Iterator<T> iter,
                                               long cnt)

      Convert given iterator to a stream with known count of entries.
      Type Parameters:
        `T` - Type of entries.
      Parameters:
        `iter` - Iterator.
        `cnt` - Count.
      Returns:
        Stream constructed from iterator.

    - #### asStream

          public static <T> Stream<T> asStream(Iterator<T> iter)

      Convert given iterator to a stream.
      Type Parameters:
        `T` - Iterator content type.
      Parameters:
        `iter` - Iterator.
      Returns:
        Stream constructed from iterator.

    - #### serialize

          public static <T extends Serializable> byte[] serialize(T o)

      Serialized the specified object.
      Parameters:
        `o` - Object to be serialized.
      Returns:
        Serialized object as byte array.

    - #### deserialize

          public static <T extends Serializable> T deserialize(byte[] o)

      Deserialized object represented as a byte array.
      Type Parameters:
        `T` - Type of serialized object.
      Parameters:
        `o` - Serialized object.
      Returns:
        Deserialized object.

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