public class CopyNDArray extends ScratchNDArray
The data and characteristics of the returned copy, including URL, will be identical to that of the base array, except that it will have random access, read access and write access, and it is likely to have mapped access (though cannot do so in the case in which the requested dimensions imply more than Integer.MAX_VALUE pixels). Note that the guaranteed readability and writability of the returned object does not indicate that reading from or writing to it will be affected by/have effects on the data of the base array.
In construction an AccessMode parameter is used, which controls when data gets copied. If and only if the mode parameter represents read access (READ or UPDATE) then all the data will be copied from the base array to the scratch copy at construction time. If and only if it represents write access (WRITE or UPDATE) then all the data will be copied from the scratch copy to the base array when the CopyNDArray is closed. The CopyNDArray will close the base array when it is closed itself.
ScratchNDArray.BackingStore
BridgeNDArray.BridgeNDArrayHdxFacade
arrayDims, arrayHandler, arrayIsRandom, arrayIsReadable, arrayIsWritable, arrayNdim, arrayNpix, arrayOrder, arrayOrigin, arrayShape, arrayType
Constructor and Description |
---|
CopyNDArray(NDArray nda,
AccessMode mode)
Constructs a new NDArray containing the same data as a given one,
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Declares that this NDArray will not be required for further use;
in particular that no further invocations will be made of the
getAccess method.
|
URL |
getURL()
Returns the URL of this NDArray, or null if it does not have one.
|
getAccess, getHdxFacade, getImpl, multipleAccess, toString
getBadHandler, getShape, getType, isRandom, isReadable, isWritable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getBadHandler, getShape, getType, isRandom, isReadable, isWritable
public CopyNDArray(NDArray nda, AccessMode mode) throws IOException
nda
- the base NDArraymode
- the access mode with which the data needs to be
accessed; this controls the copying of data.
If null, read/writability is taken from the
isReadable/isWritable flags of nda
IOException
- if an I/O error occurs during the copy of
data from the base NDArraypublic URL getURL()
NDArray
getURL
in interface NDArray
getURL
in class BridgeNDArray
public void close() throws IOException
NDArray
This method should be invoked on an NDArray when it is no longer required for pixel access. This allows reclamation of non-memory resources, and in the case of writable arrays it may also be required to ensure that data is flushed from buffers back to the actual pixel array.
An array should not however be closed if some other object might
still require pixel access to it via a retained reference.
The general rule is that an application
which obtains a new NDArray from a URL should arrange for
close
to be called
on it at the end of its lifetime, but that utility routines which
perform operations on an NDArray should not close it after use
(though they should close any ArrayAccess
objects
which they take out).
Note that closing an NDArray will normally result in closing any
arrays which it wraps.
Multiple calls of this method may harmlessly be made.
close
in interface NDArray
close
in class BridgeNDArray
IOException
- if some I/O error occurredCopyright © 2025 Central Laboratory of the Research Councils. All Rights Reserved.