DeduplicateRecord

Description:

This processor attempts to deduplicate a record set in memory using either a hashset or a bloom filter. It operates on a per-file basis rather than across an entire data set that spans multiple files.

Tags:

text, record, update, change, replace, modify, distinct, unique, filter, hash, dupe, duplicate, dedupe

Properties:

In the list below, the names of required properties appear in bold. Any other properties (not in bold) are considered optional. The table also indicates any default values, and whether a property supports the NiFi Expression Language.

NameDefault ValueAllowable ValuesDescription
Deduplication Strategysingle
  • Single File
  • Multiple Files
The strategy to use for detecting and isolating duplicate records. The option for doing it across a single data file will operate in memory, whereas the one for going across the enter repository will require a distributed map cache.
Distributed Map Cache clientController Service API:
DistributedMapCacheClient
Implementations: HBase_2_ClientMapCacheService
CassandraDistributedMapCache
HBase_1_1_2_ClientMapCacheService
DistributedMapCacheClientService
CouchbaseMapCacheClient
HazelcastMapCacheClient
RedisDistributedMapCacheClientService
This configuration is required when the deduplication strategy is set to 'multiple files.' The map cache will be used to check a data source such as HBase or Redis for entries indicating that a record has been processed before. This option requires a downstream process that uses PutDistributedMapCache to write an entry to the cache data source once the record has been processed to indicate that it has been handled before.

This Property is only considered if the <Deduplication Strategy> Property has a value of "multiple".
Cache IdentifierThis option defines a record path operation to use for defining the cache identifier. It can be used in addition to the hash settings. This field will have the expression language attribute "record.hash.value" available to it to use with it to generate the record path operation.
Supports Expression Language: true (will be evaluated using flow file attributes and variable registry)

This Property is only considered if the <Deduplication Strategy> Property has a value of "multiple".
Record ReaderController Service API:
RecordReaderFactory
Implementations: JsonPathReader
AvroReader
XMLReader
WindowsEventLogReader
ReaderLookup
Syslog5424Reader
GrokReader
ScriptedReader
CSVReader
SyslogReader
ParquetReader
JsonTreeReader
CEFReader
Specifies the Controller Service to use for reading incoming data
Record WriterController Service API:
RecordSetWriterFactory
Implementations: AvroRecordSetWriter
ScriptedRecordSetWriter
JsonRecordSetWriter
ParquetRecordSetWriter
RecordSetWriterLookup
FreeFormTextRecordSetWriter
XMLRecordSetWriter
CSVRecordSetWriter
Specifies the Controller Service to use for writing out the records
Include Zero Record FlowFilestrue
  • true
  • false
When converting an incoming FlowFile, if the conversion results in no data, this property specifies whether or not a FlowFile will be sent to the corresponding relationship
Record Hashing AlgorithmSHA-256
  • None Do not use a hashing algorithm. The value of resolved RecordPaths will be combined with tildes (~) to form the unique record key. This may use significantly more storage depending on the size and shape or your data.
  • SHA-256 The SHA-256 cryptographic hash algorithm.
  • SHA-512 The SHA-512 cryptographic hash algorithm.
The algorithm used to hash the combined set of resolved RecordPath values for cache storage.
Filter Typehash-set
  • HashSet Exactly matches records seen before with 100% accuracy at the expense of more storage usage. Stores the filter data in a single cache entry in the distributed cache, and is loaded entirely into memory during duplicate detection. This filter is preferred for small to medium data sets and offers high performance  loaded into memory when this processor is running.
  • BloomFilter Space-efficient data structure ideal for large data sets using probability to determine if a record was seen previously. False positive matches are possible, but false negatives are not – in other words, a query returns either "possibly in the set" or "definitely not in the set". You should use this option if the FlowFile content is large and you can tolerate some duplication in the data. Uses constant storage space regardless of the record set size.
The filter used to determine whether a record has been seen before based on the matching RecordPath criteria. If hash set is selected, a Java HashSet object will be used to deduplicate all encountered records. If the bloom filter option is selected, a bloom filter will be used. The bloom filter option is less memory intensive, but has a chance of having false positives.

This Property is only considered if the <Deduplication Strategy> Property has a value of "single".
Filter Capacity Hint25000An estimation of the total number of unique records to be processed. The more accurate this number is will lead to fewer false negatives on a BloomFilter.

This Property is only considered if the <Filter Type> Property has a value of "bloom-filter".
Bloom Filter Certainty0.10The desired false positive probability when using the BloomFilter type. Using a value of .05 for example, guarantees a five-percent probability that the result is a false positive. The closer to 1 this value is set, the more precise the result at the expense of more storage space utilization.

Dynamic Properties:

Dynamic Properties allow the user to specify both the name and value of a property.

NameValueDescription
RecordPathAn expression language statement used to determine how the RecordPath is resolved. The following variables are availible: ${field.name}, ${field.value}, ${field.type}The name of each user-defined property must be a valid RecordPath.
Supports Expression Language: false

Relationships:

NameDescription
duplicateRecords detected as duplicates in the FlowFile content will be routed to this relationship
non-duplicateIf the record was not found in the cache, it will be routed to this relationship
failureIf unable to communicate with the cache, the FlowFile will be penalized and routed to this relationship
originalThe original input FlowFile is sent to this relationship unless there is a fatal error in the processing.

Reads Attributes:

None specified.

Writes Attributes:

NameDescription
record.countThe number of records processed.

State management:

This component does not store state.

Restricted:

This component is not restricted.

Input requirement:

This component requires an incoming relationship.

System Resource Considerations:

ResourceDescription
MEMORYThe HashSet filter type will grow memory space proportionate to the number of unique records processed. The BloomFilter type will use constant memory regardless of the number of records processed.
CPUIf a more advanced hash algorithm is chosen, the amount of time required to hash any particular record could increase substantially.

See Also:

DistributedMapCacheClientService, DistributedMapCacheServer, DetectDuplicate