Package org.apache.sysds.runtime.util

# Class UnixPipeUtils

java.lang.Object
org.apache.sysds.runtime.util.UnixPipeUtils

public class UnixPipeUtils extends Object

## Constructor Summary

Constructors
Constructor
Description
`UnixPipeUtils()`

## Method Summary

Modifier and Type
Method
Description
`static int`
`getElementSize(Types.ValueType type)`
`static BufferedInputStream`
`openInput(String pipePath, int expectedId)`
Opens a named pipe for input, reads 4 bytes as an int, compares it to the expected ID.
`static BufferedOutputStream`
`openOutput(String pipePath, int expectedId)`
`static Array<?>`
`readFrameColumnFromPipe(BufferedInputStream in, int id, int rows, int totalBytes, int batchSize, Types.ValueType type)`
`static void`
`readHandshake(int expectedId, BufferedInputStream bis)`
`static long`
`readNumpyArrayInBatches(BufferedInputStream in, int id, int batchSize, int numElem, Types.ValueType type, double[] out, int offsetOut)`
`static long`
`writeFrameColumnToPipe(BufferedOutputStream out, int id, int batchSize, Array<?> array, Types.ValueType type)`
Symmetric with readFrameColumnFromPipe — writes FrameBlock column data to pipe.
`static void`
`writeHandshake(int expectedId, BufferedOutputStream bos)`
`static long`
`writeNumpyArrayInBatches(BufferedOutputStream out, int id, int batchSize, int numElem, Types.ValueType type, MatrixBlock mb)`
Symmetric with readNumpyArrayInBatches — writes data in batches with handshake.

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### UnixPipeUtils

public UnixPipeUtils()

## Method Details

### getElementSize

public static int getElementSize(Types.ValueType type)

### openInput

public static BufferedInputStream openInput(String pipePath, int expectedId) throws IOException
Opens a named pipe for input, reads 4 bytes as an int, compares it to the expected ID. If matched, returns the InputStream for further use.

Parameters:
  `pipePath` - The filesystem path to the FIFO pipe
  `expectedId` - The expected handshake ID
Returns:
  BufferedInputStream if handshake succeeds
Throws:
  `IOException` - if file access fails
  `IllegalStateException` - if handshake ID doesn't match

### readHandshake

public static void readHandshake(int expectedId, BufferedInputStream bis) throws IOException

Throws:
  `IOException`

### openOutput

public static BufferedOutputStream openOutput(String pipePath, int expectedId) throws IOException

Throws:
  `IOException`

### writeHandshake

public static void writeHandshake(int expectedId, BufferedOutputStream bos) throws IOException

Throws:
  `IOException`

### readNumpyArrayInBatches

public static long readNumpyArrayInBatches(BufferedInputStream in, int id, int batchSize, int numElem, Types.ValueType type, double[] out, int offsetOut) throws IOException

Throws:
  `IOException`

### writeNumpyArrayInBatches

public static long writeNumpyArrayInBatches(BufferedOutputStream out, int id, int batchSize, int numElem, Types.ValueType type, MatrixBlock mb) throws IOException
Symmetric with readNumpyArrayInBatches — writes data in batches with handshake.

Throws:
  `IOException`

### readFrameColumnFromPipe

public static Array<?> readFrameColumnFromPipe(BufferedInputStream in, int id, int rows, int totalBytes, int batchSize, Types.ValueType type) throws IOException

Throws:
  `IOException`

### writeFrameColumnToPipe

public static long writeFrameColumnToPipe(BufferedOutputStream out, int id, int batchSize, Array<?> array, Types.ValueType type) throws IOException
Symmetric with readFrameColumnFromPipe — writes FrameBlock column data to pipe. Supports both fixed-size types and variable-length types (strings).

Throws:
  `IOException`