public class Utils extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static java.time.format.DateTimeFormatter[] |
TIME_FORMAT_TIME |
static java.time.format.DateTimeFormatter[] |
TIME_FORMAT_TIMESTAMP |
| 构造器和说明 |
|---|
Utils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static boolean |
allEmpty(Collection<?>... collections) |
static boolean |
anyElementEmpty(Collection<?> collection) |
static String |
arrayToString(Object[] a,
StringBuilder b,
String delimiter)
Use
StringBuilder to build string out of an array. |
static String |
arrayToString(Object[] a,
StringBuilder b,
String delimiter,
boolean newLine)
Use
StringBuilder to build string out of an array. |
static <O> O |
cast(Object object) |
static int |
castCompare(List<Object> recordKey,
List<Object> targetKey) |
static int |
castCompare(List<Object> recordKey,
List<Object> targetKey,
List<Column> keyColumnList) |
static int |
castCompare(Object recordKey,
Object targetKey,
Column column) |
static void |
close(Closeable closeable) |
static List<Object> |
constructMaxRecord(int keyLen) |
static List<Object> |
constructMinRecord(int keyLen) |
static List<Object> |
expandRecord(List<Object> key,
ComparisonOperator operator,
int keyLen) |
static String |
formatDate(int year,
int month,
int day) |
static String |
formatIntLessThan100(int val) |
static String |
formatIntLessThan10000(int val) |
static int[] |
getBitArray(SliceInput input,
int numOfBits)
对于null超过8个字段byte[]是LSB,即排序高的字段在低字节里面。
|
static <T> List<String> |
getFromBitArray(List<T> list,
int[] bitArray,
java.util.function.Function<T,String> func) |
static String |
humanReadableBytes(long bytes) |
static String |
humanReadableBytes(long bytes,
boolean si) |
static <T> boolean |
isOptionalPresent(Optional<T> optional) |
static <T> List<T> |
makeNotNull(List<T> list) |
static <T> List<T> |
makeNotNull(T obj) |
static Long |
maybeUndefined(long val) |
static boolean |
noneEmpty(Collection<?>... collections) |
static java.time.LocalDateTime |
parseDateTimeText(String s) |
static java.time.LocalDateTime |
parseDateTimeText(String s,
int precision) |
static java.time.LocalTime |
parseTimeText(String s) |
static java.time.LocalTime |
parseTimeText(String s,
int precision) |
static Pair<Integer,String> |
processFileWithDelimiter(String filePath,
String charset,
java.util.function.Consumer<String> func,
String delimiter)
Process file by dilimiter.
|
static String |
sanitize(String input) |
static String |
tailTrim(String value) |
public static final java.time.format.DateTimeFormatter[] TIME_FORMAT_TIMESTAMP
public static final java.time.format.DateTimeFormatter[] TIME_FORMAT_TIME
public static <O> O cast(Object object)
public static String humanReadableBytes(long bytes)
public static String humanReadableBytes(long bytes, boolean si)
public static Long maybeUndefined(long val)
public static int[] getBitArray(SliceInput input, int numOfBits)
低位 高位
col9 col2 col4
[00000001][0,1,0,1,0,0,0,0]
input - SliceInputnumOfBits - number of bitspublic static <T> List<String> getFromBitArray(List<T> list, int[] bitArray, java.util.function.Function<T,String> func)
public static <T> List<T> makeNotNull(T obj)
public static boolean allEmpty(Collection<?>... collections)
public static boolean noneEmpty(Collection<?>... collections)
public static boolean anyElementEmpty(Collection<?> collection)
public static int castCompare(List<Object> recordKey, List<Object> targetKey, List<Column> keyColumnList)
public static void close(Closeable closeable) throws IOException
IOExceptionpublic static List<Object> expandRecord(List<Object> key, ComparisonOperator operator, int keyLen)
public static String arrayToString(Object[] a, StringBuilder b, String delimiter)
StringBuilder to build string out of an array.
Sometimes by reusing StringBuilder, we can avoid creating many StringBuilder and good to garbage collection.
a - arrayb - reusable StringBuilderdelimiter - delimiterpublic static String arrayToString(Object[] a, StringBuilder b, String delimiter, boolean newLine)
StringBuilder to build string out of an array.
Sometimes by reusing StringBuilder, we can avoid creating many StringBuilder and good to garbage collection.
a - arrayb - reusable StringBuilderdelimiter - delimiternewLine - if this is a new line, if true, write slash n at the endpublic static Pair<Integer,String> processFileWithDelimiter(String filePath, String charset, java.util.function.Consumer<String> func, String delimiter)
filePath - file pathcharset - encoding charsetfunc - consumer function to process each part separated by delimiterdelimiter - delimiterpublic static <T> boolean isOptionalPresent(Optional<T> optional)
public static String formatDate(int year, int month, int day)
public static String formatIntLessThan10000(int val)
public static String formatIntLessThan100(int val)
public static java.time.LocalDateTime parseDateTimeText(String s)
public static java.time.LocalDateTime parseDateTimeText(String s, int precision)
public static java.time.LocalTime parseTimeText(String s)
public static java.time.LocalTime parseTimeText(String s, int precision)
Copyright © 2019–2020 Alibaba Group Holding Limited. All rights reserved.