Module tornado.api

Class Int8Array

java.lang.Object
uk.ac.manchester.tornado.api.types.arrays.TornadoNativeArray
uk.ac.manchester.tornado.api.types.arrays.Int8Array

public final class Int8Array extends TornadoNativeArray
Int8Array relies on preview features of the Java platform:
Programs can only use Int8Array when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
  • Constructor Details

    • Int8Array

      public Int8Array(int numberOfElements)
      Constructs a new instance of the Int8Array that will store a user-specified number of elements.
      Parameters:
      numberOfElements - The number of elements in the array.
    • Int8Array

      public Int8Array(Int8Array... arrays)
      Constructs a new Int8Array instance by concatenating the contents of the given array of Int8Array instances.
      Parameters:
      arrays - An array of Int8Array instances to be concatenated into the new instance.
  • Method Details

    • fromArray

      public static Int8Array fromArray(byte[] values)
      Creates a new instance of the Int8Array class from an on-heap byte.
      Parameters:
      values - The on-heap byte array to create the instance from.
      Returns:
      A new Int8Array instance, initialized with values of the on-heap byte array.
    • fromElements

      public static Int8Array fromElements(byte... values)
      Creates a new instance of the Int8Array class from a set of byte values.
      Parameters:
      values - The byte values to initialize the array with.
      Returns:
      A new Int8Array instance, initialized with the given values.
    • fromSegment

      public static Int8Array fromSegment(MemorySegmentPREVIEW segment)
      Creates a new instance of the Int8Array class from a MemorySegmentPREVIEW.
      Parameters:
      segment - The MemorySegmentPREVIEW containing the off-heap byte int8 data.
      Returns:
      A new Int8Array instance, initialized with the segment data.
    • fromSegmentShallow

      public static Int8Array fromSegmentShallow(MemorySegmentPREVIEW segment)
      Creates a new instance of the Int8Array class by wrapping an existing MemorySegmentPREVIEW without copying its contents.
      Parameters:
      segment - The MemorySegmentPREVIEW containing *both* the off-heap int8 *header* and *data*.
      Returns:
      A new Int8Array instance that wraps the given segment.
    • toHeapArray

      public byte[] toHeapArray()
      Converts the byte array data from off-heap to on-heap, by copying the values of a Int8Array instance into a new on-heap byte array.
      Returns:
      A new on-heap byte array, initialized with the values stored in the Int8Array instance.
    • set

      public void set(int index, byte value)
      Sets the byte value at a specified index of the Int8Array instance.
      Parameters:
      index - The index at which to set the byte value.
      value - The byte value to store at the specified index.
    • get

      public byte get(int index)
      Gets the byte value stored at the specified index of the Int8Array instance.
      Parameters:
      index - The index of which to retrieve the byte value.
      Returns:
    • clear

      public void clear()
      Sets all the values of the Int8Array instance to zero.
      Specified by:
      clear in class TornadoNativeArray
    • getElementSize

      public int getElementSize()
      Specified by:
      getElementSize in class TornadoNativeArray
    • init

      public void init(byte value)
      Initializes all the elements of the Int8Array instance with a specified value.
      Parameters:
      value - The byte value to initialize the Int8Array instance with.
    • getSize

      public int getSize()
      Returns the number of byte (int 8) elements stored in the Int8Array instance.
      Specified by:
      getSize in class TornadoNativeArray
      Returns:
    • getSegment

      public MemorySegmentPREVIEW getSegment()
      Returns the underlying MemorySegmentPREVIEW of the Int8Array instance.
      Specified by:
      getSegment in class TornadoNativeArray
      Returns:
      The MemorySegmentPREVIEW associated with the Int8Array instance.
    • getSegmentWithHeader

      public MemorySegmentPREVIEW getSegmentWithHeader()
      Returns the underlying MemorySegmentPREVIEW of the Int8Array instance, including the header.
      Specified by:
      getSegmentWithHeader in class TornadoNativeArray
      Returns:
      The MemorySegmentPREVIEW associated with the Int8Array instance.
    • getNumBytesOfSegmentWithHeader

      public long getNumBytesOfSegmentWithHeader()
      Returns the total number of bytes that the MemorySegmentPREVIEW, associated with the Int8Array instance, occupies.
      Specified by:
      getNumBytesOfSegmentWithHeader in class TornadoNativeArray
      Returns:
      The total number of bytes of the MemorySegmentPREVIEW.
    • getNumBytesOfSegment

      public long getNumBytesOfSegment()
      Returns the number of bytes of the MemorySegmentPREVIEW that is associated with the Int8Array instance, excluding the header bytes.
      Specified by:
      getNumBytesOfSegment in class TornadoNativeArray
      Returns:
      The number of bytes of the raw data in the MemorySegmentPREVIEW.
    • initialize

      public static void initialize(Int8Array array, byte value)
      Factory method to initialize a Int8Array. This method can be invoked from a Task-Graph.
      Parameters:
      array - Input Array.
      value - The byte int8 value to initialize the Int8Array instance with.
    • concat

      public static Int8Array concat(Int8Array... arrays)
      Concatenates multiple Int8Array instances into a single Int8Array.
      Parameters:
      arrays - Variable number of Int8Array objects to be concatenated.
      Returns:
      A new Int8Array instance containing all the elements of the input arrays, concatenated in the order they were provided.
    • slice

      public Int8Array slice(int offset, int length)
      Extracts a slice of elements from a given Int8Array, creating a new Int8Array instance.
      Parameters:
      offset - The starting index from which to begin the slice, inclusive.
      length - The number of elements to include in the slice.
      Returns:
      A new Int8Array instance representing the specified slice of the original array.
      Throws:
      IllegalArgumentException - if the specified slice is out of the bounds of the original array.