Package biopb.tensor
Class SerializableTensorImg<T extends net.imglib2.type.NativeType<T> & net.imglib2.type.numeric.RealType<T>>
java.lang.Object
biopb.tensor.SerializableTensorImg<T>
- All Implemented Interfaces:
Externalizable,Serializable,Iterable<T>,net.imglib2.Dimensions,net.imglib2.EuclideanSpace,net.imglib2.Interval,net.imglib2.IterableInterval<T>,net.imglib2.IterableRealInterval<T>,net.imglib2.RandomAccessible<T>,net.imglib2.RandomAccessibleInterval<T>,net.imglib2.RealInterval,net.imglib2.Typed<T>
public class SerializableTensorImg<T extends net.imglib2.type.NativeType<T> & net.imglib2.type.numeric.RealType<T>>
extends Object
implements net.imglib2.RandomAccessibleInterval<T>, Externalizable
Externalizable wrapper for tensor images that enables serialization.
This class wraps the non-serializable imglib2 CellImg returned by
TensorFlightClient.getTensor() and stores connection parameters
instead of actual data. After deserialization, it lazily reconstructs
the CellImg using a pooled connection.
The wrapper is transparent - it implements RandomAccessibleInterval,
so existing code using getTensor() can serialize/deserialize tensors
without modification.
Serialization stores:
- Location URI string (server address)
- Authentication token
- Cache size (bytes)
- Source and tensor identifiers
- SliceHint (as protobuf bytes)
- scale_hint and reduction_method (flattened, as serialized bytes)
Deserialization reconstructs:
- Pooled FlightClient connection (shared across deserializations)
- Lazy CellImg that fetches chunks on-demand
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSerializableTensorImg(org.apache.arrow.flight.Location location, String token, long cacheBytes, String sourceId, String tensorId, SliceHint sliceHint, long[] scaleHint, String reductionMethod, TensorDescriptor descriptor, net.imglib2.RandomAccessibleInterval<T> delegate) Constructor for initial creation from TensorFlightClient. -
Method Summary
Modifier and TypeMethodDescriptionnet.imglib2.Cursor<T>cursor()longdimension(int d) voiddimensions(long[] dimensions) net.imglib2.Cursor<T>longmax(int d) voidmax(long[] max) longmin(int d) voidmin(long[] min) intnet.imglib2.RandomAccess<T>net.imglib2.RandomAccess<T>randomAccess(net.imglib2.Interval interval) voidlongsize()voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.imglib2.Dimensions
dimensions, dimensionsAsLongArray, dimensionsAsPointMethods inherited from interface net.imglib2.Interval
max, maxAsLongArray, maxAsPoint, min, minAsLongArray, minAsPoint, realMax, realMinMethods inherited from interface net.imglib2.IterableInterval
localizingSpliterator, spliteratorMethods inherited from interface net.imglib2.IterableRealInterval
firstElement, getType, iterator, parallelStream, streamMethods inherited from interface net.imglib2.RandomAccessible
getAt, getAt, getAtMethods inherited from interface net.imglib2.RandomAccessibleInterval
viewMethods inherited from interface net.imglib2.RealInterval
maxAsDoubleArray, maxAsRealPoint, minAsDoubleArray, minAsRealPoint, realMax, realMax, realMin, realMin
-
Constructor Details
-
SerializableTensorImg
public SerializableTensorImg() -
SerializableTensorImg
public SerializableTensorImg(org.apache.arrow.flight.Location location, String token, long cacheBytes, String sourceId, String tensorId, SliceHint sliceHint, long[] scaleHint, String reductionMethod, TensorDescriptor descriptor, net.imglib2.RandomAccessibleInterval<T> delegate) Constructor for initial creation from TensorFlightClient.- Parameters:
location- Flight server locationtoken- Authentication token (null if none)cacheBytes- Cache size in bytessourceId- Data source identifiertensorId- Tensor identifiersliceHint- Slice hint (null if none)scaleHint- Per-dimension scale factors (null if none)reductionMethod- Reduction method string (null if none)descriptor- Response tensor descriptor (contains shape, chunk info)delegate- The actual RandomAccessibleInterval to wrap
-
-
Method Details
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
min
public long min(int d) - Specified by:
minin interfacenet.imglib2.Interval
-
max
public long max(int d) - Specified by:
maxin interfacenet.imglib2.Interval
-
numDimensions
public int numDimensions()- Specified by:
numDimensionsin interfacenet.imglib2.EuclideanSpace
-
size
public long size() -
randomAccess
-
randomAccess
-
cursor
- Specified by:
cursorin interfacenet.imglib2.IterableInterval<T extends net.imglib2.type.NativeType<T> & net.imglib2.type.numeric.RealType<T>>- Specified by:
cursorin interfacenet.imglib2.IterableRealInterval<T extends net.imglib2.type.NativeType<T> & net.imglib2.type.numeric.RealType<T>>- Specified by:
cursorin interfacenet.imglib2.RandomAccessibleInterval<T extends net.imglib2.type.NativeType<T> & net.imglib2.type.numeric.RealType<T>>
-
localizingCursor
- Specified by:
localizingCursorin interfacenet.imglib2.IterableInterval<T extends net.imglib2.type.NativeType<T> & net.imglib2.type.numeric.RealType<T>>- Specified by:
localizingCursorin interfacenet.imglib2.IterableRealInterval<T extends net.imglib2.type.NativeType<T> & net.imglib2.type.numeric.RealType<T>>- Specified by:
localizingCursorin interfacenet.imglib2.RandomAccessibleInterval<T extends net.imglib2.type.NativeType<T> & net.imglib2.type.numeric.RealType<T>>
-
iterationOrder
- Specified by:
iterationOrderin interfacenet.imglib2.IterableRealInterval<T extends net.imglib2.type.NativeType<T> & net.imglib2.type.numeric.RealType<T>>- Specified by:
iterationOrderin interfacenet.imglib2.RandomAccessibleInterval<T extends net.imglib2.type.NativeType<T> & net.imglib2.type.numeric.RealType<T>>
-
dimension
public long dimension(int d) - Specified by:
dimensionin interfacenet.imglib2.Dimensions- Specified by:
dimensionin interfacenet.imglib2.Interval
-
min
public void min(long[] min) - Specified by:
minin interfacenet.imglib2.Interval
-
max
public void max(long[] max) - Specified by:
maxin interfacenet.imglib2.Interval
-
dimensions
public void dimensions(long[] dimensions) - Specified by:
dimensionsin interfacenet.imglib2.Dimensions
-