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

    Constructors
    Constructor
    Description
     
    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.
  • Method Summary

    Modifier and Type
    Method
    Description
    net.imglib2.Cursor<T>
     
    long
    dimension(int d)
     
    void
    dimensions(long[] dimensions)
     
     
    net.imglib2.Cursor<T>
     
    long
    max(int d)
     
    void
    max(long[] max)
     
    long
    min(int d)
     
    void
    min(long[] min)
     
    int
     
    net.imglib2.RandomAccess<T>
     
    net.imglib2.RandomAccess<T>
    randomAccess(net.imglib2.Interval interval)
     
    void
     
    long
     
    void
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface net.imglib2.Dimensions

    dimensions, dimensionsAsLongArray, dimensionsAsPoint

    Methods inherited from interface net.imglib2.Interval

    max, maxAsLongArray, maxAsPoint, min, minAsLongArray, minAsPoint, realMax, realMin

    Methods inherited from interface java.lang.Iterable

    forEach

    Methods inherited from interface net.imglib2.IterableInterval

    localizingSpliterator, spliterator

    Methods inherited from interface net.imglib2.IterableRealInterval

    firstElement, getType, iterator, parallelStream, stream

    Methods inherited from interface net.imglib2.RandomAccessible

    getAt, getAt, getAt

    Methods inherited from interface net.imglib2.RandomAccessibleInterval

    view

    Methods 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 location
      token - Authentication token (null if none)
      cacheBytes - Cache size in bytes
      sourceId - Data source identifier
      tensorId - Tensor identifier
      sliceHint - 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

      public void writeExternal(ObjectOutput out) throws IOException
      Specified by:
      writeExternal in interface Externalizable
      Throws:
      IOException
    • readExternal

      public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
      Specified by:
      readExternal in interface Externalizable
      Throws:
      IOException
      ClassNotFoundException
    • min

      public long min(int d)
      Specified by:
      min in interface net.imglib2.Interval
    • max

      public long max(int d)
      Specified by:
      max in interface net.imglib2.Interval
    • numDimensions

      public int numDimensions()
      Specified by:
      numDimensions in interface net.imglib2.EuclideanSpace
    • size

      public long size()
      Specified by:
      size in interface net.imglib2.IterableRealInterval<T extends net.imglib2.type.NativeType<T> & net.imglib2.type.numeric.RealType<T>>
      Specified by:
      size in interface net.imglib2.RandomAccessibleInterval<T extends net.imglib2.type.NativeType<T> & net.imglib2.type.numeric.RealType<T>>
    • randomAccess

      public net.imglib2.RandomAccess<T> randomAccess()
      Specified by:
      randomAccess in interface net.imglib2.RandomAccessible<T extends net.imglib2.type.NativeType<T> & net.imglib2.type.numeric.RealType<T>>
    • randomAccess

      public net.imglib2.RandomAccess<T> randomAccess(net.imglib2.Interval interval)
      Specified by:
      randomAccess in interface net.imglib2.RandomAccessible<T extends net.imglib2.type.NativeType<T> & net.imglib2.type.numeric.RealType<T>>
    • cursor

      public net.imglib2.Cursor<T> cursor()
      Specified by:
      cursor in interface net.imglib2.IterableInterval<T extends net.imglib2.type.NativeType<T> & net.imglib2.type.numeric.RealType<T>>
      Specified by:
      cursor in interface net.imglib2.IterableRealInterval<T extends net.imglib2.type.NativeType<T> & net.imglib2.type.numeric.RealType<T>>
      Specified by:
      cursor in interface net.imglib2.RandomAccessibleInterval<T extends net.imglib2.type.NativeType<T> & net.imglib2.type.numeric.RealType<T>>
    • localizingCursor

      public net.imglib2.Cursor<T> localizingCursor()
      Specified by:
      localizingCursor in interface net.imglib2.IterableInterval<T extends net.imglib2.type.NativeType<T> & net.imglib2.type.numeric.RealType<T>>
      Specified by:
      localizingCursor in interface net.imglib2.IterableRealInterval<T extends net.imglib2.type.NativeType<T> & net.imglib2.type.numeric.RealType<T>>
      Specified by:
      localizingCursor in interface net.imglib2.RandomAccessibleInterval<T extends net.imglib2.type.NativeType<T> & net.imglib2.type.numeric.RealType<T>>
    • iterationOrder

      public Object iterationOrder()
      Specified by:
      iterationOrder in interface net.imglib2.IterableRealInterval<T extends net.imglib2.type.NativeType<T> & net.imglib2.type.numeric.RealType<T>>
      Specified by:
      iterationOrder in interface net.imglib2.RandomAccessibleInterval<T extends net.imglib2.type.NativeType<T> & net.imglib2.type.numeric.RealType<T>>
    • dimension

      public long dimension(int d)
      Specified by:
      dimension in interface net.imglib2.Dimensions
      Specified by:
      dimension in interface net.imglib2.Interval
    • min

      public void min(long[] min)
      Specified by:
      min in interface net.imglib2.Interval
    • max

      public void max(long[] max)
      Specified by:
      max in interface net.imglib2.Interval
    • dimensions

      public void dimensions(long[] dimensions)
      Specified by:
      dimensions in interface net.imglib2.Dimensions