org.eclipse.january.dataset

## Class LazyDatasetBase

- java.lang.Object
- - org.eclipse.january.dataset.LazyDatasetBase

- All Implemented Interfaces:
    Serializable, ILazyDataset, IMetadataProvider, INameable
  Direct Known Subclasses:
    AbstractDataset, AggregateDataset, LazyDataset

      public abstract class LazyDatasetBase
      extends Object
      implements ILazyDataset, Serializable

  Common base for both lazy and normal dataset implementations
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static boolean` | `catchExceptions`
    `protected static org.slf4j.Logger` | `logger`
    `protected ConcurrentMap<Class<? extends MetadataType>,List<MetadataType>>` | `metadata`
    `protected String` | `name`
    `protected int[]` | `shape` The shape or dimensions of the dataset

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `LazyDatasetBase()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addMetadata(MetadataType metadata)` Add metadata to the dataset
    `static int[]` | `checkPermutatedAxes(int[] shape, int... axes)` Check permutation axes
    `void` | `clearMetadata(Class<? extends MetadataType> clazz)` Remove metadata of given class
    `LazyDatasetBase` | `clone()` Clone dataset
    `protected ConcurrentMap<Class<? extends MetadataType>,List<MetadataType>>` | `copyMetadata()`
    `protected static ConcurrentMap<Class<? extends MetadataType>,List<MetadataType>>` | `copyMetadata(Map<Class<? extends MetadataType>,List<MetadataType>> metadata)`
    `protected ILazyDataset` | `createFromSerializable(Serializable blob, boolean keepLazy)`
    `protected void` | `dirtyMetadata()` Dirty metadata that are annotated by @Dirtiable.
    `boolean` | `equals(Object obj)`
    `static Class<? extends MetadataType>` | `findMetadataTypeSubInterfaces(Class<? extends MetadataType> clazz)` Find first sub-interface of (or class that directly implements) MetadataType
    `abstract int` | `getDType()`
    `Class<?>` | `getElementClass()`
    `protected ErrorMetadata` | `getErrorMetadata()`
    `ILazyDataset` | `getErrors()` Get the errors, if any.
    `<S extends MetadataType,T extends S> S` | `getFirstMetadata(Class<T> clazz)`
    `IMetadata` | `getMetadata()` Deprecated.
    `<S extends MetadataType,T extends S> List<S>` | `getMetadata(Class<T> clazz)`
    `protected static ConcurrentMap<Class<? extends MetadataType>,List<MetadataType>>` | `getMetadataMap(ILazyDataset a, boolean clone)`
    `String` | `getName()`
    `int` | `getRank()` The rank (or number of dimensions/indices) of the dataset can be zero for a zero-rank (single-valued) dataset
    `int[]` | `getShape()` The shape (or array of lengths for each dimension) of the dataset can be empty for zero-rank datasets
    `boolean` | `hasErrors()` If error information is set, returns true.
    `int` | `hashCode()`
    `protected void` | `reshapeMetadata(int[] oldShape, int[] newShape)` Reshape all datasets in metadata that are annotated by @Reshapeable.
    `protected void` | `restoreMetadata(Map<Class<? extends MetadataType>,List<MetadataType>> oldMetadata)`
    `void` | `setDirty()` This method allows anything that dirties the dataset to clear various metadata values so that the other methods can work correctly.
    `void` | `setErrors(Serializable errors)` Set the errors.
    `void` | `setMetadata(MetadataType metadata)` Set metadata on the dataset
    `void` | `setName(String name)`
    `protected void` | `sliceMetadata(boolean asView, SliceND slice)` Slice all datasets in metadata that are annotated by @Sliceable.
    `protected void` | `transposeMetadata(int[] axesMap)` Transpose all datasets in metadata that are annotated by @Transposable.

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

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

    - ### Methods inherited from interface org.eclipse.january.dataset.ILazyDataset

      `getElementsPerItem, getSize, getSlice, getSlice, getSlice, getSlice, getSlice, getSlice, getSliceView, getSliceView, getSliceView, getTransposedView, setShape, squeezeEnds`

- - ### Field Detail

    - #### logger

          protected static final org.slf4j.Logger logger

    - #### catchExceptions

          protected static boolean catchExceptions

    - #### name

          protected String name

    - #### shape

          protected int[] shape

      The shape or dimensions of the dataset

    - #### metadata

          protected ConcurrentMap<Class<? extends MetadataType>,List<MetadataType>> metadata

  - ### Constructor Detail

    - #### LazyDatasetBase

          public LazyDatasetBase()

  - ### Method Detail

    - #### getDType

          public abstract int getDType()

      Returns:
        type of dataset item

    - #### getElementClass

          public Class<?> getElementClass()

      Specified by:
        `getElementClass` in interface `ILazyDataset`
      Returns:
        Boxed class of element

    - #### clone

          public LazyDatasetBase clone()

      Description copied from interface: `ILazyDataset`
      Clone dataset
      Specified by:
        `clone` in interface `ILazyDataset`
      Overrides:
        `clone` in class `Object`
      Returns:
        a (shallow) copy of dataset

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### getName

          public String getName()

      Specified by:
        `getName` in interface `INameable`
      Returns:
        the name

    - #### setName

          public void setName(String name)

      Specified by:
        `setName` in interface `INameable`

    - #### getShape

          public int[] getShape()

      Description copied from interface: `ILazyDataset`
      The shape (or array of lengths for each dimension) of the dataset can be empty for zero-rank datasets
      Specified by:
        `getShape` in interface `ILazyDataset`
      Returns:
        Copy of shape of dataset

    - #### getRank

          public int getRank()

      Description copied from interface: `ILazyDataset`
      The rank (or number of dimensions/indices) of the dataset can be zero for a zero-rank (single-valued) dataset
      Specified by:
        `getRank` in interface `ILazyDataset`
      Returns:
        rank

    - #### setDirty

          public void setDirty()

      This method allows anything that dirties the dataset to clear various metadata values so that the other methods can work correctly.
      Since:
        2.1

    - #### findMetadataTypeSubInterfaces

          public static Class<? extends MetadataType> findMetadataTypeSubInterfaces(Class<? extends MetadataType> clazz)

      Find first sub-interface of (or class that directly implements) MetadataType
      Parameters:
        `clazz` -
      Returns:
        sub-interface
      Throws:
        `IllegalArgumentException` - when given class is `MetadataType` or an anonymous sub-class of it

    - #### setMetadata

          public void setMetadata(MetadataType metadata)

      Description copied from interface: `ILazyDataset`
      Set metadata on the dataset
      Specified by:
        `setMetadata` in interface `ILazyDataset`
      Parameters:
        `metadata` - (null is ignored so use clear(null) instead)

    - #### addMetadata

          public void addMetadata(MetadataType metadata)

      Description copied from interface: `ILazyDataset`
      Add metadata to the dataset
      Specified by:
        `addMetadata` in interface `ILazyDataset`

    - #### getMetadata

          @Deprecated
          public IMetadata getMetadata()

      Deprecated.
      Specified by:
        `getMetadata` in interface `IMetadataProvider`
      Returns:
        an instance of IMetadata

    - #### getMetadata

          public <S extends MetadataType,T extends S> List<S> getMetadata(Class<T> clazz)
                                                   throws MetadataException

      Specified by:
        `getMetadata` in interface `IMetadataProvider`
      Parameters:
        `clazz` - if null return everything
      Returns:
        list of metadata with given class (or its super interface)
      Throws:
        `MetadataException`

    - #### getFirstMetadata

          public <S extends MetadataType,T extends S> S getFirstMetadata(Class<T> clazz)

      Specified by:
        `getFirstMetadata` in interface `IMetadataProvider`
      Parameters:
        `clazz` - if null return first from everything
      Returns:
        first element from list of metadata with given class (or its super interface)

    - #### clearMetadata

          public void clearMetadata(Class<? extends MetadataType> clazz)

      Description copied from interface: `ILazyDataset`
      Remove metadata of given class
      Specified by:
        `clearMetadata` in interface `ILazyDataset`
      Parameters:
        `clazz` - if null remove everything

    - #### copyMetadata

          protected ConcurrentMap<Class<? extends MetadataType>,List<MetadataType>> copyMetadata()

      Since:
        2.0

    - #### copyMetadata

          protected static ConcurrentMap<Class<? extends MetadataType>,List<MetadataType>> copyMetadata(Map<Class<? extends MetadataType>,List<MetadataType>> metadata)

      Since:
        2.0

    - #### restoreMetadata

          protected void restoreMetadata(Map<Class<? extends MetadataType>,List<MetadataType>> oldMetadata)

    - #### getMetadataMap

          protected static ConcurrentMap<Class<? extends MetadataType>,List<MetadataType>> getMetadataMap(ILazyDataset a,
                                                                                       boolean clone)

      Since:
        2.2

    - #### sliceMetadata

          protected void sliceMetadata(boolean asView,
                           SliceND slice)

      Slice all datasets in metadata that are annotated by @Sliceable. Call this on the new sliced dataset after cloning the metadata
      Parameters:
        `asView` - if true then just a view
        `slice` -

    - #### reshapeMetadata

          protected void reshapeMetadata(int[] oldShape,
                             int[] newShape)

      Reshape all datasets in metadata that are annotated by @Reshapeable. Call this when squeezing or setting the shape
      Parameters:
        `newShape` -

    - #### transposeMetadata

          protected void transposeMetadata(int[] axesMap)

      Transpose all datasets in metadata that are annotated by @Transposable. Call this on the transposed dataset after cloning the metadata
      Parameters:
        `axesMap` -

    - #### dirtyMetadata

          protected void dirtyMetadata()

      Dirty metadata that are annotated by @Dirtiable. Call this when the dataset has been modified
      Since:
        2.0

    - #### createFromSerializable

          protected ILazyDataset createFromSerializable(Serializable blob,
                                            boolean keepLazy)

    - #### setErrors

          public void setErrors(Serializable errors)

      Description copied from interface: `ILazyDataset`
      Set the errors. It may be a single double, a double array or a whole dataset that can broadcast to the dataset
      Specified by:
        `setErrors` in interface `ILazyDataset`
      Parameters:
        `errors` - - may be null to remove the error set

    - #### getErrorMetadata

          protected ErrorMetadata getErrorMetadata()

    - #### getErrors

          public ILazyDataset getErrors()

      Description copied from interface: `ILazyDataset`
      Get the errors, if any. These will be in a shape that can broadcast to the dataset
      Specified by:
        `getErrors` in interface `ILazyDataset`

    - #### hasErrors

          public boolean hasErrors()

      Description copied from interface: `ILazyDataset`
      If error information is set, returns true. Faster to call than getError() which constructs a new dataset.
      Specified by:
        `hasErrors` in interface `ILazyDataset`
      Returns:
        true if there is error data.

    - #### checkPermutatedAxes

          public static int[] checkPermutatedAxes(int[] shape,
                                  int... axes)

      Check permutation axes
      Parameters:
        `shape` -
        `axes` -
      Returns:
        cleaned up axes or null if trivial

Copyright © 2014–2018 Eclipse Foundation. All rights reserved.