Package com.tibco.patterns.dedupe_utils

## Class FileSystemPairStore

- java.lang.Object
- - com.tibco.patterns.dedupe_utils.FileSystemPairStore

- All Implemented Interfaces:
    `PairStore`, `java.lang.Iterable<FileSystemPairStore.StoredEntry>`

      public class FileSystemPairStore
      extends java.lang.Object
      implements PairStore, java.lang.Iterable<FileSystemPairStore.StoredEntry>

  This sample class demonstrates how batch pair-sets are organized, and stores them in CSV files in a specified directory. It also allows allows scanning of all stored pairs via an iterator. This enables, easy invocation of the TIBCO Patterns - Search Grouping Engine.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `class` | `FileSystemPairStore.StoredEntry` | Holds the basic information on a stored pair.

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `FileSystemPairStore​(java.io.File directory)` | Creates a new FileSystemPairStore instance at a directory location.
    `FileSystemPairStore​(java.lang.String directoryPath)` | Creates a new FileSystemPairStore instance at a directory location.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `boolean` | `isStored​(java.lang.String batchId, int deduplicatorBatchSize)` | Checks if the pairs of a batch have been stored yet.
    `java.util.Iterator<FileSystemPairStore.StoredEntry>` | `iterator()` |
    `void` | `postProcess​(java.lang.String batchId, int deduplicatorBatchSize, java.util.List<Pair> pairs, java.lang.Exception e)` | Action after the batch is stored.
    `void` | `preProcess​(java.lang.String batchId, int deduplicatorBatchSize, java.util.List<Pair> pairs)` | Action before the batch is stored.
    `void` | `store​(java.lang.String batchId, int deduplicatorBatchSize, java.util.List<Pair> pairs)` | Store a set of pairs against a batch id.

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

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface java.lang.Iterable

      `forEach, spliterator`

- - ### Constructor Detail

    - #### FileSystemPairStore

          public FileSystemPairStore​(java.lang.String directoryPath)
                              throws java.io.IOException

      Creates a new FileSystemPairStore instance at a directory location. Creates the directory if it does not exist.
      Parameters:
        `directoryPath` - Identifies the directory location.
      Throws:
        `java.io.IOException` - if the directory cannot be created or accessed.

    - #### FileSystemPairStore

          public FileSystemPairStore​(java.io.File directory)
                              throws java.io.IOException

      Creates a new FileSystemPairStore instance at a directory location. Creates the directory if it does not exist.
      Parameters:
        `directory` - Identifies the directory location.
      Throws:
        `java.io.IOException` - if the directory cannot be created or accessed.

  - ### Method Detail

    - #### store

          public void store​(java.lang.String batchId,
                            int deduplicatorBatchSize,
                            java.util.List<Pair> pairs)
                     throws java.lang.Exception

      Description copied from interface: `PairStore`
      Store a set of pairs against a batch id. Any pairs previously stored against the batch id should be removed.
      Specified by:
        `store` in interface `PairStore`
      Parameters:
        `batchId` - The batch id to store them against
        `deduplicatorBatchSize` - The batch size assigned in the Deduplicator that produced this batch.
        `pairs` - The pairs to store
      Throws:
        `java.lang.Exception` - if an error occurs. Deduplicators will report this exception back through the event handler.

    - #### isStored

          public boolean isStored​(java.lang.String batchId,
                                  int deduplicatorBatchSize)
                           throws java.lang.Exception

      Description copied from interface: `PairStore`
      Checks if the pairs of a batch have been stored yet.
      Specified by:
        `isStored` in interface `PairStore`
      Parameters:
        `batchId` - Identifies the batch.
        `deduplicatorBatchSize` - The batch size assigned in the Deduplicator that produced the batch.
      Returns:
        true if the pairs are stored, false otherwise.
      Throws:
        `java.lang.Exception` - if an error occurs.

    - #### preProcess

          public void preProcess​(java.lang.String batchId,
                                 int deduplicatorBatchSize,
                                 java.util.List<Pair> pairs)
                          throws java.lang.Exception

      Action before the batch is stored. By default does nothing. To supply an action, inherit from FileSystemPairStore and override this method.
      Parameters:
        `batchId` - As passed to FileSystemPairStore.store().
        `deduplicatorBatchSize` - As passed to FileSystemPairStore.store().
        `pairs` - As passed to FileSystemPairStore.store().
      Throws:
        `java.lang.Exception` - if an error occurs. Exceptions here prevent the batch result from being stored.

    - #### postProcess

          public void postProcess​(java.lang.String batchId,
                                  int deduplicatorBatchSize,
                                  java.util.List<Pair> pairs,
                                  java.lang.Exception e)
                           throws java.lang.Exception

      Action after the batch is stored. By default does nothing. To supply an action, inherit from FileSystemPairStore and override this method. Note, postProcessing NOT invoked if
      Parameters:
        `batchId` - As passed to FileSystemPairStore.store().
        `deduplicatorBatchSize` - As passed to FileSystemPairStore.store().
        `pairs` - As passed to FileSystemPairStore.store().
        `e` - Exception encountered in `preProcess(java.lang.String, int, java.util.List<com.tibco.patterns.deduplication.Pair>)` or `store(java.lang.String, int, java.util.List<com.tibco.patterns.deduplication.Pair>)`. If e is not null, `store(java.lang.String, int, java.util.List<com.tibco.patterns.deduplication.Pair>)` will throw it after `postProcess(java.lang.String, int, java.util.List<com.tibco.patterns.deduplication.Pair>, java.lang.Exception)` finishes.
      Throws:
        `java.lang.Exception` - never, this default implementation does nothing.

    - #### iterator

          public java.util.Iterator<FileSystemPairStore.StoredEntry> iterator()

      Specified by:
        `iterator` in interface `java.lang.Iterable<FileSystemPairStore.StoredEntry>`