/** * Constructor Unique creates a new Unique instance. * * @param name of type String * @param pipes of type Pipe[] * @param uniqueFields of type Fields * @param threshold of type int */ @ConstructorProperties({"name", "pipes", "uniqueFields", "include", "threshold"}) public Unique(String name, Pipe[] pipes, Fields uniqueFields, Include include, int threshold) { super(pipes); if (uniqueFields == null) throw new IllegalArgumentException("uniqueFields may not be null"); Pipe[] filters = new Pipe[pipes.length]; TupleHasher tupleHasher = null; Comparator[] comparators = uniqueFields.getComparators(); if (!TupleHasher.isNull(comparators)) tupleHasher = new TupleHasher(null, comparators); FilterPartialDuplicates partialDuplicates = new FilterPartialDuplicates(include, threshold, tupleHasher); for (int i = 0; i < filters.length; i++) filters[i] = new Each(pipes[i], uniqueFields, partialDuplicates); Pipe pipe = new GroupBy(name, filters, uniqueFields); pipe = new Every(pipe, Fields.ALL, new FirstNBuffer(), Fields.RESULTS); setTails(pipe); }