public class LocalFileUtils extends Object
Modifier and Type | Field and Description |
---|---|
static int |
BUFFER_SIZE |
static String |
CATEGORY_CACHE |
static String |
CATEGORY_CODEGEN |
static String |
CATEGORY_LINEAGE |
static String |
CATEGORY_PARTITIONING |
static String |
CATEGORY_RESULTMERGE |
static String |
CATEGORY_WORK |
Constructor and Description |
---|
LocalFileUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
checkAndCreateStagingDir(String dir) |
static int |
cleanupRcWorkingDirectory(String dir) |
static void |
cleanupWorkingDirectory() |
static void |
cleanupWorkingDirectory(String dir) |
static boolean |
createLocalFileIfNotExist(String dir) |
static boolean |
createLocalFileIfNotExist(String dir,
String permission) |
static String |
createWorkingDirectory() |
static String |
createWorkingDirectoryWithUUID(String uuid) |
static void |
deleteFileIfExists(String dir) |
static void |
deleteFileIfExists(String dir,
boolean fileOnly) |
static String |
getUniqueWorkingDir(String category) |
static String |
getWorkingDir(String category) |
static boolean |
isExisting(String dir) |
static int |
rcDelete(File dir)
Recursively deletes an entire local file system directory
and returns the number of files deleted.
|
static void |
rDelete(File dir)
Recursively deletes an entire local file system directory.
|
static int |
readBlockSequenceFromLocal(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 FrameBlock |
readFrameBlockFromLocal(String fname)
Reads a frame block from local file system.
|
static FrameBlock |
readFrameBlockFromStream(InputStream is)
Reads a frame block from an input stream, using a fused buffered reader
with special support for matrix blocks.
|
static MatrixBlock |
readMatrixBlockFromLocal(String fname)
Reads a matrix block from local file system.
|
static MatrixBlock |
readMatrixBlockFromLocal(String fname,
MatrixBlock reuse)
Reads a matrix block from local file system.
|
static MatrixBlock |
readMatrixBlockFromStream(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.Writable |
readWritableFromLocal(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.Writable |
readWritableFromStream(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 void |
setLocalFilePermissions(File file,
String permissions) |
static void |
writeBlockSequenceToLocal(String fname,
Pair<MatrixIndexes,MatrixValue>[] inValues,
int len) |
static void |
writeByteArrayToLocal(String fname,
byte[] data) |
static void |
writeCacheBlockToLocal(String fname,
CacheBlock cb)
Writes a matrix/frame block to local file system.
|
static void |
writeFrameBlockToLocal(String fname,
FrameBlock fb)
Writes a frame block to local file system.
|
static void |
writeMatrixBlockToLocal(String fname,
MatrixBlock mb)
Writes a matrix block to local file system.
|
static void |
writeTextFile(File file,
String text)
Writes a simple text file to local file system.
|
static void |
writeWritableToLocal(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.
|
public static final int BUFFER_SIZE
public static final String CATEGORY_CACHE
public static final String CATEGORY_PARTITIONING
public static final String CATEGORY_RESULTMERGE
public static final String CATEGORY_WORK
public static final String CATEGORY_CODEGEN
public static final String CATEGORY_LINEAGE
public static MatrixBlock readMatrixBlockFromLocal(String fname) throws IOException
fname
- file name to readIOException
- if IOException occurspublic static MatrixBlock readMatrixBlockFromLocal(String fname, MatrixBlock reuse) throws IOException
fname
- file name to readreuse
- matrix block to reuseIOException
- if IOException occurspublic static FrameBlock readFrameBlockFromLocal(String fname) throws IOException
fname
- file name to readIOException
- if IOException occurspublic static CacheBlock readCacheBlockFromLocal(String fname, boolean matrix) throws IOException
fname
- file name to readmatrix
- if true, read matrix. if false, read frame.IOException
- if IOException occurspublic static org.apache.hadoop.io.Writable readWritableFromLocal(String fname, org.apache.hadoop.io.Writable ret) throws IOException
fname
- file name to readret
- hadoop writableIOException
- if IOException occurspublic static MatrixBlock readMatrixBlockFromStream(InputStream is) throws IOException
is
- input stream to readIOException
- if IOException occurspublic static FrameBlock readFrameBlockFromStream(InputStream is) throws IOException
is
- input stream to readIOException
- if IOException occurspublic static org.apache.hadoop.io.Writable readWritableFromStream(InputStream is, org.apache.hadoop.io.Writable ret) throws IOException
is
- input stream to readret
- hadoop writableIOException
- if IOException occurspublic static void writeMatrixBlockToLocal(String fname, MatrixBlock mb) throws IOException
fname
- file name to writemb
- matrix blockIOException
- if IOException occurspublic static void writeFrameBlockToLocal(String fname, FrameBlock fb) throws IOException
fname
- file name to writefb
- fame blockIOException
- if IOException occurspublic static void writeCacheBlockToLocal(String fname, CacheBlock cb) throws IOException
fname
- file name to writecb
- cache block (common interface to matrix block and frame block)IOException
- if IOException occurspublic static void writeWritableToLocal(String fname, org.apache.hadoop.io.Writable mb) throws IOException
fname
- file name to writemb
- Hadoop writableIOException
- if IOException occurspublic static void writeByteArrayToLocal(String fname, byte[] data) throws IOException
IOException
public static int readBlockSequenceFromLocal(String fname, Pair<MatrixIndexes,MatrixValue>[] outValues, HashMap<MatrixIndexes,Integer> outMap) throws IOException
IOException
public static void writeBlockSequenceToLocal(String fname, Pair<MatrixIndexes,MatrixValue>[] inValues, int len) throws IOException
IOException
public static boolean createLocalFileIfNotExist(String dir)
public static void deleteFileIfExists(String dir)
public static void deleteFileIfExists(String dir, boolean fileOnly)
public static boolean isExisting(String dir)
public static boolean createLocalFileIfNotExist(String dir, String permission)
public static String createWorkingDirectory()
public static void cleanupWorkingDirectory()
public static void cleanupWorkingDirectory(String dir)
public static int cleanupRcWorkingDirectory(String dir)
public static void rDelete(File dir)
dir
- directory to delete recursivelypublic static int rcDelete(File dir)
dir
- directory to delete recursivelypublic static void writeTextFile(File file, String text) throws IOException
file
- output filetext
- content of text fileIOException
- errors in file open/write/closeCopyright © 2020 The Apache Software Foundation. All rights reserved.