Class DbFileRewriter


  • public class DbFileRewriter
    extends Object
    Runs a whole file rewrite of a database, and holds the page level file work the rewrites share. Adding or removing encryption touches every page and cannot be undone half way, so the work always builds a separate file and the original is replaced only once that file is complete. An interrupted rewrite leaves the original as it was.
    Author:
    James Ahlborn
    • Method Detail

      • rewriteTo

        public static void rewriteTo​(Path srcFile,
                                     Path dstFile,
                                     DbFileRewriter.Rewrite op)
                              throws IOException
        Rewrites the given database into the given destination, which must not be the source and is overwritten if it exists.
        Throws:
        IOException
      • rewriteInPlace

        public static void rewriteInPlace​(Path dbFile,
                                          DbFileRewriter.Rewrite op)
                                   throws IOException
        Rewrites the given database in place, replacing it with the result.

        The replacement gives the database a new identity on disk, so any hard link to it keeps the contents the rewrite started with, and an open handle on it keeps reading the old file. The database must not be in use.

        Throws:
        IOException