public class JavaUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static long |
DEFAULT_DRIVER_MEM_MB
Define a default value for driver memory here since this value is referenced across the code
base and nearly all files already use Utils.scala
|
| Constructor and Description |
|---|
JavaUtils() |
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
bufferToArray(ByteBuffer buffer)
Returns a byte array with the buffer's contents, trying to avoid copying the data if
possible.
|
static String |
bytesToString(ByteBuffer b)
Convert the given byte buffer to a string.
|
static long |
byteStringAs(String str,
ByteUnit unit)
Convert a passed byte string (e.g.
|
static long |
byteStringAsBytes(String str)
Convert a passed byte string (e.g.
|
static long |
byteStringAsGb(String str)
Convert a passed byte string (e.g.
|
static long |
byteStringAsKb(String str)
Convert a passed byte string (e.g.
|
static long |
byteStringAsMb(String str)
Convert a passed byte string (e.g.
|
static void |
closeQuietly(Closeable closeable)
Closes the given object, ignoring IOExceptions.
|
static void |
deleteRecursively(File file)
Delete a file or directory and its contents recursively.
|
static void |
deleteRecursively(File file,
FilenameFilter filter)
Delete a file or directory and its contents recursively.
|
static int |
nonNegativeHash(Object obj)
Returns a hash consistent with Spark's Utils.nonNegativeHash().
|
static void |
readFully(ReadableByteChannel channel,
ByteBuffer dst)
Fills a buffer with data read from the channel.
|
static ByteBuffer |
stringToBytes(String s)
Convert the given string to a byte buffer.
|
static long |
timeStringAs(String str,
TimeUnit unit)
Convert a passed time string (e.g.
|
static long |
timeStringAsMs(String str)
Convert a time parameter such as (50s, 100ms, or 250us) to milliseconds for internal use.
|
static long |
timeStringAsSec(String str)
Convert a time parameter such as (50s, 100ms, or 250us) to seconds for internal use.
|
public static final long DEFAULT_DRIVER_MEM_MB
public static void closeQuietly(Closeable closeable)
public static int nonNegativeHash(Object obj)
public static ByteBuffer stringToBytes(String s)
bytesToString(ByteBuffer).public static String bytesToString(ByteBuffer b)
stringToBytes(String).public static void deleteRecursively(File file) throws IOException
file - Input file / dir to be deletedIOException - if deletion is unsuccessfulpublic static void deleteRecursively(File file, FilenameFilter filter) throws IOException
file - Input file / dir to be deletedfilter - A filename filter that make sure only files / dirs with the satisfied filenames
are deleted.IOException - if deletion is unsuccessfulpublic static long timeStringAs(String str, TimeUnit unit)
public static long timeStringAsMs(String str)
public static long timeStringAsSec(String str)
public static long byteStringAs(String str, ByteUnit unit)
public static long byteStringAsBytes(String str)
public static long byteStringAsKb(String str)
public static long byteStringAsMb(String str)
public static long byteStringAsGb(String str)
public static byte[] bufferToArray(ByteBuffer buffer)
public static void readFully(ReadableByteChannel channel, ByteBuffer dst) throws IOException
IOExceptionCopyright © 2020. All rights reserved.