Package org.apache.sysds.runtime.util
Class LocalFileUtils
- java.lang.Object
- 
- org.apache.sysds.runtime.util.LocalFileUtils
 
- 
 public class LocalFileUtils extends Object 
- 
- 
Field SummaryFields Modifier and Type Field Description static intBUFFER_SIZEstatic StringCATEGORY_CACHEstatic StringCATEGORY_CODEGENstatic StringCATEGORY_LINEAGEstatic StringCATEGORY_PARTITIONINGstatic StringCATEGORY_RESULTMERGEstatic StringCATEGORY_WORK
 - 
Constructor SummaryConstructors Constructor Description LocalFileUtils()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static StringcheckAndCreateStagingDir(String dir)static intcleanupRcWorkingDirectory(String dir)static voidcleanupWorkingDirectory()static voidcleanupWorkingDirectory(String dir)static booleancreateLocalFileIfNotExist(String dir)static booleancreateLocalFileIfNotExist(String dir, String permission)static StringcreateWorkingDirectory()static StringcreateWorkingDirectoryWithUUID(String uuid)static voiddeleteFileIfExists(String dir)static voiddeleteFileIfExists(String dir, boolean fileOnly)static StringgetUniqueWorkingDir(String category)static StringgetWorkingDir(String category)static booleanisExisting(String dir)static intrcDelete(File dir)Recursively deletes an entire local file system directory and returns the number of files deleted.static voidrDelete(File dir)Recursively deletes an entire local file system directory.static intreadBlockSequenceFromLocal(String fname, Pair<MatrixIndexes,MatrixValue>[] outValues, HashMap<MatrixIndexes,Integer> outMap)static CacheBlockreadCacheBlockFromLocal(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 FrameBlockreadFrameBlockFromStream(InputStream is)Reads 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 MatrixBlockreadMatrixBlockFromStream(InputStream is)Reads 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)Writes an arbitrary writable to local file system, using a fused buffered writer with special support for matrix blocks.
 
- 
- 
- 
Field Detail- 
BUFFER_SIZEpublic static final int BUFFER_SIZE - See Also:
- Constant Field Values
 
 - 
CATEGORY_CACHEpublic static final String CATEGORY_CACHE - See Also:
- Constant Field Values
 
 - 
CATEGORY_PARTITIONINGpublic static final String CATEGORY_PARTITIONING - See Also:
- Constant Field Values
 
 - 
CATEGORY_RESULTMERGEpublic static final String CATEGORY_RESULTMERGE - See Also:
- Constant Field Values
 
 - 
CATEGORY_WORKpublic static final String CATEGORY_WORK - See Also:
- Constant Field Values
 
 - 
CATEGORY_CODEGENpublic static final String CATEGORY_CODEGEN - See Also:
- Constant Field Values
 
 - 
CATEGORY_LINEAGEpublic static final String CATEGORY_LINEAGE - See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
readMatrixBlockFromLocalpublic static MatrixBlock readMatrixBlockFromLocal(String fname) throws IOException Reads a matrix block from local file system.- Parameters:
- fname- file name to read
- Returns:
- matrix block
- Throws:
- IOException- if IOException occurs
 
 - 
readMatrixBlockFromLocalpublic static MatrixBlock readMatrixBlockFromLocal(String fname, MatrixBlock reuse) throws IOException Reads a matrix block from local file system.- Parameters:
- fname- file name to read
- reuse- matrix block to reuse
- Returns:
- matrix block
- Throws:
- IOException- if IOException occurs
 
 - 
readFrameBlockFromLocalpublic static FrameBlock readFrameBlockFromLocal(String fname) throws IOException Reads a frame block from local file system.- Parameters:
- fname- file name to read
- Returns:
- frame block
- Throws:
- IOException- if IOException occurs
 
 - 
readCacheBlockFromLocalpublic static CacheBlock readCacheBlockFromLocal(String fname, boolean matrix) throws IOException Reads a matrix/frame block from local file system.- Parameters:
- fname- file name to read
- matrix- if true, read matrix. if false, read frame.
- Returns:
- cache block (common interface to MatrixBlock and FrameBlock)
- Throws:
- IOException- if IOException occurs
 
 - 
readWritableFromLocalpublic 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 read
- ret- hadoop writable
- Returns:
- hadoop writable
- Throws:
- IOException- if IOException occurs
 
 - 
readMatrixBlockFromStreampublic static MatrixBlock readMatrixBlockFromStream(InputStream is) throws IOException 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
 
 - 
readFrameBlockFromStreampublic static FrameBlock readFrameBlockFromStream(InputStream is) throws IOException 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
 
 - 
readWritableFromStreampublic 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 read
- ret- hadoop writable
- Returns:
- hadoop writable
- Throws:
- IOException- if IOException occurs
 
 - 
writeMatrixBlockToLocalpublic static void writeMatrixBlockToLocal(String fname, MatrixBlock mb) throws IOException Writes a matrix block to local file system.- Parameters:
- fname- file name to write
- mb- matrix block
- Throws:
- IOException- if IOException occurs
 
 - 
writeFrameBlockToLocalpublic static void writeFrameBlockToLocal(String fname, FrameBlock fb) throws IOException Writes a frame block to local file system.- Parameters:
- fname- file name to write
- fb- fame block
- Throws:
- IOException- if IOException occurs
 
 - 
writeCacheBlockToLocalpublic static void writeCacheBlockToLocal(String fname, CacheBlock cb) throws IOException Writes a matrix/frame block to local file system.- Parameters:
- fname- file name to write
- cb- cache block (common interface to matrix block and frame block)
- Throws:
- IOException- if IOException occurs
 
 - 
writeWritableToLocalpublic static void writeWritableToLocal(String fname, org.apache.hadoop.io.Writable mb) 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 write
- mb- Hadoop writable
- Throws:
- IOException- if IOException occurs
 
 - 
writeByteArrayToLocalpublic static void writeByteArrayToLocal(String fname, byte[] data) throws IOException - Throws:
- IOException
 
 - 
readBlockSequenceFromLocalpublic static int readBlockSequenceFromLocal(String fname, Pair<MatrixIndexes,MatrixValue>[] outValues, HashMap<MatrixIndexes,Integer> outMap) throws IOException - Throws:
- IOException
 
 - 
writeBlockSequenceToLocalpublic static void writeBlockSequenceToLocal(String fname, Pair<MatrixIndexes,MatrixValue>[] inValues, int len) throws IOException - Throws:
- IOException
 
 - 
createLocalFileIfNotExistpublic static boolean createLocalFileIfNotExist(String dir) 
 - 
deleteFileIfExistspublic static void deleteFileIfExists(String dir) 
 - 
deleteFileIfExistspublic static void deleteFileIfExists(String dir, boolean fileOnly) 
 - 
isExistingpublic static boolean isExisting(String dir) 
 - 
createLocalFileIfNotExistpublic static boolean createLocalFileIfNotExist(String dir, String permission) 
 - 
createWorkingDirectorypublic static String createWorkingDirectory() 
 - 
cleanupWorkingDirectorypublic static void cleanupWorkingDirectory() 
 - 
cleanupWorkingDirectorypublic static void cleanupWorkingDirectory(String dir) 
 - 
cleanupRcWorkingDirectorypublic static int cleanupRcWorkingDirectory(String dir) 
 - 
rDeletepublic static void rDelete(File dir) Recursively deletes an entire local file system directory.- Parameters:
- dir- directory to delete recursively
 
 - 
rcDeletepublic static int rcDelete(File dir) 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
 
 - 
writeTextFilepublic static void writeTextFile(File file, String text) throws IOException Writes a simple text file to local file system.- Parameters:
- file- output file
- text- content of text file
- Throws:
- IOException- errors in file open/write/close
 
 
- 
 
-