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 classFileSystemPairStore.StoredEntryHolds 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 booleanisStored(java.lang.String batchId, int deduplicatorBatchSize)Checks if the pairs of a batch have been stored yet.java.util.Iterator<FileSystemPairStore.StoredEntry>iterator()voidpostProcess(java.lang.String batchId, int deduplicatorBatchSize, java.util.List<Pair> pairs, java.lang.Exception e)Action after the batch is stored.voidpreProcess(java.lang.String batchId, int deduplicatorBatchSize, java.util.List<Pair> pairs)Action before the batch is stored.voidstore(java.lang.String batchId, int deduplicatorBatchSize, java.util.List<Pair> pairs)Store a set of pairs against a batch id.
-
-
-
Constructor Detail
-
FileSystemPairStore
public FileSystemPairStore(java.lang.String directoryPath) throws java.io.IOExceptionCreates 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.IOExceptionCreates 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.ExceptionDescription copied from interface:PairStoreStore a set of pairs against a batch id. Any pairs previously stored against the batch id should be removed.- Specified by:
storein interfacePairStore- Parameters:
batchId- The batch id to store them againstdeduplicatorBatchSize- 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.ExceptionDescription copied from interface:PairStoreChecks if the pairs of a batch have been stored yet.
-
preProcess
public void preProcess(java.lang.String batchId, int deduplicatorBatchSize, java.util.List<Pair> pairs) throws java.lang.ExceptionAction 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.ExceptionAction 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 inpreProcess(java.lang.String, int, java.util.List<com.tibco.patterns.deduplication.Pair>)orstore(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 afterpostProcess(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:
iteratorin interfacejava.lang.Iterable<FileSystemPairStore.StoredEntry>
-
-