Commit e602d877 authored by brinn's avatar brinn

Unify and simplify rank checking in the native readers and writers.

parent eb8733c6
......@@ -78,6 +78,7 @@ import ch.systemsx.cisd.hdf5.cleanup.CleanUpCallable;
import ch.systemsx.cisd.hdf5.cleanup.CleanUpRegistry;
import ch.systemsx.cisd.hdf5.cleanup.ICallableWithCleanUp;
import ch.systemsx.cisd.hdf5.cleanup.ICleanUpRegistry;
import ch.systemsx.cisd.hdf5.exceptions.HDF5SpaceRankMismatch;
import ch.systemsx.cisd.hdf5.hdf5lib.HDFHelper;
/**
......@@ -953,7 +954,7 @@ class HDF5
}
public long openAndExtendDataSet(long fileId, String path, FileFormatVersionBounds fileFormat,
long[] dimensions, boolean overwriteMode, ICleanUpRegistry registry)
long[] newDimensions, boolean overwriteMode, ICleanUpRegistry registry)
throws HDF5JavaException
{
checkMaxLength(path);
......@@ -968,27 +969,38 @@ class HDF5
H5Dclose(dataSetId);
}
});
extendDataSet(dataSetId, null, null, dimensions, null, overwriteMode, registry);
final long dataSpaceId = getDataSpaceForDataSet(dataSetId, registry);
final int rank = getDataSpaceRank(dataSpaceId);
final long[] dataDimensions = getDataSpaceDimensions(dataSpaceId, rank);
final long[] maxDimensions = getDataSpaceMaxDimensions(dataSpaceId, rank);
final HDF5StorageLayout layout = getLayout(dataSetId, registry);
extendDataSet(dataSetId, dataSpaceId, rank, layout, dataDimensions, newDimensions, maxDimensions,
overwriteMode, registry);
return dataSetId;
}
public boolean extendDataSet(long dataSetId, HDF5StorageLayout layoutOrNull,
long[] oldDimensionsOrNull, long[] newDimensions, long[] maxDimensionsOrNull,
boolean overwriteMode, ICleanUpRegistry registry) throws HDF5JavaException
public boolean extendDataSet(HDF5DataSet dataSet, long[] newDimensions,
boolean overwriteMode, ICleanUpRegistry registry)
throws HDF5SpaceRankMismatch, HDF5JavaException
{
final long[] oldDimensions =
(oldDimensionsOrNull != null) ? oldDimensionsOrNull
: getDataDimensions(dataSetId,
registry);
return extendDataSet(dataSet.getDataSetId(), dataSet.getDataSpaceId(),
dataSet.getRank(), dataSet.getLayout(), dataSet.getDimensions(), newDimensions,
dataSet.getMaxDimensions(), overwriteMode, registry);
}
public boolean extendDataSet(long dataSetId, long dataSpaceId, int rank,
HDF5StorageLayout layout, long[] oldDimensions, long[] newDimensions,
long[] maxDimensions, boolean overwriteMode, ICleanUpRegistry registry)
throws HDF5SpaceRankMismatch, HDF5JavaException
{
checkRank(rank, newDimensions.length);
if (Arrays.equals(oldDimensions, newDimensions) == false)
{
final HDF5StorageLayout layout =
(layoutOrNull != null) ? layoutOrNull : getLayout(dataSetId, registry);
if (layout == HDF5StorageLayout.CHUNKED)
{
// Safety check. JHDF5 creates CHUNKED data sets always with unlimited max
// dimensions but we may have to work on a file we haven't created.
if (areDimensionsInBounds(dataSetId, newDimensions, maxDimensionsOrNull, registry))
if (areDimensionsInBounds(newDimensions, maxDimensions))
{
setDataSetExtentChunked(dataSetId,
computeNewDimensions(oldDimensions, newDimensions, overwriteMode));
......@@ -1002,7 +1014,7 @@ class HDF5
throw new HDF5JavaException("Cannot change dimensions on non-extendable data set.");
} else
{
long dataTypeId = getDataTypeForDataSet(dataSetId, registry);
final long dataTypeId = getDataTypeForDataSet(dataSetId, registry);
if (getClassType(dataTypeId) == H5T_ARRAY)
{
throw new HDF5JavaException("Cannot partially overwrite array type.");
......@@ -1016,7 +1028,7 @@ class HDF5
return false;
}
public boolean extendDataSet(HDF5DataSet dataSet,long[] newDimensions,
public boolean extendDataSet(HDF5DataSet dataSet, long[] newDimensions,
boolean overwriteMode) throws HDF5JavaException
{
final long dataSetId = dataSet.getDataSetId();
......@@ -1029,7 +1041,7 @@ class HDF5
{
// Safety check. JHDF5 creates CHUNKED data sets always with unlimited max
// dimensions but we may have to work on a file we haven't created.
if (areDimensionsInBounds(dataSetId, newDimensions, maxDimensions, null))
if (areDimensionsInBounds(newDimensions, maxDimensions))
{
setDataSetExtentChunked(dataSetId,
computeNewDimensions(oldDimensions, newDimensions, overwriteMode));
......@@ -1074,17 +1086,22 @@ class HDF5
}
}
void checkRank(int rankExpected, int rankFound) throws HDF5SpaceRankMismatch
{
assert rankExpected >= 0;
assert rankFound >= 0;
if (rankExpected != rankFound)
{
throw new HDF5SpaceRankMismatch(rankExpected, rankFound);
}
}
/**
* Checks whether the given <var>dimensions</var> are in bounds for <var>dataSetId</var>.
*/
private boolean areDimensionsInBounds(final long dataSetId, final long[] dimensions,
final long[] maxDimensionsOrNull, ICleanUpRegistry registry)
private boolean areDimensionsInBounds(final long[] dimensions, final long[] maxDimensions)
{
final long[] maxDimensions =
(maxDimensionsOrNull != null) ? maxDimensionsOrNull
: getDataMaxDimensions(
dataSetId, registry);
if (dimensions.length != maxDimensions.length) // Actually an error condition
{
return false;
......
......@@ -246,21 +246,6 @@ class HDF5BaseReader
}
}
void checkRank(HDF5DataSet dataSet, final long[] dataDimensions, final long[] offset) throws HDF5SpaceRankMismatch
{
assert dataSet != null;
assert dataDimensions != null;
if (dataSet.getDimensions().length != dataDimensions.length)
{
throw new HDF5SpaceRankMismatch(dataSet.getDimensions().length, dataDimensions.length);
}
if (offset.length != dataDimensions.length)
{
throw new HDF5SpaceRankMismatch(dataSet.getDimensions().length, offset.length);
}
}
/**
* Closes this object and the file referenced by this object. This object must not be used after
* being closed.
......@@ -703,7 +688,11 @@ class HDF5BaseReader
dataSpaceId = h5.getDataSpaceForDataSet(dataSetId, registry);
final long[] dimensions = h5.getDataSpaceDimensions(dataSpaceId);
if (dimensions.length != blockDimensionsOrNull.length)
if (blockDimensionsOrNull.length != offset.length)
{
throw new HDF5SpaceRankMismatch(blockDimensionsOrNull.length, offset.length);
}
if (blockDimensionsOrNull.length != dimensions.length)
{
throw new HDF5SpaceRankMismatch(blockDimensionsOrNull.length, dimensions.length);
}
......
......@@ -382,7 +382,7 @@ class HDF5ByteReader implements IHDF5ByteReader
assert dataSet != null;
baseReader.checkOpen();
baseReader.checkRank(dataSet, new long[] { blockSize }, new long[] { offset });
baseReader.h5.checkRank(1, dataSet.getRank());
final ICallableWithCleanUp<byte[]> readCallable = new ICallableWithCleanUp<byte[]>()
{
@Override
......@@ -752,7 +752,8 @@ class HDF5ByteReader implements IHDF5ByteReader
assert offset != null;
baseReader.checkOpen();
baseReader.checkRank(dataSet, MDArray.toLong(blockDimensions), offset);
baseReader.h5.checkRank(blockDimensions.length, offset.length);
baseReader.h5.checkRank(blockDimensions.length, dataSet.getRank());
final ICallableWithCleanUp<MDByteArray> readCallable = new ICallableWithCleanUp<MDByteArray>()
{
@Override
......
......@@ -436,7 +436,7 @@ class HDF5ByteWriter extends HDF5ByteReader implements IHDF5ByteWriter
assert data != null;
baseWriter.checkOpen();
baseWriter.checkRank(dataSet, new long[] { dataSize }, new long[] { offset });
baseWriter.h5.checkRank(1, dataSet.getRank());
final ICallableWithCleanUp<Void> writeRunnable = new ICallableWithCleanUp<Void>()
{
@Override
......@@ -448,9 +448,7 @@ class HDF5ByteWriter extends HDF5ByteReader implements IHDF5ByteWriter
{ offset };
final long[] requiredDimensions = new long[]
{ offset + dataSize };
if (baseWriter.h5.extendDataSet(dataSet.getDataSetId(),
dataSet.getLayout(), dataSet.getDimensions(), requiredDimensions,
dataSet.getMaxDimensions(), false, registry))
if (baseWriter.h5.extendDataSet(dataSet, requiredDimensions, false, registry))
{
dataSet.setDimensions(requiredDimensions);
}
......@@ -900,8 +898,8 @@ class HDF5ByteWriter extends HDF5ByteReader implements IHDF5ByteWriter
}
@Override
public void writeSlicedMDArrayBlock(String objectPath, MDByteArray data, long[] blockNumber,
long[] boundIndices)
public void writeSlicedMDArrayBlock(String objectPath, MDByteArray data,
long[] blockNumber, long[] boundIndices)
{
assert blockNumber != null;
......@@ -915,8 +913,8 @@ class HDF5ByteWriter extends HDF5ByteReader implements IHDF5ByteWriter
}
@Override
public void writeSlicedMDArrayBlock(HDF5DataSet dataSet, MDByteArray data, long[] blockNumber,
long[] boundIndices)
public void writeSlicedMDArrayBlock(HDF5DataSet dataSet, MDByteArray data,
long[] blockNumber, long[] boundIndices)
{
assert blockNumber != null;
......@@ -988,7 +986,8 @@ class HDF5ByteWriter extends HDF5ByteReader implements IHDF5ByteWriter
assert offset != null;
baseWriter.checkOpen();
baseWriter.checkRank(dataSet, MDArray.toLong(data.dimensions()), offset);
baseWriter.h5.checkRank(data.rank(), offset.length);
baseWriter.h5.checkRank(data.rank(), dataSet.getRank());
final ICallableWithCleanUp<Void> writeRunnable = new ICallableWithCleanUp<Void>()
{
@Override
......
......@@ -158,6 +158,11 @@ public class HDF5DataSet implements AutoCloseable
return layout;
}
int getRank()
{
return dimensions.length;
}
int getFullRank()
{
if (fullRank == -1)
......
......@@ -382,7 +382,7 @@ class HDF5DoubleReader implements IHDF5DoubleReader
assert dataSet != null;
baseReader.checkOpen();
baseReader.checkRank(dataSet, new long[] { blockSize }, new long[] { offset });
baseReader.h5.checkRank(1, dataSet.getRank());
final ICallableWithCleanUp<double[]> readCallable = new ICallableWithCleanUp<double[]>()
{
@Override
......@@ -752,7 +752,8 @@ class HDF5DoubleReader implements IHDF5DoubleReader
assert offset != null;
baseReader.checkOpen();
baseReader.checkRank(dataSet, MDArray.toLong(blockDimensions), offset);
baseReader.h5.checkRank(blockDimensions.length, offset.length);
baseReader.h5.checkRank(blockDimensions.length, dataSet.getRank());
final ICallableWithCleanUp<MDDoubleArray> readCallable = new ICallableWithCleanUp<MDDoubleArray>()
{
@Override
......
......@@ -435,7 +435,7 @@ class HDF5DoubleWriter extends HDF5DoubleReader implements IHDF5DoubleWriter
assert data != null;
baseWriter.checkOpen();
baseWriter.checkRank(dataSet, new long[] { dataSize }, new long[] { offset });
baseWriter.h5.checkRank(1, dataSet.getRank());
final ICallableWithCleanUp<Void> writeRunnable = new ICallableWithCleanUp<Void>()
{
@Override
......@@ -447,9 +447,7 @@ class HDF5DoubleWriter extends HDF5DoubleReader implements IHDF5DoubleWriter
{ offset };
final long[] requiredDimensions = new long[]
{ offset + dataSize };
if (baseWriter.h5.extendDataSet(dataSet.getDataSetId(),
dataSet.getLayout(), dataSet.getDimensions(), requiredDimensions,
dataSet.getMaxDimensions(), false, registry))
if (baseWriter.h5.extendDataSet(dataSet, requiredDimensions, false, registry))
{
dataSet.setDimensions(requiredDimensions);
}
......@@ -899,8 +897,8 @@ class HDF5DoubleWriter extends HDF5DoubleReader implements IHDF5DoubleWriter
}
@Override
public void writeSlicedMDArrayBlock(String objectPath, MDDoubleArray data, long[] blockNumber,
long[] boundIndices)
public void writeSlicedMDArrayBlock(String objectPath, MDDoubleArray data,
long[] blockNumber, long[] boundIndices)
{
assert blockNumber != null;
......@@ -914,8 +912,8 @@ class HDF5DoubleWriter extends HDF5DoubleReader implements IHDF5DoubleWriter
}
@Override
public void writeSlicedMDArrayBlock(HDF5DataSet dataSet, MDDoubleArray data, long[] blockNumber,
long[] boundIndices)
public void writeSlicedMDArrayBlock(HDF5DataSet dataSet, MDDoubleArray data,
long[] blockNumber, long[] boundIndices)
{
assert blockNumber != null;
......@@ -987,7 +985,8 @@ class HDF5DoubleWriter extends HDF5DoubleReader implements IHDF5DoubleWriter
assert offset != null;
baseWriter.checkOpen();
baseWriter.checkRank(dataSet, MDArray.toLong(data.dimensions()), offset);
baseWriter.h5.checkRank(data.rank(), offset.length);
baseWriter.h5.checkRank(data.rank(), dataSet.getRank());
final ICallableWithCleanUp<Void> writeRunnable = new ICallableWithCleanUp<Void>()
{
@Override
......
......@@ -382,7 +382,7 @@ class HDF5FloatReader implements IHDF5FloatReader
assert dataSet != null;
baseReader.checkOpen();
baseReader.checkRank(dataSet, new long[] { blockSize }, new long[] { offset });
baseReader.h5.checkRank(1, dataSet.getRank());
final ICallableWithCleanUp<float[]> readCallable = new ICallableWithCleanUp<float[]>()
{
@Override
......@@ -752,7 +752,8 @@ class HDF5FloatReader implements IHDF5FloatReader
assert offset != null;
baseReader.checkOpen();
baseReader.checkRank(dataSet, MDArray.toLong(blockDimensions), offset);
baseReader.h5.checkRank(blockDimensions.length, offset.length);
baseReader.h5.checkRank(blockDimensions.length, dataSet.getRank());
final ICallableWithCleanUp<MDFloatArray> readCallable = new ICallableWithCleanUp<MDFloatArray>()
{
@Override
......
......@@ -435,7 +435,7 @@ class HDF5FloatWriter extends HDF5FloatReader implements IHDF5FloatWriter
assert data != null;
baseWriter.checkOpen();
baseWriter.checkRank(dataSet, new long[] { dataSize }, new long[] { offset });
baseWriter.h5.checkRank(1, dataSet.getRank());
final ICallableWithCleanUp<Void> writeRunnable = new ICallableWithCleanUp<Void>()
{
@Override
......@@ -447,9 +447,7 @@ class HDF5FloatWriter extends HDF5FloatReader implements IHDF5FloatWriter
{ offset };
final long[] requiredDimensions = new long[]
{ offset + dataSize };
if (baseWriter.h5.extendDataSet(dataSet.getDataSetId(),
dataSet.getLayout(), dataSet.getDimensions(), requiredDimensions,
dataSet.getMaxDimensions(), false, registry))
if (baseWriter.h5.extendDataSet(dataSet, requiredDimensions, false, registry))
{
dataSet.setDimensions(requiredDimensions);
}
......@@ -899,8 +897,8 @@ class HDF5FloatWriter extends HDF5FloatReader implements IHDF5FloatWriter
}
@Override
public void writeSlicedMDArrayBlock(String objectPath, MDFloatArray data, long[] blockNumber,
long[] boundIndices)
public void writeSlicedMDArrayBlock(String objectPath, MDFloatArray data,
long[] blockNumber, long[] boundIndices)
{
assert blockNumber != null;
......@@ -914,8 +912,8 @@ class HDF5FloatWriter extends HDF5FloatReader implements IHDF5FloatWriter
}
@Override
public void writeSlicedMDArrayBlock(HDF5DataSet dataSet, MDFloatArray data, long[] blockNumber,
long[] boundIndices)
public void writeSlicedMDArrayBlock(HDF5DataSet dataSet, MDFloatArray data,
long[] blockNumber, long[] boundIndices)
{
assert blockNumber != null;
......@@ -987,7 +985,8 @@ class HDF5FloatWriter extends HDF5FloatReader implements IHDF5FloatWriter
assert offset != null;
baseWriter.checkOpen();
baseWriter.checkRank(dataSet, MDArray.toLong(data.dimensions()), offset);
baseWriter.h5.checkRank(data.rank(), offset.length);
baseWriter.h5.checkRank(data.rank(), dataSet.getRank());
final ICallableWithCleanUp<Void> writeRunnable = new ICallableWithCleanUp<Void>()
{
@Override
......
......@@ -382,7 +382,7 @@ class HDF5IntReader implements IHDF5IntReader
assert dataSet != null;
baseReader.checkOpen();
baseReader.checkRank(dataSet, new long[] { blockSize }, new long[] { offset });
baseReader.h5.checkRank(1, dataSet.getRank());
final ICallableWithCleanUp<int[]> readCallable = new ICallableWithCleanUp<int[]>()
{
@Override
......@@ -752,7 +752,8 @@ class HDF5IntReader implements IHDF5IntReader
assert offset != null;
baseReader.checkOpen();
baseReader.checkRank(dataSet, MDArray.toLong(blockDimensions), offset);
baseReader.h5.checkRank(blockDimensions.length, offset.length);
baseReader.h5.checkRank(blockDimensions.length, dataSet.getRank());
final ICallableWithCleanUp<MDIntArray> readCallable = new ICallableWithCleanUp<MDIntArray>()
{
@Override
......
......@@ -436,7 +436,7 @@ class HDF5IntWriter extends HDF5IntReader implements IHDF5IntWriter
assert data != null;
baseWriter.checkOpen();
baseWriter.checkRank(dataSet, new long[] { dataSize }, new long[] { offset });
baseWriter.h5.checkRank(1, dataSet.getRank());
final ICallableWithCleanUp<Void> writeRunnable = new ICallableWithCleanUp<Void>()
{
@Override
......@@ -448,9 +448,7 @@ class HDF5IntWriter extends HDF5IntReader implements IHDF5IntWriter
{ offset };
final long[] requiredDimensions = new long[]
{ offset + dataSize };
if (baseWriter.h5.extendDataSet(dataSet.getDataSetId(),
dataSet.getLayout(), dataSet.getDimensions(), requiredDimensions,
dataSet.getMaxDimensions(), false, registry))
if (baseWriter.h5.extendDataSet(dataSet, requiredDimensions, false, registry))
{
dataSet.setDimensions(requiredDimensions);
}
......@@ -900,8 +898,8 @@ class HDF5IntWriter extends HDF5IntReader implements IHDF5IntWriter
}
@Override
public void writeSlicedMDArrayBlock(String objectPath, MDIntArray data, long[] blockNumber,
long[] boundIndices)
public void writeSlicedMDArrayBlock(String objectPath, MDIntArray data,
long[] blockNumber, long[] boundIndices)
{
assert blockNumber != null;
......@@ -915,8 +913,8 @@ class HDF5IntWriter extends HDF5IntReader implements IHDF5IntWriter
}
@Override
public void writeSlicedMDArrayBlock(HDF5DataSet dataSet, MDIntArray data, long[] blockNumber,
long[] boundIndices)
public void writeSlicedMDArrayBlock(HDF5DataSet dataSet, MDIntArray data,
long[] blockNumber, long[] boundIndices)
{
assert blockNumber != null;
......@@ -988,7 +986,8 @@ class HDF5IntWriter extends HDF5IntReader implements IHDF5IntWriter
assert offset != null;
baseWriter.checkOpen();
baseWriter.checkRank(dataSet, MDArray.toLong(data.dimensions()), offset);
baseWriter.h5.checkRank(data.rank(), offset.length);
baseWriter.h5.checkRank(data.rank(), dataSet.getRank());
final ICallableWithCleanUp<Void> writeRunnable = new ICallableWithCleanUp<Void>()
{
@Override
......
......@@ -382,7 +382,7 @@ class HDF5LongReader implements IHDF5LongReader
assert dataSet != null;
baseReader.checkOpen();
baseReader.checkRank(dataSet, new long[] { blockSize }, new long[] { offset });
baseReader.h5.checkRank(1, dataSet.getRank());
final ICallableWithCleanUp<long[]> readCallable = new ICallableWithCleanUp<long[]>()
{
@Override
......@@ -752,7 +752,8 @@ class HDF5LongReader implements IHDF5LongReader
assert offset != null;
baseReader.checkOpen();
baseReader.checkRank(dataSet, MDArray.toLong(blockDimensions), offset);
baseReader.h5.checkRank(blockDimensions.length, offset.length);
baseReader.h5.checkRank(blockDimensions.length, dataSet.getRank());
final ICallableWithCleanUp<MDLongArray> readCallable = new ICallableWithCleanUp<MDLongArray>()
{
@Override
......
......@@ -436,7 +436,7 @@ class HDF5LongWriter extends HDF5LongReader implements IHDF5LongWriter
assert data != null;
baseWriter.checkOpen();
baseWriter.checkRank(dataSet, new long[] { dataSize }, new long[] { offset });
baseWriter.h5.checkRank(1, dataSet.getRank());
final ICallableWithCleanUp<Void> writeRunnable = new ICallableWithCleanUp<Void>()
{
@Override
......@@ -448,9 +448,7 @@ class HDF5LongWriter extends HDF5LongReader implements IHDF5LongWriter
{ offset };
final long[] requiredDimensions = new long[]
{ offset + dataSize };
if (baseWriter.h5.extendDataSet(dataSet.getDataSetId(),
dataSet.getLayout(), dataSet.getDimensions(), requiredDimensions,
dataSet.getMaxDimensions(), false, registry))
if (baseWriter.h5.extendDataSet(dataSet, requiredDimensions, false, registry))
{
dataSet.setDimensions(requiredDimensions);
}
......@@ -900,8 +898,8 @@ class HDF5LongWriter extends HDF5LongReader implements IHDF5LongWriter
}
@Override
public void writeSlicedMDArrayBlock(String objectPath, MDLongArray data, long[] blockNumber,
long[] boundIndices)
public void writeSlicedMDArrayBlock(String objectPath, MDLongArray data,
long[] blockNumber, long[] boundIndices)
{
assert blockNumber != null;
......@@ -915,8 +913,8 @@ class HDF5LongWriter extends HDF5LongReader implements IHDF5LongWriter
}
@Override
public void writeSlicedMDArrayBlock(HDF5DataSet dataSet, MDLongArray data, long[] blockNumber,
long[] boundIndices)
public void writeSlicedMDArrayBlock(HDF5DataSet dataSet, MDLongArray data,
long[] blockNumber, long[] boundIndices)
{
assert blockNumber != null;
......@@ -988,7 +986,8 @@ class HDF5LongWriter extends HDF5LongReader implements IHDF5LongWriter
assert offset != null;
baseWriter.checkOpen();
baseWriter.checkRank(dataSet, MDArray.toLong(data.dimensions()), offset);
baseWriter.h5.checkRank(data.rank(), offset.length);
baseWriter.h5.checkRank(data.rank(), dataSet.getRank());
final ICallableWithCleanUp<Void> writeRunnable = new ICallableWithCleanUp<Void>()
{
@Override
......
......@@ -382,7 +382,7 @@ class HDF5ShortReader implements IHDF5ShortReader
assert dataSet != null;
baseReader.checkOpen();
baseReader.checkRank(dataSet, new long[] { blockSize }, new long[] { offset });
baseReader.h5.checkRank(1, dataSet.getRank());
final ICallableWithCleanUp<short[]> readCallable = new ICallableWithCleanUp<short[]>()
{
@Override
......@@ -752,7 +752,8 @@ class HDF5ShortReader implements IHDF5ShortReader
assert offset != null;
baseReader.checkOpen();
baseReader.checkRank(dataSet, MDArray.toLong(blockDimensions), offset);
baseReader.h5.checkRank(blockDimensions.length, offset.length);
baseReader.h5.checkRank(blockDimensions.length, dataSet.getRank());
final ICallableWithCleanUp<MDShortArray> readCallable = new ICallableWithCleanUp<MDShortArray>()
{
@Override
......
......@@ -436,7 +436,7 @@ class HDF5ShortWriter extends HDF5ShortReader implements IHDF5ShortWriter
assert data != null;
baseWriter.checkOpen();
baseWriter.checkRank(dataSet, new long[] { dataSize }, new long[] { offset });
baseWriter.h5.checkRank(1, dataSet.getRank());
final ICallableWithCleanUp<Void> writeRunnable = new ICallableWithCleanUp<Void>()
{
@Override
......@@ -448,9 +448,7 @@ class HDF5ShortWriter extends HDF5ShortReader implements IHDF5ShortWriter
{ offset };
final long[] requiredDimensions = new long[]
{ offset + dataSize };
if (baseWriter.h5.extendDataSet(dataSet.getDataSetId(),
dataSet.getLayout(), dataSet.getDimensions(), requiredDimensions,
dataSet.getMaxDimensions(), false, registry))
if (baseWriter.h5.extendDataSet(dataSet, requiredDimensions, false, registry))
{
dataSet.setDimensions(requiredDimensions);
}
......@@ -900,8 +898,8 @@ class HDF5ShortWriter extends HDF5ShortReader implements IHDF5ShortWriter
}
@Override
public void writeSlicedMDArrayBlock(String objectPath, MDShortArray data, long[] blockNumber,
long[] boundIndices)
public void writeSlicedMDArrayBlock(String objectPath, MDShortArray data,
long[] blockNumber, long[] boundIndices)
{
assert blockNumber != null;
......@@ -915,8 +913,8 @@ class HDF5ShortWriter extends HDF5ShortReader implements IHDF5ShortWriter
}
@Override
public void writeSlicedMDArrayBlock(HDF5DataSet dataSet, MDShortArray data, long[] blockNumber,
long[] boundIndices)
public void writeSlicedMDArrayBlock(HDF5DataSet dataSet, MDShortArray data,
long[] blockNumber, long[] boundIndices)
{
assert blockNumber != null;
......@@ -988,7 +986,8 @@ class HDF5ShortWriter extends HDF5ShortReader implements IHDF5ShortWriter
assert offset != null;
baseWriter.checkOpen();
baseWriter.checkRank(dataSet, MDArray.toLong(data.dimensions()), offset);
baseWriter.h5.checkRank(data.rank(), offset.length);
baseWriter.h5.checkRank(data.rank(), dataSet.getRank());
final ICallableWithCleanUp<Void> writeRunnable = new ICallableWithCleanUp<Void>()
{
@Override
......
......@@ -382,7 +382,7 @@ class HDF5UnsignedByteReader implements IHDF5ByteReader
assert dataSet != null;
baseReader.checkOpen();
baseReader.checkRank(dataSet, new long[] { blockSize }, new long[] { offset });
baseReader.h5.checkRank(1, dataSet.getRank());
final ICallableWithCleanUp<byte[]> readCallable = new ICallableWithCleanUp<byte[]>()
{
@Override
......@@ -497,8 +497,7 @@ class HDF5UnsignedByteReader implements IHDF5ByteReader
final long[] fullOffset = new long[fullDimensions.length];
final int cardBoundIndices = cardinalityBoundIndices(boundIndices);
checkBoundIndices(objectPath, fullDimensions, boundIndices);
final int[] effectiveBlockDimensions =
new int[fullBlockDimensions.length - cardBoundIndices];
final int[] effectiveBlockDimensions = new int[fullBlockDimensions.length - cardBoundIndices];
Arrays.fill(effectiveBlockDimensions, -1);
createFullBlockDimensionsAndOffset(effectiveBlockDimensions, null, boundIndices, fullDimensions,
fullBlockDimensions, fullOffset);
......@@ -753,7 +752,8 @@ class HDF5UnsignedByteReader implements IHDF5ByteReader
assert offset != null;
baseReader.checkOpen();
baseReader.checkRank(dataSet, MDArray.toLong(blockDimensions), offset);
baseReader.h5.checkRank(blockDimensions.length, offset.length);
baseReader.h5.checkRank(blockDimensions.length, dataSet.getRank());
final ICallableWithCleanUp<MDByteArray> readCallable = new ICallableWithCleanUp<MDByteArray>()
{
@Override
......@@ -852,7 +852,7 @@ class HDF5UnsignedByteReader implements IHDF5ByteReader
if (effectiveBlockDimensions == blockDimensions)
{
effectiveBlockDimensions = blockDimensions.clone();
}
}
effectiveBlockDimensions[j] = arrayDimensions[i];
}
if (effectiveBlockDimensions[j] != arrayDimensions[i])
......@@ -890,7 +890,7 @@ class HDF5UnsignedByteReader implements IHDF5ByteReader
{
return new Iterator<HDF5DataBlock<byte[]>>()
{