Package com.metsci.glimpse.dnc.util
Class DncMiscUtils
- java.lang.Object
-
- com.metsci.glimpse.dnc.util.DncMiscUtils
-
public class DncMiscUtils extends Object
-
-
Constructor Summary
Constructors Constructor Description DncMiscUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <F,T>
Function<F,T>constFunc(T value)static MappedByteBuffercreateAndMemmapReadWrite(File file, int newFileSize)static FilecreateNewDir(File dir)static FilecreateNewDir(File parentDir, String childPath)static FilecreateNewDir(String dirPath)static BufferedReadercreateReader(URL url)static FilefilenameToLowercase(File file)Lowercases the last segment of the specified path.static FilefilenameToUppercase(File file)Uppercases the last segment of the specified path.static <T> it.unimi.dsi.fastutil.objects.Object2IntMap<T>invertIdsMap(it.unimi.dsi.fastutil.ints.Int2ObjectMap<T> idsMap)static <T> it.unimi.dsi.fastutil.objects.Object2IntMap<T>invertList(List<T> list)static booleanisFilenameCaseSensitive(File file)static <T> Tlast(List<T> list)static MappedByteBuffermemmapReadOnly(File file)static MappedByteBuffermemmapReadWrite(File file)static Function<String,Object>newAttrsFunc(Map<String,Object> map)static Map<String,Object>newAttrsMap(Object... keysAndValues)static ThreadFactorynewThreadFactory(String namePrefix, boolean isDaemon)static ExecutorServicenewWorkerDaemon(String threadNamePrefix)Creates an executor with a single daemon thread and an unbounded job queue.static intnextPowerOfTwo(int x)ThrowsIllegalArgumentExceptionif x is negativestatic longpackBytesIntoLong(byte[] bytes)static voidposlim(Buffer buf, int first, int count, int size)static it.unimi.dsi.fastutil.ints.Int2ObjectMap<String>readIdsMapFile(File file, Charset charset)static StringreadText(URL url, Charset charset)static Stringrepchar(char c, int n)static <T> TrequireResult(Future<? extends T> future)static <V> List<V>sorted(Collection<V> values, Comparator<? super V> comparator)static ThreadstartThread(String name, boolean daemon, Runnable runnable)static intsum(int... xs)static <V> VtakeNewValue(BlockingQueue<V> queue, V oldValue)static longtimeSince_MILLIS(long start_PMILLIS)static <T> ArrayList<T>toArrayList(Iterable<? extends T> iterable)static byte[]unpackLongIntoBytes(long packed)static voidwriteIdsMapFile(it.unimi.dsi.fastutil.objects.Object2IntMap<String> idsMap, File file, Charset charset)
-
-
-
Field Detail
-
MiB
public static final long MiB
- See Also:
- Constant Field Values
-
GiB
public static final long GiB
- See Also:
- Constant Field Values
-
-
Method Detail
-
requireResult
public static <T> T requireResult(Future<? extends T> future)
-
takeNewValue
public static <V> V takeNewValue(BlockingQueue<V> queue, V oldValue) throws InterruptedException
- Throws:
InterruptedException
-
newWorkerDaemon
public static ExecutorService newWorkerDaemon(String threadNamePrefix)
Creates an executor with a single daemon thread and an unbounded job queue. Jobs submitted after the executor has been shutdown will be silently dropped.
-
newThreadFactory
public static ThreadFactory newThreadFactory(String namePrefix, boolean isDaemon)
-
nextPowerOfTwo
public static int nextPowerOfTwo(int x)
ThrowsIllegalArgumentExceptionif x is negative
-
sum
public static int sum(int... xs)
-
timeSince_MILLIS
public static long timeSince_MILLIS(long start_PMILLIS)
-
sorted
public static <V> List<V> sorted(Collection<V> values, Comparator<? super V> comparator)
-
last
public static <T> T last(List<T> list)
-
isFilenameCaseSensitive
public static boolean isFilenameCaseSensitive(File file)
-
filenameToLowercase
public static File filenameToLowercase(File file)
Lowercases the last segment of the specified path.
-
filenameToUppercase
public static File filenameToUppercase(File file)
Uppercases the last segment of the specified path.
-
memmapReadOnly
public static MappedByteBuffer memmapReadOnly(File file) throws IOException
- Throws:
IOException
-
memmapReadWrite
public static MappedByteBuffer memmapReadWrite(File file) throws IOException
- Throws:
IOException
-
createAndMemmapReadWrite
public static MappedByteBuffer createAndMemmapReadWrite(File file, int newFileSize) throws IOException
- Throws:
IOException
-
poslim
public static void poslim(Buffer buf, int first, int count, int size)
-
packBytesIntoLong
public static long packBytesIntoLong(byte[] bytes)
-
unpackLongIntoBytes
public static byte[] unpackLongIntoBytes(long packed)
-
repchar
public static String repchar(char c, int n)
-
writeIdsMapFile
public static void writeIdsMapFile(it.unimi.dsi.fastutil.objects.Object2IntMap<String> idsMap, File file, Charset charset) throws IOException
- Throws:
IOException
-
readIdsMapFile
public static it.unimi.dsi.fastutil.ints.Int2ObjectMap<String> readIdsMapFile(File file, Charset charset) throws IOException
- Throws:
IOException
-
invertIdsMap
public static <T> it.unimi.dsi.fastutil.objects.Object2IntMap<T> invertIdsMap(it.unimi.dsi.fastutil.ints.Int2ObjectMap<T> idsMap)
-
invertList
public static <T> it.unimi.dsi.fastutil.objects.Object2IntMap<T> invertList(List<T> list)
-
constFunc
public static <F,T> Function<F,T> constFunc(T value)
-
readText
public static String readText(URL url, Charset charset) throws IOException
- Throws:
IOException
-
createReader
public static BufferedReader createReader(URL url) throws IOException
- Throws:
IOException
-
-