Package nz.org.riskscape.hdf5
Class H5Dataset
java.lang.Object
nz.org.riskscape.hdf5.H5Object
nz.org.riskscape.hdf5.H5Dataset
- All Implemented Interfaces:
AutoCloseable
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
double[]
long
openCursor
(int bufferSize) byte[][]
readVlenElements
(H5DataSpace memspace, H5DataSpace filespace, int numElements) Read n variable length (vlen) elements and return them as a 2d array of bytes, where the 1st dimension contains the bytes of each element.toString()
Methods inherited from class nz.org.riskscape.hdf5.H5Object
getPointer
-
Method Details
-
openCursor
- Parameters:
bufferSize
- the size of the memory buffer that elements are read into- Returns:
- a new cursor/iterator over this data. There is as yet no support for reading from chunks stored in different data spaces
-
openCursor
-
newDataSpace
- Returns:
- a new dataspace that can be used to select elements from the dataset independently from the default dataspace that comes from getDataSpace(). Be aware that you'll need to close this dataspace when you're finished with it, otherwise you'll end up with resource leaks.
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in classH5Object
-
getElementsAsDouble
public double[] getElementsAsDouble()- Returns:
- the dataset elements as an array of doubles Warning: this will only work for datasets small enough to fit in an array
-
numElements
public long numElements()- Returns:
- the total number of elements in the dataset, as per
H5DataSpace.numElements()
-
toString
-
readVlenElements
Read n variable length (vlen) elements and return them as a 2d array of bytes, where the 1st dimension contains the bytes of each element. You can then pass each byte array to a vlen type's member type to deserialize the bytes in to the java representation of the data.
This is done as a special case because H5 vlen types are stored "off to the side" and the data is not kept in the same contiguous block as a non vlen type. This makes reading the data in to java difficult/impossible, and in fact required patching of the h5 library's jni bindings to even make possible in this way.
- Parameters:
memspace
- a dataspace that data is being read in to. This must be big enough to hold numElementsfilespace
- the dataspace that data is being read from. Its selection must yield the same number of elements as numElements, i.e. by callingH5DataSpace.selectElements(long[], long[])
numElements
- the number of elements to select. Must agree with the sizes of memspace and filespace- Returns:
- an array of byte arrays you can read the elements from
-
getDataType
-
getDataSpace
-
getDatasetName
-