Deduplication¶
A mapping can produce the same triple more than once: the source repeats a row, or two triples maps produce the same triple. CARML does not remove duplicates unless it has a reason to. The deduplication mode sets how far it goes.
Modes¶
Set the mode with dedupMode(DedupMode.VIEW) on the builder or --dedup view on the CLI.
| Mode | Plain logical source, or view without annotations | View with annotations |
|---|---|---|
AUTO (default) |
No deduplication | Rows are deduplicated unless a key proves them distinct |
NONE |
No deduplication | No deduplication |
VIEW |
Rows are deduplicated | Rows are deduplicated unless a key proves them distinct |
FULL |
As VIEW, and duplicate statements are removed from the whole output |
Same |
A key proves rows distinct when a primary key, or a unique key whose fields are not null, is among the fields the triples map uses.
Rows, not triples¶
AUTO and VIEW remove duplicate rows of a view. A row is compared on the fields the triples map uses. Two different
rows that happen to produce the same triple both go through, and so do equal triples from two triples maps.
Only FULL compares statements. It remembers every distinct statement, so its memory use grows with the size of the
output.
Choosing a mode¶
- If the output goes into a triple store, which drops duplicates anyway,
AUTOorNONEis enough. - If you need a file without duplicates, use
FULLwhen the output is small enough to hold in memory. Otherwise sort and deduplicate the N-Triples file afterwards. NONEis not always the fastest. Every duplicate still has to be serialized, so on a source with many repeated rowsVIEWcan finish sooner. Measure on your own data.
VIEW and FULL also switch off direct serialization for most mappings.