public class DataConverter extends Object
Constructor and Description |
---|
DataConverter() |
Modifier and Type | Method and Description |
---|---|
static org.apache.commons.math3.linear.Array2DRowRealMatrix |
convertToArray2DRowRealMatrix(MatrixBlock mb)
Helper method that converts SystemDS matrix variable (
varname ) into a Array2DRowRealMatrix format,
which is useful in invoking Apache CommonsMath. |
static org.apache.commons.math3.linear.BlockRealMatrix |
convertToBlockRealMatrix(MatrixBlock mb) |
static boolean[] |
convertToBooleanVector(MatrixBlock mb) |
static DenseBlock |
convertToDenseBlock(MatrixBlock mb) |
static DenseBlock |
convertToDenseBlock(MatrixBlock mb,
boolean deep) |
static List<Double> |
convertToDoubleList(MatrixBlock mb) |
static double[][] |
convertToDoubleMatrix(MatrixBlock mb)
Creates a two-dimensional double matrix of the input matrix block.
|
static double[] |
convertToDoubleVector(MatrixBlock mb) |
static double[] |
convertToDoubleVector(MatrixBlock mb,
boolean deep) |
static double[] |
convertToDoubleVector(MatrixBlock mb,
boolean deep,
boolean allowNull) |
static FrameBlock |
convertToFrameBlock(MatrixBlock mb)
Converts a matrix block into a frame block of value type double.
|
static FrameBlock |
convertToFrameBlock(MatrixBlock mb,
Types.ValueType vt)
Converts a matrix block into a frame block of a given value type.
|
static FrameBlock |
convertToFrameBlock(MatrixBlock mb,
Types.ValueType[] schema) |
static FrameBlock |
convertToFrameBlock(String[][] data)
Converts a two dimensions string array into a frame block of
value type string.
|
static FrameBlock |
convertToFrameBlock(String[][] data,
Types.ValueType[] schema) |
static FrameBlock |
convertToFrameBlock(String[][] data,
Types.ValueType[] schema,
String[] colnames) |
static int[] |
convertToIntVector(MatrixBlock mb) |
static long[] |
convertToLongVector(MatrixBlock mb) |
static MatrixBlock |
convertToMatrixBlock(CTableMap map) |
static MatrixBlock |
convertToMatrixBlock(CTableMap map,
int rlen,
int clen)
NOTE: this method also ensures the specified matrix dimensions
|
static MatrixBlock |
convertToMatrixBlock(double[][] data)
Creates a dense Matrix Block and copies the given double matrix into it.
|
static MatrixBlock |
convertToMatrixBlock(double[] data,
boolean columnVector)
Creates a dense Matrix Block and copies the given double vector into it.
|
static MatrixBlock |
convertToMatrixBlock(FrameBlock frame)
Converts a frame block with arbitrary schema into a matrix block.
|
static MatrixBlock |
convertToMatrixBlock(HashMap<MatrixIndexes,Double> map) |
static MatrixBlock |
convertToMatrixBlock(HashMap<MatrixIndexes,Double> map,
int rlen,
int clen)
NOTE: this method also ensures the specified matrix dimensions
|
static MatrixBlock |
convertToMatrixBlock(int[][] data)
Converts an Integer matrix to an MatrixBlock
|
static MatrixBlock |
convertToMatrixBlock(org.apache.commons.math3.linear.RealMatrix rm) |
static MatrixBlock[] |
convertToMatrixBlockPartitions(MatrixBlock mb,
boolean colwise) |
static String[][] |
convertToStringFrame(FrameBlock frame)
Converts a frame block with arbitrary schema into a two dimensional
string array.
|
static TensorBlock |
convertToTensorBlock(MatrixBlock mb,
Types.ValueType vt,
boolean toBasicTensor) |
static void |
copyToDoubleVector(MatrixBlock mb,
double[] dest,
int destPos) |
static int[] |
getTensorDimensions(ExecutionContext ec,
CPOperand dims) |
static MatrixBlock |
readMatrixFromHDFS(ReadProperties prop)
Core method for reading matrices in format textcell, matrixmarket, binarycell, or binaryblock
from HDFS into main memory.
|
static MatrixBlock |
readMatrixFromHDFS(String dir,
Types.FileFormat fmt,
long rlen,
long clen,
int blen) |
static MatrixBlock |
readMatrixFromHDFS(String dir,
Types.FileFormat fmt,
long rlen,
long clen,
int blen,
boolean localFS) |
static MatrixBlock |
readMatrixFromHDFS(String dir,
Types.FileFormat fmt,
long rlen,
long clen,
int blen,
long expectedNnz) |
static MatrixBlock |
readMatrixFromHDFS(String dir,
Types.FileFormat fmt,
long rlen,
long clen,
int blen,
long expectedNnz,
boolean localFS) |
static MatrixBlock |
readMatrixFromHDFS(String dir,
Types.FileFormat fmt,
long rlen,
long clen,
int blen,
long expectedNnz,
FileFormatProperties formatProperties) |
static TensorBlock |
readTensorFromHDFS(String dir,
Types.FileFormat fmt,
long[] dims,
int blen,
Types.ValueType[] schema) |
static BitSet |
toBitSet(double[] data) |
static double[] |
toDouble(BitSet data,
int len) |
static double[] |
toDouble(float[] data) |
static double[] |
toDouble(int[] data) |
static double[] |
toDouble(long[] data) |
static double[] |
toDouble(String[] data) |
static float[] |
toFloat(double[] data) |
static int[] |
toInt(double[] data) |
static long[] |
toLong(double[] data) |
static String[] |
toString(double[] data) |
static String |
toString(FrameBlock fb) |
static String |
toString(FrameBlock fb,
boolean sparse,
String separator,
String lineseparator,
int rowsToPrint,
int colsToPrint,
int decimal) |
static String |
toString(ListObject list,
int rows,
int cols,
boolean sparse,
String separator,
String lineSeparator,
int rowsToPrint,
int colsToPrint,
int decimal) |
static String |
toString(MatrixBlock mb) |
static String |
toString(MatrixBlock mb,
boolean sparse,
String separator,
String lineseparator,
int rowsToPrint,
int colsToPrint,
int decimal)
Returns a string representation of a matrix
|
static String |
toString(TensorBlock tb) |
static String |
toString(TensorBlock tb,
boolean sparse,
String separator,
String lineseparator,
String leftBorder,
String rightBorder,
int rowsToPrint,
int colsToPrint,
int decimal)
Returns a string representation of a tensor
|
static void |
writeMatrixToHDFS(MatrixBlock mat,
String dir,
Types.FileFormat fmt,
DataCharacteristics dc) |
static void |
writeMatrixToHDFS(MatrixBlock mat,
String dir,
Types.FileFormat fmt,
DataCharacteristics dc,
int replication,
FileFormatProperties formatProperties) |
static void |
writeMatrixToHDFS(MatrixBlock mat,
String dir,
Types.FileFormat fmt,
DataCharacteristics dc,
int replication,
FileFormatProperties formatProperties,
boolean diag) |
static void |
writeTensorToHDFS(TensorBlock tensor,
String dir,
Types.FileFormat fmt,
DataCharacteristics dc) |
public static void writeMatrixToHDFS(MatrixBlock mat, String dir, Types.FileFormat fmt, DataCharacteristics dc) throws IOException
IOException
public static void writeMatrixToHDFS(MatrixBlock mat, String dir, Types.FileFormat fmt, DataCharacteristics dc, int replication, FileFormatProperties formatProperties) throws IOException
IOException
public static void writeMatrixToHDFS(MatrixBlock mat, String dir, Types.FileFormat fmt, DataCharacteristics dc, int replication, FileFormatProperties formatProperties, boolean diag) throws IOException
IOException
public static void writeTensorToHDFS(TensorBlock tensor, String dir, Types.FileFormat fmt, DataCharacteristics dc) throws IOException
IOException
public static MatrixBlock readMatrixFromHDFS(String dir, Types.FileFormat fmt, long rlen, long clen, int blen, boolean localFS) throws IOException
IOException
public static MatrixBlock readMatrixFromHDFS(String dir, Types.FileFormat fmt, long rlen, long clen, int blen) throws IOException
IOException
public static MatrixBlock readMatrixFromHDFS(String dir, Types.FileFormat fmt, long rlen, long clen, int blen, long expectedNnz) throws IOException
IOException
public static MatrixBlock readMatrixFromHDFS(String dir, Types.FileFormat fmt, long rlen, long clen, int blen, long expectedNnz, boolean localFS) throws IOException
IOException
public static MatrixBlock readMatrixFromHDFS(String dir, Types.FileFormat fmt, long rlen, long clen, int blen, long expectedNnz, FileFormatProperties formatProperties) throws IOException
IOException
public static TensorBlock readTensorFromHDFS(String dir, Types.FileFormat fmt, long[] dims, int blen, Types.ValueType[] schema) throws IOException
IOException
public static MatrixBlock readMatrixFromHDFS(ReadProperties prop) throws IOException
prop
- read propertiesIOException
- if IOException occurspublic static double[][] convertToDoubleMatrix(MatrixBlock mb)
mb
- matrix blockpublic static boolean[] convertToBooleanVector(MatrixBlock mb)
public static int[] convertToIntVector(MatrixBlock mb)
public static long[] convertToLongVector(MatrixBlock mb)
public static DenseBlock convertToDenseBlock(MatrixBlock mb)
public static DenseBlock convertToDenseBlock(MatrixBlock mb, boolean deep)
public static double[] convertToDoubleVector(MatrixBlock mb)
public static double[] convertToDoubleVector(MatrixBlock mb, boolean deep)
public static double[] convertToDoubleVector(MatrixBlock mb, boolean deep, boolean allowNull)
public static List<Double> convertToDoubleList(MatrixBlock mb)
public static MatrixBlock convertToMatrixBlock(double[][] data)
data
- 2d double arraypublic static MatrixBlock convertToMatrixBlock(int[][] data)
data
- Int matrix input that is converted to double MatrixBlockpublic static MatrixBlock convertToMatrixBlock(double[] data, boolean columnVector)
data
- double arraycolumnVector
- if true, create matrix with single column. if false, create matrix with single rowpublic static MatrixBlock convertToMatrixBlock(HashMap<MatrixIndexes,Double> map)
public static MatrixBlock convertToMatrixBlock(HashMap<MatrixIndexes,Double> map, int rlen, int clen)
map
- map of matrix index keys and double valuesrlen
- number of rowsclen
- number of columnspublic static MatrixBlock convertToMatrixBlock(CTableMap map)
public static MatrixBlock convertToMatrixBlock(CTableMap map, int rlen, int clen)
map
- ?rlen
- number of rowsclen
- number of columnspublic static MatrixBlock convertToMatrixBlock(FrameBlock frame)
frame
- frame blockpublic static String[][] convertToStringFrame(FrameBlock frame)
frame
- frame blockpublic static FrameBlock convertToFrameBlock(String[][] data)
data
- 2d string arraypublic static FrameBlock convertToFrameBlock(String[][] data, Types.ValueType[] schema)
public static FrameBlock convertToFrameBlock(String[][] data, Types.ValueType[] schema, String[] colnames)
public static FrameBlock convertToFrameBlock(MatrixBlock mb)
mb
- matrix blockpublic static FrameBlock convertToFrameBlock(MatrixBlock mb, Types.ValueType vt)
mb
- matrix blockvt
- value typepublic static FrameBlock convertToFrameBlock(MatrixBlock mb, Types.ValueType[] schema)
public static TensorBlock convertToTensorBlock(MatrixBlock mb, Types.ValueType vt, boolean toBasicTensor)
public static MatrixBlock[] convertToMatrixBlockPartitions(MatrixBlock mb, boolean colwise)
public static org.apache.commons.math3.linear.Array2DRowRealMatrix convertToArray2DRowRealMatrix(MatrixBlock mb)
varname
) into a Array2DRowRealMatrix format,
which is useful in invoking Apache CommonsMath.mb
- matrix objectpublic static org.apache.commons.math3.linear.BlockRealMatrix convertToBlockRealMatrix(MatrixBlock mb)
public static MatrixBlock convertToMatrixBlock(org.apache.commons.math3.linear.RealMatrix rm)
public static void copyToDoubleVector(MatrixBlock mb, double[] dest, int destPos)
public static String toString(MatrixBlock mb)
public static String toString(MatrixBlock mb, boolean sparse, String separator, String lineseparator, int rowsToPrint, int colsToPrint, int decimal)
mb
- matrix blocksparse
- if true, string will contain a table with row index, col index, value (where value != 0.0)
otherwise it will be a rectangular string with all values of the matrix blockseparator
- Separator string between each element in a row, or between the columns in sparse formatlineseparator
- Separator string between each rowrowsToPrint
- maximum number of rows to print, -1 for allcolsToPrint
- maximum number of columns to print, -1 for alldecimal
- number of decimal places to print, -1 for defaultpublic static String toString(TensorBlock tb)
public static String toString(TensorBlock tb, boolean sparse, String separator, String lineseparator, String leftBorder, String rightBorder, int rowsToPrint, int colsToPrint, int decimal)
tb
- tensor blocksparse
- if true, string will contain a table with row index, col index, value (where value != 0.0)
otherwise it will be a rectangular string with all values of the tensor blockseparator
- Separator string between each element in a row, or between the columns in sparse formatlineseparator
- Separator string between each rowleftBorder
- Characters placed at the start of a new dimension levelrightBorder
- Characters placed at the end of a new dimension levelrowsToPrint
- maximum number of rows to print, -1 for allcolsToPrint
- maximum number of columns to print, -1 for alldecimal
- number of decimal places to print, -1 for defaultpublic static String toString(FrameBlock fb)
public static String toString(FrameBlock fb, boolean sparse, String separator, String lineseparator, int rowsToPrint, int colsToPrint, int decimal)
public static String toString(ListObject list, int rows, int cols, boolean sparse, String separator, String lineSeparator, int rowsToPrint, int colsToPrint, int decimal)
public static int[] getTensorDimensions(ExecutionContext ec, CPOperand dims)
public static double[] toDouble(float[] data)
public static double[] toDouble(long[] data)
public static double[] toDouble(int[] data)
public static double[] toDouble(BitSet data, int len)
public static double[] toDouble(String[] data)
public static float[] toFloat(double[] data)
public static int[] toInt(double[] data)
public static long[] toLong(double[] data)
public static BitSet toBitSet(double[] data)
public static String[] toString(double[] data)
Copyright © 2020 The Apache Software Foundation. All rights reserved.