public class Utils
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Utils.AtomicDoubleArray |
static class |
Utils.AtomicFloatArray |
static class |
Utils.AtomicIntArray |
static class |
Utils.AtomicLongArray |
static class |
Utils.ExpectedExceptionForDebug |
static class |
Utils.IcedArrayList<T extends Iced>
Simple wrapper around ArrayList with support for H2O serialization
|
static class |
Utils.IcedHashMap<K extends Iced,V extends Iced>
Simple wrapper around HashMap with support for H2O serialization
|
static class |
Utils.IcedInt |
static class |
Utils.IcedLong |
Modifier and Type | Field and Description |
---|---|
static java.util.regex.Pattern[] |
ILLEGAL_CHARACTERS
Java-string illegal characters which need to be escaped
|
static byte[][][] |
MMS |
static java.lang.String[] |
REPLACEMENTS |
Constructor and Description |
---|
Utils() |
Modifier and Type | Method and Description |
---|---|
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 double[][] |
append(double[][] a,
double[][] b) |
static double[] |
append(double[] a,
double e) |
static int[] |
append(int[] a,
int[] b) |
static long[][][] |
append(long[][][] a,
long[][] e) |
static java.lang.String[] |
append(java.lang.String[] a,
java.lang.String[] b) |
static <T> T[] |
append(T[] a,
T... b) |
static long |
attemptTimeParse(ValueString str) |
static double |
avg(double[] nums) |
static double |
avg(long[] nums) |
static java.lang.String |
className(java.lang.String path) |
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[][] second) |
static int[] |
compose(int[] first,
int[] transf) |
static boolean |
contains(int[] a,
int d) |
static boolean |
contains(java.lang.String[] names,
java.lang.String name) |
static boolean |
contains(java.lang.String s,
java.lang.CharSequence cs)
Returns true if given string contains at least on of character of
given sequence.
|
static int[] |
difference(int[] a,
int[] b) |
static int |
digit(int x,
int c) |
static double[] |
div(double[] nums,
double n) |
static float[] |
div(float[] nums,
float n) |
static float[] |
div(float[] nums,
int n) |
static float |
entropy(byte[] f) |
static boolean |
equalsWithinOneSmallUlp(double a,
double b) |
static boolean |
equalsWithinOneSmallUlp(float a,
float b)
Compare two numbers to see if they are within one ulp of the smaller decade.
|
static java.lang.String |
escapeJava(java.lang.String s)
Escape all " and \ characters to provide a proper Java-like string
Does not escape unicode characters.
|
static int[] |
filter(int[] values,
boolean[] filter,
int fcnt) |
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 int[] |
or(int[] a,
int[] b) |
static java.lang.String |
p2d(double d) |
static java.lang.String |
p5d(double d) |
static int[][] |
pack(int[] values,
boolean[] usemap) |
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 void |
readFile(java.io.File file,
java.io.OutputStream out) |
static int[] |
remove(int[] a,
int i) |
static <T> T[] |
remove(T[] a,
int i) |
static java.lang.StringBuilder |
replace(java.lang.StringBuilder sb,
java.lang.CharSequence from,
java.lang.CharSequence to)
Replace given characters in a given string builder.
|
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,
long seed) |
static <T> T[] |
subarray(T[] a,
int off,
int len) |
static double |
sum(double[] from) |
static float |
sum(float[] from) |
static int |
sum(int[] from) |
static java.io.File |
tmp()
Returns the system temporary folder, e.g.
|
static java.lang.String[] |
toStringMap(int[] dom) |
static java.lang.String[] |
toStringMap(int first,
int last) |
static java.lang.String[] |
union(java.lang.String[] a,
java.lang.String[] b) |
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) |
public static final byte[][][] MMS
public static final java.util.regex.Pattern[] ILLEGAL_CHARACTERS
public static final java.lang.String[] REPLACEMENTS
public static int maxIndex(int[] from, java.util.Random rand)
public static int maxIndex(int[] from)
public static int maxIndex(float[] from)
public static boolean equalsWithinOneSmallUlp(float a, float b)
a
- First numberb
- Second numberpublic static boolean equalsWithinOneSmallUlp(double a, double b)
public static double lnF(double what)
public static java.lang.String p2d(double d)
public static java.lang.String p5d(double d)
public static int set4(byte[] buf, int off, int x)
public static int get4(byte[] buf, int off)
public static int set8d(byte[] buf, int off, double d)
public static double get8d(byte[] buf, int off)
public static int sum(int[] from)
public static float sum(float[] from)
public static double sum(double[] from)
public static java.lang.String sampleToString(int[] val, int max)
public static java.util.Random getDeterRNG(long seed)
public static void setUsedRNGKind(H2ORandomRNG.RNGKind kind)
public static java.util.Random getRNG(long... seed)
public static void setUsedRNGType(H2ORandomRNG.RNGType rngType)
public static H2ORandomRNG.RNGType getUsedRNGType()
public static H2ORandomRNG.RNGKind getUsedRNGKind()
public static float entropy(byte[] f)
public static int[] unpackInts(long... longs)
public static void shuffleArray(long[] a, long seed)
public static void close(java.io.Closeable... closeable)
public static void close(java.net.Socket s)
public static java.lang.String readConsole()
public static java.io.File writeFile(java.lang.String content)
public static java.io.File writeFile(java.io.File file, java.lang.String content)
public static void writeFileAndClose(java.io.File file, java.io.InputStream in)
public static java.lang.String readFile(java.io.File file)
public static void readFile(java.io.File file, java.io.OutputStream out)
public static java.lang.String join(char sep, java.lang.Object[] array)
public static java.lang.String join(char sep, java.lang.Iterable it)
public static byte[] or(byte[] a, byte[] b)
public static int[] or(int[] a, int[] b)
public static byte[] add(byte[] a, byte[] b)
public static int[] add(int[] a, int[] b)
public static int[][] add(int[][] a, int[][] b)
public static long[] add(long[] a, long[] b)
public static long[][] add(long[][] a, long[][] b)
public static float[] add(float[] a, float[] b)
public static float[][] add(float[][] a, float[][] b)
public static double[] add(double[] a, double[] b)
public static double[][] add(double[][] a, double[][] b)
public static double[][] append(double[][] a, double[][] b)
public static int[] append(int[] a, int[] b)
public static java.lang.String[] append(java.lang.String[] a, java.lang.String[] b)
public static double[] append(double[] a, double e)
public static long[][][] append(long[][][] a, long[][] e)
public static <T> T[] append(T[] a, T... b)
public static <T> T[] remove(T[] a, int i)
public static int[] remove(int[] a, int i)
public static <T> T[] subarray(T[] a, int off, int len)
public static void clearFolder(java.lang.String folder)
public static void clearFolder(java.io.File folder)
public static java.io.File tmp()
public static ValueArray loadAndParseKey(java.lang.String path)
public static ValueArray loadAndParseKey(Key okey, java.lang.String path)
public static byte[] getFirstUnzipedBytes(Key k)
public static byte[] getFirstUnzipedBytes(Value v)
public static ParseDataset.Compression guessCompressionMethod(byte[] bits)
public static byte[] unzipBytes(byte[] bs, ParseDataset.Compression cmp)
public static final boolean hasNaNsOrInfs(double[] arr)
public static java.lang.String getStackAsString(java.lang.Throwable t)
public static int digit(int x, int c)
public static long attemptTimeParse(ValueString str)
public static int[] mapping(int[] dom)
public static java.lang.String[] toStringMap(int[] dom)
public static java.lang.String[] toStringMap(int first, int last)
public static int[] compose(int[] first, int[] transf)
public static int[][] compose(int[][] first, int[][] second)
public static java.lang.String pprint(double[][] arr)
public static java.lang.String pprint(double[][] arr, java.text.DecimalFormat dformat)
public static boolean isEmpty(int[] a)
public static boolean contains(int[] a, int d)
public static int[] difference(int[] a, int[] b)
public static int[] seq(int start, int stop)
public static java.lang.String className(java.lang.String path)
public static double avg(double[] nums)
public static double avg(long[] nums)
public static float[] div(float[] nums, int n)
public static float[] div(float[] nums, float n)
public static double[] div(double[] nums, double n)
public static java.lang.StringBuilder replace(java.lang.StringBuilder sb, java.lang.CharSequence from, java.lang.CharSequence to)
sb
- string builder containing a string to be modifiedfrom
- characters to replacedto
- replacement characterspublic static boolean contains(java.lang.String s, java.lang.CharSequence cs)
s
- stringcs
- a sequence of characterpublic static boolean contains(java.lang.String[] names, java.lang.String name)
public static java.lang.String escapeJava(java.lang.String s)
public static java.lang.String[] union(java.lang.String[] a, java.lang.String[] b)
public static int[] filter(int[] values, boolean[] filter, int fcnt)
public static int[][] pack(int[] values, boolean[] usemap)