Package org.rocksdb

Class ComparatorOptions

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class ComparatorOptions
    extends RocksObject
    This class controls the behaviour of Java implementations of AbstractComparator

    Note that dispose() must be called before a ComparatorOptions instance becomes out-of-scope to release the allocated memory in C++.

    • Constructor Detail

      • ComparatorOptions

        public ComparatorOptions()
    • Method Detail

      • useDirectBuffer

        public boolean useDirectBuffer()
        Indicates if a direct byte buffer (i.e. outside the normal garbage-collected heap) is used, as opposed to a non-direct byte buffer which is a wrapper around an on-heap byte[].

        Default: true

        Returns:
        true if a direct byte buffer will be used, false otherwise
      • setUseDirectBuffer

        public ComparatorOptions setUseDirectBuffer​(boolean useDirectBuffer)
        Controls whether a direct byte buffer (i.e. outside the normal garbage-collected heap) is used, as opposed to a non-direct byte buffer which is a wrapper around an on-heap byte[].

        Default: true

        Parameters:
        useDirectBuffer - true if a direct byte buffer should be used, false otherwise
        Returns:
        the reference to the current comparator options.
      • maxReusedBufferSize

        public int maxReusedBufferSize()
        Maximum size of a buffer (in bytes) that will be reused. Comparators will use 5 of these buffers, so the retained memory size will be 5 * max_reused_buffer_size. When a buffer is needed for transferring data to a callback, if it requires less than maxReuseBufferSize, then an existing buffer will be reused, else a new buffer will be allocated just for that callback.

        Default: 64 bytes

        Returns:
        the maximum size of a buffer which is reused, or 0 if reuse is disabled
      • setMaxReusedBufferSize

        public ComparatorOptions setMaxReusedBufferSize​(int maxReusedBufferSize)
        Sets the maximum size of a buffer (in bytes) that will be reused. Comparators will use 5 of these buffers, so the retained memory size will be 5 * max_reused_buffer_size. When a buffer is needed for transferring data to a callback, if it requires less than maxReuseBufferSize, then an existing buffer will be reused, else a new buffer will be allocated just for that callback.

        Default: 64 bytes

        Parameters:
        maxReusedBufferSize - the maximum size for a buffer to reuse, or 0 to disable reuse
        Returns:
        the maximum size of a buffer which is reused