[
https://issues.apache.org/jira/browse/APEXMALHAR-1701?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15379097#comment-15379097
]
ASF GitHub Bot commented on APEXMALHAR-1701:
--------------------------------------------
Github user bhupeshchawda commented on a diff in the pull request:
https://github.com/apache/apex-malhar/pull/343#discussion_r70945247
--- Diff:
library/src/main/java/org/apache/apex/malhar/lib/dedup/AbstractWindowedDeduper.java
---
@@ -0,0 +1,97 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.apex.malhar.lib.dedup;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.apex.malhar.lib.window.Tuple;
+import org.apache.apex.malhar.lib.window.Window;
+import org.apache.apex.malhar.lib.window.impl.WindowedOperatorImpl;
+
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.api.annotation.OutputPortFieldAnnotation;
+
+/**
+ * Abstract implementation for the Windowed Dedup operator
+ *
+ * @param <T>
+ */
+public abstract class AbstractWindowedDeduper<T> extends
WindowedOperatorImpl<T, List<T>, T>
+{
+
+ /**
+ * The output port on which unique events are emitted.
+ */
+ public final transient DefaultOutputPort<T> unique = new
DefaultOutputPort<T>();
+
+ /**
+ * The output port on which duplicate events are emitted.
+ */
+ @OutputPortFieldAnnotation(optional = true)
+ public final transient DefaultOutputPort<T> duplicates = new
DefaultOutputPort<T>();
+
+ /**
+ * The output port on which expired events are emitted.
+ */
+ @OutputPortFieldAnnotation(optional = true)
+ public final transient DefaultOutputPort<T> expired = new
DefaultOutputPort<T>();
+
+ /**
+ * Returns the key of the tuple based on which the tuples are
de-duplicated
+ */
+ protected abstract Object getKey(T tuple);
+
+ /**
+ * Insead of dropping, emit on expired port
+ */
+ @Override
+ public void dropTuple(Tuple<T> input)
+ {
+ expired.emit(input.getValue());
+ }
+
+ /**
+ * Performs the de-duplication
+ */
+ @Override
+ public void accumulateTuple(Tuple.WindowedTuple<T> tuple)
+ {
+ for (Window window : tuple.getWindows()) { // There will be exactly
one window
+ // process each window
+ List<T> accum = dataStorage.get(window);
+ if (accum == null) {
+ // New window?
+ accum = new ArrayList<T>();
--- End diff --
agreed. Will change this.
> Deduper : create a deduper backed by Managed State
> --------------------------------------------------
>
> Key: APEXMALHAR-1701
> URL: https://issues.apache.org/jira/browse/APEXMALHAR-1701
> Project: Apache Apex Malhar
> Issue Type: Task
> Components: algorithms
> Reporter: Chandni Singh
> Assignee: Chandni Singh
>
> Need a de-deduplicator operator that is based on Managed State.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)