org.apache.lucene.store

## Class TrackingDirectoryWrapper

- java.lang.Object
- - org.apache.lucene.store.Directory
  - - org.apache.lucene.store.FilterDirectory
    - - org.apache.lucene.store.TrackingDirectoryWrapper

- All Implemented Interfaces:
    Closeable, AutoCloseable

      public final class TrackingDirectoryWrapper
      extends FilterDirectory

  A delegating Directory that records which files were written to and deleted.

- - ### Field Summary

    - ### Fields inherited from class org.apache.lucene.store.FilterDirectory

      `in`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TrackingDirectoryWrapper(Directory in)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clearCreatedFiles()`
    `void` | `copyFrom(Directory from, String src, String dest, IOContext context)` Copies the file src in from to this directory under the new file name dest.
    `IndexOutput` | `createOutput(String name, IOContext context)` Creates a new, empty file in the directory with the given name.
    `IndexOutput` | `createTempOutput(String prefix, String suffix, IOContext context)` Creates a new, empty file for writing in the directory, with a temporary file name including prefix and suffix, ending with the reserved extension `.tmp`.
    `void` | `deleteFile(String name)` Removes an existing file in the directory.
    `Set<String>` | `getCreatedFiles()` NOTE: returns a copy of the created files.
    `void` | `rename(String source, String dest)` Renames `source` to `dest` as an atomic operation, where `dest` does not yet exist in the directory.

    - ### Methods inherited from class org.apache.lucene.store.FilterDirectory

      `close, fileLength, getDelegate, listAll, obtainLock, openInput, sync, syncMetaData, toString, unwrap`

    - ### Methods inherited from class org.apache.lucene.store.Directory

      `ensureOpen, openChecksumInput, renameFile`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### TrackingDirectoryWrapper

          public TrackingDirectoryWrapper(Directory in)

  - ### Method Detail

    - #### deleteFile

          public void deleteFile(String name)
                          throws IOException

      Description copied from class: `Directory`
      Removes an existing file in the directory.
      Overrides:
        `deleteFile` in class `FilterDirectory`
      Throws:
        `IOException`

    - #### createOutput

          public IndexOutput createOutput(String name,
                                          IOContext context)
                                   throws IOException

      Description copied from class: `Directory`
      Creates a new, empty file in the directory with the given name. Returns a stream writing this file.
      Overrides:
        `createOutput` in class `FilterDirectory`
      Throws:
        `IOException`

    - #### createTempOutput

          public IndexOutput createTempOutput(String prefix,
                                              String suffix,
                                              IOContext context)
                                       throws IOException

      Description copied from class: `Directory`
      Creates a new, empty file for writing in the directory, with a temporary file name including prefix and suffix, ending with the reserved extension `.tmp`. Use `IndexOutput.getName()` to see what name was used.
      Overrides:
        `createTempOutput` in class `FilterDirectory`
      Throws:
        `IOException`

    - #### copyFrom

          public void copyFrom(Directory from,
                               String src,
                               String dest,
                               IOContext context)
                        throws IOException

      Description copied from class: `Directory`
      Copies the file src in from to this directory under the new file name dest.

      If you want to copy the entire source directory to the destination one, you can do so like this:

           Directory to; // the directory to copy to
           for (String file : dir.listAll()) {
             to.copyFrom(dir, file, newFile, IOContext.DEFAULT); // newFile can be either file, or a new name
           }

      NOTE: this method does not check whether dest exist and will overwrite it if it does.

      Overrides:
        `copyFrom` in class `Directory`
      Throws:
        `IOException`

    - #### rename

          public void rename(String source,
                             String dest)
                      throws IOException

      Description copied from class: `Directory`
      Renames `source` to `dest` as an atomic operation, where `dest` does not yet exist in the directory.

      Notes: This method is used by IndexWriter to publish commits. It is ok if this operation is not truly atomic, for example both `source` and `dest` can be visible temporarily. It is just important that the contents of `dest` appear atomically, or an exception is thrown.

      Overrides:
        `rename` in class `FilterDirectory`
      Throws:
        `IOException`

    - #### getCreatedFiles

          public Set<String> getCreatedFiles()

      NOTE: returns a copy of the created files.

    - #### clearCreatedFiles

          public void clearCreatedFiles()

Copyright © 2000-2019 Apache Software Foundation. All Rights Reserved.