ucar.nc2
Class Sequence

java.lang.Object
  extended by ucar.nc2.Variable
      extended by ucar.nc2.Structure
          extended by ucar.nc2.Sequence
All Implemented Interfaces:
Comparable<VariableSimpleIF>, ProxyReader, VariableIF, VariableSimpleIF

public class Sequence
extends Structure

Sequence is a one-dimensional Structure with indeterminate length. The only data access is through getStructureIterator(). However, read() will read in the entire data and return an ArraySequence.

Since:
Feb 23, 2008
Author:
caron

Nested Class Summary
 
Nested classes/interfaces inherited from class ucar.nc2.Variable
Variable.Cache
 
Field Summary
 
Fields inherited from class ucar.nc2.Structure
defaultBufferSize, isSubset, log, memberHash, members
 
Fields inherited from class ucar.nc2.Variable
attributes, cache, dataType, debugCaching, defaultCoordsSizeToCache, defaultSizeToCache, dimensions, elementSize, group, hashCode, isMetadata, isVariableLength, ncfile, parent, proxyReader, shape, shapeAsSection, shortName, sizeToCache, spiObject
 
Constructor Summary
Sequence(NetcdfFile ncfile, Group group, Structure parent, String shortName)
           
 
Method Summary
 StructureDataIterator getStructureIterator(int bufferSize)
          Get an efficient iterator over all the data in the Structure.
 Array read(int[] origin, int[] shape)
          UnsupportedOperation
 Array read(List<Range> ranges)
          UnsupportedOperation
 Array read(Section section)
          UnsupportedOperation
 Array read(String sectionSpec)
          UnsupportedOperation
 StructureData readStructure()
          UnsupportedOperation
 StructureData readStructure(int index)
          UnsupportedOperation
 ArrayStructure readStructure(int start, int count)
          UnsupportedOperation
 Variable section(Section subsection)
          UnsupportedOperation
 Variable slice(int dim, int value)
          UnsupportedOperation
 
Methods inherited from class ucar.nc2.Structure
addMemberVariable, calcElementSize, calcStructureSize, copy, findVariable, getElementSize, getNameAndAttributes, getNumberOfMemberVariables, getStructureIterator, getVariableNames, getVariables, isCaching, isSubset, makeStructureMembers, removeMemberVariable, replaceMemberVariable, select, select, setCaching, setImmutable, setMemberVariables, setParentGroup, writeCDL
 
Methods inherited from class ucar.nc2.Variable
_read, _read, addAttribute, clone, compareTo, createNewCache, equals, extraInfo, findAttribute, findAttributeIgnoreCase, findDimensionIndex, getAttributes, getDataType, getDescription, getDimension, getDimensions, getDimensionsAll, getDimensionsString, getEnumTypedef, getFullName, getFullNameEscaped, getName, getNameAndDimensions, getNameAndDimensions, getNameAndDimensions, getNameAndDimensions, getNameAndDimensions, getNameAndDimensions, getParentGroup, getParentStructure, getProxyReader, getRanges, getRank, getScalarData, getShape, getShape, getShapeAll, getShapeAsSection, getShortName, getSize, getSizeToCache, getSPobject, getUnitsString, hasCachedData, hashCode, invalidateCache, isCoordinateVariable, isImmutable, isMemberOfStructure, isMetadata, isScalar, isUnknownLength, isUnlimited, isUnsigned, isVariableLength, lookupEnumString, read, readScalarByte, readScalarDouble, readScalarFloat, readScalarInt, readScalarLong, readScalarShort, readScalarString, readToByteChannel, reallyRead, reallyRead, remove, removeAttribute, removeAttributeIgnoreCase, resetDimensions, resetShape, section, setCachedData, setCachedData, setDataType, setDimension, setDimensions, setDimensions, setDimensionsAnonymous, setElementSize, setEnumTypedef, setIsScalar, setName, setParentStructure, setProxyReader, setSizeToCache, setSPobject, setValues, setValues, toString, toStringDebug, writeCDL
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Sequence

public Sequence(NetcdfFile ncfile,
                Group group,
                Structure parent,
                String shortName)
Method Detail

getStructureIterator

public StructureDataIterator getStructureIterator(int bufferSize)
                                           throws IOException
Description copied from class: Structure
Get an efficient iterator over all the data in the Structure. This is the efficient way to get all the data, it can be much faster than reading one record at a time, and is optimized for large datasets. This is accomplished by buffering bufferSize amount of data at once.
Example:

  StructureDataIterator ii = structVariable.getStructureIterator(100 * 1000);
  while (ii.hasNext()) {
    StructureData sdata = ii.next();
  }
 

Overrides:
getStructureIterator in class Structure
Parameters:
bufferSize - size in bytes to buffer, set < 0 to use default size
Returns:
StructureDataIterator over type StructureData
Throws:
IOException - on read error

read

public Array read(int[] origin,
                  int[] shape)
           throws IOException,
                  InvalidRangeException
UnsupportedOperation

Specified by:
read in interface VariableIF
Overrides:
read in class Variable
Parameters:
origin - int array specifying the starting index. If null, assume all zeroes.
shape - int array specifying the extents in each dimension. This becomes the shape of the returned Array.
Returns:
the requested data in a memory-resident Array
Throws:
UnsupportedOperationException
IOException
InvalidRangeException

read

public Array read(String sectionSpec)
           throws IOException,
                  InvalidRangeException
UnsupportedOperation

Specified by:
read in interface VariableIF
Overrides:
read in class Variable
Parameters:
sectionSpec - specification string, eg "1:2,10,:,1:100:10". May optionally have ().
Returns:
the requested data in a memory-resident Array
Throws:
UnsupportedOperationException
IOException
InvalidRangeException
See Also:
for sectionSpec syntax

read

public Array read(List<Range> ranges)
           throws IOException,
                  InvalidRangeException
UnsupportedOperation

Overrides:
read in class Variable
Parameters:
ranges - list of Range specifying the section of data to read.
Returns:
the requested data in a memory-resident Array
Throws:
UnsupportedOperationException
IOException - if error
InvalidRangeException - if ranges is invalid
See Also:
Variable.read(Section)

read

public Array read(Section section)
           throws IOException,
                  InvalidRangeException
UnsupportedOperation

Specified by:
read in interface VariableIF
Overrides:
read in class Variable
Parameters:
section - list of Range specifying the section of data to read. Must be null or same rank as variable. If list is null, assume all data. Each Range corresponds to a Dimension. If the Range object is null, it means use the entire dimension.
Returns:
the requested data in a memory-resident Array
Throws:
UnsupportedOperationException
IOException - if error
InvalidRangeException - if section is invalid

readStructure

public StructureData readStructure()
                            throws IOException
UnsupportedOperation

Overrides:
readStructure in class Structure
Returns:
StructureData for a scalar
Throws:
UnsupportedOperationException
IOException - on read error

readStructure

public StructureData readStructure(int index)
                            throws IOException,
                                   InvalidRangeException
UnsupportedOperation

Overrides:
readStructure in class Structure
Parameters:
index - index into 1D array
Returns:
ith StructureData
Throws:
UnsupportedOperationException
IOException - on read error
InvalidRangeException - if index out of range

readStructure

public ArrayStructure readStructure(int start,
                                    int count)
                             throws IOException,
                                    InvalidRangeException
UnsupportedOperation

Overrides:
readStructure in class Structure
Parameters:
start - start at this index
count - return this many StructureData
Returns:
the StructureData recordsfrom start to start+count-1
Throws:
UnsupportedOperationException
IOException - on read error
InvalidRangeException - if start, count out of range

slice

public Variable slice(int dim,
                      int value)
               throws InvalidRangeException
UnsupportedOperation

Overrides:
slice in class Variable
Parameters:
dim - which dimension to fix
value - at what index value
Returns:
a new Variable which is a logical slice of this Variable.
Throws:
UnsupportedOperationException
InvalidRangeException - if dimension or value is illegal

section

public Variable section(Section subsection)
                 throws InvalidRangeException
UnsupportedOperation

Overrides:
section in class Variable
Parameters:
subsection - Section of this variable. Each Range in the section corresponds to a Dimension, and specifies the section of data to read in that Dimension. A Range object may be null, which means use the entire dimension.
Returns:
a new Variable which is a logical section of this Variable.
Throws:
UnsupportedOperationException
InvalidRangeException - if section not compatible with shape


Copyright © 1999-2011 UCAR/Unidata. All Rights Reserved.