def compact
      load
      with_tmpfile do |path, file|
        # Compactified database has the same size -> return
        return self if @pos == file.write(dump(yield, @format.header))
        with_flock(File::LOCK_EX) do
          # Database was replaced (cleared or compactified) in the meantime
          if @pos != nil
            # Append changed journal records if the database changed during compactification
            file.write(read)
            file.close
            File.rename(path, @file)
          end
        end
      end
      open
      replay
    end
def compact
      load
      with_tmpfile do |path, file|
        # Compactified database has the same size -> return
        return self if @pos == file.write(dump(yield, @format.header))
        with_flock(File::LOCK_EX) do
          # Database was replaced (cleared or compactified) in the meantime
          if @pos != nil
            # Append changed journal records if the database changed during compactification
            file.write(read)
            file.close
            File.rename(path, @file)
          end
        end
      end
      open
      replay
    end
Compact the logfile to represent the in-memory state