Package org.apache.sysds.runtime.util
Class UnixPipeUtils
java.lang.Object
org.apache.sysds.runtime.util.UnixPipeUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intstatic BufferedInputStreamOpens a named pipe for input, reads 4 bytes as an int, compares it to the expected ID.static BufferedOutputStreamopenOutput(String pipePath, int expectedId) static Array<?>readFrameColumnFromPipe(BufferedInputStream in, int id, int rows, int totalBytes, int batchSize, Types.ValueType type) static voidreadHandshake(int expectedId, BufferedInputStream bis) static longreadNumpyArrayInBatches(BufferedInputStream in, int id, int batchSize, int numElem, Types.ValueType type, double[] out, int offsetOut) static longwriteFrameColumnToPipe(BufferedOutputStream out, int id, int batchSize, Array<?> array, Types.ValueType type) Symmetric with readFrameColumnFromPipe — writes FrameBlock column data to pipe.static voidwriteHandshake(int expectedId, BufferedOutputStream bos) static longwriteNumpyArrayInBatches(BufferedOutputStream out, int id, int batchSize, int numElem, Types.ValueType type, MatrixBlock mb) Symmetric with readNumpyArrayInBatches — writes data in batches with handshake.
-
Constructor Details
-
UnixPipeUtils
public UnixPipeUtils()
-
-
Method Details
-
getElementSize
-
openInput
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 pipeexpectedId- The expected handshake ID- Returns:
- BufferedInputStream if handshake succeeds
- Throws:
IOException- if file access failsIllegalStateException- if handshake ID doesn't match
-
readHandshake
- Throws:
IOException
-
openOutput
- Throws:
IOException
-
writeHandshake
- 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
-