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

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated 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
    `protected void` | `checkSliceND(SliceND slice)`
    `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()`
    `protected ErrorMetadata` | `getErrorMetadata()`
    `ILazyDataset` | `getErrors()` Get the errors, if any.
    `<T extends MetadataType> T` | `getFirstMetadata(Class<T> clazz)`
    `IMetadata` | `getMetadata()` Deprecated.
    `<T extends MetadataType> List<T>` | `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

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

- - ### Field Detail

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

    - #### 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`
      Parameters:
        `name` - to use

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

    - #### checkSliceND

          protected void checkSliceND(SliceND slice)

    - #### findMetadataTypeSubInterfaces

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

      Find first sub-interface of (or class that directly implements) MetadataType
      Parameters:
        `clazz` - metadata type
      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`
      Parameters:
        `metadata` - to add

    - #### getMetadata

          @Deprecated
          public IMetadata getMetadata()

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

    - #### getMetadata

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

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

    - #### getFirstMetadata

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

      Specified by:
        `getFirstMetadata` in interface `IMetadataProvider`
      Type Parameters:
        `T` - metadata sub-interface
      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()

      Returns:
        copy of metadata
      Since:
        2.0

    - #### copyMetadata

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

      Parameters:
        `metadata` - type
      Returns:
        copy of metadata of given type
      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)

      Parameters:
        `a` - dataset
        `clone` - if true, copy metadata
      Returns:
        copy of metadata
      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` - an n-D 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:
        `oldShape` - old shape
        `newShape` - new shape

    - #### 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` - if zero length then axes order reversed

    - #### 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`
      Returns:
        errors

    - #### 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` - to use
        `axes` - if zero length then axes order reversed
      Returns:
        cleaned up copy of axes or null if trivial

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