Class RocksUtils


  • public final class RocksUtils
    extends java.lang.Object
    Convenience methods for working with RocksDB.
    • Method Detail

      • toByteArray

        public static byte[] toByteArray​(long long1,
                                         long long2)
        Parameters:
        long1 - a long value
        long2 - a long value
        Returns:
        a byte array formed by writing the two long values as bytes
      • toByteArray

        public static byte[] toByteArray​(long n,
                                         java.lang.String str)
        Parameters:
        n - a long value
        str - a string value
        Returns:
        a byte array formed by writing the bytes of n followed by the bytes of str
      • readLong

        public static long readLong​(byte[] bytes,
                                    int start)
        Parameters:
        bytes - an array of bytes
        start - the place in the array to read the long from
        Returns:
        the long
      • createCloseableIterator

        public static <T> CloseableIterator<T> createCloseableIterator​(org.rocksdb.RocksIterator rocksIterator,
                                                                       RocksUtils.RocksIteratorParser<T> parser)
        Used to wrap an CloseableIterator over RocksIterator. It seeks given iterator to first entry before returning the iterator.
        Type Parameters:
        T - iterator value type
        Parameters:
        rocksIterator - the rocks iterator
        parser - parser to produce iterated values from rocks key-value
        Returns:
        wrapped iterator