Class PersistentCollections


  • public final class PersistentCollections
    extends Object
    A set of static utility methods to help in the selection, creation, and management of persistent collections.
    Author:
    AO Industries, Inc.
    • Method Detail

      • ensureZeros

        public static boolean ensureZeros​(RandomAccessFile raf,
                                          long position,
                                          long count)
                                   throws IOException
        Writes the requested number of zeros to the provided RandomAccessFile, but only if they do not already contain zeros. This is to avoid unnecessary writes on flash media. This may also have a positive interaction with sparse files.
        Returns:
        true when the byteBuffer was written to
        Throws:
        IOException
      • ensureZeros

        public static boolean ensureZeros​(ByteBuffer byteBuffer,
                                          int position,
                                          int count)
        Stores the requested number of zeros to the provided ByteBuffer, but only if they do not already contain zeros. This is to avoid unnecessary writes on flash media. This may also have a positive interaction with sparse files.
        Returns:
        true when the byteBuffer was written to
      • getSerializer

        public static <E> Serializer<E> getSerializer​(Class<E> type)
        Selects the most efficient Serializer for the provided class.
      • getPersistentBlockBuffer

        public static PersistentBlockBuffer getPersistentBlockBuffer​(Serializer<?> serializer,
                                                                     PersistentBuffer pbuffer,
                                                                     long additionalBlockSpace)
                                                              throws IOException
        Gets the most efficient PersistentBlockBuffer for the provided provided Serializer. If using fixed record sizes, the size of the block buffer is rounded up to the nearest power of two, to help alignment with system page tables.
        Parameters:
        serializer - The Serializer that will be used to write to the blocks
        pbuffer - The PersistentBuffer that will be wrapped by the block buffer
        additionalBlockSpace - The maximum additional space needed beyond the space used by the serializer. This may be used for linked list pointers, for example.
        Throws:
        IOException