water.util
Class Utils
java.lang.Object
water.util.Utils
public class Utils
- extends java.lang.Object
Field Summary |
static byte[][][] |
MMS
|
Constructor Summary |
Utils()
|
Method Summary |
static byte[] |
add(byte[] a,
byte[] b)
|
static double[][] |
add(double[][] a,
double[][] b)
|
static double[] |
add(double[] a,
double[] b)
|
static float[][] |
add(float[][] a,
float[][] b)
|
static float[] |
add(float[] a,
float[] b)
|
static int[][] |
add(int[][] a,
int[][] b)
|
static int[] |
add(int[] a,
int[] b)
|
static long[][] |
add(long[][] a,
long[][] b)
|
static long[] |
add(long[] a,
long[] b)
|
static
|
add(T[] a,
T... b)
|
static long |
attemptTimeParse(ValueString str)
|
static void |
clearFolder(java.io.File folder)
|
static void |
clearFolder(java.lang.String folder)
|
static void |
close(java.io.Closeable... closeable)
|
static void |
close(java.net.Socket s)
|
static int[] |
compose(int[] first,
int[] transf)
|
static boolean |
contains(int[] a,
int d)
|
static int[] |
difference(int[] a,
int[] b)
|
static int |
digit(int x,
int c)
|
static float |
entropy(byte[] f)
|
static int |
get4(byte[] buf,
int off)
|
static double |
get8d(byte[] buf,
int off)
|
static java.util.Random |
getDeterRNG(long seed)
|
static byte[] |
getFirstUnzipedBytes(Key k)
|
static byte[] |
getFirstUnzipedBytes(Value v)
|
static java.util.Random |
getRNG(long... seed)
|
static java.lang.String |
getStackAsString(java.lang.Throwable t)
|
static H2ORandomRNG.RNGKind |
getUsedRNGKind()
|
static H2ORandomRNG.RNGType |
getUsedRNGType()
|
static ParseDataset.Compression |
guessCompressionMethod(byte[] bits)
|
static boolean |
hasNaNsOrInfs(double[] arr)
|
static boolean |
isEmpty(int[] a)
|
static java.lang.String |
join(char sep,
java.lang.Iterable it)
|
static java.lang.String |
join(char sep,
java.lang.Object[] array)
|
static double |
lnF(double what)
|
static ValueArray |
loadAndParseKey(Key okey,
java.lang.String path)
|
static ValueArray |
loadAndParseKey(java.lang.String path)
|
static int[] |
mapping(int[] dom)
Returns a mapping of given domain to values (0, ... |
static int |
maxIndex(float[] from)
|
static int |
maxIndex(int[] from)
|
static int |
maxIndex(int[] from,
java.util.Random rand)
Returns the index of the largest value in the array. |
static byte[] |
or(byte[] a,
byte[] b)
|
static java.lang.String |
p2d(double d)
|
static java.lang.String |
p5d(double d)
|
static java.lang.String |
pprint(double[][] arr)
|
static java.lang.String |
pprint(double[][] arr,
java.text.DecimalFormat dformat)
|
static java.lang.String |
readConsole()
|
static java.lang.String |
readFile(java.io.File file)
|
static
|
remove(T[] a,
int i)
|
static java.lang.String |
sampleToString(int[] val,
int max)
|
static int[] |
seq(int start,
int stop)
Generates sequence
|
static int |
set4(byte[] buf,
int off,
int x)
|
static int |
set8d(byte[] buf,
int off,
double d)
|
static void |
setUsedRNGKind(H2ORandomRNG.RNGKind kind)
|
static void |
setUsedRNGType(H2ORandomRNG.RNGType rngType)
|
static void |
shuffleArray(long[] a)
|
static
|
subarray(T[] a,
int off,
int len)
|
static int |
sum(int[] from)
|
static java.lang.String[] |
toStringMap(int[] dom)
|
static int[] |
unpackInts(long... longs)
|
static byte[] |
unzipBytes(byte[] bs,
ParseDataset.Compression cmp)
|
static java.io.File |
writeFile(java.io.File file,
java.lang.String content)
|
static java.io.File |
writeFile(java.lang.String content)
|
static void |
writeFileAndClose(java.io.File file,
java.io.InputStream in)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MMS
public static final byte[][][] MMS
Utils
public Utils()
maxIndex
public static int maxIndex(int[] from,
java.util.Random rand)
- Returns the index of the largest value in the array.
In case of a tie, an the index is selected randomly.
maxIndex
public static int maxIndex(int[] from)
maxIndex
public static int maxIndex(float[] from)
lnF
public static double lnF(double what)
p2d
public static java.lang.String p2d(double d)
p5d
public static java.lang.String p5d(double d)
set4
public static int set4(byte[] buf,
int off,
int x)
get4
public static int get4(byte[] buf,
int off)
set8d
public static int set8d(byte[] buf,
int off,
double d)
get8d
public static double get8d(byte[] buf,
int off)
sum
public static int sum(int[] from)
sampleToString
public static java.lang.String sampleToString(int[] val,
int max)
getDeterRNG
public static java.util.Random getDeterRNG(long seed)
setUsedRNGKind
public static void setUsedRNGKind(H2ORandomRNG.RNGKind kind)
getRNG
public static java.util.Random getRNG(long... seed)
setUsedRNGType
public static void setUsedRNGType(H2ORandomRNG.RNGType rngType)
getUsedRNGType
public static H2ORandomRNG.RNGType getUsedRNGType()
getUsedRNGKind
public static H2ORandomRNG.RNGKind getUsedRNGKind()
entropy
public static float entropy(byte[] f)
unpackInts
public static int[] unpackInts(long... longs)
shuffleArray
public static void shuffleArray(long[] a)
close
public static void close(java.io.Closeable... closeable)
close
public static void close(java.net.Socket s)
readConsole
public static java.lang.String readConsole()
writeFile
public static java.io.File writeFile(java.lang.String content)
writeFile
public static java.io.File writeFile(java.io.File file,
java.lang.String content)
writeFileAndClose
public static void writeFileAndClose(java.io.File file,
java.io.InputStream in)
readFile
public static java.lang.String readFile(java.io.File file)
join
public static java.lang.String join(char sep,
java.lang.Object[] array)
join
public static java.lang.String join(char sep,
java.lang.Iterable it)
add
public static <T> T[] add(T[] a,
T... b)
remove
public static <T> T[] remove(T[] a,
int i)
or
public static byte[] or(byte[] a,
byte[] b)
add
public static byte[] add(byte[] a,
byte[] b)
add
public static int[] add(int[] a,
int[] b)
add
public static int[][] add(int[][] a,
int[][] b)
add
public static long[] add(long[] a,
long[] b)
add
public static long[][] add(long[][] a,
long[][] b)
add
public static float[] add(float[] a,
float[] b)
add
public static float[][] add(float[][] a,
float[][] b)
add
public static double[] add(double[] a,
double[] b)
add
public static double[][] add(double[][] a,
double[][] b)
subarray
public static <T> T[] subarray(T[] a,
int off,
int len)
clearFolder
public static void clearFolder(java.lang.String folder)
clearFolder
public static void clearFolder(java.io.File folder)
loadAndParseKey
public static ValueArray loadAndParseKey(java.lang.String path)
loadAndParseKey
public static ValueArray loadAndParseKey(Key okey,
java.lang.String path)
getFirstUnzipedBytes
public static byte[] getFirstUnzipedBytes(Key k)
getFirstUnzipedBytes
public static byte[] getFirstUnzipedBytes(Value v)
guessCompressionMethod
public static ParseDataset.Compression guessCompressionMethod(byte[] bits)
unzipBytes
public static byte[] unzipBytes(byte[] bs,
ParseDataset.Compression cmp)
hasNaNsOrInfs
public static final boolean hasNaNsOrInfs(double[] arr)
getStackAsString
public static java.lang.String getStackAsString(java.lang.Throwable t)
digit
public static int digit(int x,
int c)
attemptTimeParse
public static long attemptTimeParse(ValueString str)
mapping
public static int[] mapping(int[] dom)
- Returns a mapping of given domain to values (0, ... max(dom)).
Unused domain items has mapping to -1.
toStringMap
public static java.lang.String[] toStringMap(int[] dom)
compose
public static int[] compose(int[] first,
int[] transf)
pprint
public static java.lang.String pprint(double[][] arr)
pprint
public static java.lang.String pprint(double[][] arr,
java.text.DecimalFormat dformat)
isEmpty
public static boolean isEmpty(int[] a)
contains
public static boolean contains(int[] a,
int d)
difference
public static int[] difference(int[] a,
int[] b)
seq
public static int[] seq(int start,
int stop)
- Generates sequence