Class CompositeFunction

java.lang.Object
noaa.coastwatch.util.chunk.CompositeFunction
All Implemented Interfaces:
ChunkFunction

public class CompositeFunction extends Object implements ChunkFunction
The CompositeFunction class implements a composite function that takes many chunks and collapses them into just one chunk using a reduction operator. If the number of input chunks is less than the minimum valid, or the input chunks contain all invalid data, the function returns null from the apply(noaa.coastwatch.util.chunk.ChunkPosition, java.util.List<noaa.coastwatch.util.chunk.DataChunk>) method. All input chunks must have the same external data type.
Since:
3.5.0
Author:
Peter Hollemans
  • Constructor Details

    • CompositeFunction

      public CompositeFunction(ArrayReduction operator, int minValid, DataChunk protoChunk)
      Creates a new chunk compositing function.
      Parameters:
      operator - the reduction operator to use for compositing input chunk values.
      minValid - the minimum number of valid input values that must be present to form a composite value, at least 1. If the valid input count falls below the minimum, the output at that chunk location is marked as missing.
      protoChunk - the prototype chunk for the function result. The chunk returned by the apply(noaa.coastwatch.util.chunk.ChunkPosition, java.util.List<noaa.coastwatch.util.chunk.DataChunk>) method will be compatible with the prototype.
  • Method Details

    • getMemory

      public long getMemory(ChunkPosition pos, int chunks)
      Description copied from interface: ChunkFunction
      Estimates the memory requirements for processing a chunk of data at the specified position, not including the input and output chunk internal data arrays.
      Specified by:
      getMemory in interface ChunkFunction
      Parameters:
      pos - the position to estimate the memory usage.
      chunks - the number of input chunks that will be processed at once.
      Returns:
      the memory in bytes.
    • apply

      public DataChunk apply(ChunkPosition pos, List<DataChunk> inputChunks)
      Description copied from interface: ChunkFunction
      Applies some function to a list of chunks.
      Specified by:
      apply in interface ChunkFunction
      Parameters:
      pos - the position to perform the function.
      inputChunks - the list of chunks as input to the function.
      Returns:
      the output chunk of the function, or null if no valid output chunk could be computed.