Package org.apache.sysds.runtime.util
Class HDFSTool
java.lang.Object
org.apache.sysds.runtime.util.HDFSTool
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddBinaryBlockSerializationFramework(org.apache.hadoop.conf.Configuration job) static voidcopyFileOnHDFS(String originalDir, String newDir) static voidcreateDirIfNotExistOnHDFS(String dir, String permissions) static voidcreateDirIfNotExistOnHDFS(org.apache.hadoop.fs.Path path) static voidcreateDirIfNotExistOnHDFS(org.apache.hadoop.fs.Path path, String permissions) static voidstatic voiddeleteFileIfExistOnHDFS(org.apache.hadoop.fs.Path outpath, org.apache.hadoop.mapred.JobConf job) static voiddeleteFileIfExistOnLFS(org.apache.hadoop.fs.Path outpath, org.apache.hadoop.mapred.JobConf job) static voidstatic longestimateNnzBasedOnFileSize(org.apache.hadoop.fs.Path path, long rlen, long clen, int blen, double factor) static booleanexistsFileOnHDFS(String fname) static org.apache.hadoop.fs.FileStatus[]getDirectoryListing(String fname) static longgetFilesizeOnHDFS(org.apache.hadoop.fs.Path path) Returns the size of a file or directory on hdfs in bytes.static org.apache.hadoop.fs.FSDataOutputStreamgetHDFSDataOutputStream(String filename, boolean overwrite) static booleanisDirectory(String fname) static booleanisDirectory(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path) static booleanisFileEmpty(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path dir) static booleanisHDFSFileEmpty(String dir) static voidmergeIntoSingleFile(String originalDir, String newFile) static StringmetaDataToString(Types.ValueType vt, Types.ValueType[] schema, Types.DataType dt, DataCharacteristics dc, Types.FileFormat fmt, FileFormatProperties formatProperties) static StringmetaDataToString(Types.ValueType vt, Types.ValueType[] schema, Types.DataType dt, DataCharacteristics dc, Types.FileFormat fmt, FileFormatProperties formatProperties, String privacyConstraints) static booleanreadBooleanFromHDFSFile(String filename) static double[]readColumnVectorFromHDFS(String dir, Types.FileFormat fmt, long rlen, long clen, int blen) static doublereadDoubleFromHDFSFile(String filename) static longreadIntegerFromHDFSFile(String filename) static double[][]readMatrixFromHDFS(String dir, Types.FileFormat fmt, long rlen, long clen, int blen) static ObjectreadObjectFromHDFSFile(String filename, Types.ValueType vt) static ScalarObjectreadScalarObjectFromHDFSFile(String fname, Types.ValueType vt) static StringreadStringFromHDFSFile(String filename) static voidrenameFileOnHDFS(String originalDir, String newDir) static voidwriteBooleanToHDFS(boolean b, String filename) static voidwriteDoubleToHDFS(double d, String filename) static voidwriteIntToHDFS(long i, String filename) static voidwriteMetaDataFile(String mtdfile, Types.ValueType vt, Types.ValueType[] schema, Types.DataType dt, DataCharacteristics mc, Types.FileFormat fmt) static voidwriteMetaDataFile(String mtdfile, Types.ValueType vt, Types.ValueType[] schema, Types.DataType dt, DataCharacteristics dc, Types.FileFormat fmt, FileFormatProperties formatProperties) static voidwriteMetaDataFile(String mtdfile, Types.ValueType vt, Types.ValueType[] schema, Types.DataType dt, DataCharacteristics dc, Types.FileFormat fmt, FileFormatProperties formatProperties, String privacyConstraints) static voidwriteMetaDataFile(String mtdfile, Types.ValueType vt, DataCharacteristics mc, Types.FileFormat fmt) static voidwriteMetaDataFile(String mtdfile, Types.ValueType vt, DataCharacteristics dc, Types.FileFormat fmt, FileFormatProperties formatProperties) static voidwriteMetaDataFileFrame(String mtdfile, Types.ValueType[] schema, DataCharacteristics dc, Types.FileFormat fmt) static voidwriteObjectToHDFS(Object obj, String filename) static voidwriteScalarMetaDataFile(String mtdfile, Types.ValueType vt) static voidwriteScalarToHDFS(ScalarObject scalar, String fname) Helper function to write scalars to HDFS, including writing its meta data and removing CRC files in local file systemstatic voidwriteStringToHDFS(String s, String filename)
-
Field Details
-
DFS_REPLICATION
- See Also:
-
IO_FILE_BUFFER_SIZE
- See Also:
-
IO_SERIALIZATIONS
- See Also:
-
DFS_BLOCKSIZE
- See Also:
-
DFS_PERMISSIONS_ENABLED
- See Also:
-
FS_DEFAULTFS
- See Also:
-
USE_BINARYBLOCK_SERIALIZATION
public static final boolean USE_BINARYBLOCK_SERIALIZATION- See Also:
-
-
Constructor Details
-
HDFSTool
public HDFSTool()
-
-
Method Details
-
addBinaryBlockSerializationFramework
public static void addBinaryBlockSerializationFramework(org.apache.hadoop.conf.Configuration job) -
existsFileOnHDFS
-
isDirectory
-
isDirectory
public static boolean isDirectory(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path) throws IOException - Throws:
IOException
-
getDirectoryListing
-
deleteFileWithMTDIfExistOnHDFS
- Throws:
IOException
-
deleteFileIfExistOnHDFS
- Throws:
IOException
-
deleteFileIfExistOnHDFS
public static void deleteFileIfExistOnHDFS(org.apache.hadoop.fs.Path outpath, org.apache.hadoop.mapred.JobConf job) throws IOException - Throws:
IOException
-
deleteFileIfExistOnLFS
public static void deleteFileIfExistOnLFS(org.apache.hadoop.fs.Path outpath, org.apache.hadoop.mapred.JobConf job) throws IOException - Throws:
IOException
-
isHDFSFileEmpty
- Throws:
IOException
-
isFileEmpty
public static boolean isFileEmpty(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path dir) throws IOException - Throws:
IOException
-
renameFileOnHDFS
- Throws:
IOException
-
mergeIntoSingleFile
- Throws:
IOException
-
copyFileOnHDFS
- Throws:
IOException
-
estimateNnzBasedOnFileSize
public static long estimateNnzBasedOnFileSize(org.apache.hadoop.fs.Path path, long rlen, long clen, int blen, double factor) throws IOException - Throws:
IOException
-
getFilesizeOnHDFS
Returns the size of a file or directory on hdfs in bytes.- Parameters:
path- file system path- Returns:
- file size
- Throws:
IOException- if IOException occurs
-
readDoubleFromHDFSFile
- Throws:
IOException
-
readIntegerFromHDFSFile
- Throws:
IOException
-
readBooleanFromHDFSFile
- Throws:
IOException
-
readStringFromHDFSFile
- Throws:
IOException
-
readObjectFromHDFSFile
- Throws:
IOException
-
readScalarObjectFromHDFSFile
-
writeScalarToHDFS
Helper function to write scalars to HDFS, including writing its meta data and removing CRC files in local file system- Parameters:
scalar- scalar data objectfname- file name
-
writeDoubleToHDFS
- Throws:
IOException
-
writeIntToHDFS
- Throws:
IOException
-
writeBooleanToHDFS
- Throws:
IOException
-
writeStringToHDFS
- Throws:
IOException
-
writeObjectToHDFS
- Throws:
IOException
-
writeMetaDataFile
public static void writeMetaDataFile(String mtdfile, Types.ValueType vt, DataCharacteristics mc, Types.FileFormat fmt) throws IOException - Throws:
IOException
-
writeMetaDataFile
public static void writeMetaDataFile(String mtdfile, Types.ValueType vt, Types.ValueType[] schema, Types.DataType dt, DataCharacteristics mc, Types.FileFormat fmt) throws IOException - Throws:
IOException
-
writeMetaDataFile
public static void writeMetaDataFile(String mtdfile, Types.ValueType vt, DataCharacteristics dc, Types.FileFormat fmt, FileFormatProperties formatProperties) throws IOException - Throws:
IOException
-
writeMetaDataFileFrame
public static void writeMetaDataFileFrame(String mtdfile, Types.ValueType[] schema, DataCharacteristics dc, Types.FileFormat fmt) throws IOException - Throws:
IOException
-
writeMetaDataFile
public static void writeMetaDataFile(String mtdfile, Types.ValueType vt, Types.ValueType[] schema, Types.DataType dt, DataCharacteristics dc, Types.FileFormat fmt, FileFormatProperties formatProperties) throws IOException - Throws:
IOException
-
writeMetaDataFile
public static void writeMetaDataFile(String mtdfile, Types.ValueType vt, Types.ValueType[] schema, Types.DataType dt, DataCharacteristics dc, Types.FileFormat fmt, FileFormatProperties formatProperties, String privacyConstraints) throws IOException - Throws:
IOException
-
writeScalarMetaDataFile
- Throws:
IOException
-
metaDataToString
public static String metaDataToString(Types.ValueType vt, Types.ValueType[] schema, Types.DataType dt, DataCharacteristics dc, Types.FileFormat fmt, FileFormatProperties formatProperties) throws org.apache.wink.json4j.JSONException, DMLRuntimeException - Throws:
org.apache.wink.json4j.JSONExceptionDMLRuntimeException
-
metaDataToString
public static String metaDataToString(Types.ValueType vt, Types.ValueType[] schema, Types.DataType dt, DataCharacteristics dc, Types.FileFormat fmt, FileFormatProperties formatProperties, String privacyConstraints) throws org.apache.wink.json4j.JSONException, DMLRuntimeException - Throws:
org.apache.wink.json4j.JSONExceptionDMLRuntimeException
-
readMatrixFromHDFS
public static double[][] readMatrixFromHDFS(String dir, Types.FileFormat fmt, long rlen, long clen, int blen) throws IOException, DMLRuntimeException - Throws:
IOExceptionDMLRuntimeException
-
readColumnVectorFromHDFS
public static double[] readColumnVectorFromHDFS(String dir, Types.FileFormat fmt, long rlen, long clen, int blen) throws IOException, DMLRuntimeException - Throws:
IOExceptionDMLRuntimeException
-
createDirIfNotExistOnHDFS
- Throws:
IOException
-
createDirIfNotExistOnHDFS
- Throws:
IOException
-
createDirIfNotExistOnHDFS
public static void createDirIfNotExistOnHDFS(org.apache.hadoop.fs.Path path, String permissions) throws IOException - Throws:
IOException
-
getHDFSDataOutputStream
public static org.apache.hadoop.fs.FSDataOutputStream getHDFSDataOutputStream(String filename, boolean overwrite) throws IOException - Throws:
IOException
-