Package org.apache.sysds.runtime.util
Class LocalFileUtils
java.lang.Object
org.apache.sysds.runtime.util.LocalFileUtils
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringstatic intstatic voidstatic voidstatic booleanstatic booleancreateLocalFileIfNotExist(String dir, String permission) static Stringstatic Stringstatic voiddeleteFileIfExists(String dir) static voiddeleteFileIfExists(String dir, boolean fileOnly) static StringgetUniqueWorkingDir(String category) static StringgetWorkingDir(String category) static booleanisExisting(String dir) static intRecursively deletes an entire local file system directory and returns the number of files deleted.static voidRecursively deletes an entire local file system directory.static intreadBlockSequenceFromLocal(String fname, Pair<MatrixIndexes, MatrixValue>[] outValues, HashMap<MatrixIndexes, Integer> outMap) static CacheBlock<?>readCacheBlockFromLocal(String fname, boolean matrix) Reads a matrix/frame block from local file system.static FrameBlockreadFrameBlockFromLocal(String fname) Reads a frame block from local file system.static FrameBlockReads a frame block from an input stream, using a fused buffered reader with special support for matrix blocks.static MatrixBlockreadMatrixBlockFromLocal(String fname) Reads a matrix block from local file system.static MatrixBlockreadMatrixBlockFromLocal(String fname, MatrixBlock reuse) Reads a matrix block from local file system.static MatrixBlockReads a matrix block from an input stream, using a fused buffered reader with special support for matrix blocks.static org.apache.hadoop.io.WritablereadWritableFromLocal(String fname, org.apache.hadoop.io.Writable ret) Reads an arbitrary writable from local file system, using a fused buffered reader with special support for matrix blocks.static org.apache.hadoop.io.WritablereadWritableFromStream(InputStream is, org.apache.hadoop.io.Writable ret) Reads an arbitrary writable from an input stream, using a fused buffered reader with special support for matrix blocks.static voidsetLocalFilePermissions(File file, String permissions) static voidwriteBlockSequenceToLocal(String fname, Pair<MatrixIndexes, MatrixValue>[] inValues, int len) static voidwriteByteArrayToLocal(String fname, byte[] data) static voidwriteCacheBlockToLocal(String fname, CacheBlock<?> cb) Writes a matrix/frame block to local file system.static voidwriteFrameBlockToLocal(String fname, FrameBlock fb) Writes a frame block to local file system.static voidwriteMatrixBlockToLocal(String fname, MatrixBlock mb) Writes a matrix block to local file system.static voidwriteTextFile(File file, String text) Writes a simple text file to local file system.static voidwriteWritableToLocal(String fname, org.apache.hadoop.io.Writable mb, boolean doubleBuffering) Writes an arbitrary writable to local file system, using a fused buffered writer with special support for matrix blocks.
-
Field Details
-
BUFFER_SIZE
public static final int BUFFER_SIZE- See Also:
-
DOUBLE_BUFFERING_MIN
public static final int DOUBLE_BUFFERING_MIN- See Also:
-
CATEGORY_CACHE
- See Also:
-
CATEGORY_PARTITIONING
- See Also:
-
CATEGORY_RESULTMERGE
- See Also:
-
CATEGORY_WORK
- See Also:
-
CATEGORY_CODEGEN
- See Also:
-
CATEGORY_LINEAGE
- See Also:
-
-
Constructor Details
-
LocalFileUtils
public LocalFileUtils()
-
-
Method Details
-
readMatrixBlockFromLocal
Reads a matrix block from local file system.- Parameters:
fname- file name to read- Returns:
- matrix block
- Throws:
IOException- if IOException occurs
-
readMatrixBlockFromLocal
public static MatrixBlock readMatrixBlockFromLocal(String fname, MatrixBlock reuse) throws IOException Reads a matrix block from local file system.- Parameters:
fname- file name to readreuse- matrix block to reuse- Returns:
- matrix block
- Throws:
IOException- if IOException occurs
-
readFrameBlockFromLocal
Reads a frame block from local file system.- Parameters:
fname- file name to read- Returns:
- frame block
- Throws:
IOException- if IOException occurs
-
readCacheBlockFromLocal
public static CacheBlock<?> readCacheBlockFromLocal(String fname, boolean matrix) throws IOException Reads a matrix/frame block from local file system.- Parameters:
fname- file name to readmatrix- if true, read matrix. if false, read frame.- Returns:
- cache block (common interface to MatrixBlock and FrameBlock)
- Throws:
IOException- if IOException occurs
-
readWritableFromLocal
public static org.apache.hadoop.io.Writable readWritableFromLocal(String fname, org.apache.hadoop.io.Writable ret) throws IOException Reads an arbitrary writable from local file system, using a fused buffered reader with special support for matrix blocks.- Parameters:
fname- file name to readret- hadoop writable- Returns:
- hadoop writable
- Throws:
IOException- if IOException occurs
-
readMatrixBlockFromStream
Reads a matrix block from an input stream, using a fused buffered reader with special support for matrix blocks.- Parameters:
is- input stream to read- Returns:
- matrix block
- Throws:
IOException- if IOException occurs
-
readFrameBlockFromStream
Reads a frame block from an input stream, using a fused buffered reader with special support for matrix blocks.- Parameters:
is- input stream to read- Returns:
- frame block
- Throws:
IOException- if IOException occurs
-
readWritableFromStream
public static org.apache.hadoop.io.Writable readWritableFromStream(InputStream is, org.apache.hadoop.io.Writable ret) throws IOException Reads an arbitrary writable from an input stream, using a fused buffered reader with special support for matrix blocks.- Parameters:
is- input stream to readret- hadoop writable- Returns:
- hadoop writable
- Throws:
IOException- if IOException occurs
-
writeMatrixBlockToLocal
Writes a matrix block to local file system.- Parameters:
fname- file name to writemb- matrix block- Throws:
IOException- if IOException occurs
-
writeFrameBlockToLocal
Writes a frame block to local file system.- Parameters:
fname- file name to writefb- fame block- Throws:
IOException- if IOException occurs
-
writeCacheBlockToLocal
Writes a matrix/frame block to local file system.- Parameters:
fname- file name to writecb- cache block (common interface to matrix block and frame block)- Throws:
IOException- if IOException occurs
-
writeWritableToLocal
public static void writeWritableToLocal(String fname, org.apache.hadoop.io.Writable mb, boolean doubleBuffering) throws IOException Writes an arbitrary writable to local file system, using a fused buffered writer with special support for matrix blocks.- Parameters:
fname- file name to writemb- Hadoop writabledoubleBuffering- overlay serialization and I/O- Throws:
IOException- if IOException occurs
-
writeByteArrayToLocal
- Throws:
IOException
-
readBlockSequenceFromLocal
public static int readBlockSequenceFromLocal(String fname, Pair<MatrixIndexes, MatrixValue>[] outValues, HashMap<MatrixIndexes, throws IOExceptionInteger> outMap) - Throws:
IOException
-
writeBlockSequenceToLocal
public static void writeBlockSequenceToLocal(String fname, Pair<MatrixIndexes, MatrixValue>[] inValues, int len) throws IOException- Throws:
IOException
-
createLocalFileIfNotExist
-
deleteFileIfExists
-
deleteFileIfExists
-
isExisting
-
createLocalFileIfNotExist
-
setLocalFilePermissions
-
checkAndCreateStagingDir
-
createWorkingDirectory
-
createWorkingDirectoryWithUUID
-
cleanupWorkingDirectory
public static void cleanupWorkingDirectory() -
cleanupWorkingDirectory
-
cleanupRcWorkingDirectory
-
rDelete
Recursively deletes an entire local file system directory.- Parameters:
dir- directory to delete recursively
-
rcDelete
Recursively deletes an entire local file system directory and returns the number of files deleted.- Parameters:
dir- directory to delete recursively- Returns:
- number of files deleted
-
getWorkingDir
-
getUniqueWorkingDir
-
writeTextFile
Writes a simple text file to local file system.- Parameters:
file- output filetext- content of text file- Throws:
IOException- errors in file open/write/close
-