You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apex.apache.org by th...@apache.org on 2016/09/01 18:30:45 UTC

[01/12] apex-malhar git commit: Updated algo & working on math operators

Repository: apex-malhar
Updated Branches:
  refs/heads/master 2e47b4cd7 -> 8f00cefa2


http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/streamquery/advanced/CompoundConditionTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/streamquery/advanced/CompoundConditionTest.java b/library/src/test/java/com/datatorrent/lib/streamquery/advanced/CompoundConditionTest.java
deleted file mode 100644
index 2f92c9b..0000000
--- a/library/src/test/java/com/datatorrent/lib/streamquery/advanced/CompoundConditionTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery.advanced;
-
-import java.util.HashMap;
-
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.datatorrent.lib.streamquery.SelectOperator;
-import com.datatorrent.lib.streamquery.condition.CompoundCondition;
-import com.datatorrent.lib.streamquery.condition.EqualValueCondition;
-import com.datatorrent.lib.streamquery.index.ColumnIndex;
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-/**
- * Functional test for {@link com.datatorrent.lib.streamquery.advanced.CompoundConditionTest}.
- */
-public class CompoundConditionTest
-{
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  @Test
-  public void testSqlSelect()
-  {
-    // create operator
-    SelectOperator oper = new SelectOperator();
-    oper.addIndex(new ColumnIndex("b", null));
-    oper.addIndex(new ColumnIndex("c", null));
-
-    EqualValueCondition  left = new EqualValueCondition();
-    left.addEqualValue("a", 1);
-    EqualValueCondition  right = new EqualValueCondition();
-    right.addEqualValue("b", 1);
-
-    oper.setCondition(new CompoundCondition(left, right));
-
-
-    CollectorTestSink sink = new CollectorTestSink();
-    oper.outport.setSink(sink);
-
-    oper.setup(null);
-    oper.beginWindow(1);
-
-    HashMap<String, Object> tuple = new HashMap<String, Object>();
-    tuple.put("a", 0);
-    tuple.put("b", 1);
-    tuple.put("c", 2);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 3);
-    tuple.put("c", 4);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 5);
-    tuple.put("c", 6);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 3);
-    tuple.put("b", 7);
-    tuple.put("c", 8);
-    oper.inport.process(tuple);
-    
-    oper.endWindow();
-    oper.teardown();
-
-    LOG.debug("{}", sink.collectedTuples);
-  }
-
-  private static final Logger LOG = LoggerFactory.getLogger(CompoundConditionTest.class);
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/streamquery/advanced/InConditionTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/streamquery/advanced/InConditionTest.java b/library/src/test/java/com/datatorrent/lib/streamquery/advanced/InConditionTest.java
deleted file mode 100644
index d235a9c..0000000
--- a/library/src/test/java/com/datatorrent/lib/streamquery/advanced/InConditionTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery.advanced;
-
-import java.util.HashMap;
-
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.datatorrent.lib.streamquery.SelectOperator;
-import com.datatorrent.lib.streamquery.condition.InCondition;
-import com.datatorrent.lib.streamquery.index.ColumnIndex;
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-/**
- * Functional test for {@link com.datatorrent.lib.streamquery.advanced.InConditionTest}.
- */
-public class InConditionTest
-{
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  @Test
-  public void testSqlSelect()
-  {
-    // create operator
-    SelectOperator oper = new SelectOperator();
-    oper.addIndex(new ColumnIndex("b", null));
-    oper.addIndex(new ColumnIndex("c", null));
-
-    InCondition cond = new InCondition("a"); 
-    cond.addInValue(0);
-    cond.addInValue(1);
-    oper.setCondition(cond);
-
-
-    CollectorTestSink sink = new CollectorTestSink();
-    oper.outport.setSink(sink);
-
-    oper.setup(null);
-    oper.beginWindow(1);
-
-    HashMap<String, Object> tuple = new HashMap<String, Object>();
-    tuple.put("a", 0);
-    tuple.put("b", 1);
-    tuple.put("c", 2);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 3);
-    tuple.put("c", 4);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 2);
-    tuple.put("b", 5);
-    tuple.put("c", 6);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 3);
-    tuple.put("b", 7);
-    tuple.put("c", 8);
-    oper.inport.process(tuple);
-    
-    oper.endWindow();
-    oper.teardown();
-
-    LOG.debug("{}", sink.collectedTuples);
-  }
-
-  private static final Logger LOG = LoggerFactory.getLogger(InConditionTest.class);
-
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/streamquery/advanced/LikeConditionTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/streamquery/advanced/LikeConditionTest.java b/library/src/test/java/com/datatorrent/lib/streamquery/advanced/LikeConditionTest.java
deleted file mode 100644
index b4d8539..0000000
--- a/library/src/test/java/com/datatorrent/lib/streamquery/advanced/LikeConditionTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery.advanced;
-
-import java.util.HashMap;
-
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.datatorrent.lib.streamquery.SelectOperator;
-import com.datatorrent.lib.streamquery.condition.LikeCondition;
-import com.datatorrent.lib.streamquery.index.ColumnIndex;
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-/**
- * Functional test for {@link com.datatorrent.lib.streamquery.advanced.LikeConditionTest}.
- */
-public class LikeConditionTest
-{
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  @Test
-  public void testSqlSelect()
-  {
-    // create operator
-    SelectOperator oper = new SelectOperator();
-    oper.addIndex(new ColumnIndex("b", null));
-    oper.addIndex(new ColumnIndex("c", null));
-
-    LikeCondition  condition = new LikeCondition("a", "test*");
-    oper.setCondition(condition);
-
-    CollectorTestSink sink = new CollectorTestSink();
-    oper.outport.setSink(sink);
-
-    oper.setup(null);
-    oper.beginWindow(1);
-
-    HashMap<String, Object> tuple = new HashMap<String, Object>();
-    tuple.put("a", "testing");
-    tuple.put("b", 1);
-    tuple.put("c", 2);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", "null");
-    tuple.put("b", 3);
-    tuple.put("c", 4);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", "testall");
-    tuple.put("b", 5);
-    tuple.put("c", 6);
-    oper.inport.process(tuple);
-
-    oper.endWindow();
-    oper.teardown();
-
-    LOG.debug("{}", sink.collectedTuples);
-  }
-
-  private static final Logger LOG = LoggerFactory.getLogger(LikeConditionTest.class);
-
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/streamquery/advanced/NegateIndexTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/streamquery/advanced/NegateIndexTest.java b/library/src/test/java/com/datatorrent/lib/streamquery/advanced/NegateIndexTest.java
deleted file mode 100644
index 3ccb03e..0000000
--- a/library/src/test/java/com/datatorrent/lib/streamquery/advanced/NegateIndexTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery.advanced;
-
-import java.util.HashMap;
-
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.datatorrent.lib.streamquery.SelectOperator;
-import com.datatorrent.lib.streamquery.index.NegateExpression;
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-/**
- * Functional test for {@link com.datatorrent.lib.streamquery.SelectOperatorTest}.
- */
-public class NegateIndexTest
-{
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  @Test
-  public void testSqlSelect()
-  {
-    // create operator
-    SelectOperator oper = new SelectOperator();
-    oper.addIndex(new NegateExpression("b", null));
-
-    CollectorTestSink sink = new CollectorTestSink();
-    oper.outport.setSink(sink);
-
-    oper.setup(null);
-    oper.beginWindow(1);
-
-    HashMap<String, Object> tuple = new HashMap<String, Object>();
-    tuple.put("a", 0);
-    tuple.put("b", 1);
-    tuple.put("c", 2);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 3);
-    tuple.put("c", 4);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 5);
-    tuple.put("c", 6);
-    oper.inport.process(tuple);
-
-    oper.endWindow();
-    oper.teardown();
-
-    LOG.debug("{}", sink.collectedTuples);
-  }
-
-  private static final Logger LOG = LoggerFactory.getLogger(NegateIndexTest.class);
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/streamquery/advanced/SelectAverageTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/streamquery/advanced/SelectAverageTest.java b/library/src/test/java/com/datatorrent/lib/streamquery/advanced/SelectAverageTest.java
deleted file mode 100644
index 5279dac..0000000
--- a/library/src/test/java/com/datatorrent/lib/streamquery/advanced/SelectAverageTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery.advanced;
-
-import java.util.HashMap;
-
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.datatorrent.lib.streamquery.SelectFunctionOperator;
-import com.datatorrent.lib.streamquery.function.AverageFunction;
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-/**
- * Functional test for {@link com.datatorrent.lib.streamquery.SelectOperatorTest}.
- */
-public class SelectAverageTest
-{
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  @Test
-  public void testSqlSelect()
-  {
-    // create operator
-    SelectFunctionOperator oper = new SelectFunctionOperator();
-    oper.addSqlFunction(new AverageFunction("b", null));
-
-    CollectorTestSink sink = new CollectorTestSink();
-    oper.outport.setSink(sink);
-
-    oper.setup(null);
-    oper.beginWindow(1);
-
-    HashMap<String, Object> tuple = new HashMap<String, Object>();
-    tuple.put("a", 0);
-    tuple.put("b", 1);
-    tuple.put("c", 2);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 3);
-    tuple.put("c", 4);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 5);
-    tuple.put("c", 6);
-    oper.inport.process(tuple);
-
-    oper.endWindow();
-    oper.teardown();
-
-    LOG.debug("{}", sink.collectedTuples);
-  }
-
-  private static final Logger LOG = LoggerFactory.getLogger(SelectAverageTest.class);
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/streamquery/advanced/SelectCountTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/streamquery/advanced/SelectCountTest.java b/library/src/test/java/com/datatorrent/lib/streamquery/advanced/SelectCountTest.java
deleted file mode 100644
index 9c235e1..0000000
--- a/library/src/test/java/com/datatorrent/lib/streamquery/advanced/SelectCountTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery.advanced;
-
-import java.util.HashMap;
-
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.datatorrent.lib.streamquery.SelectFunctionOperator;
-import com.datatorrent.lib.streamquery.function.CountFunction;
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-/**
- * Functional test for {@link com.datatorrent.lib.streamquery.SelectOperatorTest}.
- */
-public class SelectCountTest
-{
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  @Test
-  public void testSqlSelect()
-  {
-    // create operator
-    SelectFunctionOperator oper = new SelectFunctionOperator();
-    oper.addSqlFunction(new CountFunction("b", null));
-
-    CollectorTestSink sink = new CollectorTestSink();
-    oper.outport.setSink(sink);
-
-    oper.setup(null);
-    oper.beginWindow(1);
-
-    HashMap<String, Object> tuple = new HashMap<String, Object>();
-    tuple.put("a", 0);
-    tuple.put("b", null);
-    tuple.put("c", 2);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", null);
-    tuple.put("c", 4);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 5);
-    tuple.put("c", 6);
-    oper.inport.process(tuple);
-
-    oper.endWindow();
-    oper.teardown();
-
-    LOG.debug("{}", sink.collectedTuples);
-  }
-
-  private static final Logger LOG = LoggerFactory.getLogger(SelectCountTest.class);
-
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/streamquery/advanced/SelectFirstLastTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/streamquery/advanced/SelectFirstLastTest.java b/library/src/test/java/com/datatorrent/lib/streamquery/advanced/SelectFirstLastTest.java
deleted file mode 100644
index c7b56fe..0000000
--- a/library/src/test/java/com/datatorrent/lib/streamquery/advanced/SelectFirstLastTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery.advanced;
-
-import java.util.HashMap;
-
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.datatorrent.lib.streamquery.SelectFunctionOperator;
-import com.datatorrent.lib.streamquery.function.FirstLastFunction;
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-/**
- * Functional test for {@link com.datatorrent.lib.streamquery.SelectOperatorTest}.
- */
-public class SelectFirstLastTest
-{
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  @Test
-  public void testSqlSelect()
-  {
-    // create operator
-    SelectFunctionOperator oper = new SelectFunctionOperator();
-    oper.addSqlFunction(new FirstLastFunction("b", null, false));
-
-    CollectorTestSink sink = new CollectorTestSink();
-    oper.outport.setSink(sink);
-
-    oper.setup(null);
-    oper.beginWindow(1);
-
-    HashMap<String, Object> tuple = new HashMap<String, Object>();
-    tuple.put("a", 0);
-    tuple.put("b", null);
-    tuple.put("c", 2);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", null);
-    tuple.put("c", 4);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 5);
-    tuple.put("c", 6);
-    oper.inport.process(tuple);
-
-    oper.endWindow();
-    oper.teardown();
-
-    LOG.debug("{}", sink.collectedTuples);
-  }
-
-  private static final Logger LOG = LoggerFactory.getLogger(SelectFirstLastTest.class);
-
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/streamquery/advanced/SelectMaxMinTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/streamquery/advanced/SelectMaxMinTest.java b/library/src/test/java/com/datatorrent/lib/streamquery/advanced/SelectMaxMinTest.java
deleted file mode 100644
index e57554a..0000000
--- a/library/src/test/java/com/datatorrent/lib/streamquery/advanced/SelectMaxMinTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery.advanced;
-
-import java.util.HashMap;
-
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.datatorrent.lib.streamquery.SelectFunctionOperator;
-import com.datatorrent.lib.streamquery.function.MaxMinFunction;
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-/**
- * Functional test for {@link com.datatorrent.lib.streamquery.SelectOperatorTest}.
- */
-public class SelectMaxMinTest
-{
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  @Test
-  public void testSqlSelect()
-  {
-    // create operator
-    SelectFunctionOperator oper = new SelectFunctionOperator();
-    oper.addSqlFunction(new MaxMinFunction("b", null, false));
-
-    CollectorTestSink sink = new CollectorTestSink();
-    oper.outport.setSink(sink);
-
-    oper.setup(null);
-    oper.beginWindow(1);
-
-    HashMap<String, Object> tuple = new HashMap<String, Object>();
-    tuple.put("a", 0);
-    tuple.put("b", 1);
-    tuple.put("c", 2);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 3);
-    tuple.put("c", 4);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 5);
-    tuple.put("c", 6);
-    oper.inport.process(tuple);
-
-    oper.endWindow();
-    oper.teardown();
-
-    LOG.debug("{}", sink.collectedTuples);
-  }
-
-  private static final Logger LOG = LoggerFactory.getLogger(SelectMaxMinTest.class);
-
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/streamquery/advanced/SumIndexTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/streamquery/advanced/SumIndexTest.java b/library/src/test/java/com/datatorrent/lib/streamquery/advanced/SumIndexTest.java
deleted file mode 100644
index f9f1e10..0000000
--- a/library/src/test/java/com/datatorrent/lib/streamquery/advanced/SumIndexTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery.advanced;
-
-import java.util.HashMap;
-
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.datatorrent.lib.streamquery.SelectOperator;
-import com.datatorrent.lib.streamquery.index.SumExpression;
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-/**
- * Functional test for {@link com.datatorrent.lib.streamquery.SelectOperatorTest}.
- */
-public class SumIndexTest
-{
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  @Test
-  public void testSqlSelect()
-  {
-    // create operator
-    SelectOperator oper = new SelectOperator();
-    oper.addIndex(new SumExpression("b", "c", null));
-
-    CollectorTestSink sink = new CollectorTestSink();
-    oper.outport.setSink(sink);
-
-    oper.setup(null);
-    oper.beginWindow(1);
-
-    HashMap<String, Object> tuple = new HashMap<String, Object>();
-    tuple.put("a", 0);
-    tuple.put("b", 1);
-    tuple.put("c", 2);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 3);
-    tuple.put("c", 4);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 5);
-    tuple.put("c", 6);
-    oper.inport.process(tuple);
-
-    oper.endWindow();
-    oper.teardown();
-
-    LOG.debug("{}", sink.collectedTuples);
-  }
-
-  private static final Logger LOG = LoggerFactory.getLogger(SumIndexTest.class);
-
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/samples/pom.xml
----------------------------------------------------------------------
diff --git a/samples/pom.xml b/samples/pom.xml
index d84f86b..9eb3c36 100644
--- a/samples/pom.xml
+++ b/samples/pom.xml
@@ -40,8 +40,8 @@
 
   <dependencies>
     <dependency>
-      <groupId>${project.groupId}</groupId>
-      <artifactId>malhar-library</artifactId>
+      <groupId>org.apache.apex</groupId>
+      <artifactId>malhar-contrib</artifactId>
       <version>${project.version}</version>
     </dependency>
     <dependency>

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/samples/src/main/java/com/datatorrent/samples/lib/algo/AllAfterMatchMapSample.java
----------------------------------------------------------------------
diff --git a/samples/src/main/java/com/datatorrent/samples/lib/algo/AllAfterMatchMapSample.java b/samples/src/main/java/com/datatorrent/samples/lib/algo/AllAfterMatchMapSample.java
index 59764a7..78f479c 100644
--- a/samples/src/main/java/com/datatorrent/samples/lib/algo/AllAfterMatchMapSample.java
+++ b/samples/src/main/java/com/datatorrent/samples/lib/algo/AllAfterMatchMapSample.java
@@ -18,14 +18,12 @@
  */
 package com.datatorrent.samples.lib.algo;
 
-
+import org.apache.apex.malhar.contrib.misc.algo.AllAfterMatchMap;
 import org.apache.hadoop.conf.Configuration;
 
 import com.datatorrent.api.Context.OperatorContext;
 import com.datatorrent.api.DAG;
 import com.datatorrent.api.StreamingApplication;
-
-import com.datatorrent.lib.algo.AllAfterMatchMap;
 import com.datatorrent.lib.io.ConsoleOutputOperator;
 import com.datatorrent.samples.lib.math.RandomKeyValMap;
 

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/samples/src/main/java/com/datatorrent/samples/lib/math/ChangeSample.java
----------------------------------------------------------------------
diff --git a/samples/src/main/java/com/datatorrent/samples/lib/math/ChangeSample.java b/samples/src/main/java/com/datatorrent/samples/lib/math/ChangeSample.java
index fa8694d..e9b8dec 100644
--- a/samples/src/main/java/com/datatorrent/samples/lib/math/ChangeSample.java
+++ b/samples/src/main/java/com/datatorrent/samples/lib/math/ChangeSample.java
@@ -18,12 +18,12 @@
  */
 package com.datatorrent.samples.lib.math;
 
+import org.apache.apex.malhar.contrib.misc.math.Change;
 import org.apache.hadoop.conf.Configuration;
 
-import com.datatorrent.api.StreamingApplication;
 import com.datatorrent.api.DAG;
+import com.datatorrent.api.StreamingApplication;
 import com.datatorrent.lib.io.ConsoleOutputOperator;
-import com.datatorrent.lib.math.Change;
 import com.datatorrent.lib.testbench.RandomEventGenerator;
 
 /**

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/samples/src/main/java/com/datatorrent/samples/lib/math/CompreMapSample.java
----------------------------------------------------------------------
diff --git a/samples/src/main/java/com/datatorrent/samples/lib/math/CompreMapSample.java b/samples/src/main/java/com/datatorrent/samples/lib/math/CompreMapSample.java
index 62e1574..abf4d4b 100644
--- a/samples/src/main/java/com/datatorrent/samples/lib/math/CompreMapSample.java
+++ b/samples/src/main/java/com/datatorrent/samples/lib/math/CompreMapSample.java
@@ -18,12 +18,12 @@
  */
 package com.datatorrent.samples.lib.math;
 
+import org.apache.apex.malhar.contrib.misc.math.CompareMap;
 import org.apache.hadoop.conf.Configuration;
 
-import com.datatorrent.api.StreamingApplication;
 import com.datatorrent.api.DAG;
+import com.datatorrent.api.StreamingApplication;
 import com.datatorrent.lib.io.ConsoleOutputOperator;
-import com.datatorrent.lib.math.CompareMap;
 
 
 /**

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/samples/src/main/java/com/datatorrent/samples/lib/math/CountKeyValSample.java
----------------------------------------------------------------------
diff --git a/samples/src/main/java/com/datatorrent/samples/lib/math/CountKeyValSample.java b/samples/src/main/java/com/datatorrent/samples/lib/math/CountKeyValSample.java
index 66b1247..e7460ea 100644
--- a/samples/src/main/java/com/datatorrent/samples/lib/math/CountKeyValSample.java
+++ b/samples/src/main/java/com/datatorrent/samples/lib/math/CountKeyValSample.java
@@ -18,15 +18,13 @@
  */
 package com.datatorrent.samples.lib.math;
 
-
+import org.apache.apex.malhar.contrib.misc.math.CountKeyVal;
 import org.apache.hadoop.conf.Configuration;
 
 import com.datatorrent.api.Context.OperatorContext;
 import com.datatorrent.api.DAG;
 import com.datatorrent.api.StreamingApplication;
-
 import com.datatorrent.lib.io.ConsoleOutputOperator;
-import com.datatorrent.lib.math.CountKeyVal;
 
 /**
  * This sample application code for showing sample usage of malhar operator(s). <br>


[08/12] apex-malhar git commit: Updated algo & working on math operators

Posted by th...@apache.org.
http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/InvertIndexTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/InvertIndexTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/InvertIndexTest.java
new file mode 100644
index 0000000..337cefb
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/InvertIndexTest.java
@@ -0,0 +1,104 @@
+/**
+ * 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.contrib.misc.algo;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.datatorrent.api.Sink;
+
+import com.datatorrent.lib.testbench.CollectorTestSink;
+
+/**
+ * @deprecated
+ * Functional tests for {@link InvertIndex} <p>
+ *
+ */
+@Deprecated
+public class InvertIndexTest
+{
+  private static Logger log = LoggerFactory.getLogger(InvertIndexTest.class);
+
+  /**
+   * Test oper logic emits correct results
+   */
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  @Test
+  public void testNodeProcessing() throws Exception
+  {
+    InvertIndex<String,String> oper = new InvertIndex<String,String>();
+    CollectorTestSink indexSink = new CollectorTestSink();
+
+    Sink inSink = oper.data.getSink();
+    oper.index.setSink(indexSink);
+
+    oper.beginWindow(0);
+
+    HashMap<String, String> input = new HashMap<String, String>();
+
+    input.put("a", "str");
+    input.put("b", "str");
+    inSink.put(input);
+
+    input.clear();
+    input.put("a", "str1");
+    input.put("b", "str1");
+    inSink.put(input);
+
+    input.clear();
+    input.put("c", "blah");
+    inSink.put(input);
+
+    input.clear();
+    input.put("c", "str1");
+    inSink.put(input);
+    oper.endWindow();
+
+    Assert.assertEquals("number emitted tuples", 3, indexSink.collectedTuples.size());
+    for (Object o: indexSink.collectedTuples) {
+      log.debug(o.toString());
+      HashMap<String, ArrayList<String>> output = (HashMap<String, ArrayList<String>>)o;
+      for (Map.Entry<String, ArrayList<String>> e: output.entrySet()) {
+        String key = e.getKey();
+        ArrayList<String> alist = e.getValue();
+        if (key.equals("str1")) {
+          Assert.assertEquals("Index for \"str1\" contains \"a\"", true, alist.contains("a"));
+          Assert.assertEquals("Index for \"str1\" contains \"b\"", true, alist.contains("b"));
+          Assert.assertEquals("Index for \"str1\" contains \"c\"", true, alist.contains("c"));
+
+        } else if (key.equals("str")) {
+          Assert.assertEquals("Index for \"str1\" contains \"a\"", true, alist.contains("a"));
+          Assert.assertEquals("Index for \"str1\" contains \"b\"", true, alist.contains("b"));
+          Assert.assertEquals("Index for \"str1\" contains \"c\"", false, alist.contains("c"));
+
+        } else if (key.equals("blah")) {
+          Assert.assertEquals("Index for \"str1\" contains \"a\"", false, alist.contains("a"));
+          Assert.assertEquals("Index for \"str1\" contains \"b\"", false, alist.contains("b"));
+          Assert.assertEquals("Index for \"str1\" contains \"c\"", true, alist.contains("c"));
+        }
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/LastMatchMapTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/LastMatchMapTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/LastMatchMapTest.java
new file mode 100644
index 0000000..c930932
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/LastMatchMapTest.java
@@ -0,0 +1,105 @@
+/**
+ * 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.contrib.misc.algo;
+
+import java.util.HashMap;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.datatorrent.lib.testbench.CountAndLastTupleTestSink;
+
+/**
+ * @deprecated
+ * Functional tests for {@link LastMatchMap}<p>
+ *
+ */
+@Deprecated
+public class LastMatchMapTest
+{
+  /**
+   * Test node logic emits correct results
+   */
+  @Test
+  public void testNodeProcessing() throws Exception
+  {
+    testNodeProcessingSchema(new LastMatchMap<String, Integer>());
+    testNodeProcessingSchema(new LastMatchMap<String, Double>());
+    testNodeProcessingSchema(new LastMatchMap<String, Float>());
+    testNodeProcessingSchema(new LastMatchMap<String, Short>());
+    testNodeProcessingSchema(new LastMatchMap<String, Long>());
+  }
+
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  public void testNodeProcessingSchema(LastMatchMap oper)
+  {
+    CountAndLastTupleTestSink matchSink = new CountAndLastTupleTestSink();
+    oper.last.setSink(matchSink);
+    oper.setKey("a");
+    oper.setValue(3);
+    oper.setTypeEQ();
+
+    oper.beginWindow(0);
+    HashMap<String, Number> input = new HashMap<String, Number>();
+    input.put("a", 4);
+    input.put("b", 20);
+    input.put("c", 1000);
+    oper.data.process(input);
+    input.put("a", 3);
+    input.put("b", 20);
+    input.put("c", 1000);
+    oper.data.process(input);
+    input.clear();
+    input.put("a", 2);
+    oper.data.process(input);
+    input.clear();
+    input.put("a", 4);
+    input.put("b", 21);
+    input.put("c", 1000);
+    oper.data.process(input);
+    input.clear();
+    input.put("a", 3);
+    input.put("b", 52);
+    input.put("c", 5);
+    oper.data.process(input);
+    oper.endWindow();
+
+    Assert.assertEquals("number emitted tuples", 1, matchSink.count);
+    HashMap<String, Number> tuple = (HashMap<String, Number>)matchSink.tuple;
+    Number aval = tuple.get("a");
+    Number bval = tuple.get("b");
+    Assert.assertEquals("Value of a was ", 3, aval.intValue());
+    Assert.assertEquals("Value of a was ", 52, bval.intValue());
+    matchSink.clear();
+
+    oper.beginWindow(0);
+    input.clear();
+    input.put("a", 2);
+    input.put("b", 20);
+    input.put("c", 1000);
+    oper.data.process(input);
+    input.clear();
+    input.put("a", 5);
+    oper.data.process(input);
+    oper.endWindow();
+    // There should be no emit as all tuples do not match
+    Assert.assertEquals("number emitted tuples", 0, matchSink.count);
+    matchSink.clear();
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/LeastFrequentKeyMapTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/LeastFrequentKeyMapTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/LeastFrequentKeyMapTest.java
new file mode 100644
index 0000000..2c0fcad
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/LeastFrequentKeyMapTest.java
@@ -0,0 +1,117 @@
+/**
+ * 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.contrib.misc.algo;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.datatorrent.lib.testbench.CountAndLastTupleTestSink;
+
+/**
+ * @deprecated
+ * Functional tests for {@link LeastFrequentKeyMap}<p>
+ *
+ */
+@Deprecated
+public class LeastFrequentKeyMapTest
+{
+  /**
+   * Test node logic emits correct results
+   */
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  @Test
+  public void testNodeProcessing() throws Exception
+  {
+    LeastFrequentKeyMap<String, Integer> oper = new LeastFrequentKeyMap<String, Integer>();
+    CountAndLastTupleTestSink matchSink = new CountAndLastTupleTestSink();
+    CountAndLastTupleTestSink listSink = new CountAndLastTupleTestSink();
+    oper.least.setSink(matchSink);
+    oper.list.setSink(listSink);
+
+    oper.beginWindow(0);
+    HashMap<String, Integer> amap = new HashMap<String, Integer>(1);
+    HashMap<String, Integer> bmap = new HashMap<String, Integer>(1);
+    HashMap<String, Integer> cmap = new HashMap<String, Integer>(1);
+    int atot = 5;
+    int btot = 3;
+    int ctot = 6;
+    amap.put("a", null);
+    bmap.put("b", null);
+    cmap.put("c", null);
+    for (int i = 0; i < atot; i++) {
+      oper.data.process(amap);
+    }
+    for (int i = 0; i < btot; i++) {
+      oper.data.process(bmap);
+    }
+    for (int i = 0; i < ctot; i++) {
+      oper.data.process(cmap);
+    }
+    oper.endWindow();
+    Assert.assertEquals("number emitted tuples", 1, matchSink.count);
+    HashMap<String, Integer> tuple = (HashMap<String, Integer>)matchSink.tuple;
+    Integer val = tuple.get("b");
+    Assert.assertEquals("Count of b was ", btot, val.intValue());
+    Assert.assertEquals("number emitted tuples", 1, listSink.count);
+    ArrayList<HashMap<String, Integer>> list = (ArrayList<HashMap<String, Integer>>)listSink.tuple;
+    val = list.get(0).get("b");
+    Assert.assertEquals("Count of b was ", btot, val.intValue());
+
+    matchSink.clear();
+    listSink.clear();
+    oper.beginWindow(0);
+    atot = 5;
+    btot = 10;
+    ctot = 5;
+    for (int i = 0; i < atot; i++) {
+      oper.data.process(amap);
+    }
+    for (int i = 0; i < btot; i++) {
+      oper.data.process(bmap);
+    }
+    for (int i = 0; i < ctot; i++) {
+      oper.data.process(cmap);
+    }
+    oper.endWindow();
+    Assert.assertEquals("number emitted tuples", 1, matchSink.count);
+    Assert.assertEquals("number emitted tuples", 1, listSink.count);
+    list = (ArrayList<HashMap<String, Integer>>)listSink.tuple;
+    int acount = 0;
+    int ccount = 0;
+    for (HashMap<String, Integer> h : list) {
+      val = h.get("a");
+      if (val == null) {
+        ccount = h.get("c");
+      } else {
+        acount = val;
+      }
+    }
+    Assert.assertEquals("Count of a was ", atot, acount);
+    Assert.assertEquals("Count of c was ", ctot, ccount);
+    HashMap<String, Integer> mtuple = (HashMap<String, Integer>)matchSink.tuple;
+    val = mtuple.get("a");
+    if (val == null) {
+      val = mtuple.get("c");
+    }
+    Assert.assertEquals("Count of least frequent key was ", ctot, val.intValue());
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/LeastFrequentKeyValueMapTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/LeastFrequentKeyValueMapTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/LeastFrequentKeyValueMapTest.java
new file mode 100644
index 0000000..287312c
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/LeastFrequentKeyValueMapTest.java
@@ -0,0 +1,109 @@
+/**
+ * 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.contrib.misc.algo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Assert;
+
+import org.junit.Test;
+
+import com.datatorrent.lib.testbench.CollectorTestSink;
+
+/**
+ * @deprecated
+ * Functional tests for {@link LeastFrequentKeyValueMap}<p>
+ *
+ */
+@Deprecated
+public class LeastFrequentKeyValueMapTest
+{
+  /**
+   * Test node logic emits correct results
+   */
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  @Test
+  public void testNodeProcessing() throws Exception
+  {
+    LeastFrequentKeyValueMap<String, Integer> oper = new LeastFrequentKeyValueMap<String, Integer>();
+    CollectorTestSink matchSink = new CollectorTestSink();
+    oper.least.setSink(matchSink);
+
+    oper.beginWindow(0);
+    HashMap<String, Integer> amap = new HashMap<String, Integer>(1);
+    HashMap<String, Integer> bmap = new HashMap<String, Integer>(1);
+    HashMap<String, Integer> cmap = new HashMap<String, Integer>(1);
+    int atot1 = 5;
+    int btot1 = 3;
+    int ctot1 = 6;
+    amap.put("a", 1);
+    bmap.put("b", 2);
+    cmap.put("c", 4);
+    for (int i = 0; i < atot1; i++) {
+      oper.data.process(amap);
+    }
+    for (int i = 0; i < btot1; i++) {
+      oper.data.process(bmap);
+    }
+    for (int i = 0; i < ctot1; i++) {
+      oper.data.process(cmap);
+    }
+
+    atot1 = 4;
+    btot1 = 3;
+    ctot1 = 10;
+    amap.put("a", 5);
+    bmap.put("b", 4);
+    cmap.put("c", 3);
+    for (int i = 0; i < atot1; i++) {
+      oper.data.process(amap);
+    }
+    for (int i = 0; i < btot1; i++) {
+      oper.data.process(bmap);
+    }
+    for (int i = 0; i < ctot1; i++) {
+      oper.data.process(cmap);
+    }
+
+    oper.endWindow();
+    Assert.assertEquals("number emitted tuples", 3, matchSink.collectedTuples.size());
+    int vcount;
+    for (Object o: matchSink.collectedTuples) {
+      HashMap<String, HashMap<Integer, Integer>> omap = (HashMap<String, HashMap<Integer, Integer>>)o;
+      for (Map.Entry<String, HashMap<Integer, Integer>> e: omap.entrySet()) {
+        String key = e.getKey();
+        if (key.equals("a")) {
+          vcount = e.getValue().get(5);
+          Assert.assertEquals("Key \"a\" has value ", 4, vcount);
+
+        } else if (key.equals("b")) {
+          vcount = e.getValue().get(2);
+          Assert.assertEquals("Key \"a\" has value ", 3, vcount);
+          vcount = e.getValue().get(4);
+          Assert.assertEquals("Key \"a\" has value ", 3, vcount);
+
+        } else if (key.equals("c")) {
+          vcount = e.getValue().get(4);
+          Assert.assertEquals("Key \"a\" has value ", 6, vcount);
+        }
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/MatchMapTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/MatchMapTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/MatchMapTest.java
new file mode 100644
index 0000000..1d2b5ff
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/MatchMapTest.java
@@ -0,0 +1,83 @@
+/**
+ * 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.contrib.misc.algo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.datatorrent.lib.algo.MatchMap;
+import com.datatorrent.lib.testbench.CountAndLastTupleTestSink;
+
+/**
+ * @deprecated
+ * Functional tests for {@link com.datatorrent.lib.algo.MatchMap}<p>
+ *
+ */
+@Deprecated
+public class MatchMapTest
+{
+  /**
+   * Test node logic emits correct results
+   */
+  @Test
+  public void testNodeProcessing() throws Exception
+  {
+    testNodeProcessingSchema(new MatchMap<String, Integer>());
+    testNodeProcessingSchema(new MatchMap<String, Double>());
+    testNodeProcessingSchema(new MatchMap<String, Float>());
+    testNodeProcessingSchema(new MatchMap<String, Short>());
+    testNodeProcessingSchema(new MatchMap<String, Long>());
+  }
+
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  public void testNodeProcessingSchema(MatchMap oper)
+  {
+    CountAndLastTupleTestSink matchSink = new CountAndLastTupleTestSink();
+    oper.match.setSink(matchSink);
+    oper.setKey("a");
+    oper.setValue(3.0);
+    oper.setTypeNEQ();
+
+    oper.beginWindow(0);
+    HashMap<String, Number> input = new HashMap<String, Number>();
+    input.put("a", 2);
+    input.put("b", 20);
+    input.put("c", 1000);
+    oper.data.process(input);
+    input.clear();
+    input.put("a", 3);
+    oper.data.process(input);
+    oper.endWindow();
+
+    // One for each key
+    Assert.assertEquals("number emitted tuples", 1, matchSink.count);
+    for (Map.Entry<String, Number> e : ((HashMap<String, Number>)matchSink.tuple).entrySet()) {
+      if (e.getKey().equals("a")) {
+        Assert.assertEquals("emitted value for 'a' was ", new Double(2), new Double(e.getValue().doubleValue()));
+      } else if (e.getKey().equals("b")) {
+        Assert.assertEquals("emitted tuple for 'b' was ", new Double(20), new Double(e.getValue().doubleValue()));
+      } else if (e.getKey().equals("c")) {
+        Assert.assertEquals("emitted tuple for 'c' was ", new Double(1000), new Double(e.getValue().doubleValue()));
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/MostFrequentKeyMapTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/MostFrequentKeyMapTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/MostFrequentKeyMapTest.java
new file mode 100644
index 0000000..58a1059
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/MostFrequentKeyMapTest.java
@@ -0,0 +1,118 @@
+/**
+ * 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.contrib.misc.algo;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import org.junit.Assert;
+
+import org.junit.Test;
+
+import com.datatorrent.lib.testbench.CountAndLastTupleTestSink;
+
+/**
+ * @deprecated
+ * Functional tests for {@link MostFrequentKeyMap}<p>
+ *
+ */
+@Deprecated
+public class MostFrequentKeyMapTest
+{
+  /**
+   * Test node logic emits correct results
+   */
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  @Test
+  public void testNodeProcessing() throws Exception
+  {
+    MostFrequentKeyMap<String, Integer> oper = new MostFrequentKeyMap<String, Integer>();
+    CountAndLastTupleTestSink matchSink = new CountAndLastTupleTestSink();
+    CountAndLastTupleTestSink listSink = new CountAndLastTupleTestSink();
+    oper.most.setSink(matchSink);
+    oper.list.setSink(listSink);
+
+    oper.beginWindow(0);
+    HashMap<String, Integer> amap = new HashMap<String, Integer>(1);
+    HashMap<String, Integer> bmap = new HashMap<String, Integer>(1);
+    HashMap<String, Integer> cmap = new HashMap<String, Integer>(1);
+    int atot = 5;
+    int btot = 7;
+    int ctot = 6;
+    amap.put("a", null);
+    bmap.put("b", null);
+    cmap.put("c", null);
+    for (int i = 0; i < atot; i++) {
+      oper.data.process(amap);
+    }
+    for (int i = 0; i < btot; i++) {
+      oper.data.process(bmap);
+    }
+    for (int i = 0; i < ctot; i++) {
+      oper.data.process(cmap);
+    }
+    oper.endWindow();
+    Assert.assertEquals("number emitted tuples", 1, matchSink.count);
+    HashMap<String, Integer> tuple = (HashMap<String, Integer>)matchSink.tuple;
+    Integer val = tuple.get("b");
+    Assert.assertEquals("Count of b was ", btot, val.intValue());
+    Assert.assertEquals("number emitted tuples", 1, listSink.count);
+    ArrayList<HashMap<String, Integer>> list = (ArrayList<HashMap<String, Integer>>)listSink.tuple;
+    val = list.get(0).get("b");
+    Assert.assertEquals("Count of b was ", btot, val.intValue());
+
+    matchSink.clear();
+    listSink.clear();
+    oper.beginWindow(0);
+    atot = 5;
+    btot = 4;
+    ctot = 5;
+    for (int i = 0; i < atot; i++) {
+      oper.data.process(amap);
+    }
+    for (int i = 0; i < btot; i++) {
+      oper.data.process(bmap);
+    }
+    for (int i = 0; i < ctot; i++) {
+      oper.data.process(cmap);
+    }
+    oper.endWindow();
+    Assert.assertEquals("number emitted tuples", 1, matchSink.count);
+    Assert.assertEquals("number emitted tuples", 1, listSink.count);
+    list = (ArrayList<HashMap<String, Integer>>)listSink.tuple;
+    int acount = 0;
+    int ccount = 0;
+    for (HashMap<String, Integer> h : list) {
+      val = h.get("a");
+      if (val == null) {
+        ccount = h.get("c");
+      } else {
+        acount = val;
+      }
+    }
+    Assert.assertEquals("Count of a was ", atot, acount);
+    Assert.assertEquals("Count of c was ", ctot, ccount);
+    HashMap<String, Integer> mtuple = (HashMap<String, Integer>)matchSink.tuple;
+    val = mtuple.get("a");
+    if (val == null) {
+      val = mtuple.get("c");
+    }
+    Assert.assertEquals("Count of least frequent key was ", ctot, val.intValue());
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/MostFrequentKeyValueMapTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/MostFrequentKeyValueMapTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/MostFrequentKeyValueMapTest.java
new file mode 100644
index 0000000..c356079
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/MostFrequentKeyValueMapTest.java
@@ -0,0 +1,109 @@
+/**
+ * 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.contrib.misc.algo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Assert;
+
+import org.junit.Test;
+
+import com.datatorrent.lib.testbench.CollectorTestSink;
+
+/**
+ * @deprecated
+ * Functional tests for {@link MostFrequentKeyValueMap}<p>
+ *
+ */
+@Deprecated
+public class MostFrequentKeyValueMapTest
+{
+  /**
+   * Test node logic emits correct results
+   */
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  @Test
+  public void testNodeProcessing() throws Exception
+  {
+    MostFrequentKeyValueMap<String, Integer> oper = new MostFrequentKeyValueMap<String, Integer>();
+    CollectorTestSink matchSink = new CollectorTestSink();
+    oper.most.setSink(matchSink);
+
+    oper.beginWindow(0);
+    HashMap<String, Integer> amap = new HashMap<String, Integer>(1);
+    HashMap<String, Integer> bmap = new HashMap<String, Integer>(1);
+    HashMap<String, Integer> cmap = new HashMap<String, Integer>(1);
+    int atot1 = 5;
+    int btot1 = 3;
+    int ctot1 = 6;
+    amap.put("a", 1);
+    bmap.put("b", 2);
+    cmap.put("c", 4);
+    for (int i = 0; i < atot1; i++) {
+      oper.data.process(amap);
+    }
+    for (int i = 0; i < btot1; i++) {
+      oper.data.process(bmap);
+    }
+    for (int i = 0; i < ctot1; i++) {
+      oper.data.process(cmap);
+    }
+
+    atot1 = 4;
+    btot1 = 3;
+    ctot1 = 10;
+    amap.put("a", 5);
+    bmap.put("b", 4);
+    cmap.put("c", 3);
+    for (int i = 0; i < atot1; i++) {
+      oper.data.process(amap);
+    }
+    for (int i = 0; i < btot1; i++) {
+      oper.data.process(bmap);
+    }
+    for (int i = 0; i < ctot1; i++) {
+      oper.data.process(cmap);
+    }
+
+    oper.endWindow();
+    Assert.assertEquals("number emitted tuples", 3, matchSink.collectedTuples.size());
+    int vcount;
+    for (Object o: matchSink.collectedTuples) {
+      HashMap<String, HashMap<Integer, Integer>> omap = (HashMap<String, HashMap<Integer, Integer>>)o;
+      for (Map.Entry<String, HashMap<Integer, Integer>> e: omap.entrySet()) {
+        String key = e.getKey();
+        if (key.equals("a")) {
+          vcount = e.getValue().get(1);
+          Assert.assertEquals("Key \"a\" has value ", 5, vcount);
+
+        } else if (key.equals("b")) {
+          vcount = e.getValue().get(2);
+          Assert.assertEquals("Key \"a\" has value ", 3, vcount);
+          vcount = e.getValue().get(4);
+          Assert.assertEquals("Key \"a\" has value ", 3, vcount);
+
+        } else if (key.equals("c")) {
+          vcount = e.getValue().get(3);
+          Assert.assertEquals("Key \"a\" has value ", 10, vcount);
+        }
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/SamplerTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/SamplerTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/SamplerTest.java
new file mode 100644
index 0000000..e91b0f9
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/SamplerTest.java
@@ -0,0 +1,64 @@
+/**
+ * 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.contrib.misc.algo;
+
+import org.junit.Assert;
+
+import org.junit.Test;
+
+import com.datatorrent.lib.testbench.CountTestSink;
+
+/**
+ * @deprecated
+ * Functional tests for {@link Sampler}<p>
+ *
+ */
+@Deprecated
+public class SamplerTest
+{
+  /**
+   * Test node logic emits correct results
+   */
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  @Test
+  public void testNodeProcessing() throws Exception
+  {
+    Sampler<String> oper = new Sampler<String>();
+    CountTestSink sink = new CountTestSink<String>();
+    oper.sample.setSink(sink);
+    oper.setSamplingPercentage(.1);
+
+    String tuple = "a";
+
+
+    int numTuples = 10000;
+    oper.beginWindow(0);
+    for (int i = 0; i < numTuples; i++) {
+      oper.data.process(tuple);
+    }
+
+    oper.endWindow();
+    int lowerlimit = 5;
+    int upperlimit = 15;
+    int actual = (100 * sink.count) / numTuples;
+
+    Assert.assertEquals("number emitted tuples", true, lowerlimit < actual);
+    Assert.assertEquals("number emitted tuples", true, upperlimit > actual);
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/ChangeAlertKeyValTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/ChangeAlertKeyValTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/ChangeAlertKeyValTest.java
new file mode 100644
index 0000000..a5bd664
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/ChangeAlertKeyValTest.java
@@ -0,0 +1,108 @@
+/**
+ * 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.contrib.misc.math;
+
+import org.junit.Assert;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.datatorrent.lib.testbench.CollectorTestSink;
+import com.datatorrent.lib.util.KeyValPair;
+
+/**
+ *
+ * Functional tests for {@link ChangeAlertKeyVal}.
+ * <p>
+ * @deprecated
+ */
+@Deprecated
+public class ChangeAlertKeyValTest
+{
+  private static Logger log = LoggerFactory
+      .getLogger(ChangeAlertKeyValTest.class);
+
+  /**
+   * Test node logic emits correct results.
+   */
+  @Test
+  public void testNodeProcessing() throws Exception
+  {
+    testNodeProcessingSchema(new ChangeAlertKeyVal<String, Integer>());
+    testNodeProcessingSchema(new ChangeAlertKeyVal<String, Double>());
+    testNodeProcessingSchema(new ChangeAlertKeyVal<String, Float>());
+    testNodeProcessingSchema(new ChangeAlertKeyVal<String, Short>());
+    testNodeProcessingSchema(new ChangeAlertKeyVal<String, Long>());
+  }
+
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  public <V extends Number> void testNodeProcessingSchema(
+      ChangeAlertKeyVal<String, V> oper)
+  {
+    CollectorTestSink alertSink = new CollectorTestSink();
+
+    oper.alert.setSink(alertSink);
+    oper.setPercentThreshold(5);
+
+    oper.beginWindow(0);
+    oper.data.process(new KeyValPair<String, V>("a", oper.getValue(200)));
+    oper.data.process(new KeyValPair<String, V>("b", oper.getValue(10)));
+    oper.data.process(new KeyValPair<String, V>("c", oper.getValue(100)));
+
+    oper.data.process(new KeyValPair<String, V>("a", oper.getValue(203)));
+    oper.data.process(new KeyValPair<String, V>("b", oper.getValue(12)));
+    oper.data.process(new KeyValPair<String, V>("c", oper.getValue(101)));
+
+    oper.data.process(new KeyValPair<String, V>("a", oper.getValue(210)));
+    oper.data.process(new KeyValPair<String, V>("b", oper.getValue(12)));
+    oper.data.process(new KeyValPair<String, V>("c", oper.getValue(102)));
+
+    oper.data.process(new KeyValPair<String, V>("a", oper.getValue(231)));
+    oper.data.process(new KeyValPair<String, V>("b", oper.getValue(18)));
+    oper.data.process(new KeyValPair<String, V>("c", oper.getValue(103)));
+    oper.endWindow();
+
+    // One for a, Two for b
+    Assert.assertEquals("number emitted tuples", 3,
+        alertSink.collectedTuples.size());
+
+    double aval = 0;
+    double bval = 0;
+    log.debug("\nLogging tuples");
+    for (Object o : alertSink.collectedTuples) {
+      KeyValPair<String, KeyValPair<Number, Double>> map = (KeyValPair<String, KeyValPair<Number, Double>>)o;
+
+      log.debug(o.toString());
+      if (map.getKey().equals("a")) {
+        KeyValPair<Number, Double> vmap = map.getValue();
+        if (vmap != null) {
+          aval += vmap.getValue().doubleValue();
+        }
+      } else {
+        KeyValPair<Number, Double> vmap = map.getValue();
+        if (vmap != null) {
+          bval += vmap.getValue().doubleValue();
+        }
+      }
+    }
+    Assert.assertEquals("change in a", 10.0, aval,0);
+    Assert.assertEquals("change in a", 70.0, bval,0);
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/ChangeAlertMapTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/ChangeAlertMapTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/ChangeAlertMapTest.java
new file mode 100644
index 0000000..aa757af
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/ChangeAlertMapTest.java
@@ -0,0 +1,116 @@
+/**
+ * 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.contrib.misc.math;
+
+import java.util.HashMap;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.datatorrent.lib.testbench.CollectorTestSink;
+
+/**
+ *
+ * Functional tests for {@link ChangeAlertMap}.
+ * <p>
+ * @deprecated
+ */
+@Deprecated
+public class ChangeAlertMapTest
+{
+  private static Logger log = LoggerFactory.getLogger(ChangeAlertMapTest.class);
+
+  /**
+   * Test node logic emits correct results.
+   */
+  @Test
+  public void testNodeProcessing() throws Exception
+  {
+    testNodeProcessingSchema(new ChangeAlertMap<String, Integer>());
+    testNodeProcessingSchema(new ChangeAlertMap<String, Double>());
+    testNodeProcessingSchema(new ChangeAlertMap<String, Float>());
+    testNodeProcessingSchema(new ChangeAlertMap<String, Short>());
+    testNodeProcessingSchema(new ChangeAlertMap<String, Long>());
+  }
+
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  public <V extends Number> void testNodeProcessingSchema(
+      ChangeAlertMap<String, V> oper)
+  {
+    CollectorTestSink alertSink = new CollectorTestSink();
+
+    oper.alert.setSink(alertSink);
+    oper.setPercentThreshold(5);
+
+    oper.beginWindow(0);
+    HashMap<String, V> input = new HashMap<String, V>();
+    input.put("a", oper.getValue(200));
+    input.put("b", oper.getValue(10));
+    input.put("c", oper.getValue(100));
+    oper.data.process(input);
+
+    input.clear();
+    input.put("a", oper.getValue(203));
+    input.put("b", oper.getValue(12));
+    input.put("c", oper.getValue(101));
+    oper.data.process(input);
+
+    input.clear();
+    input.put("a", oper.getValue(210));
+    input.put("b", oper.getValue(12));
+    input.put("c", oper.getValue(102));
+    oper.data.process(input);
+
+    input.clear();
+    input.put("a", oper.getValue(231));
+    input.put("b", oper.getValue(18));
+    input.put("c", oper.getValue(103));
+    oper.data.process(input);
+    oper.endWindow();
+
+    // One for a, Two for b
+    Assert.assertEquals("number emitted tuples", 3,
+        alertSink.collectedTuples.size());
+
+    double aval = 0;
+    double bval = 0;
+    log.debug("\nLogging tuples");
+    for (Object o : alertSink.collectedTuples) {
+      HashMap<String, HashMap<Number, Double>> map = (HashMap<String, HashMap<Number, Double>>)o;
+      Assert.assertEquals("map size", 1, map.size());
+      log.debug(o.toString());
+      HashMap<Number, Double> vmap = map.get("a");
+      if (vmap != null) {
+        aval += vmap.get(231.0).doubleValue();
+      }
+      vmap = map.get("b");
+      if (vmap != null) {
+        if (vmap.get(12.0) != null) {
+          bval += vmap.get(12.0).doubleValue();
+        } else {
+          bval += vmap.get(18.0).doubleValue();
+        }
+      }
+    }
+    Assert.assertEquals("change in a", 10.0, aval,0);
+    Assert.assertEquals("change in a", 70.0, bval,0);
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/ChangeAlertTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/ChangeAlertTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/ChangeAlertTest.java
new file mode 100644
index 0000000..745b7e5
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/ChangeAlertTest.java
@@ -0,0 +1,83 @@
+/**
+ * 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.contrib.misc.math;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.datatorrent.lib.testbench.CollectorTestSink;
+import com.datatorrent.lib.util.KeyValPair;
+
+/**
+ *
+ * Functional tests for {@link ChangeAlert}. <p>
+ * @deprecated
+ */
+@Deprecated
+public class ChangeAlertTest
+{
+  private static Logger log = LoggerFactory.getLogger(ChangeAlertTest.class);
+
+  /**
+   * Test node logic emits correct results.
+   */
+  @Test
+  public void testNodeProcessing() throws Exception
+  {
+    testNodeProcessingSchema(new ChangeAlert<Integer>());
+    testNodeProcessingSchema(new ChangeAlert<Double>());
+    testNodeProcessingSchema(new ChangeAlert<Float>());
+    testNodeProcessingSchema(new ChangeAlert<Short>());
+    testNodeProcessingSchema(new ChangeAlert<Long>());
+  }
+
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  public <V extends Number> void testNodeProcessingSchema(ChangeAlert<V> oper)
+  {
+    CollectorTestSink alertSink = new CollectorTestSink();
+
+    oper.alert.setSink(alertSink);
+    oper.setPercentThreshold(5);
+
+    oper.beginWindow(0);
+    oper.data.process(oper.getValue(10));
+    oper.data.process(oper.getValue(12)); // alert
+    oper.data.process(oper.getValue(12));
+    oper.data.process(oper.getValue(18)); // alert
+    oper.data.process(oper.getValue(0));  // alert
+    oper.data.process(oper.getValue(20)); // this will not alert
+    oper.data.process(oper.getValue(30)); // alert
+
+    oper.endWindow();
+
+    // One for a, Two for b
+    Assert.assertEquals("number emitted tuples", 4, alertSink.collectedTuples.size());
+
+    double aval = 0;
+    log.debug("\nLogging tuples");
+    for (Object o: alertSink.collectedTuples) {
+      KeyValPair<Number, Double> map = (KeyValPair<Number, Double>)o;
+      log.debug(o.toString());
+      aval += map.getValue().doubleValue();
+    }
+    Assert.assertEquals("change in a", 220.0, aval,0);
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/ChangeKeyValTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/ChangeKeyValTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/ChangeKeyValTest.java
new file mode 100644
index 0000000..0b3318c
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/ChangeKeyValTest.java
@@ -0,0 +1,112 @@
+/**
+ * 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.contrib.misc.math;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.datatorrent.lib.testbench.CollectorTestSink;
+import com.datatorrent.lib.util.KeyValPair;
+
+/**
+ *
+ * Functional tests for {@link ChangeKeyVal}.
+ * <p>
+ * @deprecated
+ */
+@Deprecated
+public class ChangeKeyValTest
+{
+  private static Logger log = LoggerFactory.getLogger(ChangeKeyValTest.class);
+
+  /**
+   * Test node logic emits correct results.
+   */
+  @Test
+  public void testNodeProcessing() throws Exception
+  {
+    testNodeProcessingSchema(new ChangeKeyVal<String, Integer>());
+    testNodeProcessingSchema(new ChangeKeyVal<String, Double>());
+    testNodeProcessingSchema(new ChangeKeyVal<String, Float>());
+    testNodeProcessingSchema(new ChangeKeyVal<String, Short>());
+    testNodeProcessingSchema(new ChangeKeyVal<String, Long>());
+  }
+
+  /**
+   *
+   * @param oper
+   *          key/value pair for comparison.
+   */
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  public <V extends Number> void testNodeProcessingSchema(
+      ChangeKeyVal<String, V> oper)
+  {
+    CollectorTestSink changeSink = new CollectorTestSink();
+    CollectorTestSink percentSink = new CollectorTestSink();
+
+    oper.change.setSink(changeSink);
+    oper.percent.setSink(percentSink);
+
+    oper.beginWindow(0);
+    oper.base.process(new KeyValPair<String, V>("a", oper.getValue(2)));
+    oper.base.process(new KeyValPair<String, V>("b", oper.getValue(10)));
+    oper.base.process(new KeyValPair<String, V>("c", oper.getValue(100)));
+
+    oper.data.process(new KeyValPair<String, V>("a", oper.getValue(3)));
+    oper.data.process(new KeyValPair<String, V>("b", oper.getValue(2)));
+    oper.data.process(new KeyValPair<String, V>("c", oper.getValue(4)));
+
+    oper.endWindow();
+
+    // One for each key
+    Assert.assertEquals("number emitted tuples", 3,
+        changeSink.collectedTuples.size());
+    Assert.assertEquals("number emitted tuples", 3,
+        percentSink.collectedTuples.size());
+
+    log.debug("\nLogging tuples");
+    for (Object o : changeSink.collectedTuples) {
+      KeyValPair<String, Number> kv = (KeyValPair<String, Number>)o;
+      if (kv.getKey().equals("a")) {
+        Assert.assertEquals("change in a ", 1.0, kv.getValue());
+      }
+      if (kv.getKey().equals("b")) {
+        Assert.assertEquals("change in b ", -8.0, kv.getValue());
+      }
+      if (kv.getKey().equals("c")) {
+        Assert.assertEquals("change in c ", -96.0, kv.getValue());
+      }
+    }
+
+    for (Object o : percentSink.collectedTuples) {
+      KeyValPair<String, Number> kv = (KeyValPair<String, Number>)o;
+      if (kv.getKey().equals("a")) {
+        Assert.assertEquals("change in a ", 50.0, kv.getValue());
+      }
+      if (kv.getKey().equals("b")) {
+        Assert.assertEquals("change in b ", -80.0, kv.getValue());
+      }
+      if (kv.getKey().equals("c")) {
+        Assert.assertEquals("change in c ", -96.0, kv.getValue());
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/ChangeTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/ChangeTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/ChangeTest.java
new file mode 100644
index 0000000..9ce0a73
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/ChangeTest.java
@@ -0,0 +1,85 @@
+/**
+ * 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.contrib.misc.math;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.datatorrent.lib.testbench.CollectorTestSink;
+
+/**
+ *
+ * Functional tests for {@link Change}.
+ * <p>
+ * @deprecated
+ */
+@Deprecated
+public class ChangeTest
+{
+  private static Logger log = LoggerFactory.getLogger(ChangeTest.class);
+
+  /**
+   * Test node logic emits correct results.
+   */
+  @Test
+  public void testNodeProcessing() throws Exception
+  {
+    testNodeProcessingSchema(new Change<Integer>());
+    testNodeProcessingSchema(new Change<Double>());
+    testNodeProcessingSchema(new Change<Float>());
+    testNodeProcessingSchema(new Change<Short>());
+    testNodeProcessingSchema(new Change<Long>());
+  }
+
+  /**
+   *
+   * @param oper  Data value for comparison.
+   */
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  public <V extends Number> void testNodeProcessingSchema(Change<V> oper)
+  {
+    CollectorTestSink changeSink = new CollectorTestSink();
+    CollectorTestSink percentSink = new CollectorTestSink();
+
+    oper.change.setSink(changeSink);
+    oper.percent.setSink(percentSink);
+
+    oper.beginWindow(0);
+    oper.base.process(oper.getValue(10));
+    oper.data.process(oper.getValue(5));
+    oper.data.process(oper.getValue(15));
+    oper.data.process(oper.getValue(20));
+    oper.endWindow();
+
+    Assert.assertEquals("number emitted tuples", 3,
+        changeSink.collectedTuples.size());
+    Assert.assertEquals("number emitted tuples", 3,
+        percentSink.collectedTuples.size());
+
+    log.debug("\nLogging tuples");
+    for (Object o : changeSink.collectedTuples) {
+      log.debug(String.format("change %s", o));
+    }
+    for (Object o : percentSink.collectedTuples) {
+      log.debug(String.format("percent change %s", o));
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/CompareExceptMapTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/CompareExceptMapTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/CompareExceptMapTest.java
new file mode 100644
index 0000000..9785a4a
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/CompareExceptMapTest.java
@@ -0,0 +1,98 @@
+/**
+ * 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.contrib.misc.math;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.datatorrent.lib.testbench.CountAndLastTupleTestSink;
+
+/**
+ *
+ * Functional tests for {@link CompareExceptMap}<p>
+ * @deprecated
+ */
+@Deprecated
+public class CompareExceptMapTest
+{
+  /**
+   * Test node logic emits correct results
+   */
+  @Test
+  public void testNodeProcessing() throws Exception
+  {
+    testNodeProcessingSchema(new CompareExceptMap<String, Integer>());
+    testNodeProcessingSchema(new CompareExceptMap<String, Double>());
+    testNodeProcessingSchema(new CompareExceptMap<String, Float>());
+    testNodeProcessingSchema(new CompareExceptMap<String, Short>());
+    testNodeProcessingSchema(new CompareExceptMap<String, Long>());
+  }
+
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  public void testNodeProcessingSchema(CompareExceptMap oper)
+  {
+    CountAndLastTupleTestSink compareSink = new CountAndLastTupleTestSink();
+    CountAndLastTupleTestSink exceptSink = new CountAndLastTupleTestSink();
+    oper.compare.setSink(compareSink);
+    oper.except.setSink(exceptSink);
+
+    oper.setKey("a");
+    oper.setValue(3.0);
+    oper.setTypeEQ();
+
+    oper.beginWindow(0);
+    HashMap<String, Number> input = new HashMap<String, Number>();
+    input.put("a", 2);
+    input.put("b", 20);
+    input.put("c", 1000);
+    oper.data.process(input);
+    input.clear();
+    input.put("a", 3);
+    input.put("b", 21);
+    input.put("c", 30);
+    oper.data.process(input);
+    oper.endWindow();
+
+    // One for each key
+    Assert.assertEquals("number emitted tuples", 1, exceptSink.count);
+    for (Map.Entry<String, Number> e : ((HashMap<String, Number>)exceptSink.tuple).entrySet()) {
+      if (e.getKey().equals("a")) {
+        Assert.assertEquals("emitted value for 'a' was ", new Double(2), e.getValue().doubleValue(), 0);
+      } else if (e.getKey().equals("b")) {
+        Assert.assertEquals("emitted tuple for 'b' was ", new Double(20), e.getValue().doubleValue(), 0);
+      } else if (e.getKey().equals("c")) {
+        Assert.assertEquals("emitted tuple for 'c' was ", new Double(1000), e.getValue().doubleValue(), 0);
+      }
+    }
+
+    Assert.assertEquals("number emitted tuples", 1, compareSink.count);
+    for (Map.Entry<String, Number> e : ((HashMap<String, Number>)compareSink.tuple).entrySet()) {
+      if (e.getKey().equals("a")) {
+        Assert.assertEquals("emitted value for 'a' was ", new Double(3), e.getValue().doubleValue(), 0);
+      } else if (e.getKey().equals("b")) {
+        Assert.assertEquals("emitted tuple for 'b' was ", new Double(21), e.getValue().doubleValue(), 0);
+      } else if (e.getKey().equals("c")) {
+        Assert.assertEquals("emitted tuple for 'c' was ", new Double(30), e.getValue().doubleValue(), 0);
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/CompareMapTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/CompareMapTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/CompareMapTest.java
new file mode 100644
index 0000000..c91e4c9
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/CompareMapTest.java
@@ -0,0 +1,83 @@
+/**
+ * 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.contrib.misc.math;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.datatorrent.lib.testbench.CountAndLastTupleTestSink;
+
+/**
+ *
+ * Functional tests for {@link CompareMap}<p>
+ * @deprecated
+ */
+@Deprecated
+public class CompareMapTest
+{
+  /**
+   * Test node logic emits correct results
+   */
+  @Test
+  public void testNodeProcessing() throws Exception
+  {
+    testNodeProcessingSchema(new CompareMap<String, Integer>());
+    testNodeProcessingSchema(new CompareMap<String, Double>());
+    testNodeProcessingSchema(new CompareMap<String, Float>());
+    testNodeProcessingSchema(new CompareMap<String, Short>());
+    testNodeProcessingSchema(new CompareMap<String, Long>());
+  }
+
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  public void testNodeProcessingSchema(CompareMap oper)
+  {
+    CountAndLastTupleTestSink matchSink = new CountAndLastTupleTestSink();
+    oper.compare.setSink(matchSink);
+    oper.setKey("a");
+    oper.setValue(3.0);
+    oper.setTypeNEQ();
+
+    oper.beginWindow(0);
+    HashMap<String, Number> input = new HashMap<String, Number>();
+
+    input.put("a", 2);
+    input.put("b", 20);
+    input.put("c", 1000);
+    oper.data.process(input);
+    input.clear();
+    input.put("a", 3);
+    oper.data.process(input);
+    oper.endWindow();
+
+    // One for each key
+    Assert.assertEquals("number emitted tuples", 1, matchSink.count);
+    for (Map.Entry<String, Number> e : ((HashMap<String, Number>)matchSink.tuple).entrySet()) {
+      if (e.getKey().equals("a")) {
+        Assert.assertEquals("emitted value for 'a' was ", new Double(2), e.getValue().doubleValue(), 0);
+      } else if (e.getKey().equals("b")) {
+        Assert.assertEquals("emitted tuple for 'b' was ", new Double(20), e.getValue().doubleValue(), 0);
+      } else if (e.getKey().equals("c")) {
+        Assert.assertEquals("emitted tuple for 'c' was ", new Double(1000), e.getValue().doubleValue(), 0);
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/CountKeyValTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/CountKeyValTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/CountKeyValTest.java
new file mode 100644
index 0000000..317790a
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/CountKeyValTest.java
@@ -0,0 +1,83 @@
+/**
+ * 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.contrib.misc.math;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.datatorrent.lib.testbench.CollectorTestSink;
+import com.datatorrent.lib.util.KeyValPair;
+
+/**
+ *
+ * Functional tests for {@link CountKeyVal}. <p>
+ * @deprecated
+ */
+@Deprecated
+public class CountKeyValTest
+{
+  /**
+   * Test operator logic emits correct results.
+   */
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  @Test
+  public void testNodeProcessing()
+  {
+    CountKeyVal<String, Double> oper = new CountKeyVal<String, Double>();
+    CollectorTestSink countSink = new CollectorTestSink();
+    oper.count.setSink(countSink);
+
+    oper.beginWindow(0); //
+
+    oper.data.process(new KeyValPair("a", 2.0));
+    oper.data.process(new KeyValPair("b", 20.0));
+    oper.data.process(new KeyValPair("c", 1000.0));
+    oper.data.process(new KeyValPair("a", 1.0));
+    oper.data.process(new KeyValPair("a", 10.0));
+    oper.data.process(new KeyValPair("b", 5.0));
+    oper.data.process(new KeyValPair("d", 55.0));
+    oper.data.process(new KeyValPair("b", 12.0));
+    oper.data.process(new KeyValPair("d", 22.0));
+    oper.data.process(new KeyValPair("d", 14.2));
+    oper.data.process(new KeyValPair("d", 46.0));
+    oper.data.process(new KeyValPair("e", 2.0));
+    oper.data.process(new KeyValPair("a", 23.0));
+    oper.data.process(new KeyValPair("d", 4.0));
+
+    oper.endWindow(); //
+
+    // payload should be 1 bag of tuples with keys "a", "b", "c", "d", "e"
+    Assert.assertEquals("number emitted tuples", 5, countSink.collectedTuples.size());
+    for (Object o : countSink.collectedTuples) {
+      KeyValPair<String, Integer> e = (KeyValPair<String, Integer>)o;
+      Integer val = (Integer)e.getValue();
+      if (e.getKey().equals("a")) {
+        Assert.assertEquals("emitted value for 'a' was ", 4, val.intValue());
+      } else if (e.getKey().equals("b")) {
+        Assert.assertEquals("emitted tuple for 'b' was ", 3, val.intValue());
+      } else if (e.getKey().equals("c")) {
+        Assert.assertEquals("emitted tuple for 'c' was ", 1, val.intValue());
+      } else if (e.getKey().equals("d")) {
+        Assert.assertEquals("emitted tuple for 'd' was ", 5, val.intValue());
+      } else if (e.getKey().equals("e")) {
+        Assert.assertEquals("emitted tuple for 'e' was ", 1, val.intValue());
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/ExceptMapTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/ExceptMapTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/ExceptMapTest.java
new file mode 100644
index 0000000..8c8b267
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/ExceptMapTest.java
@@ -0,0 +1,85 @@
+/**
+ * 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.contrib.misc.math;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.datatorrent.lib.testbench.CountAndLastTupleTestSink;
+
+/**
+ * @deprecated
+ * Functional tests for {@link ExceptMap}
+ */
+@Deprecated
+public class ExceptMapTest
+{
+  /**
+   * Test node logic emits correct results
+   */
+  @Test
+  public void testNodeProcessing() throws Exception
+  {
+    testNodeProcessingSchema(new ExceptMap<String, Integer>());
+    testNodeProcessingSchema(new ExceptMap<String, Double>());
+    testNodeProcessingSchema(new ExceptMap<String, Float>());
+    testNodeProcessingSchema(new ExceptMap<String, Short>());
+    testNodeProcessingSchema(new ExceptMap<String, Long>());
+  }
+
+  @SuppressWarnings({"rawtypes", "unchecked"})
+  public void testNodeProcessingSchema(ExceptMap oper)
+  {
+    CountAndLastTupleTestSink exceptSink = new CountAndLastTupleTestSink();
+    oper.except.setSink(exceptSink);
+    oper.setKey("a");
+    oper.setValue(3.0);
+    oper.setTypeEQ();
+
+    oper.beginWindow(0);
+    HashMap<String, Number> input = new HashMap<String, Number>();
+    input.put("a", 2);
+    input.put("b", 20);
+    input.put("c", 1000);
+    oper.data.process(input);
+    input.clear();
+    input.put("a", 3);
+    oper.data.process(input);
+    oper.endWindow();
+
+    // One for each key
+    Assert.assertEquals("number emitted tuples", 1, exceptSink.count);
+    for (Map.Entry<String, Number> e : ((HashMap<String, Number>)exceptSink.tuple)
+        .entrySet()) {
+      if (e.getKey().equals("a")) {
+        Assert.assertEquals("emitted value for 'a' was ", new Double(2), e
+            .getValue().doubleValue(), 0);
+      } else if (e.getKey().equals("b")) {
+        Assert.assertEquals("emitted tuple for 'b' was ", new Double(20), e
+            .getValue().doubleValue(), 0);
+      } else if (e.getKey().equals("c")) {
+        Assert.assertEquals("emitted tuple for 'c' was ", new Double(1000), e
+            .getValue().doubleValue(), 0);
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/QuotientMapTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/QuotientMapTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/QuotientMapTest.java
new file mode 100644
index 0000000..7682ae3
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/QuotientMapTest.java
@@ -0,0 +1,94 @@
+/**
+ * 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.contrib.misc.math;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.datatorrent.lib.testbench.CountAndLastTupleTestSink;
+
+/**
+ * @deprecated
+ * Functional tests for {@link QuotientMap}
+ */
+@Deprecated
+public class QuotientMapTest
+{
+  private static Logger LOG = LoggerFactory.getLogger(QuotientMap.class);
+
+  /**
+   * Test node logic emits correct results
+   */
+  @Test
+  public void testNodeProcessing() throws Exception
+  {
+    testNodeProcessingSchema(new QuotientMap<String, Integer>());
+    testNodeProcessingSchema(new QuotientMap<String, Double>());
+  }
+
+  @SuppressWarnings({ "unchecked", "rawtypes" })
+  public void testNodeProcessingSchema(QuotientMap oper) throws Exception
+  {
+    CountAndLastTupleTestSink quotientSink = new CountAndLastTupleTestSink();
+
+    oper.quotient.setSink(quotientSink);
+    oper.setMult_by(2);
+
+    oper.beginWindow(0); //
+    HashMap<String, Number> input = new HashMap<String, Number>();
+    int numtuples = 100;
+    for (int i = 0; i < numtuples; i++) {
+      input.clear();
+      input.put("a", 2);
+      input.put("b", 20);
+      input.put("c", 1000);
+      oper.numerator.process(input);
+      input.clear();
+      input.put("a", 2);
+      input.put("b", 40);
+      input.put("c", 500);
+      oper.denominator.process(input);
+    }
+
+    oper.endWindow();
+
+    // One for each key
+    Assert.assertEquals("number emitted tuples", 1, quotientSink.count);
+    HashMap<String, Number> output = (HashMap<String, Number>)quotientSink.tuple;
+    for (Map.Entry<String, Number> e : output.entrySet()) {
+      if (e.getKey().equals("a")) {
+        Assert.assertEquals("emitted value for 'a' was ", 2d,
+            e.getValue());
+      } else if (e.getKey().equals("b")) {
+        Assert.assertEquals("emitted tuple for 'b' was ", 1d,
+            e.getValue());
+      } else if (e.getKey().equals("c")) {
+        Assert.assertEquals("emitted tuple for 'c' was ", 4d,
+            e.getValue());
+      } else {
+        LOG.debug(String.format("key was %s", e.getKey()));
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/QuotientTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/QuotientTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/QuotientTest.java
new file mode 100644
index 0000000..4d1c7ff
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/QuotientTest.java
@@ -0,0 +1,104 @@
+/**
+ * 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.contrib.misc.math;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.datatorrent.api.Sink;
+
+/**
+ * @deprecated
+ * Functional tests for {@link Quotient}
+ */
+@Deprecated
+public class QuotientTest
+{
+
+  class TestSink implements Sink<Object>
+  {
+    List<Object> collectedTuples = new ArrayList<Object>();
+
+    @Override
+    public void put(Object payload)
+    {
+      collectedTuples.add(payload);
+    }
+
+    @Override
+    public int getCount(boolean reset)
+    {
+      throw new UnsupportedOperationException("Not supported yet.");
+    }
+  }
+
+  /**
+   * Test oper logic emits correct results.
+   */
+  @Test
+  public void testNodeSchemaProcessing()
+  {
+    Quotient<Double> oper = new Quotient<Double>();
+    TestSink quotientSink = new TestSink();
+    oper.quotient.setSink(quotientSink);
+
+    oper.setMult_by(2);
+
+    oper.beginWindow(0); //
+    Double a = 30.0;
+    Double b = 20.0;
+    Double c = 100.0;
+    oper.denominator.process(a);
+    oper.denominator.process(b);
+    oper.denominator.process(c);
+
+    a = 5.0;
+    oper.numerator.process(a);
+    a = 1.0;
+    oper.numerator.process(a);
+    b = 44.0;
+    oper.numerator.process(b);
+
+    b = 10.0;
+    oper.numerator.process(b);
+    c = 22.0;
+    oper.numerator.process(c);
+    c = 18.0;
+    oper.numerator.process(c);
+
+    a = 0.5;
+    oper.numerator.process(a);
+    b = 41.5;
+    oper.numerator.process(b);
+    a = 8.0;
+    oper.numerator.process(a);
+    oper.endWindow(); //
+
+    // payload should be 1 bag of tuples with keys "a", "b", "c", "d", "e"
+    Assert.assertEquals("number emitted tuples", 1,
+        quotientSink.collectedTuples.size());
+    for (Object o : quotientSink.collectedTuples) { // sum is 1157
+      Double val = (Double)o;
+      Assert.assertEquals("emitted quotient value was ", new Double(2.0), val);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/SumCountMapTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/SumCountMapTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/SumCountMapTest.java
new file mode 100644
index 0000000..a50a3bd
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/math/SumCountMapTest.java
@@ -0,0 +1,156 @@
+/**
+ * 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.contrib.misc.math;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.datatorrent.lib.testbench.CollectorTestSink;
+
+/**
+ * @deprecated
+ * Functional tests for {@link SumCountMap}.
+ */
+@Deprecated
+public class SumCountMapTest
+{
+  /**
+   * Test operator logic emits correct results.
+   */
+  @Test
+  public void testNodeProcessing()
+  {
+    testNodeSchemaProcessing(true, true);
+    testNodeSchemaProcessing(true, false);
+    testNodeSchemaProcessing(false, true);
+    testNodeSchemaProcessing(false, false);
+  }
+
+  @SuppressWarnings({ "unchecked", "rawtypes" })
+  public void testNodeSchemaProcessing(boolean sum, boolean count)
+  {
+    SumCountMap<String, Double> oper = new SumCountMap<String, Double>();
+    oper.setType(Double.class);
+    CollectorTestSink sumSink = new CollectorTestSink();
+    CollectorTestSink countSink = new CollectorTestSink();
+    if (sum) {
+      oper.sum.setSink(sumSink);
+    }
+    if (count) {
+      oper.count.setSink(countSink);
+    }
+
+    oper.beginWindow(0); //
+
+    HashMap<String, Double> input = new HashMap<String, Double>();
+
+    input.put("a", 2.0);
+    input.put("b", 20.0);
+    input.put("c", 1000.0);
+    oper.data.process(input);
+    input.clear();
+    input.put("a", 1.0);
+    oper.data.process(input);
+    input.clear();
+    input.put("a", 10.0);
+    input.put("b", 5.0);
+    oper.data.process(input);
+    input.clear();
+    input.put("d", 55.0);
+    input.put("b", 12.0);
+    oper.data.process(input);
+    input.clear();
+    input.put("d", 22.0);
+    oper.data.process(input);
+    input.clear();
+    input.put("d", 14.2);
+    oper.data.process(input);
+    input.clear();
+
+    // Mix integers and doubles
+    HashMap<String, Double> inputi = new HashMap<String, Double>();
+    inputi.put("d", 46.0);
+    inputi.put("e", 2.0);
+    oper.data.process(inputi);
+    inputi.clear();
+    inputi.put("a", 23.0);
+    inputi.put("d", 4.0);
+    oper.data.process(inputi);
+    inputi.clear();
+
+    oper.endWindow(); //
+
+    if (sum) {
+      // payload should be 1 bag of tuples with keys "a", "b", "c", "d", "e"
+      Assert.assertEquals("number emitted tuples", 1, sumSink.collectedTuples.size());
+
+      for (Object o : sumSink.collectedTuples) {
+        HashMap<String, Object> output = (HashMap<String, Object>)o;
+        for (Map.Entry<String, Object> e : output.entrySet()) {
+          Double val = (Double)e.getValue();
+          if (e.getKey().equals("a")) {
+            Assert.assertEquals("emitted value for 'a' was ", new Double(36),
+                val);
+          } else if (e.getKey().equals("b")) {
+            Assert.assertEquals("emitted tuple for 'b' was ", new Double(37),
+                val);
+          } else if (e.getKey().equals("c")) {
+            Assert.assertEquals("emitted tuple for 'c' was ", new Double(1000),
+                val);
+          } else if (e.getKey().equals("d")) {
+            Assert.assertEquals("emitted tuple for 'd' was ",
+                new Double(141.2), val);
+          } else if (e.getKey().equals("e")) {
+            Assert.assertEquals("emitted tuple for 'e' was ", new Double(2),
+                val);
+          }
+        }
+      }
+    }
+    if (count) {
+      // payload should be 1 bag of tuples with keys "a", "b", "c", "d", "e"
+      Assert.assertEquals("number emitted tuples", 1, countSink.collectedTuples.size());
+      for (Object o : countSink.collectedTuples) {
+        HashMap<String, Object> output = (HashMap<String, Object>)o;
+        for (Map.Entry<String, Object> e : output.entrySet()) {
+          Integer val = (Integer)e.getValue();
+          if (e.getKey().equals("a")) {
+            Assert
+                .assertEquals("emitted value for 'a' was ", 4, val.intValue());
+          } else if (e.getKey().equals("b")) {
+            Assert
+                .assertEquals("emitted tuple for 'b' was ", 3, val.intValue());
+          } else if (e.getKey().equals("c")) {
+            Assert
+                .assertEquals("emitted tuple for 'c' was ", 1, val.intValue());
+          } else if (e.getKey().equals("d")) {
+            Assert
+                .assertEquals("emitted tuple for 'd' was ", 5, val.intValue());
+          } else if (e.getKey().equals("e")) {
+            Assert
+                .assertEquals("emitted tuple for 'e' was ", 1, val.intValue());
+          }
+        }
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/DeleteOperatorTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/DeleteOperatorTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/DeleteOperatorTest.java
new file mode 100644
index 0000000..a535053
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/DeleteOperatorTest.java
@@ -0,0 +1,80 @@
+/**
+ * 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.contrib.misc.streamquery;
+
+import java.util.HashMap;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.apex.malhar.contrib.misc.streamquery.condition.EqualValueCondition;
+
+import com.datatorrent.lib.testbench.CollectorTestSink;
+
+/**
+ * Functional test for {@link org.apache.apex.malhar.contrib.misc.streamquery.DeleteOperator}.
+ * @deprecated
+ */
+@Deprecated
+public class DeleteOperatorTest
+{
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  @Test
+  public void testSqlSelect()
+  {
+    // create operator
+    DeleteOperator oper = new DeleteOperator();
+
+    EqualValueCondition condition = new EqualValueCondition();
+    condition.addEqualValue("a", 1);
+    oper.setCondition(condition);
+
+    CollectorTestSink sink = new CollectorTestSink();
+    oper.outport.setSink(sink);
+
+    oper.setup(null);
+    oper.beginWindow(1);
+
+    HashMap<String, Object> tuple = new HashMap<String, Object>();
+    tuple.put("a", 0);
+    tuple.put("b", 1);
+    tuple.put("c", 2);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 3);
+    tuple.put("c", 4);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 5);
+    tuple.put("c", 6);
+    oper.inport.process(tuple);
+
+    oper.endWindow();
+    oper.teardown();
+
+    LOG.debug("{}", sink.collectedTuples);
+  }
+
+  private static final Logger LOG = LoggerFactory.getLogger(DeleteOperatorTest.class);
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/FullOuterJoinOperatorTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/FullOuterJoinOperatorTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/FullOuterJoinOperatorTest.java
new file mode 100644
index 0000000..762d322
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/FullOuterJoinOperatorTest.java
@@ -0,0 +1,93 @@
+/**
+ * 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.contrib.misc.streamquery;
+
+import java.util.HashMap;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.datatorrent.lib.streamquery.condition.Condition;
+import com.datatorrent.lib.streamquery.condition.JoinColumnEqualCondition;
+import com.datatorrent.lib.streamquery.index.ColumnIndex;
+import com.datatorrent.lib.testbench.CollectorTestSink;
+@Deprecated
+public class FullOuterJoinOperatorTest
+{
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  @Test
+  public void testSqlSelect()
+  {
+    // create operator
+    OuterJoinOperator oper = new OuterJoinOperator();
+    oper.setFullJoin(true);
+    CollectorTestSink sink = new CollectorTestSink();
+    oper.outport.setSink(sink);
+
+    // set column join condition  
+    Condition cond = new JoinColumnEqualCondition("a", "a");
+    oper.setJoinCondition(cond);
+    
+    // add columns  
+    oper.selectTable1Column(new ColumnIndex("b", null));
+    oper.selectTable2Column(new ColumnIndex("c", null));
+
+    oper.setup(null);
+    oper.beginWindow(1);
+
+    HashMap<String, Object> tuple = new HashMap<String, Object>();
+    tuple.put("a", 0);
+    tuple.put("b", 1);
+    tuple.put("c", 2);
+    oper.inport1.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 3);
+    tuple.put("c", 4);
+    oper.inport1.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 2);
+    tuple.put("b", 11);
+    tuple.put("c", 12);
+    oper.inport1.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 0);
+    tuple.put("b", 7);
+    tuple.put("c", 8);
+    oper.inport2.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 5);
+    tuple.put("c", 6);
+    oper.inport2.process(tuple);
+
+    oper.endWindow();
+    oper.teardown();
+
+    LOG.debug("{}", sink.collectedTuples);
+  }
+
+  private static final Logger LOG = LoggerFactory.getLogger(FullOuterJoinOperatorTest.class);
+
+}


[07/12] apex-malhar git commit: Updated algo & working on math operators

Posted by th...@apache.org.
http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/GroupByOperatorTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/GroupByOperatorTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/GroupByOperatorTest.java
new file mode 100644
index 0000000..6ad818e
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/GroupByOperatorTest.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.contrib.misc.streamquery;
+
+import java.util.HashMap;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.apex.malhar.contrib.misc.streamquery.condition.EqualValueCondition;
+import org.apache.apex.malhar.contrib.misc.streamquery.function.SumFunction;
+
+import com.datatorrent.lib.streamquery.index.ColumnIndex;
+import com.datatorrent.lib.testbench.CollectorTestSink;
+
+/**
+ * Functional test for {@link org.apache.apex.malhar.contrib.misc.streamquery.GroupByOperatorTest}.
+ * @deprecated
+ */
+@Deprecated
+public class GroupByOperatorTest
+{
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  @Test
+  public void testSqlGroupBy()
+  {
+    // create operator
+    GroupByHavingOperator oper = new GroupByHavingOperator();
+    oper.addColumnGroupByIndex(new ColumnIndex("b", null));
+    try {
+      oper.addAggregateIndex(new SumFunction("c", null));
+    } catch (Exception e) {
+      // TODO Auto-generated catch block
+      e.printStackTrace();
+      return;
+    }
+
+    EqualValueCondition condition = new EqualValueCondition();
+    condition.addEqualValue("a", 1);
+    oper.setCondition(condition);
+
+    CollectorTestSink sink = new CollectorTestSink();
+    oper.outport.setSink(sink);
+
+    oper.setup(null);
+    oper.beginWindow(1);
+
+    HashMap<String, Object> tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 1);
+    tuple.put("c", 2);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 1);
+    tuple.put("c", 4);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 2);
+    tuple.put("c", 6);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 2);
+    tuple.put("c", 7);
+    oper.inport.process(tuple);
+    
+    oper.endWindow();
+    oper.teardown();
+
+    LOG.debug("{}", sink.collectedTuples);
+  }
+
+  private static final Logger LOG = LoggerFactory.getLogger(GroupByOperatorTest.class);
+
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/HavingOperatorTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/HavingOperatorTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/HavingOperatorTest.java
new file mode 100644
index 0000000..5b696f1
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/HavingOperatorTest.java
@@ -0,0 +1,99 @@
+/**
+ * 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.contrib.misc.streamquery;
+
+import java.util.HashMap;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.apex.malhar.contrib.misc.streamquery.condition.EqualValueCondition;
+import org.apache.apex.malhar.contrib.misc.streamquery.condition.HavingCompareValue;
+import org.apache.apex.malhar.contrib.misc.streamquery.condition.HavingCondition;
+import org.apache.apex.malhar.contrib.misc.streamquery.function.FunctionIndex;
+import org.apache.apex.malhar.contrib.misc.streamquery.function.SumFunction;
+
+import com.datatorrent.lib.streamquery.index.ColumnIndex;
+import com.datatorrent.lib.testbench.CollectorTestSink;
+
+/**
+ * Functional test for {@link org.apache.apex.malhar.contrib.misc.streamquery.HavingOperatorTest}.
+ * @deprecated
+ */
+@Deprecated
+public class HavingOperatorTest
+{
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  @Test
+  public void testSqlGroupBy() throws Exception
+  {
+    // create operator
+    GroupByHavingOperator oper = new GroupByHavingOperator();
+    oper.addColumnGroupByIndex(new ColumnIndex("b", null));
+    FunctionIndex sum = new SumFunction("c", null);
+    oper.addAggregateIndex(sum);
+
+    // create having condition
+    HavingCondition having = new HavingCompareValue<Double>(sum, 6.0, 0);
+    oper.addHavingCondition(having);
+
+    EqualValueCondition condition = new EqualValueCondition();
+    condition.addEqualValue("a", 1);
+    oper.setCondition(condition);
+
+    CollectorTestSink sink = new CollectorTestSink();
+    oper.outport.setSink(sink);
+
+    oper.setup(null);
+    oper.beginWindow(1);
+
+    HashMap<String, Object> tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 1);
+    tuple.put("c", 2);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 1);
+    tuple.put("c", 4);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 2);
+    tuple.put("c", 6);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 2);
+    tuple.put("c", 7);
+    oper.inport.process(tuple);
+    
+    oper.endWindow();
+    oper.teardown();
+
+    LOG.debug("{}", sink.collectedTuples);
+  }
+
+  private static final Logger LOG = LoggerFactory.getLogger(HavingOperatorTest.class);
+
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/InnerJoinOperatorTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/InnerJoinOperatorTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/InnerJoinOperatorTest.java
new file mode 100644
index 0000000..8b4f923
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/InnerJoinOperatorTest.java
@@ -0,0 +1,92 @@
+/**
+ * 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.contrib.misc.streamquery;
+
+import java.util.HashMap;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.datatorrent.lib.streamquery.condition.Condition;
+import com.datatorrent.lib.streamquery.condition.JoinColumnEqualCondition;
+import com.datatorrent.lib.streamquery.index.ColumnIndex;
+import com.datatorrent.lib.testbench.CollectorTestSink;
+
+/**
+ * 
+ * Functional test for {@link com.datatorrent.lib.streamquery.InnerJoinOperator }.
+ * @deprecated
+ */
+@Deprecated
+public class InnerJoinOperatorTest
+{
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  @Test
+  public void testSqlSelect()
+  {
+    // create operator
+    InnerJoinOperator oper = new InnerJoinOperator();
+    CollectorTestSink sink = new CollectorTestSink();
+    oper.outport.setSink(sink);
+
+    // set column join condition
+    Condition cond = new JoinColumnEqualCondition("a", "a");
+    oper.setJoinCondition(cond);
+
+    // add columns
+    oper.selectTable1Column(new ColumnIndex("b", null));
+    oper.selectTable2Column(new ColumnIndex("c", null));
+
+    oper.setup(null);
+    oper.beginWindow(1);
+
+    HashMap<String, Object> tuple = new HashMap<String, Object>();
+    tuple.put("a", 0);
+    tuple.put("b", 1);
+    tuple.put("c", 2);
+    oper.inport1.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 3);
+    tuple.put("c", 4);
+    oper.inport1.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 0);
+    tuple.put("b", 7);
+    tuple.put("c", 8);
+    oper.inport2.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 5);
+    tuple.put("c", 6);
+    oper.inport2.process(tuple);
+
+    oper.endWindow();
+    oper.teardown();
+
+    LOG.debug("{}", sink.collectedTuples);
+  }
+
+  private static final Logger LOG = LoggerFactory.getLogger(InnerJoinOperatorTest.class);
+
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/LeftOuterJoinOperatorTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/LeftOuterJoinOperatorTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/LeftOuterJoinOperatorTest.java
new file mode 100644
index 0000000..f78ba21
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/LeftOuterJoinOperatorTest.java
@@ -0,0 +1,93 @@
+/**
+ * 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.contrib.misc.streamquery;
+
+import java.util.HashMap;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.datatorrent.lib.streamquery.condition.Condition;
+import com.datatorrent.lib.streamquery.condition.JoinColumnEqualCondition;
+import com.datatorrent.lib.streamquery.index.ColumnIndex;
+import com.datatorrent.lib.testbench.CollectorTestSink;
+
+@Deprecated
+public class LeftOuterJoinOperatorTest
+{
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  @Test
+  public void testSqlSelect()
+  {
+    // create operator
+    OuterJoinOperator oper = new OuterJoinOperator();
+    CollectorTestSink sink = new CollectorTestSink();
+    oper.outport.setSink(sink);
+
+    // set column join condition  
+    Condition cond = new JoinColumnEqualCondition("a", "a");
+    oper.setJoinCondition(cond);
+    
+    // add columns  
+    oper.selectTable1Column(new ColumnIndex("b", null));
+    oper.selectTable2Column(new ColumnIndex("c", null));
+
+    oper.setup(null);
+    oper.beginWindow(1);
+
+    HashMap<String, Object> tuple = new HashMap<String, Object>();
+    tuple.put("a", 0);
+    tuple.put("b", 1);
+    tuple.put("c", 2);
+    oper.inport1.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 3);
+    tuple.put("c", 4);
+    oper.inport1.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 2);
+    tuple.put("b", 11);
+    tuple.put("c", 12);
+    oper.inport1.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 0);
+    tuple.put("b", 7);
+    tuple.put("c", 8);
+    oper.inport2.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 5);
+    tuple.put("c", 6);
+    oper.inport2.process(tuple);
+
+    oper.endWindow();
+    oper.teardown();
+
+    LOG.debug("{}", sink.collectedTuples);
+  }
+
+  private static final Logger LOG = LoggerFactory.getLogger(LeftOuterJoinOperatorTest.class);
+
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/OrderByOperatorTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/OrderByOperatorTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/OrderByOperatorTest.java
new file mode 100644
index 0000000..88aa2d0
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/OrderByOperatorTest.java
@@ -0,0 +1,95 @@
+/**
+ * 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.contrib.misc.streamquery;
+
+import java.util.HashMap;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.datatorrent.lib.testbench.CollectorTestSink;
+
+/**
+ *  Functional test for {@link com.datatorrent.lib.streamquery.OrderByOperatorTest}.
+ *  @deprecated
+ */
+@Deprecated
+public class OrderByOperatorTest
+{
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  @Test
+  public void testSqlSelect()
+  {
+    // craete operator
+    OrderByOperator oper = new OrderByOperator();
+
+    CollectorTestSink sink = new CollectorTestSink();
+    oper.outport.setSink(sink);
+    oper.addOrderByRule(new OrderByRule<Integer>("b"));
+    oper.setDescending(true);
+
+    oper.setup(null);
+    oper.beginWindow(1);
+
+    HashMap<String, Object> tuple = new HashMap<String, Object>();
+    tuple.put("c", 2);
+    tuple.put("a", 0);
+    tuple.put("b", 1);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 2);
+    tuple.put("b", 5);
+    tuple.put("c", 6);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 2);
+    tuple.put("b", 6);
+    tuple.put("c", 6);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 3);
+    tuple.put("c", 4);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 4);
+    tuple.put("c", 4);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 8);
+    tuple.put("c", 4);
+    oper.inport.process(tuple);
+
+    oper.endWindow();
+    oper.teardown();
+
+    LOG.debug("{}", sink.collectedTuples);
+  }
+
+  private static final Logger LOG = LoggerFactory.getLogger(OrderByOperatorTest.class);
+
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/RightOuterJoinOperatorTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/RightOuterJoinOperatorTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/RightOuterJoinOperatorTest.java
new file mode 100644
index 0000000..8142276
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/RightOuterJoinOperatorTest.java
@@ -0,0 +1,95 @@
+/**
+ * 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.contrib.misc.streamquery;
+
+import java.util.HashMap;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.datatorrent.lib.streamquery.condition.Condition;
+import com.datatorrent.lib.streamquery.condition.JoinColumnEqualCondition;
+import com.datatorrent.lib.streamquery.index.ColumnIndex;
+import com.datatorrent.lib.testbench.CollectorTestSink;
+
+@Deprecated
+public class RightOuterJoinOperatorTest
+{
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  @Test
+  public void testSqlSelect()
+  {
+    // create operator
+    OuterJoinOperator oper = new OuterJoinOperator();
+    oper.setRighttJoin();
+    CollectorTestSink sink = new CollectorTestSink();
+    oper.outport.setSink(sink);
+
+    // set column join condition  
+    Condition cond = new JoinColumnEqualCondition("a", "a");
+    oper.setJoinCondition(cond);
+    
+    // add columns  
+    oper.selectTable1Column(new ColumnIndex("b", null));
+    oper.selectTable2Column(new ColumnIndex("c", null));
+
+    oper.setup(null);
+    oper.beginWindow(1);
+
+    HashMap<String, Object> tuple = new HashMap<String, Object>();
+    tuple.put("a", 0);
+    tuple.put("b", 1);
+    tuple.put("c", 2);
+    oper.inport1.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 3);
+    tuple.put("c", 4);
+    oper.inport1.process(tuple);
+
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 0);
+    tuple.put("b", 7);
+    tuple.put("c", 8);
+    oper.inport2.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 5);
+    tuple.put("c", 6);
+    oper.inport2.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 2);
+    tuple.put("b", 11);
+    tuple.put("c", 12);
+    oper.inport2.process(tuple);
+    
+    oper.endWindow();
+    oper.teardown();
+
+    LOG.debug("{}", sink.collectedTuples);
+  }
+
+  private static final Logger LOG = LoggerFactory.getLogger(RightOuterJoinOperatorTest.class);
+
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/SelectOperatorTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/SelectOperatorTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/SelectOperatorTest.java
new file mode 100644
index 0000000..c5acbdd
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/SelectOperatorTest.java
@@ -0,0 +1,84 @@
+/**
+ * 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.contrib.misc.streamquery;
+
+import java.util.HashMap;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.apex.malhar.contrib.misc.streamquery.condition.EqualValueCondition;
+
+import com.datatorrent.lib.streamquery.index.ColumnIndex;
+import com.datatorrent.lib.testbench.CollectorTestSink;
+
+/**
+ * Functional test for {@link org.apache.apex.malhar.contrib.misc.streamquery.SelectOperatorTest}.
+ * @deprecated
+ */
+@Deprecated
+public class SelectOperatorTest
+{
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  @Test
+  public void testSqlSelect()
+  {
+    // create operator
+    SelectOperator oper = new SelectOperator();
+    oper.addIndex(new ColumnIndex("b", null));
+    oper.addIndex(new ColumnIndex("c", null));
+
+    EqualValueCondition condition = new EqualValueCondition();
+    condition.addEqualValue("a", 1);
+    oper.setCondition(condition);
+
+    CollectorTestSink sink = new CollectorTestSink();
+    oper.outport.setSink(sink);
+
+    oper.setup(null);
+    oper.beginWindow(1);
+
+    HashMap<String, Object> tuple = new HashMap<String, Object>();
+    tuple.put("a", 0);
+    tuple.put("b", 1);
+    tuple.put("c", 2);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 3);
+    tuple.put("c", 4);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 5);
+    tuple.put("c", 6);
+    oper.inport.process(tuple);
+
+    oper.endWindow();
+    oper.teardown();
+
+    LOG.debug("{}", sink.collectedTuples);
+  }
+
+  private static final Logger LOG = LoggerFactory.getLogger(SelectOperatorTest.class);
+
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/SelectTopOperatorTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/SelectTopOperatorTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/SelectTopOperatorTest.java
new file mode 100644
index 0000000..90480cf
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/SelectTopOperatorTest.java
@@ -0,0 +1,66 @@
+/**
+ * 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.contrib.misc.streamquery;
+
+import java.util.HashMap;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.datatorrent.lib.testbench.CollectorTestSink;
+
+@Deprecated
+public class SelectTopOperatorTest
+{
+  @SuppressWarnings({"rawtypes", "unchecked"})
+  @Test
+  public void testOperator() throws Exception
+  {
+    SelectTopOperator oper = new SelectTopOperator();
+    oper.setTopValue(2);
+    CollectorTestSink sink = new CollectorTestSink();
+    oper.outport.setSink(sink);
+    
+    oper.beginWindow(1);
+    HashMap<String, Object> tuple = new HashMap<String, Object>();
+    tuple.put("a", 0);
+    tuple.put("b", 1);
+    tuple.put("c", 2);
+    oper.inport.process(tuple);
+    
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 3);
+    tuple.put("c", 4);
+    oper.inport.process(tuple);
+    
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 5);
+    tuple.put("c", 6);
+    oper.inport.process(tuple);
+    oper.endWindow();
+
+    LOG.debug("{}", sink.collectedTuples);
+  }
+
+  private static final Logger LOG = LoggerFactory.getLogger(SelectTopOperatorTest.class);
+
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/UpdateOperatorTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/UpdateOperatorTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/UpdateOperatorTest.java
new file mode 100644
index 0000000..f480cc7
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/UpdateOperatorTest.java
@@ -0,0 +1,78 @@
+/**
+ * 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.contrib.misc.streamquery;
+
+import java.util.HashMap;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.apex.malhar.contrib.misc.streamquery.condition.EqualValueCondition;
+
+import com.datatorrent.lib.testbench.CollectorTestSink;
+
+@Deprecated
+public class UpdateOperatorTest
+{
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  @Test
+  public void testSqlSelect()
+  {
+    // create operator
+    UpdateOperator oper = new UpdateOperator();
+
+    EqualValueCondition condition = new EqualValueCondition();
+    condition.addEqualValue("a", 1);
+    oper.setCondition(condition);
+    oper.addUpdate("c", 100);
+
+    CollectorTestSink sink = new CollectorTestSink();
+    oper.outport.setSink(sink);
+
+    oper.setup(null);
+    oper.beginWindow(1);
+
+    HashMap<String, Object> tuple = new HashMap<String, Object>();
+    tuple.put("a", 0);
+    tuple.put("b", 1);
+    tuple.put("c", 2);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 3);
+    tuple.put("c", 4);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 5);
+    tuple.put("c", 6);
+    oper.inport.process(tuple);
+
+    oper.endWindow();
+    oper.teardown();
+
+    LOG.debug("{}", sink.collectedTuples);
+  }
+
+  private static final Logger LOG = LoggerFactory.getLogger(UpdateOperatorTest.class);
+
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/BetweenConditionTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/BetweenConditionTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/BetweenConditionTest.java
new file mode 100644
index 0000000..01465db
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/BetweenConditionTest.java
@@ -0,0 +1,90 @@
+/**
+ * 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.contrib.misc.streamquery.advanced;
+
+import java.util.HashMap;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.apex.malhar.contrib.misc.streamquery.SelectOperator;
+import org.apache.apex.malhar.contrib.misc.streamquery.condition.BetweenCondition;
+
+import com.datatorrent.lib.streamquery.index.ColumnIndex;
+import com.datatorrent.lib.testbench.CollectorTestSink;
+
+/**
+ * Functional test for {@link org.apache.apex.malhar.contrib.misc.streamquery.advanced.BetweenConditionTest}.
+ * @deprecated
+ */
+@Deprecated
+public class BetweenConditionTest
+{
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  @Test
+  public void testSqlSelect()
+  {
+    // create operator
+    SelectOperator oper = new SelectOperator();
+    oper.addIndex(new ColumnIndex("b", null));
+    oper.addIndex(new ColumnIndex("c", null));
+
+    BetweenCondition cond = new BetweenCondition("a", 0, 2);
+    oper.setCondition(cond);
+
+
+    CollectorTestSink sink = new CollectorTestSink();
+    oper.outport.setSink(sink);
+
+    oper.setup(null);
+    oper.beginWindow(1);
+
+    HashMap<String, Object> tuple = new HashMap<String, Object>();
+    tuple.put("a", 0);
+    tuple.put("b", 1);
+    tuple.put("c", 2);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 3);
+    tuple.put("c", 4);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 2);
+    tuple.put("b", 5);
+    tuple.put("c", 6);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 3);
+    tuple.put("b", 7);
+    tuple.put("c", 8);
+    oper.inport.process(tuple);
+    
+    oper.endWindow();
+    oper.teardown();
+
+    LOG.debug("{}", sink.collectedTuples);
+  }
+
+  private static final Logger LOG = LoggerFactory.getLogger(BetweenConditionTest.class);
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/CompoundConditionTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/CompoundConditionTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/CompoundConditionTest.java
new file mode 100644
index 0000000..e160e5d
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/CompoundConditionTest.java
@@ -0,0 +1,95 @@
+/**
+ * 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.contrib.misc.streamquery.advanced;
+
+import java.util.HashMap;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.apex.malhar.contrib.misc.streamquery.SelectOperator;
+import org.apache.apex.malhar.contrib.misc.streamquery.condition.CompoundCondition;
+import org.apache.apex.malhar.contrib.misc.streamquery.condition.EqualValueCondition;
+
+import com.datatorrent.lib.streamquery.index.ColumnIndex;
+import com.datatorrent.lib.testbench.CollectorTestSink;
+
+/**
+ * Functional test for {@link org.apache.apex.malhar.contrib.misc.streamquery.advanced.CompoundConditionTest}.
+ * @deprecated
+ */
+@Deprecated
+public class CompoundConditionTest
+{
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  @Test
+  public void testSqlSelect()
+  {
+    // create operator
+    SelectOperator oper = new SelectOperator();
+    oper.addIndex(new ColumnIndex("b", null));
+    oper.addIndex(new ColumnIndex("c", null));
+
+    EqualValueCondition left = new EqualValueCondition();
+    left.addEqualValue("a", 1);
+    EqualValueCondition  right = new EqualValueCondition();
+    right.addEqualValue("b", 1);
+
+    oper.setCondition(new CompoundCondition(left, right));
+
+
+    CollectorTestSink sink = new CollectorTestSink();
+    oper.outport.setSink(sink);
+
+    oper.setup(null);
+    oper.beginWindow(1);
+
+    HashMap<String, Object> tuple = new HashMap<String, Object>();
+    tuple.put("a", 0);
+    tuple.put("b", 1);
+    tuple.put("c", 2);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 3);
+    tuple.put("c", 4);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 5);
+    tuple.put("c", 6);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 3);
+    tuple.put("b", 7);
+    tuple.put("c", 8);
+    oper.inport.process(tuple);
+    
+    oper.endWindow();
+    oper.teardown();
+
+    LOG.debug("{}", sink.collectedTuples);
+  }
+
+  private static final Logger LOG = LoggerFactory.getLogger(CompoundConditionTest.class);
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/InConditionTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/InConditionTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/InConditionTest.java
new file mode 100644
index 0000000..d641a1c
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/InConditionTest.java
@@ -0,0 +1,93 @@
+/**
+ * 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.contrib.misc.streamquery.advanced;
+
+import java.util.HashMap;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.apex.malhar.contrib.misc.streamquery.SelectOperator;
+import org.apache.apex.malhar.contrib.misc.streamquery.condition.InCondition;
+
+import com.datatorrent.lib.streamquery.index.ColumnIndex;
+import com.datatorrent.lib.testbench.CollectorTestSink;
+
+/**
+ * Functional test for {@link org.apache.apex.malhar.contrib.misc.streamquery.advanced.InConditionTest}.
+ * @deprecated
+ */
+@Deprecated
+public class InConditionTest
+{
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  @Test
+  public void testSqlSelect()
+  {
+    // create operator
+    SelectOperator oper = new SelectOperator();
+    oper.addIndex(new ColumnIndex("b", null));
+    oper.addIndex(new ColumnIndex("c", null));
+
+    InCondition cond = new InCondition("a");
+    cond.addInValue(0);
+    cond.addInValue(1);
+    oper.setCondition(cond);
+
+
+    CollectorTestSink sink = new CollectorTestSink();
+    oper.outport.setSink(sink);
+
+    oper.setup(null);
+    oper.beginWindow(1);
+
+    HashMap<String, Object> tuple = new HashMap<String, Object>();
+    tuple.put("a", 0);
+    tuple.put("b", 1);
+    tuple.put("c", 2);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 3);
+    tuple.put("c", 4);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 2);
+    tuple.put("b", 5);
+    tuple.put("c", 6);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 3);
+    tuple.put("b", 7);
+    tuple.put("c", 8);
+    oper.inport.process(tuple);
+    
+    oper.endWindow();
+    oper.teardown();
+
+    LOG.debug("{}", sink.collectedTuples);
+  }
+
+  private static final Logger LOG = LoggerFactory.getLogger(InConditionTest.class);
+
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/LikeConditionTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/LikeConditionTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/LikeConditionTest.java
new file mode 100644
index 0000000..e09d47a
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/LikeConditionTest.java
@@ -0,0 +1,84 @@
+/**
+ * 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.contrib.misc.streamquery.advanced;
+
+import java.util.HashMap;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.apex.malhar.contrib.misc.streamquery.SelectOperator;
+import org.apache.apex.malhar.contrib.misc.streamquery.condition.LikeCondition;
+
+import com.datatorrent.lib.streamquery.index.ColumnIndex;
+import com.datatorrent.lib.testbench.CollectorTestSink;
+
+/**
+ * Functional test for {@link org.apache.apex.malhar.contrib.misc.streamquery.advanced.LikeConditionTest}.
+ * @deprecated
+ */
+@Deprecated
+public class LikeConditionTest
+{
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  @Test
+  public void testSqlSelect()
+  {
+    // create operator
+    SelectOperator oper = new SelectOperator();
+    oper.addIndex(new ColumnIndex("b", null));
+    oper.addIndex(new ColumnIndex("c", null));
+
+    LikeCondition condition = new LikeCondition("a", "test*");
+    oper.setCondition(condition);
+
+    CollectorTestSink sink = new CollectorTestSink();
+    oper.outport.setSink(sink);
+
+    oper.setup(null);
+    oper.beginWindow(1);
+
+    HashMap<String, Object> tuple = new HashMap<String, Object>();
+    tuple.put("a", "testing");
+    tuple.put("b", 1);
+    tuple.put("c", 2);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", "null");
+    tuple.put("b", 3);
+    tuple.put("c", 4);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", "testall");
+    tuple.put("b", 5);
+    tuple.put("c", 6);
+    oper.inport.process(tuple);
+
+    oper.endWindow();
+    oper.teardown();
+
+    LOG.debug("{}", sink.collectedTuples);
+  }
+
+  private static final Logger LOG = LoggerFactory.getLogger(LikeConditionTest.class);
+
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/NegateIndexTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/NegateIndexTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/NegateIndexTest.java
new file mode 100644
index 0000000..745c8c9
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/NegateIndexTest.java
@@ -0,0 +1,78 @@
+/**
+ * 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.contrib.misc.streamquery.advanced;
+
+import java.util.HashMap;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.apex.malhar.contrib.misc.streamquery.SelectOperator;
+import org.apache.apex.malhar.contrib.misc.streamquery.index.NegateExpression;
+
+import com.datatorrent.lib.testbench.CollectorTestSink;
+
+/**
+ * Functional test for {@link org.apache.apex.malhar.contrib.misc.streamquery.SelectOperatorTest}.
+ * @deprecated
+ */
+@Deprecated
+public class NegateIndexTest
+{
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  @Test
+  public void testSqlSelect()
+  {
+    // create operator
+    SelectOperator oper = new SelectOperator();
+    oper.addIndex(new NegateExpression("b", null));
+
+    CollectorTestSink sink = new CollectorTestSink();
+    oper.outport.setSink(sink);
+
+    oper.setup(null);
+    oper.beginWindow(1);
+
+    HashMap<String, Object> tuple = new HashMap<String, Object>();
+    tuple.put("a", 0);
+    tuple.put("b", 1);
+    tuple.put("c", 2);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 3);
+    tuple.put("c", 4);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 5);
+    tuple.put("c", 6);
+    oper.inport.process(tuple);
+
+    oper.endWindow();
+    oper.teardown();
+
+    LOG.debug("{}", sink.collectedTuples);
+  }
+
+  private static final Logger LOG = LoggerFactory.getLogger(NegateIndexTest.class);
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/SelectAverageTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/SelectAverageTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/SelectAverageTest.java
new file mode 100644
index 0000000..c1fa8b7
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/SelectAverageTest.java
@@ -0,0 +1,78 @@
+/**
+ * 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.contrib.misc.streamquery.advanced;
+
+import java.util.HashMap;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.apex.malhar.contrib.misc.streamquery.SelectFunctionOperator;
+import org.apache.apex.malhar.contrib.misc.streamquery.function.AverageFunction;
+
+import com.datatorrent.lib.testbench.CollectorTestSink;
+
+/**
+ * Functional test for {@link org.apache.apex.malhar.contrib.misc.streamquery.SelectOperatorTest}.
+ * @deprecated
+ */
+@Deprecated
+public class SelectAverageTest
+{
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  @Test
+  public void testSqlSelect()
+  {
+    // create operator
+    SelectFunctionOperator oper = new SelectFunctionOperator();
+    oper.addSqlFunction(new AverageFunction("b", null));
+
+    CollectorTestSink sink = new CollectorTestSink();
+    oper.outport.setSink(sink);
+
+    oper.setup(null);
+    oper.beginWindow(1);
+
+    HashMap<String, Object> tuple = new HashMap<String, Object>();
+    tuple.put("a", 0);
+    tuple.put("b", 1);
+    tuple.put("c", 2);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 3);
+    tuple.put("c", 4);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 5);
+    tuple.put("c", 6);
+    oper.inport.process(tuple);
+
+    oper.endWindow();
+    oper.teardown();
+
+    LOG.debug("{}", sink.collectedTuples);
+  }
+
+  private static final Logger LOG = LoggerFactory.getLogger(SelectAverageTest.class);
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/SelectCountTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/SelectCountTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/SelectCountTest.java
new file mode 100644
index 0000000..8ac1e33
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/SelectCountTest.java
@@ -0,0 +1,79 @@
+/**
+ * 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.contrib.misc.streamquery.advanced;
+
+import java.util.HashMap;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.apex.malhar.contrib.misc.streamquery.SelectFunctionOperator;
+import org.apache.apex.malhar.contrib.misc.streamquery.function.CountFunction;
+
+import com.datatorrent.lib.testbench.CollectorTestSink;
+
+/**
+ * Functional test for {@link org.apache.apex.malhar.contrib.misc.streamquery.SelectOperatorTest}.
+ * @deprecated
+ */
+@Deprecated
+public class SelectCountTest
+{
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  @Test
+  public void testSqlSelect()
+  {
+    // create operator
+    SelectFunctionOperator oper = new SelectFunctionOperator();
+    oper.addSqlFunction(new CountFunction("b", null));
+
+    CollectorTestSink sink = new CollectorTestSink();
+    oper.outport.setSink(sink);
+
+    oper.setup(null);
+    oper.beginWindow(1);
+
+    HashMap<String, Object> tuple = new HashMap<String, Object>();
+    tuple.put("a", 0);
+    tuple.put("b", null);
+    tuple.put("c", 2);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", null);
+    tuple.put("c", 4);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 5);
+    tuple.put("c", 6);
+    oper.inport.process(tuple);
+
+    oper.endWindow();
+    oper.teardown();
+
+    LOG.debug("{}", sink.collectedTuples);
+  }
+
+  private static final Logger LOG = LoggerFactory.getLogger(SelectCountTest.class);
+
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/SelectFirstLastTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/SelectFirstLastTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/SelectFirstLastTest.java
new file mode 100644
index 0000000..17341da
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/SelectFirstLastTest.java
@@ -0,0 +1,79 @@
+/**
+ * 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.contrib.misc.streamquery.advanced;
+
+import java.util.HashMap;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.apex.malhar.contrib.misc.streamquery.SelectFunctionOperator;
+import org.apache.apex.malhar.contrib.misc.streamquery.function.FirstLastFunction;
+
+import com.datatorrent.lib.testbench.CollectorTestSink;
+
+/**
+ * Functional test for {@link org.apache.apex.malhar.contrib.misc.streamquery.SelectOperatorTest}.
+ * @deprecated
+ */
+@Deprecated
+public class SelectFirstLastTest
+{
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  @Test
+  public void testSqlSelect()
+  {
+    // create operator
+    SelectFunctionOperator oper = new SelectFunctionOperator();
+    oper.addSqlFunction(new FirstLastFunction("b", null, false));
+
+    CollectorTestSink sink = new CollectorTestSink();
+    oper.outport.setSink(sink);
+
+    oper.setup(null);
+    oper.beginWindow(1);
+
+    HashMap<String, Object> tuple = new HashMap<String, Object>();
+    tuple.put("a", 0);
+    tuple.put("b", null);
+    tuple.put("c", 2);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", null);
+    tuple.put("c", 4);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 5);
+    tuple.put("c", 6);
+    oper.inport.process(tuple);
+
+    oper.endWindow();
+    oper.teardown();
+
+    LOG.debug("{}", sink.collectedTuples);
+  }
+
+  private static final Logger LOG = LoggerFactory.getLogger(SelectFirstLastTest.class);
+
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/SelectMaxMinTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/SelectMaxMinTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/SelectMaxMinTest.java
new file mode 100644
index 0000000..fa347c1
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/SelectMaxMinTest.java
@@ -0,0 +1,79 @@
+/**
+ * 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.contrib.misc.streamquery.advanced;
+
+import java.util.HashMap;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.apex.malhar.contrib.misc.streamquery.SelectFunctionOperator;
+import org.apache.apex.malhar.contrib.misc.streamquery.function.MaxMinFunction;
+
+import com.datatorrent.lib.testbench.CollectorTestSink;
+
+/**
+ * Functional test for {@link org.apache.apex.malhar.contrib.misc.streamquery.SelectOperatorTest}.
+ * @deprecated
+ */
+@Deprecated
+public class SelectMaxMinTest
+{
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  @Test
+  public void testSqlSelect()
+  {
+    // create operator
+    SelectFunctionOperator oper = new SelectFunctionOperator();
+    oper.addSqlFunction(new MaxMinFunction("b", null, false));
+
+    CollectorTestSink sink = new CollectorTestSink();
+    oper.outport.setSink(sink);
+
+    oper.setup(null);
+    oper.beginWindow(1);
+
+    HashMap<String, Object> tuple = new HashMap<String, Object>();
+    tuple.put("a", 0);
+    tuple.put("b", 1);
+    tuple.put("c", 2);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 3);
+    tuple.put("c", 4);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 5);
+    tuple.put("c", 6);
+    oper.inport.process(tuple);
+
+    oper.endWindow();
+    oper.teardown();
+
+    LOG.debug("{}", sink.collectedTuples);
+  }
+
+  private static final Logger LOG = LoggerFactory.getLogger(SelectMaxMinTest.class);
+
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/SumIndexTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/SumIndexTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/SumIndexTest.java
new file mode 100644
index 0000000..0d374dc
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/streamquery/advanced/SumIndexTest.java
@@ -0,0 +1,79 @@
+/**
+ * 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.contrib.misc.streamquery.advanced;
+
+import java.util.HashMap;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.apex.malhar.contrib.misc.streamquery.SelectOperator;
+import org.apache.apex.malhar.contrib.misc.streamquery.index.SumExpression;
+
+import com.datatorrent.lib.testbench.CollectorTestSink;
+
+/**
+ * Functional test for {@link org.apache.apex.malhar.contrib.misc.streamquery.SelectOperatorTest}.
+ * @deprecated
+ */
+@Deprecated
+public class SumIndexTest
+{
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  @Test
+  public void testSqlSelect()
+  {
+    // create operator
+    SelectOperator oper = new SelectOperator();
+    oper.addIndex(new SumExpression("b", "c", null));
+
+    CollectorTestSink sink = new CollectorTestSink();
+    oper.outport.setSink(sink);
+
+    oper.setup(null);
+    oper.beginWindow(1);
+
+    HashMap<String, Object> tuple = new HashMap<String, Object>();
+    tuple.put("a", 0);
+    tuple.put("b", 1);
+    tuple.put("c", 2);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 3);
+    tuple.put("c", 4);
+    oper.inport.process(tuple);
+
+    tuple = new HashMap<String, Object>();
+    tuple.put("a", 1);
+    tuple.put("b", 5);
+    tuple.put("c", 6);
+    oper.inport.process(tuple);
+
+    oper.endWindow();
+    oper.teardown();
+
+    LOG.debug("{}", sink.collectedTuples);
+  }
+
+  private static final Logger LOG = LoggerFactory.getLogger(SumIndexTest.class);
+
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/demos/yahoofinance/pom.xml
----------------------------------------------------------------------
diff --git a/demos/yahoofinance/pom.xml b/demos/yahoofinance/pom.xml
index 12e5eb0..d92cf2a 100644
--- a/demos/yahoofinance/pom.xml
+++ b/demos/yahoofinance/pom.xml
@@ -49,6 +49,17 @@
       <artifactId>derby</artifactId>
       <version>10.9.1.0</version>
     </dependency>
+    <dependency>
+      <groupId>org.apache.apex</groupId>
+      <artifactId>malhar-contrib</artifactId>
+      <version>${project.version}</version>
+      <exclusions>
+        <exclusion>
+          <groupId>*</groupId>
+          <artifactId>*</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
   </dependencies>
 
 </project>

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/demos/yahoofinance/src/main/java/com/datatorrent/demos/yahoofinance/ApplicationWithDerbySQL.java
----------------------------------------------------------------------
diff --git a/demos/yahoofinance/src/main/java/com/datatorrent/demos/yahoofinance/ApplicationWithDerbySQL.java b/demos/yahoofinance/src/main/java/com/datatorrent/demos/yahoofinance/ApplicationWithDerbySQL.java
index 50b306d..1a38495 100644
--- a/demos/yahoofinance/src/main/java/com/datatorrent/demos/yahoofinance/ApplicationWithDerbySQL.java
+++ b/demos/yahoofinance/src/main/java/com/datatorrent/demos/yahoofinance/ApplicationWithDerbySQL.java
@@ -18,14 +18,14 @@
  */
 package com.datatorrent.demos.yahoofinance;
 
+import org.apache.apex.malhar.contrib.misc.streamquery.AbstractSqlStreamOperator;
+import org.apache.apex.malhar.contrib.misc.streamquery.DerbySqlStreamOperator;
 import org.apache.hadoop.conf.Configuration;
 
 import com.datatorrent.api.DAG;
 import com.datatorrent.api.StreamingApplication;
 import com.datatorrent.api.annotation.ApplicationAnnotation;
 import com.datatorrent.lib.io.ConsoleOutputOperator;
-import com.datatorrent.lib.streamquery.AbstractSqlStreamOperator;
-import com.datatorrent.lib.streamquery.DerbySqlStreamOperator;
 
 /**
  * This demo will output the stock market data from yahoo finance

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/algo/AbstractStreamPatternMatcher.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/algo/AbstractStreamPatternMatcher.java b/library/src/main/java/com/datatorrent/lib/algo/AbstractStreamPatternMatcher.java
deleted file mode 100644
index 252ea2f..0000000
--- a/library/src/main/java/com/datatorrent/lib/algo/AbstractStreamPatternMatcher.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-import java.util.Iterator;
-import java.util.List;
-
-import javax.validation.constraints.NotNull;
-
-import org.apache.commons.lang3.mutable.MutableInt;
-
-import com.google.common.collect.Lists;
-
-import com.datatorrent.api.Context;
-import com.datatorrent.api.DefaultInputPort;
-import com.datatorrent.api.annotation.OperatorAnnotation;
-import com.datatorrent.common.util.BaseOperator;
-
-/**
- * <p>
- * This operator searches for a given pattern in the input stream.<br>
- * For e.g. If the pattern is defined as \u201caa\u201d and your input events arrive in following manner \u201ca\u201d, \u201ca\u201d, \u201ca\u201d, then this operator
- * will emit 2 matches for the given pattern. One matching event 1 and 2 and other matching 2 and 3.
- * </p>
- *
- * <br>
- * <b> StateFull : Yes, </b> Pattern is found over application window(s). <br>
- * <b> Partitionable : No, </b> will yield wrong result. <br>
- *
- * <br>
- * <b>Ports</b>:<br>
- * <b>inputPort</b>: the port to receive input<br>
- *
- * <br>
- * <b>Properties</b>:<br>
- * <b>pattern</b>: The pattern that needs to be searched<br>
- *
- * @param <T> event type
- *
- * @since 2.0.0
- */
-
-@OperatorAnnotation(partitionable = false)
-public abstract class AbstractStreamPatternMatcher<T> extends BaseOperator
-{
-  /**
-   * The pattern to be searched in the input stream of events
-   */
-  @NotNull
-  private Pattern<T> pattern;
-
-  // this stores the index of the partial matches found so far
-  private List<MutableInt> partialMatches = Lists.newLinkedList();
-  private transient MutableInt patternLength;
-
-  /**
-   * Set the pattern that needs to be searched in the input stream of events
-   *
-   * @param pattern The pattern to be searched
-   */
-  public void setPattern(Pattern<T> pattern)
-  {
-    this.pattern = pattern;
-    partialMatches.clear();
-    patternLength = new MutableInt(pattern.getStates().length - 1);
-  }
-
-  @Override
-  public void setup(Context.OperatorContext context)
-  {
-    super.setup(context);
-    patternLength = new MutableInt(pattern.getStates().length - 1);
-  }
-
-  /**
-   * Get the pattern that is searched in the input stream of events
-   *
-   * @return Returns the pattern searched
-   */
-  public Pattern<T> getPattern()
-  {
-    return pattern;
-  }
-
-  public transient DefaultInputPort<T> inputPort = new DefaultInputPort<T>()
-  {
-    @Override
-    public void process(T t)
-    {
-      if (pattern.checkState(t, 0)) {
-        partialMatches.add(new MutableInt(-1));
-      }
-      if (partialMatches.size() > 0) {
-        MutableInt tempInt;
-        Iterator<MutableInt> itr = partialMatches.iterator();
-        while (itr.hasNext()) {
-          tempInt = itr.next();
-          tempInt.increment();
-          if (!pattern.checkState(t, tempInt.intValue())) {
-            itr.remove();
-          } else if (tempInt.equals(patternLength)) {
-            itr.remove();
-            processPatternFound();
-          }
-        }
-      }
-    }
-  };
-
-  /**
-   * This function determines how to process the pattern found
-   */
-  public abstract void processPatternFound();
-
-  public static class Pattern<T>
-  {
-    /**
-     * The states of the pattern
-     */
-    @NotNull
-    private final T[] states;
-
-    //for kryo
-    private Pattern()
-    {
-      states = null;
-    }
-
-    public Pattern(@NotNull T[] states)
-    {
-      this.states = states;
-    }
-
-    /**
-     * Checks if the input state matches the state at index "index" of the pattern
-     *
-     * @param t     The input state
-     * @param index The index to match in the pattern
-     * @return True if the state exists at index "index" else false
-     */
-    public boolean checkState(T t, int index)
-    {
-      return states[index].equals(t);
-    }
-
-    /**
-     * Get the states of the pattern
-     *
-     * @return The states of the pattern
-     */
-    public T[] getStates()
-    {
-      return states;
-    }
-
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/algo/AllAfterMatchMap.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/algo/AllAfterMatchMap.java b/library/src/main/java/com/datatorrent/lib/algo/AllAfterMatchMap.java
deleted file mode 100644
index 82d2201..0000000
--- a/library/src/main/java/com/datatorrent/lib/algo/AllAfterMatchMap.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import com.datatorrent.api.DefaultInputPort;
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.api.annotation.OperatorAnnotation;
-
-import com.datatorrent.lib.util.BaseMatchOperator;
-
-/**
- * This operator takes Maps, whose values are numbers, as input tuples.&nbsp;
- * It then performs a numeric comparison on the values corresponding to one of the keys in the input tuple maps.&nbsp;
- * All tuples processed by the operator before the first successful comparison are not output by the operator,
- * all tuples processed by the operator after and including a successful comparison are output by the operator.
- *
- * <p>
- * A compare metric is done on input tuple based on the property "key",
- * "value", and "cmp" type. All tuples are emitted (inclusive) once a match is made.
- * The comparison is done by getting double value from the Number.
- * This module is a pass through<br>
- * <br>
- * <b> StateFull : Yes, </b> Count is aggregated over application window(s). <br>
- * <b> Partitions : No, </b> will yield wrong result. <br>
- * <br>
- * <br>
- * <b>Ports</b>:<br>
- * <b>data</b>: expects Map&lt;K,V extends Number&gt;<br>
- * <b>allafter</b>: emits Map&lt;K,V extends Number&gt; if compare function
- * returns true<br>
- * <br>
- * <b>Properties</b>:<br>
- * <b>key</b>: The key on which compare is done<br>
- * <b>value</b>: The value to compare with<br>
- * <b>cmp</b>: The compare function. Supported values are "lte", "lt", "eq",
- * "neq", "gt", "gte". Default is "eq"<br>
- * <br>
- * <b>Specific compile time checks</b>:<br>
- * Key must be non empty<br>
- * Value must be able to convert to a "double"<br>
- * Compare string, if specified, must be one of "lte", "lt", "eq", "neq", "gt",
- * "gte"<br>
- * <b>Specific run time checks</b>: None<br>
- * <br>
- * </p>
- *
- * @displayName Emit All After Match (Number)
- * @category Rules and Alerts
- * @tags filter, compare, numeric, key value
- *
- * @since 0.3.2
- */
-@OperatorAnnotation(partitionable = false)
-public class AllAfterMatchMap<K, V extends Number> extends
-    BaseMatchOperator<K, V>
-{
-  /**
-   * The input port on which tuples are received.
-   */
-  public final transient DefaultInputPort<Map<K, V>> data = new DefaultInputPort<Map<K, V>>()
-  {
-    /**
-     * Process HashMap<K,V> and emit all tuples at and after match
-     */
-    @Override
-    public void process(Map<K, V> tuple)
-    {
-      if (doemit) {
-        allafter.emit(cloneTuple(tuple));
-        return;
-      }
-      V v = tuple.get(getKey());
-      if (v == null) { // error tuple
-        return;
-      }
-      if (compareValue(v.doubleValue())) {
-        doemit = true;
-        allafter.emit(cloneTuple(tuple));
-      }
-    }
-  };
-
-  /**
-   * The output port on which all tuples after a match are emitted.
-   */
-  public final transient DefaultOutputPort<HashMap<K, V>> allafter = new DefaultOutputPort<HashMap<K, V>>();
-  boolean doemit = false;
-
-  /**
-   * Resets the matched variable
-   *
-   * @param windowId
-   */
-  @Override
-  public void beginWindow(long windowId)
-  {
-    doemit = false;
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/algo/CompareExceptCountMap.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/algo/CompareExceptCountMap.java b/library/src/main/java/com/datatorrent/lib/algo/CompareExceptCountMap.java
index ba5e5a1..1989f24 100644
--- a/library/src/main/java/com/datatorrent/lib/algo/CompareExceptCountMap.java
+++ b/library/src/main/java/com/datatorrent/lib/algo/CompareExceptCountMap.java
@@ -61,8 +61,9 @@ import com.datatorrent.lib.util.UnifierSumNumber;
  * @tags count, key value
  *
  * @since 0.3.2
+ * @deprecated
  */
-
+@Deprecated
 @OperatorAnnotation(partitionable = true)
 public class CompareExceptCountMap<K, V extends Number> extends MatchMap<K, V>
 {

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/algo/Distinct.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/algo/Distinct.java b/library/src/main/java/com/datatorrent/lib/algo/Distinct.java
index c694bd2..ce29c50 100644
--- a/library/src/main/java/com/datatorrent/lib/algo/Distinct.java
+++ b/library/src/main/java/com/datatorrent/lib/algo/Distinct.java
@@ -76,10 +76,7 @@ public class Distinct<K> extends BaseKeyOperator<K> implements Unifier<K>
     @Override
     public void process(K tuple)
     {
-      if (!map.containsKey(tuple)) {
-        distinct.emit(cloneKey(tuple));
-        map.put(cloneKey(tuple), null);
-      }
+      Distinct.this.process(tuple);
     }
   };
 

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/algo/DistinctMap.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/algo/DistinctMap.java b/library/src/main/java/com/datatorrent/lib/algo/DistinctMap.java
deleted file mode 100644
index e3d658b..0000000
--- a/library/src/main/java/com/datatorrent/lib/algo/DistinctMap.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import com.datatorrent.api.DefaultInputPort;
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.api.annotation.OperatorAnnotation;
-
-import com.datatorrent.lib.util.BaseKeyValueOperator;
-import com.datatorrent.lib.util.UnifierHashMap;
-
-/**
- * This operator computes and emits distinct key,val pairs (i.e drops duplicates).
- * <p>
- * Computes and emits distinct key,val pairs (i.e drops duplicates)
- * </p>
- * <p>
- * This is a pass through operator<br>
- * <br>
- * This module is same as a "FirstOf" metric on any key,val pair. At end of window all data is flushed.<br>
- * <br>
- * <b>StateFull : Yes, </b> tuple are compare across application window(s). <br>
- * <b>Partitions : Yes, </b> distinct output is unified by unifier hash map operator. <br>
- * <br>
- * <b>Ports</b>:<br>
- * <b>data</b>: Input data port expects Map&lt;K,V&gt;<br>
- * <b>distinct</b>: Output data port, emits HashMap&lt;K,V&gt;(1)<br>
- * <br>
- * </p>
- *
- * @displayName Distinct Key Value Merge
- * @category Stream Manipulators
- * @tags filter, unique, key value
- *
- * @since 0.3.2
- */
-
-@OperatorAnnotation(partitionable = true)
-public class DistinctMap<K, V> extends BaseKeyValueOperator<K, V>
-{
-  /**
-   * The input port on which key value pairs are received.
-   */
-  public final transient DefaultInputPort<Map<K, V>> data = new DefaultInputPort<Map<K, V>>()
-  {
-    /**
-     * Process HashMap<K,V> tuple on input port data, and emits if match not found. Updates the cache
-     * with new key,val pair
-     */
-    @Override
-    public void process(Map<K, V> tuple)
-    {
-      for (Map.Entry<K, V> e: tuple.entrySet()) {
-        HashMap<V, Object> vals = mapkeyval.get(e.getKey());
-        if ((vals == null) || !vals.containsKey(e.getValue())) {
-          HashMap<K, V> otuple = new HashMap<K, V>(1);
-          otuple.put(cloneKey(e.getKey()), cloneValue(e.getValue()));
-          distinct.emit(otuple);
-          if (vals == null) {
-            vals = new HashMap<V, Object>();
-            mapkeyval.put(cloneKey(e.getKey()), vals);
-          }
-          vals.put(cloneValue(e.getValue()), null);
-        }
-      }
-    }
-  };
-
-  /**
-   * The output port on which distinct key value pairs are emitted.
-   */
-  public final transient DefaultOutputPort<HashMap<K, V>> distinct = new DefaultOutputPort<HashMap<K, V>>()
-  {
-    @Override
-    public Unifier<HashMap<K, V>> getUnifier()
-    {
-      return new UnifierHashMap<K, V>();
-    }
-  };
-
-
-  protected HashMap<K, HashMap<V, Object>> mapkeyval = new HashMap<K, HashMap<V, Object>>();
-
-  /**
-   * Clears the cache/hash
-   */
-  @Override
-  public void endWindow()
-  {
-    mapkeyval.clear();
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/algo/FilterKeyVals.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/algo/FilterKeyVals.java b/library/src/main/java/com/datatorrent/lib/algo/FilterKeyVals.java
deleted file mode 100644
index 41259a7..0000000
--- a/library/src/main/java/com/datatorrent/lib/algo/FilterKeyVals.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.validation.constraints.NotNull;
-
-import com.datatorrent.api.DefaultInputPort;
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.api.annotation.OperatorAnnotation;
-import com.datatorrent.api.annotation.Stateless;
-
-import com.datatorrent.lib.util.BaseKeyOperator;
-
-/**
- * This operator filters the incoming stream of tuples using a set of specified key value pairs.&nbsp;
- * Tuples that match the filter are emitted by the operator.
- * <p>
- * Filters the incoming stream based of specified key,val pairs, and emits those that match the filter. If
- * property "inverse" is set to "true", then all key,val pairs except those specified by in keyvals parameter are emitted
- * </p>
- * <p>
- * Operator assumes that the key, val pairs are immutable objects. If this operator has to be used for mutable objects,
- * override "cloneKey()" to make copy of K, and "cloneValue()" to make copy of V.<br>
- * This is a pass through node<br>
- * <br>
- * <b>StateFull : No, </b> tuple are processed in current window. <br>
- * <b>Partitions : Yes, </b> no dependency among input tuples. <br>
- * <br>
- * <b>Ports</b>:<br>
- * <b>data</b>: expects HashMap&lt;K,V&gt;<br>
- * <b>filter</b>: emits HashMap&lt;K,V&gt;(1)<br>
- * <br>
- * <b>Properties</b>:<br>
- * <b>keyvals</b>: The keyvals is key,val pairs to pass through, rest are filtered/dropped.<br>
- * <br>
- * </p>
- *
- * @displayName Filter Keyval Pairs
- * @category Rules and Alerts
- * @tags filter, key value
- *
- * @since 0.3.2
- */
-@Stateless
-@OperatorAnnotation(partitionable = true)
-public class FilterKeyVals<K,V> extends BaseKeyOperator<K>
-{
-  /**
-   * The input port on which key value pairs are received.
-   */
-  public final transient DefaultInputPort<HashMap<K, V>> data = new DefaultInputPort<HashMap<K, V>>()
-  {
-    /**
-     * Processes incoming tuples one key,val at a time. Emits if at least one key makes the cut
-     * By setting inverse as true, match is changed to un-matched
-     */
-    @Override
-    public void process(HashMap<K, V> tuple)
-    {
-      for (Map.Entry<K, V> e: tuple.entrySet()) {
-        entry.clear();
-        entry.put(e.getKey(),e.getValue());
-        boolean contains = keyvals.containsKey(entry);
-        if ((contains && !inverse) || (!contains && inverse)) {
-          HashMap<K, V> dtuple = new HashMap<K,V>(1);
-          dtuple.put(cloneKey(e.getKey()), cloneValue(e.getValue()));
-          filter.emit(dtuple);
-        }
-      }
-    }
-  };
-
-  /**
-   * The output port on which filtered key value pairs are emitted.
-   */
-  public final transient DefaultOutputPort<HashMap<K, V>> filter = new DefaultOutputPort<HashMap<K, V>>();
-
-  @NotNull()
-  HashMap<HashMap<K,V>,Object> keyvals = new HashMap<HashMap<K,V>,Object>();
-  boolean inverse = false;
-  private transient HashMap<K,V> entry = new HashMap<K,V>(1);
-
-  /**
-   * Gets the inverse property.
-   * @return inverse
-   */
-  public boolean getInverse()
-  {
-    return inverse;
-  }
-
-  /**
-   * If true then only matches are emitted. If false then only non matches are emitted.
-   * @param val
-   */
-  public void setInverse(boolean val)
-  {
-    inverse = val;
-  }
-
-  /**
-   * True means match; False means unmatched
-   * @return keyvals hash
-   */
-  @NotNull()
-  public HashMap<HashMap<K,V>,Object> getKeyVals()
-  {
-    return keyvals;
-  }
-
-  /**
-   * Adds a key to the filter list
-   * @param map with key,val pairs to set as filters
-   */
-  @SuppressWarnings({ "unchecked", "rawtypes" })
-  public void setKeyVals(HashMap<K,V> map)
-  {
-    for (Map.Entry<K, V> e: map.entrySet()) {
-      HashMap kvpair = new HashMap<K,V>(1);
-      kvpair.put(cloneKey(e.getKey()), cloneValue(e.getValue()));
-      keyvals.put(kvpair, null);
-    }
-  }
-
-  /*
-   * Clears the filter list
-   */
-  public void clearKeys()
-  {
-    keyvals.clear();
-  }
-
-  /**
-   * Clones V object. By default assumes immutable object (i.e. a copy is not made). If object is mutable, override this method
-   * @param v value to be cloned
-   * @return returns v as is (assumes immutable object)
-   */
-  public V cloneValue(V v)
-  {
-    return v;
-  }
-}


[09/12] apex-malhar git commit: Updated algo & working on math operators

Posted by th...@apache.org.
http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/function/CountFunction.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/function/CountFunction.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/function/CountFunction.java
new file mode 100644
index 0000000..ac83885
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/function/CountFunction.java
@@ -0,0 +1,87 @@
+/**
+ * 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.contrib.misc.streamquery.function;
+
+import java.util.ArrayList;
+import java.util.Map;
+
+import javax.validation.constraints.NotNull;
+
+import org.apache.commons.lang.StringUtils;
+
+/**
+ * An implementation of function index that implements sql count function semantic. <br>
+ * <p>
+ * Counts number of values of given column and returns count of non null values in column.
+ *   e.g : sql => SELECT COUNT(column_name) FROM table_name. <br>
+ *   <br>
+ *   <b> Properties : </b> <br>
+ *   <b> column : </b> column name for values count.   <br>
+ *   <b> alias  : </b> Alias name for aggregate output. <br>
+ * @displayName Count Function
+ * @category Stream Manipulators
+ * @tags sql count
+ * @since 0.3.4
+ * @deprecated
+ */
+@Deprecated
+public class CountFunction extends FunctionIndex
+{
+  /**
+   * @param column column for values count, must be non null.
+   * @param alias  Alias name for aggregate output.
+   */
+  public CountFunction(@NotNull String column, String alias)
+  {
+    super(column, alias);
+  }
+
+  /**
+   * Count number of values of given column.
+   * @return Count of non null values in column.
+   */
+  @Override
+  public Object compute(ArrayList<Map<String, Object>> rows) throws Exception
+  {
+    if (column.equals("*")) {
+      return rows.size();
+    }
+    long count = 0;
+    for (Map<String, Object> row : rows) {
+      if (row.containsKey(column) && (row.get(column) != null)) {
+        count++;
+      }
+    }
+    return count;
+  }
+
+  /**
+   * Aggregate output name.
+   * @return name string.
+   */
+  @Override
+  protected String aggregateName()
+  {
+    if (!StringUtils.isEmpty(alias)) {
+      return alias;
+    }
+    return "COUNT(" + column + ")";
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/function/FirstLastFunction.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/function/FirstLastFunction.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/function/FirstLastFunction.java
new file mode 100644
index 0000000..296e449
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/function/FirstLastFunction.java
@@ -0,0 +1,113 @@
+/**
+ * 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.contrib.misc.streamquery.function;
+
+import java.util.ArrayList;
+import java.util.Map;
+
+import javax.validation.constraints.NotNull;
+
+import org.apache.commons.lang.StringUtils;
+
+/**
+ * An implementation of function index that implements sql first,last function semantic. <br>
+ * <p>
+ *   e.g : sql => SELECT FIRST/LAST(column_name) FROM table_name. <br>
+ *   <br>
+ *   <b> Properties : </b> <br>
+ *   <b> column : </b> column name for first/last value.   <br>
+ *   <b> alias  : </b> Alias name for output. <br>
+ *   <b> isFirst : </b> return first value if true.
+ * @displayName First Last Function
+ * @category Stream Manipulators
+ * @tags sql first, sql last
+ * @since 0.3.4
+ * @deprecated
+ */
+@Deprecated
+public class FirstLastFunction extends FunctionIndex
+{
+  /**
+   * return first value if true.
+   */
+  private boolean isFirst;
+
+  /**
+   * @param column  column name for first/last value.
+   * @param  alias   Alias name for output.
+   * @param  isFirst return first value if true.
+   */
+  public FirstLastFunction(@NotNull String column, String alias, boolean isLast)
+  {
+    super(column, alias);
+    isFirst = !isLast;
+  }
+
+  /**
+   * Get first/last non null value for column.
+   */
+  @Override
+  public Object compute(@NotNull ArrayList<Map<String, Object>> rows) throws Exception
+  {
+    if (rows.size() == 0) {
+      return null;
+    }
+    if (isFirst) {
+      for (int i = 0; i < rows.size(); i++) {
+        if (rows.get(i).get(column) != null) {
+          return rows.get(i).get(column);
+        }
+      }
+    } else {
+      for (int i = (rows.size() - 1); i >= 0; i--) {
+        if (rows.get(i).get(column) != null) {
+          return rows.get(i).get(column);
+        }
+      }
+    }
+    return null;
+  }
+
+  /**
+   * Aggregate output name.
+   * @return name string.
+   */
+  @Override
+  protected String aggregateName()
+  {
+    if (!StringUtils.isEmpty(alias)) {
+      return alias;
+    }
+    if (isFirst) {
+      return "FIRST(" + column + ")";
+    }
+    return "LAST(" + column + ")";
+  }
+
+  public boolean isFirst()
+  {
+    return isFirst;
+  }
+
+  public void setFirst(boolean isFirst)
+  {
+    this.isFirst = isFirst;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/function/FunctionIndex.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/function/FunctionIndex.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/function/FunctionIndex.java
new file mode 100644
index 0000000..d307ad2
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/function/FunctionIndex.java
@@ -0,0 +1,95 @@
+/**
+ * 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.contrib.misc.streamquery.function;
+
+import java.util.ArrayList;
+import java.util.Map;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * A base class for select aggregate function implementation.&nbsp; Subclasses should provide the
+   implementation for aggregate compute functions.
+ * <p>
+ * <br>
+ * <b>Properties : </b> <br>
+ * <b>column : </b> Column name for aggregation.
+ * <b>alias : </b> Output value alias name.
+ * @displayName Function Index
+ * @category Stream Manipulators
+ * @tags sql aggregate
+ * @since 0.3.4
+ * @deprecated
+ */
+@Deprecated
+public abstract class FunctionIndex
+{
+  /**
+   * Column name.
+   */
+  @NotNull
+  protected String column;
+
+  /**
+   * Alias name.
+   */
+  protected String alias;
+
+  /**
+   * @param column Column name for aggregation.
+   * @param alias Output value alias name.
+   */
+  public FunctionIndex(@NotNull String column, String alias)
+  {
+    this.column = column;
+    this.alias = alias;
+  }
+
+  /**
+   * Aggregate compute function, implementation in sub class.
+   * @param rows Tuple list over application window.
+   * @return aggregate result object.
+   */
+  public abstract Object compute(@NotNull ArrayList<Map<String, Object>> rows) throws Exception;
+
+  /**
+   * Get aggregate output value name.
+   * @return name string.
+   */
+  protected abstract String aggregateName();
+
+  /**
+   * Apply compute function to given rows and store result in collect by output value name.
+   * @param  rows Tuple list over application window.
+   */
+  public void filter(ArrayList<Map<String, Object>> rows, Map<String, Object> collect) throws Exception
+  {
+    if (rows == null) {
+      return;
+    }
+    String name = column;
+    if (alias != null) {
+      name = alias;
+    }
+    if (name == null) {
+      name = aggregateName();
+    }
+    collect.put(name, compute(rows));
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/function/MaxMinFunction.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/function/MaxMinFunction.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/function/MaxMinFunction.java
new file mode 100644
index 0000000..a602614
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/function/MaxMinFunction.java
@@ -0,0 +1,105 @@
+/**
+ * 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.contrib.misc.streamquery.function;
+
+import java.util.ArrayList;
+import java.util.Map;
+
+import javax.validation.constraints.NotNull;
+
+import org.apache.commons.lang.StringUtils;
+
+/**
+ * An implementation of function index that implements sql max and sql min function semantic. <br>
+ * <p>
+ *   e.g : sql => SELECT MAX/MIN(column_name) FROM table_name. <br>
+ *   <br>
+ *   <b> Properties : </b> <br>
+ *   <b> column : </b> column name for values max/min computation.   <br>
+ *   <b> alias  : </b> Alias name for  output value. <br>
+ *   <b> isMax : </b> Flag to indicate max/min compute value. <br>
+ * @displayName Max Min Function
+ * @category Stream Manipulators
+ * @tags sql max, sql min
+ * @since 0.3.4
+ * @deprecated
+ */
+@Deprecated
+public class MaxMinFunction extends FunctionIndex
+{
+  /**
+   * Flag to indicate max/min compute value, compute max if true.
+   */
+  private boolean isMax = true;
+
+  /**
+   * @param column column name for values max/min computation.   <br>
+   * @param alias  Alias name for output. <br>
+   * @param isMax  Flag to indicate max/min compute value. <br>
+   */
+  public MaxMinFunction(@NotNull String column, String alias, boolean isMin)
+  {
+    super(column, alias);
+    isMax = !isMin;
+  }
+
+  /**
+   * Compute max/min for given column.
+   * @return max/min value.
+   */
+  @Override
+  public Object compute(ArrayList<Map<String, Object>> rows) throws Exception
+  {
+    double minMax = 0.0;
+    for (Map<String, Object> row : rows) {
+      double value = ((Number)row.get(column)).doubleValue();
+      if ((isMax && (minMax < value)) || (!isMax && (minMax > value))) {
+        minMax = value;
+      }
+    }
+    return minMax;
+  }
+
+  /**
+   * Aggregate output name.
+   * @return name string.
+   */
+  @Override
+  protected String aggregateName()
+  {
+    if (!StringUtils.isEmpty(alias)) {
+      return alias;
+    }
+    if (isMax) {
+      return "MAX(" + column + ")";
+    }
+    return "MIN(" + column + ")";
+  }
+
+  public boolean isMax()
+  {
+    return isMax;
+  }
+
+  public void setMax(boolean isMax)
+  {
+    this.isMax = isMax;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/function/SumFunction.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/function/SumFunction.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/function/SumFunction.java
new file mode 100644
index 0000000..ef4fb4b
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/function/SumFunction.java
@@ -0,0 +1,64 @@
+/**
+ * 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.contrib.misc.streamquery.function;
+
+import java.util.ArrayList;
+import java.util.Map;
+
+import javax.validation.constraints.NotNull;
+
+
+
+/**
+ * <p> An implementation of sql sum function. </p>
+ * <p>
+ * @displayName Sum Function
+ * @category Stream Manipulators
+ * @tags sql sum, aggregate
+ * @since 0.3.4
+ * @deprecated
+ */
+@Deprecated
+public class SumFunction extends FunctionIndex
+{
+  public SumFunction(String column, String alias) throws Exception
+  {
+    super(column, alias);
+  }
+
+  @Override
+  public Object compute(@NotNull ArrayList<Map<String, Object>> rows) throws Exception
+  {
+    Double result = 0.0;
+    for (Map<String, Object> row : rows) {
+      if (!row.containsKey(column)) {
+        continue;
+      }
+      result += ((Number)row.get(column)).doubleValue();
+    }
+    return result;
+  }
+
+  @Override
+  protected String aggregateName()
+  {
+    return "Sum(" + column;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/index/BinaryExpression.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/index/BinaryExpression.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/index/BinaryExpression.java
new file mode 100644
index 0000000..4de58c1
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/index/BinaryExpression.java
@@ -0,0 +1,75 @@
+/**
+ * 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.contrib.misc.streamquery.index;
+
+import javax.validation.constraints.NotNull;
+
+import com.datatorrent.lib.streamquery.index.Index;
+
+/**
+ * Abstract class to filter row by binary expression index.
+ * <p>
+ * Sub class will implement filter/getExpressionName functions.
+ * @displayName Binary Expression
+ * @category Stream Manipulators
+ * @tags alias
+ * @since 0.3.4
+ * @deprecated
+ */
+@Deprecated
+public abstract class BinaryExpression  implements Index
+{
+  /**
+   * Left column name argument for expression.
+   */
+  @NotNull
+  protected String left;
+
+  /**
+   * Right column name argument for expression.
+   */
+  @NotNull
+  protected String right;
+
+  /**
+   *  Alias name for output field.
+   */
+  protected String alias;
+
+  /**
+   * @param left column name argument for expression.
+   * @param right column name argument for expression.
+   * @param alias name for output field.
+   */
+  public BinaryExpression(@NotNull String left, @NotNull String right, String alias)
+  {
+    this.left = left;
+    this.right = right;
+  }
+
+  public String getAlias()
+  {
+    return alias;
+  }
+
+  public void setAlias(String alias)
+  {
+    this.alias = alias;
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/index/MidIndex.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/index/MidIndex.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/index/MidIndex.java
new file mode 100644
index 0000000..c165d89
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/index/MidIndex.java
@@ -0,0 +1,82 @@
+/**
+ * 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.contrib.misc.streamquery.index;
+
+import java.util.Map;
+
+import javax.validation.constraints.NotNull;
+
+import com.datatorrent.lib.streamquery.index.ColumnIndex;
+
+/**
+ * <p>An implementation of Column Index that implements filter method based on mid index. </p>
+ * <p>
+ * @displayName Mid Index
+ * @category Stream Manipulators
+ * @tags index
+ * @since 0.3.4
+ * @deprecated
+ */
+@Deprecated
+public class MidIndex extends ColumnIndex
+{
+  private int start;
+  private int length = 0;
+
+  public MidIndex(@NotNull String column, String alias, int start)
+  {
+    super(column, alias);
+    assert (start >= 0);
+    this.start = start;
+  }
+
+  @Override
+  public void filter(@NotNull  Map<String, Object> row, @NotNull  Map<String, Object> collect)
+  {
+    if (!row.containsKey(column)) {
+      return;
+    }
+    if (!(row.get(column) instanceof String)) {
+      assert (false);
+    }
+    String name = getColumn();
+    if (alias != null) {
+      name = alias;
+    }
+
+    int endIndex = start + length;
+    if ((length == 0) || (endIndex > ((String)row.get(column)).length())) {
+      collect.put(name, row.get(column));
+    } else {
+      collect.put(name, ((String)row.get(column)).substring(start, endIndex));
+    }
+  }
+
+  public int getLength()
+  {
+    return length;
+  }
+
+  public void setLength(int length)
+  {
+    assert (length > 0);
+    this.length = length;
+  }
+}
+

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/index/NegateExpression.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/index/NegateExpression.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/index/NegateExpression.java
new file mode 100644
index 0000000..0a6f64d
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/index/NegateExpression.java
@@ -0,0 +1,61 @@
+/**
+ * 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.contrib.misc.streamquery.index;
+
+import java.util.Map;
+
+import javax.validation.constraints.Null;
+
+
+/**
+ * An implementation of Unary Expression that implements filter method using negate metric sql semantic on column value.
+ * <p>
+ * @displayName Negate Expression
+ * @category Stream Manipulators
+ * @tags expression, alias
+ * @since 0.3.4
+ * @deprecated
+ */
+@Deprecated
+public class NegateExpression extends UnaryExpression
+{
+
+  /**
+   * @param column   Name of column value to be negated.
+   */
+  public NegateExpression(@Null String column, String alias)
+  {
+    super(column, alias);
+    if (this.alias == null) {
+      this.alias = "NEGATE(" + column + ")";
+    }
+  }
+
+  /* (non-Javadoc)
+   * @see com.datatorrent.lib.streamquery.index.Index#filter(java.util.Map, java.util.Map)
+   */
+  @Override
+  public void filter(Map<String, Object> row, Map<String, Object> collect)
+  {
+    if (!row.containsKey(column)) {
+      return;
+    }
+    collect.put(alias, -((Number)row.get(column)).doubleValue());
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/index/RoundDoubleIndex.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/index/RoundDoubleIndex.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/index/RoundDoubleIndex.java
new file mode 100644
index 0000000..495063f
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/index/RoundDoubleIndex.java
@@ -0,0 +1,64 @@
+/**
+ * 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.contrib.misc.streamquery.index;
+
+import java.util.Map;
+
+import javax.validation.constraints.NotNull;
+
+import com.datatorrent.lib.streamquery.index.ColumnIndex;
+
+/**
+ * <p>An implementation of column index that implements filter method using Round Double Index. </p>
+ *
+ * @displayName Round Double Index
+ * @category Stream Manipulators
+ * @tags alias, maths
+ * @since 0.3.4
+ * @deprecated
+ */
+@Deprecated
+public class RoundDoubleIndex  extends ColumnIndex
+{
+  private int rounder;
+  public RoundDoubleIndex(@NotNull String column, String alias, int numDecimals)
+  {
+    super(column, alias);
+    rounder = 1;
+    if (numDecimals > 0) {
+      rounder = (int)Math.pow(10, numDecimals);
+    }
+  }
+
+  @Override
+  public void filter(@NotNull  Map<String, Object> row, @NotNull  Map<String, Object> collect)
+  {
+    if (!row.containsKey(column)) {
+      return;
+    }
+    double value = (Double)row.get(column);
+    value = Math.round(value * rounder) / rounder;
+    String name = getColumn();
+    if (alias != null) {
+      name = alias;
+    }
+    collect.put(name, value);
+  }
+}
+

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/index/StringCaseIndex.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/index/StringCaseIndex.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/index/StringCaseIndex.java
new file mode 100644
index 0000000..31c9468
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/index/StringCaseIndex.java
@@ -0,0 +1,66 @@
+/**
+ * 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.contrib.misc.streamquery.index;
+
+import java.util.Map;
+
+import javax.validation.constraints.NotNull;
+
+import com.datatorrent.lib.streamquery.index.ColumnIndex;
+
+/**
+ * <p>An implementation of Column Index that implements filter method using case of a string index. </p>
+ *
+ * @displayName String Case Index
+ * @category Stream Manipulators
+ * @tags alias
+ * @since 0.3.4
+ * @deprecated
+ */
+@Deprecated
+public class StringCaseIndex extends ColumnIndex
+{
+  private boolean toUpperCase = true;
+  public StringCaseIndex(@NotNull String column, String alias, boolean toLowerCase)
+  {
+    super(column, alias);
+    toUpperCase = !toLowerCase;
+  }
+
+  @Override
+  public void filter(@NotNull  Map<String, Object> row, @NotNull  Map<String, Object> collect)
+  {
+    if (!row.containsKey(column)) {
+      return;
+    }
+    if (!(row.get(column) instanceof String)) {
+      assert (false);
+    }
+
+    String name = getColumn();
+    if (alias != null) {
+      name = alias;
+    }
+    if (toUpperCase) {
+      collect.put(name, ((String)row.get(column)).toUpperCase());
+    } else {
+      collect.put(name, ((String)row.get(column)).toLowerCase());
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/index/StringLenIndex.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/index/StringLenIndex.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/index/StringLenIndex.java
new file mode 100644
index 0000000..f764c9e
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/index/StringLenIndex.java
@@ -0,0 +1,60 @@
+/**
+ * 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.contrib.misc.streamquery.index;
+
+import java.util.Map;
+
+import javax.validation.constraints.NotNull;
+
+import com.datatorrent.lib.streamquery.index.ColumnIndex;
+
+/**
+ * <p>An implementation of Column Index that implements filter method using length of a string Index. </p>
+ * <p>
+ * @displayName String Length Index
+ * @category Stream Manipulators
+ * @tags alias
+ * @since 0.3.4
+ * @deprecated
+ */
+@Deprecated
+public class StringLenIndex  extends ColumnIndex
+{
+  public StringLenIndex(@NotNull String column, String alias)
+  {
+    super(column, alias);
+  }
+
+  @Override
+  public void filter(@NotNull  Map<String, Object> row, @NotNull  Map<String, Object> collect)
+  {
+    if (!row.containsKey(column)) {
+      return;
+    }
+    if (!(row.get(column) instanceof String)) {
+      assert (false);
+    }
+
+    String name = getColumn();
+    if (alias != null) {
+      name = alias;
+    }
+    collect.put(name, ((String)row.get(column)).length());
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/index/SumExpression.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/index/SumExpression.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/index/SumExpression.java
new file mode 100644
index 0000000..91d4ec7
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/index/SumExpression.java
@@ -0,0 +1,65 @@
+/**
+ * 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.contrib.misc.streamquery.index;
+
+import java.util.Map;
+
+import javax.validation.constraints.NotNull;
+
+
+/**
+ * Implements sum on column index.
+ * <p>
+ * Select index class for implementing sum column index.
+ * @displayName Sum Expression
+ * @category Stream Manipulators
+ * @tags sum
+ * @since 0.3.4
+ * @deprecated
+ */
+@Deprecated
+public class SumExpression extends BinaryExpression
+{
+
+  /**
+   * @param left column name argument for expression.
+   * @param right column name argument for expression.
+   * @param alias name for output field.
+   */
+  public SumExpression(@NotNull String left, @NotNull String right, String alias)
+  {
+    super(left, right, alias);
+    if (this.alias == null) {
+      this.alias = "SUM(" + left + "," + right + ")";
+    }
+  }
+
+  /* sum column values.
+   * @see com.datatorrent.lib.streamquery.index.Index#filter(java.util.Map, java.util.Map)
+   */
+  @Override
+  public void filter(Map<String, Object> row, Map<String, Object> collect)
+  {
+    if (!row.containsKey(left) || !row.containsKey(right)) {
+      return;
+    }
+    collect.put(alias, ((Number)row.get(left)).doubleValue() + ((Number)row.get(right)).doubleValue());
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/index/UnaryExpression.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/index/UnaryExpression.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/index/UnaryExpression.java
new file mode 100644
index 0000000..04d5fc6
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/index/UnaryExpression.java
@@ -0,0 +1,78 @@
+/**
+ * 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.contrib.misc.streamquery.index;
+
+import javax.validation.constraints.NotNull;
+
+import com.datatorrent.lib.streamquery.index.Index;
+
+/**
+ * A base implementation of an index that filters row by unary expression.&nbsp; Subclasses should provide the
+   implementation of filter/getExpressionName functions.
+ * <p>
+ * Sub class will implement filter/getExpressionName functions.
+ * @displayName Unary Expression
+ * @category Stream Manipulators
+ * @tags unary, alias
+ * @since 0.3.4
+ * @deprecated
+ */
+@Deprecated
+public abstract class UnaryExpression  implements Index
+{
+  /**
+   * Column name argument for unary expression.
+   */
+  @NotNull
+  protected String column;
+
+  /**
+   *  Alias name for output field.
+   */
+  protected String alias;
+
+  /**
+   * @param column name argument for unary expression.
+   * @param alias name for output field.
+   */
+  public UnaryExpression(@NotNull String column, String alias)
+  {
+    this.column = column;
+  }
+
+  public String getColumn()
+  {
+    return column;
+  }
+
+  public void setColumn(String column)
+  {
+    this.column = column;
+  }
+
+  public String getAlias()
+  {
+    return alias;
+  }
+
+  public void setAlias(String alias)
+  {
+    this.alias = alias;
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/package-info.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/package-info.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/package-info.java
new file mode 100644
index 0000000..358c0bb
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/package-info.java
@@ -0,0 +1,23 @@
+/**
+ * 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.
+ */
+/**
+ * Library of operators for streaming query language.
+ */
+@org.apache.hadoop.classification.InterfaceStability.Evolving
+package org.apache.apex.malhar.lib.misc.streamquery;

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/AbstractStreamPatternMatcherTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/AbstractStreamPatternMatcherTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/AbstractStreamPatternMatcherTest.java
new file mode 100644
index 0000000..1f669bc
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/AbstractStreamPatternMatcherTest.java
@@ -0,0 +1,173 @@
+/**
+ * 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.contrib.misc.algo;
+
+/**
+ *
+ * Functional tests for {@link org.apache.apex.malhar.contrib.misc.algo.AbstractStreamPatternMatcher}<p>
+ * @deprecated
+ */
+
+import java.util.Random;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.lib.testbench.CollectorTestSink;
+
+
+@Deprecated
+public class AbstractStreamPatternMatcherTest
+{
+
+  public static class StreamPatternMatcher<T> extends AbstractStreamPatternMatcher<T>
+  {
+    @Override
+    public void processPatternFound()
+    {
+      outputPort.emit(getPattern().getStates());
+    }
+
+    public transient DefaultOutputPort<T[]> outputPort = new DefaultOutputPort<T[]>();
+  }
+
+  private StreamPatternMatcher<Integer> streamPatternMatcher;
+  private AbstractStreamPatternMatcher.Pattern<Integer> pattern;
+  private Integer[] inputPattern;
+  private CollectorTestSink<Object> sink;
+
+  @Before
+  public void setup()
+  {
+    streamPatternMatcher = new StreamPatternMatcher<Integer>();
+    sink = new CollectorTestSink<Object>();
+    streamPatternMatcher.outputPort.setSink(sink);
+  }
+
+  @After
+  public void cleanup()
+  {
+    streamPatternMatcher.teardown();
+    sink.collectedTuples.clear();
+  }
+
+  @Test
+  public void test() throws Exception
+  {
+    inputPattern = new Integer[]{0, 1, 0, 1, 2};
+    pattern = new AbstractStreamPatternMatcher.Pattern<Integer>(inputPattern);
+    streamPatternMatcher.setPattern(pattern);
+    streamPatternMatcher.setup(null);
+    streamPatternMatcher.beginWindow(0);
+    streamPatternMatcher.inputPort.process(0);
+    streamPatternMatcher.inputPort.process(1);
+    streamPatternMatcher.inputPort.process(1);
+    streamPatternMatcher.inputPort.process(0);
+    streamPatternMatcher.inputPort.process(1);
+    streamPatternMatcher.inputPort.process(0);
+    streamPatternMatcher.inputPort.process(1);
+    streamPatternMatcher.inputPort.process(2);
+    streamPatternMatcher.inputPort.process(1);
+    streamPatternMatcher.endWindow();
+    Assert.assertEquals("The number of tuples emitted is one", 1, sink.collectedTuples.size());
+    Assert.assertEquals("Matching the output pattern with input pattern", inputPattern, sink.collectedTuples.get(0));
+  }
+
+  @Test
+  public void testSimplePattern() throws Exception
+  {
+    inputPattern = new Integer[]{0, 0};
+    pattern = new AbstractStreamPatternMatcher.Pattern<Integer>(inputPattern);
+    streamPatternMatcher.setPattern(pattern);
+    streamPatternMatcher.setup(null);
+    streamPatternMatcher.beginWindow(0);
+    streamPatternMatcher.inputPort.process(0);
+    streamPatternMatcher.inputPort.process(0);
+    streamPatternMatcher.inputPort.process(0);
+    streamPatternMatcher.inputPort.process(1);
+    streamPatternMatcher.inputPort.process(0);
+    streamPatternMatcher.inputPort.process(0);
+    streamPatternMatcher.endWindow();
+    Assert.assertEquals("The number of tuples emitted are three", 3, sink.collectedTuples.size());
+    for (Object object : sink.collectedTuples) {
+      Assert.assertEquals("Matching the output pattern with input pattern", inputPattern, object);
+    }
+  }
+
+  @Test
+  public void testPatternWithSingleState() throws Exception
+  {
+    inputPattern = new Integer[]{0};
+    pattern = new AbstractStreamPatternMatcher.Pattern<Integer>(inputPattern);
+    streamPatternMatcher.setPattern(pattern);
+    streamPatternMatcher.setup(null);
+    streamPatternMatcher.beginWindow(0);
+    streamPatternMatcher.inputPort.process(0);
+    streamPatternMatcher.inputPort.process(0);
+    streamPatternMatcher.inputPort.process(0);
+    streamPatternMatcher.inputPort.process(1);
+    streamPatternMatcher.inputPort.process(0);
+    streamPatternMatcher.inputPort.process(0);
+    streamPatternMatcher.endWindow();
+    Assert.assertEquals("The number of tuples emitted are three", 5, sink.collectedTuples.size());
+    for (Object object : sink.collectedTuples) {
+      Assert.assertEquals("Matching the output pattern with input pattern", inputPattern, object);
+    }
+  }
+
+  @Test
+  public void testAutoGeneratedPattern() throws Exception
+  {
+    Random random = new Random();
+    int patternSize = 15;
+    inputPattern = new Integer[patternSize];
+    int max = 10;
+    int min = 1;
+    int primeNumber = 5;
+    for (int i = 0; i < patternSize; i++) {
+      inputPattern[i] = (min + random.nextInt(max));
+    }
+    pattern = new AbstractStreamPatternMatcher.Pattern<Integer>(inputPattern);
+    streamPatternMatcher.setPattern(pattern);
+    streamPatternMatcher.setup(null);
+    streamPatternMatcher.beginWindow(0);
+    int numberOfIterations = 20;
+    for (int i = 0; i < patternSize; i++) {
+      for (int j = 0; j <= i; j++) {
+        streamPatternMatcher.inputPort.process(inputPattern[j]);
+      }
+      for (int k = 0; k < numberOfIterations; k++) {
+        streamPatternMatcher.inputPort.process(max + min + random.nextInt(max));
+      }
+      if (i % primeNumber == 0) {
+        for (int j = 0; j < patternSize; j++) {
+          streamPatternMatcher.inputPort.process(inputPattern[j]);
+        }
+      }
+    }
+    streamPatternMatcher.endWindow();
+    Assert.assertEquals("The number of tuples emitted ", 1 + patternSize / primeNumber, sink.collectedTuples.size());
+    for (Object output : sink.collectedTuples) {
+      Assert.assertEquals("Matching the output pattern with input pattern", inputPattern, output);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/AllAfterMatchMapTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/AllAfterMatchMapTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/AllAfterMatchMapTest.java
new file mode 100644
index 0000000..1356004
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/AllAfterMatchMapTest.java
@@ -0,0 +1,93 @@
+/**
+ * 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.contrib.misc.algo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.datatorrent.lib.testbench.CollectorTestSink;
+
+/**
+ * @deprecated
+ * Functional tests for {@link AllAfterMatchMapTest}
+ * <p>
+ */
+@Deprecated
+public class AllAfterMatchMapTest
+{
+  /**
+   * Test node logic emits correct results
+   */
+  @Test
+  public void testNodeProcessing() throws Exception
+  {
+    testNodeProcessingSchema(new AllAfterMatchMap<String, Integer>());
+    testNodeProcessingSchema(new AllAfterMatchMap<String, Double>());
+    testNodeProcessingSchema(new AllAfterMatchMap<String, Float>());
+    testNodeProcessingSchema(new AllAfterMatchMap<String, Short>());
+    testNodeProcessingSchema(new AllAfterMatchMap<String, Long>());
+  }
+
+  @SuppressWarnings({ "unchecked", "rawtypes", "unchecked" })
+  public void testNodeProcessingSchema(AllAfterMatchMap oper)
+  {
+    CollectorTestSink allSink = new CollectorTestSink();
+    oper.allafter.setSink(allSink);
+    oper.setKey("a");
+    oper.setValue(3.0);
+    oper.setTypeEQ();
+
+    oper.beginWindow(0);
+    HashMap<String, Number> input = new HashMap<String, Number>();
+    input.put("a", 2);
+    input.put("b", 20);
+    input.put("c", 1000);
+    oper.data.process(input);
+    input.clear();
+    input.put("a", 3);
+    oper.data.process(input);
+
+    input.clear();
+    input.put("b", 6);
+    oper.data.process(input);
+
+    input.clear();
+    input.put("c", 9);
+    oper.data.process(input);
+
+    oper.endWindow();
+
+    Assert.assertEquals("number emitted tuples", 3,
+        allSink.collectedTuples.size());
+    for (Object o : allSink.collectedTuples) {
+      for (Map.Entry<String, Number> e : ((HashMap<String, Number>)o).entrySet()) {
+        if (e.getKey().equals("a")) {
+          Assert.assertEquals("emitted value for 'a' was ", new Double(3), new Double(e.getValue().doubleValue()));
+        } else if (e.getKey().equals("b")) {
+          Assert.assertEquals("emitted tuple for 'b' was ", new Double(6), new Double(e.getValue().doubleValue()));
+        } else if (e.getKey().equals("c")) {
+          Assert.assertEquals("emitted tuple for 'c' was ", new Double(9), new Double(e.getValue().doubleValue()));
+        }
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/DistinctMapTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/DistinctMapTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/DistinctMapTest.java
new file mode 100644
index 0000000..c082f83
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/DistinctMapTest.java
@@ -0,0 +1,111 @@
+/**
+ * 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.contrib.misc.algo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Assert;
+
+import org.junit.Test;
+
+import com.datatorrent.lib.testbench.CollectorTestSink;
+
+/**
+ * @deprecated
+ * Functional tests for {@link DistinctMap}<p>
+ *
+ */
+@Deprecated
+public class DistinctMapTest
+{
+  /**
+   * Test node logic emits correct results
+   */
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  @Test
+  public void testNodeProcessing() throws Exception
+  {
+    DistinctMap<String, Number> oper = new DistinctMap<String, Number>();
+
+    CollectorTestSink sortSink = new CollectorTestSink();
+    oper.distinct.setSink(sortSink);
+
+
+    oper.beginWindow(0);
+    HashMap<String, Number> input = new HashMap<String, Number>();
+
+    input.put("a", 2);
+    oper.data.process(input);
+    input.clear();
+    input.put("a", 2);
+    oper.data.process(input);
+
+    input.clear();
+    input.put("a", 1000);
+    oper.data.process(input);
+
+    input.clear();
+    input.put("a", 5);
+    oper.data.process(input);
+
+    input.clear();
+    input.put("a", 2);
+    input.put("b", 33);
+    oper.data.process(input);
+
+    input.clear();
+    input.put("a", 33);
+    input.put("b", 34);
+    oper.data.process(input);
+
+    input.clear();
+    input.put("b", 34);
+    oper.data.process(input);
+
+    input.clear();
+    input.put("b", 6);
+    input.put("a", 2);
+    oper.data.process(input);
+    input.clear();
+    input.put("c", 9);
+    oper.data.process(input);
+    oper.endWindow();
+
+    Assert.assertEquals("number emitted tuples", 8, sortSink.collectedTuples.size());
+    int aval = 0;
+    int bval = 0;
+    int cval = 0;
+    for (Object o: sortSink.collectedTuples) {
+      for (Map.Entry<String, Integer> e: ((HashMap<String, Integer>)o).entrySet()) {
+        String key = e.getKey();
+        if (key.equals("a")) {
+          aval += e.getValue();
+        } else if (key.equals("b")) {
+          bval += e.getValue();
+        } else if (key.equals("c")) {
+          cval += e.getValue();
+        }
+      }
+    }
+    Assert.assertEquals("Total for key \"a\" ", 1040, aval);
+    Assert.assertEquals("Total for key \"a\" ", 73, bval);
+    Assert.assertEquals("Total for key \"a\" ", 9, cval);
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/FilterKeyValsTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/FilterKeyValsTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/FilterKeyValsTest.java
new file mode 100644
index 0000000..be2f6ee
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/FilterKeyValsTest.java
@@ -0,0 +1,127 @@
+/**
+ * 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.contrib.misc.algo;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.datatorrent.lib.testbench.CollectorTestSink;
+
+/**
+ * @deprecated
+ * Functional tests for {@link FilterKeyVals}<p>
+ *
+ */
+@Deprecated
+public class FilterKeyValsTest
+{
+  @SuppressWarnings("unchecked")
+  int getTotal(List<Object> list)
+  {
+    int ret = 0;
+    for (Object map: list) {
+      for (Map.Entry<String, Number> e: ((HashMap<String, Number>)map).entrySet()) {
+        ret += e.getValue().intValue();
+      }
+    }
+    return ret;
+  }
+
+  /**
+   * Test node logic emits correct results
+   */
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  @Test
+  public void testNodeProcessing() throws Exception
+  {
+    FilterKeyVals<String,Number> oper = new FilterKeyVals<String,Number>();
+
+    CollectorTestSink sortSink = new CollectorTestSink();
+    oper.filter.setSink(sortSink);
+    HashMap<String,Number> filter = new HashMap<String,Number>();
+    filter.put("b",2);
+    oper.setKeyVals(filter);
+    oper.clearKeys();
+
+    filter.clear();
+    filter.put("e", 200);
+    filter.put("f", 2);
+    filter.put("blah", 2);
+    oper.setKeyVals(filter);
+    filter.clear();
+    filter.put("a", 2);
+    oper.setKeyVals(filter);
+
+    oper.beginWindow(0);
+    HashMap<String, Number> input = new HashMap<String, Number>();
+    input.put("a", 2);
+    input.put("b", 5);
+    input.put("c", 7);
+    input.put("d", 42);
+    input.put("e", 202);
+    input.put("e", 200);
+    input.put("f", 2);
+    oper.data.process(input);
+    Assert.assertEquals("number emitted tuples", 3, sortSink.collectedTuples.size());
+    Assert.assertEquals("Total filtered value is ", 204, getTotal(sortSink.collectedTuples));
+    sortSink.clear();
+
+    input.clear();
+    input.put("a", 5);
+    oper.data.process(input);
+    Assert.assertEquals("number emitted tuples", 0, sortSink.collectedTuples.size());
+    sortSink.clear();
+
+    input.clear();
+    input.put("a", 2);
+    input.put("b", 33);
+    input.put("f", 2);
+    oper.data.process(input);
+    Assert.assertEquals("number emitted tuples", 2, sortSink.collectedTuples.size());
+    Assert.assertEquals("Total filtered value is ", 4, getTotal(sortSink.collectedTuples));
+    sortSink.clear();
+
+    input.clear();
+    input.put("b", 6);
+    input.put("a", 2);
+    input.put("j", 6);
+    input.put("e", 2);
+    input.put("dd", 6);
+    input.put("blah", 2);
+    input.put("another", 6);
+    input.put("notmakingit", 2);
+    oper.data.process(input);
+    Assert.assertEquals("number emitted tuples", 2, sortSink.collectedTuples.size());
+    Assert.assertEquals("Total filtered value is ", 4, getTotal(sortSink.collectedTuples));
+    sortSink.clear();
+
+    input.clear();
+    input.put("c", 9);
+    oper.setInverse(true);
+    oper.data.process(input);
+    Assert.assertEquals("number emitted tuples", 1, sortSink.collectedTuples.size());
+    Assert.assertEquals("Total filtered value is ", 9, getTotal(sortSink.collectedTuples));
+
+    oper.endWindow();
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/FilterKeysHashMapTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/FilterKeysHashMapTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/FilterKeysHashMapTest.java
new file mode 100644
index 0000000..a25c2df
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/FilterKeysHashMapTest.java
@@ -0,0 +1,151 @@
+/**
+ * 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.contrib.misc.algo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Assert;
+
+import org.junit.Test;
+
+import com.datatorrent.lib.testbench.CollectorTestSink;
+
+/**
+ *
+ * Functional tests for {@link FilterKeysHashMap}<p>
+ * @deprecated
+ */
+@Deprecated
+public class FilterKeysHashMapTest
+{
+  @SuppressWarnings("unchecked")
+  int getTotal(Object o)
+  {
+    HashMap<String, HashMap<String, Number>> map = (HashMap<String, HashMap<String, Number>>)o;
+    int ret = 0;
+    for (Map.Entry<String, HashMap<String, Number>> e: map.entrySet()) {
+      for (Map.Entry<String, Number> e2: e.getValue().entrySet()) {
+        ret += e2.getValue().intValue();
+      }
+    }
+    return ret;
+  }
+
+  /**
+   * Test node logic emits correct results
+   */
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  @Test
+  public void testNodeProcessing() throws Exception
+  {
+    FilterKeysHashMap<String, Number> oper = new FilterKeysHashMap<String, Number>();
+
+    CollectorTestSink sortSink = new CollectorTestSink();
+    oper.filter.setSink(sortSink);
+    oper.setKey("b");
+    oper.clearKeys();
+    String[] keys = new String[3];
+    keys[0] = "e";
+    keys[1] = "f";
+    keys[2] = "blah";
+    oper.setKey("a");
+    oper.setKeys(keys);
+
+    oper.beginWindow(0);
+    HashMap<String, HashMap<String, Number>> inputA = new HashMap<String, HashMap<String, Number>>();
+    HashMap<String, Number> input = new HashMap<String, Number>();
+    HashMap<String, Number> input2 = new HashMap<String, Number>();
+
+    input.put("a", 2);
+    input.put("b", 5);
+    input.put("c", 7);
+    input.put("d", 42);
+    input.put("e", 200);
+    input.put("f", 2);
+    inputA.put("A", input);
+    oper.data.process(inputA);
+    Assert.assertEquals("number emitted tuples", 1, sortSink.collectedTuples.size());
+    Assert.assertEquals("Total filtered value is ", 204, getTotal(sortSink.collectedTuples.get(0)));
+    sortSink.clear();
+
+    input.clear();
+    inputA.clear();
+    input.put("a", 5);
+    inputA.put("A", input);
+    oper.data.process(inputA);
+    Assert.assertEquals("number emitted tuples", 1, sortSink.collectedTuples.size());
+    Assert.assertEquals("Total filtered value is ", 5, getTotal(sortSink.collectedTuples.get(0)));
+    sortSink.clear();
+
+    input.clear();
+    inputA.clear();
+    input.put("a", 2);
+    input.put("b", 33);
+    input.put("f", 2);
+    inputA.put("A", input);
+    oper.data.process(inputA);
+    Assert.assertEquals("number emitted tuples", 1, sortSink.collectedTuples.size());
+    Assert.assertEquals("Total filtered value is ", 4, getTotal(sortSink.collectedTuples.get(0)));
+    sortSink.clear();
+
+    input.clear();
+    inputA.clear();
+    input.put("b", 6);
+    input.put("a", 2);
+    input.put("j", 6);
+    input.put("e", 2);
+    input.put("dd", 6);
+    input.put("blah", 2);
+    input.put("another", 6);
+    input.put("notmakingit", 2);
+    inputA.put("A", input);
+    oper.data.process(inputA);
+    Assert.assertEquals("number emitted tuples", 1, sortSink.collectedTuples.size());
+    Assert.assertEquals("Total filtered value is ", 6, getTotal(sortSink.collectedTuples.get(0)));
+    sortSink.clear();
+
+    input.clear();
+    inputA.clear();
+    input.put("c", 9);
+    oper.setInverse(true);
+    inputA.put("A", input);
+    oper.data.process(inputA);
+    Assert.assertEquals("number emitted tuples", 1, sortSink.collectedTuples.size());
+    Assert.assertEquals("Total filtered value is ", 9, getTotal(sortSink.collectedTuples.get(0)));
+    sortSink.clear();
+
+    input.clear();
+    input2.clear();
+    inputA.clear();
+    input.put("e", 2); // pass
+    input.put("c", 9);
+    input2.put("a", 5); // pass
+    input2.put("p", 8);
+    oper.setInverse(false);
+    inputA.put("A", input);
+    inputA.put("B", input2);
+    oper.data.process(inputA);
+    Assert.assertEquals("number emitted tuples", 1, sortSink.collectedTuples.size());
+    Assert.assertEquals("Total filtered value is ", 7, getTotal(sortSink.collectedTuples.get(0)));
+    sortSink.clear();
+
+    oper.endWindow();
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/FilterKeysMapTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/FilterKeysMapTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/FilterKeysMapTest.java
new file mode 100644
index 0000000..74cebdd
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/FilterKeysMapTest.java
@@ -0,0 +1,121 @@
+/**
+ * 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.contrib.misc.algo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.datatorrent.lib.testbench.CollectorTestSink;
+
+/**
+ * @deprecated
+ * Functional tests for {@link FilterKeysMap}<p>
+ *
+ */
+@Deprecated
+public class FilterKeysMapTest
+{
+  @SuppressWarnings("unchecked")
+  int getTotal(Object o)
+  {
+    HashMap<String, Number> map = (HashMap<String, Number>)o;
+    int ret = 0;
+    for (Map.Entry<String, Number> e: map.entrySet()) {
+      ret += e.getValue().intValue();
+    }
+    return ret;
+  }
+
+  /**
+   * Test node logic emits correct results
+   */
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  @Test
+  public void testNodeProcessing() throws Exception
+  {
+    FilterKeysMap<String,Number> oper = new FilterKeysMap<String,Number>();
+
+    CollectorTestSink sortSink = new CollectorTestSink();
+    oper.filter.setSink(sortSink);
+    oper.setKey("b");
+    oper.clearKeys();
+    String[] keys = new String[3];
+    keys[0] = "e";
+    keys[1] = "f";
+    keys[2] = "blah";
+    oper.setKey("a");
+    oper.setKeys(keys);
+
+    oper.beginWindow(0);
+    HashMap<String, Number> input = new HashMap<String, Number>();
+
+    input.put("a", 2);
+    input.put("b", 5);
+    input.put("c", 7);
+    input.put("d", 42);
+    input.put("e", 200);
+    input.put("f", 2);
+    oper.data.process(input);
+    Assert.assertEquals("number emitted tuples", 1, sortSink.collectedTuples.size());
+    Assert.assertEquals("Total filtered value is ", 204, getTotal(sortSink.collectedTuples.get(0)));
+    sortSink.clear();
+
+    input.clear();
+    input.put("a", 5);
+    oper.data.process(input);
+    Assert.assertEquals("number emitted tuples", 1, sortSink.collectedTuples.size());
+    Assert.assertEquals("Total filtered value is ", 5, getTotal(sortSink.collectedTuples.get(0)));
+    sortSink.clear();
+
+    input.clear();
+    input.put("a", 2);
+    input.put("b", 33);
+    input.put("f", 2);
+    oper.data.process(input);
+    Assert.assertEquals("number emitted tuples", 1, sortSink.collectedTuples.size());
+    Assert.assertEquals("Total filtered value is ", 4, getTotal(sortSink.collectedTuples.get(0)));
+    sortSink.clear();
+
+    input.clear();
+    input.put("b", 6);
+    input.put("a", 2);
+    input.put("j", 6);
+    input.put("e", 2);
+    input.put("dd", 6);
+    input.put("blah", 2);
+    input.put("another", 6);
+    input.put("notmakingit", 2);
+    oper.data.process(input);
+    Assert.assertEquals("number emitted tuples", 1, sortSink.collectedTuples.size());
+    Assert.assertEquals("Total filtered value is ", 6, getTotal(sortSink.collectedTuples.get(0)));
+    sortSink.clear();
+
+    input.clear();
+    input.put("c", 9);
+    oper.setInverse(true);
+    oper.data.process(input);
+    Assert.assertEquals("number emitted tuples", 1, sortSink.collectedTuples.size());
+    Assert.assertEquals("Total filtered value is ", 9, getTotal(sortSink.collectedTuples.get(0)));
+
+    oper.endWindow();
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/FirstMatchMapTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/FirstMatchMapTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/FirstMatchMapTest.java
new file mode 100644
index 0000000..d02ee27
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/FirstMatchMapTest.java
@@ -0,0 +1,103 @@
+/**
+ * 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.contrib.misc.algo;
+
+import java.util.HashMap;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.datatorrent.lib.testbench.CountAndLastTupleTestSink;
+
+/**
+ * @deprecated
+ * Functional tests for {@link FirstMatchMap}<p>
+ *
+ */
+@Deprecated
+public class FirstMatchMapTest
+{
+  /**
+   * Test node logic emits correct results
+   */
+  @Test
+  public void testNodeProcessing() throws Exception
+  {
+    testNodeProcessingSchema(new FirstMatchMap<String, Integer>());
+    testNodeProcessingSchema(new FirstMatchMap<String, Double>());
+    testNodeProcessingSchema(new FirstMatchMap<String, Float>());
+    testNodeProcessingSchema(new FirstMatchMap<String, Short>());
+    testNodeProcessingSchema(new FirstMatchMap<String, Long>());
+  }
+
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  public void testNodeProcessingSchema(FirstMatchMap oper)
+  {
+    CountAndLastTupleTestSink matchSink = new CountAndLastTupleTestSink();
+    oper.first.setSink(matchSink);
+    oper.setKey("a");
+    oper.setValue(3);
+    oper.setTypeEQ();
+
+    oper.beginWindow(0);
+    HashMap<String, Number> input = new HashMap<String, Number>();
+    input.put("a", 4);
+    input.put("b", 20);
+    input.put("c", 1000);
+    oper.data.process(input);
+    input.put("a", 3);
+    input.put("b", 20);
+    input.put("c", 1000);
+    oper.data.process(input);
+    input.clear();
+    input.put("a", 2);
+    oper.data.process(input);
+    input.clear();
+    input.put("a", 4);
+    input.put("b", 21);
+    input.put("c", 1000);
+    oper.data.process(input);
+    input.clear();
+    input.put("a", 4);
+    input.put("b", 20);
+    input.put("c", 5);
+    oper.data.process(input);
+    oper.endWindow();
+
+    Assert.assertEquals("number emitted tuples", 1, matchSink.count);
+    HashMap<String, Number> tuple = (HashMap<String, Number>)matchSink.tuple;
+    Number aval = tuple.get("a");
+    Assert.assertEquals("Value of a was ", 3, aval.intValue());
+    matchSink.clear();
+
+    oper.beginWindow(0);
+    input.clear();
+    input.put("a", 2);
+    input.put("b", 20);
+    input.put("c", 1000);
+    oper.data.process(input);
+    input.clear();
+    input.put("a", 5);
+    oper.data.process(input);
+    oper.endWindow();
+    // There should be no emit as all tuples do not match
+    Assert.assertEquals("number emitted tuples", 0, matchSink.count);
+    matchSink.clear();
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/FirstNTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/FirstNTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/FirstNTest.java
new file mode 100644
index 0000000..e6c3e7e
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/FirstNTest.java
@@ -0,0 +1,123 @@
+/**
+ * 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.contrib.misc.algo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Assert;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.datatorrent.lib.testbench.CollectorTestSink;
+
+/**
+ * @deprecated
+ * Functional tests for {@link FirstN}<p>
+ */
+@Deprecated
+public class FirstNTest
+{
+  private static Logger log = LoggerFactory.getLogger(FirstNTest.class);
+
+  /**
+   * Test node logic emits correct results
+   */
+  @Test
+  public void testNodeProcessing() throws Exception
+  {
+    testNodeProcessingSchema(new FirstN<String, Integer>());
+    testNodeProcessingSchema(new FirstN<String, Double>());
+    testNodeProcessingSchema(new FirstN<String, Float>());
+    testNodeProcessingSchema(new FirstN<String, Short>());
+    testNodeProcessingSchema(new FirstN<String, Long>());
+  }
+
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  public void testNodeProcessingSchema(FirstN oper)
+  {
+    CollectorTestSink sortSink = new CollectorTestSink();
+    oper.first.setSink(sortSink);
+    oper.setN(3);
+
+    oper.beginWindow(0);
+    HashMap<String, Number> input = new HashMap<String, Number>();
+
+    input.put("a", 2);
+    oper.data.process(input);
+
+    input.clear();
+    input.put("a", 20);
+    oper.data.process(input);
+
+    input.clear();
+    input.put("a", 1000);
+    oper.data.process(input);
+
+    input.clear();
+    input.put("a", 5);
+    oper.data.process(input);
+
+    input.clear();
+    input.put("a", 20);
+    input.put("b", 33);
+    oper.data.process(input);
+
+    input.clear();
+    input.put("a", 33);
+    input.put("b", 34);
+    oper.data.process(input);
+
+    input.clear();
+    input.put("b", 34);
+    input.put("a", 1001);
+    oper.data.process(input);
+
+    input.clear();
+    input.put("b", 6);
+    input.put("a", 1);
+    oper.data.process(input);
+    input.clear();
+    input.put("c", 9);
+    oper.data.process(input);
+    oper.endWindow();
+
+    Assert.assertEquals("number emitted tuples", 7, sortSink.collectedTuples.size());
+    int aval = 0;
+    int bval = 0;
+    int cval = 0;
+    for (Object o : sortSink.collectedTuples) {
+      for (Map.Entry<String, Number> e : ((HashMap<String, Number>)o).entrySet()) {
+        if (e.getKey().equals("a")) {
+          aval += e.getValue().intValue();
+        } else if (e.getKey().equals("b")) {
+          bval += e.getValue().intValue();
+        } else if (e.getKey().equals("c")) {
+          cval += e.getValue().intValue();
+        }
+      }
+    }
+    Assert.assertEquals("Value of \"a\" was ", 1022, aval);
+    Assert.assertEquals("Value of \"a\" was ", 101, bval);
+    Assert.assertEquals("Value of \"a\" was ", 9, cval);
+    log.debug("Done testing round\n");
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/FirstTillMatchTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/FirstTillMatchTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/FirstTillMatchTest.java
new file mode 100644
index 0000000..51b8415
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/FirstTillMatchTest.java
@@ -0,0 +1,110 @@
+/**
+ * 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.contrib.misc.algo;
+
+import java.util.HashMap;
+
+import org.junit.Assert;
+
+import org.junit.Test;
+
+import com.datatorrent.lib.testbench.CollectorTestSink;
+
+/**
+ * @deprecated
+ * Functional tests for {@link FirstTillMatch}<p>
+ *
+ */
+@Deprecated
+public class FirstTillMatchTest
+{
+  /**
+   * Test node logic emits correct results
+   */
+  @Test
+  public void testNodeProcessing() throws Exception
+  {
+    testNodeProcessingSchema(new FirstTillMatch<String, Integer>());
+    testNodeProcessingSchema(new FirstTillMatch<String, Double>());
+    testNodeProcessingSchema(new FirstTillMatch<String, Float>());
+    testNodeProcessingSchema(new FirstTillMatch<String, Short>());
+    testNodeProcessingSchema(new FirstTillMatch<String, Long>());
+  }
+
+  @SuppressWarnings( {"unchecked", "rawtypes"})
+  public void testNodeProcessingSchema(FirstTillMatch oper)
+  {
+    CollectorTestSink matchSink = new CollectorTestSink();
+    oper.first.setSink(matchSink);
+    oper.setKey("a");
+    oper.setValue(3);
+    oper.setTypeEQ();
+
+    oper.beginWindow(0);
+    HashMap<String, Number> input = new HashMap<String, Number>();
+    input.put("a", 4);
+    input.put("b", 20);
+    input.put("c", 1000);
+    oper.data.process(input);
+    input.clear();
+    input.put("a", 2);
+    oper.data.process(input);
+    input.put("a", 3);
+    input.put("b", 20);
+    input.put("c", 1000);
+    oper.data.process(input);
+    input.clear();
+    input.put("a", 4);
+    input.put("b", 21);
+    input.put("c", 1000);
+    oper.data.process(input);
+    input.clear();
+    input.put("a", 6);
+    input.put("b", 20);
+    input.put("c", 5);
+    oper.data.process(input);
+    oper.endWindow();
+
+    Assert.assertEquals("number emitted tuples", 2, matchSink.collectedTuples.size());
+    int atotal = 0;
+    for (Object o: matchSink.collectedTuples) {
+      atotal += ((HashMap<String,Number>)o).get("a").intValue();
+    }
+    Assert.assertEquals("Value of a was ", 6, atotal);
+    matchSink.clear();
+
+    oper.beginWindow(0);
+    input.clear();
+    input.put("a", 2);
+    input.put("b", 20);
+    input.put("c", 1000);
+    oper.data.process(input);
+    input.clear();
+    input.put("a", 5);
+    oper.data.process(input);
+    oper.endWindow();
+    // There should be no emit as all tuples do not match
+    Assert.assertEquals("number emitted tuples", 2, matchSink.collectedTuples.size());
+    atotal = 0;
+    for (Object o: matchSink.collectedTuples) {
+      atotal += ((HashMap<String,Number>)o).get("a").intValue();
+    }
+    Assert.assertEquals("Value of a was ", 7, atotal);
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/InsertSortDescTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/InsertSortDescTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/InsertSortDescTest.java
new file mode 100644
index 0000000..cebd628
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/InsertSortDescTest.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.contrib.misc.algo;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.datatorrent.lib.testbench.CollectorTestSink;
+
+/**
+ * @deprecated
+ * Functional tests for {@link InsertSortDesc}<p>
+ */
+@Deprecated
+public class InsertSortDescTest
+{
+  private static Logger log = LoggerFactory.getLogger(InsertSortDescTest.class);
+
+  /**
+   * Test node logic emits correct results
+   */
+  @Test
+  public void testNodeProcessing() throws Exception
+  {
+    testNodeProcessingSchema(new InsertSortDesc<Integer>(), "Integer");
+    testNodeProcessingSchema(new InsertSortDesc<Double>(), "Double");
+    testNodeProcessingSchema(new InsertSortDesc<Float>(), "Float");
+    testNodeProcessingSchema(new InsertSortDesc<String>(), "String");
+  }
+
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  public void testNodeProcessingSchema(InsertSortDesc oper, String debug)
+  {
+    //FirstN<String,Float> aoper = new FirstN<String,Float>();
+    CollectorTestSink sortSink = new CollectorTestSink();
+    CollectorTestSink hashSink = new CollectorTestSink();
+    oper.sort.setSink(sortSink);
+    oper.sorthash.setSink(hashSink);
+
+    ArrayList input = new ArrayList();
+
+    oper.beginWindow(0);
+
+    input.add(2);
+    oper.datalist.process(input);
+    oper.data.process(20);
+
+    input.clear();
+    input.add(1000);
+    input.add(5);
+    input.add(20);
+    input.add(33);
+    input.add(33);
+    input.add(34);
+    oper.datalist.process(input);
+
+    input.clear();
+    input.add(34);
+    input.add(1001);
+    input.add(6);
+    input.add(1);
+    input.add(33);
+    input.add(9);
+    oper.datalist.process(input);
+    oper.endWindow();
+
+    Assert.assertEquals("number emitted tuples", 1, sortSink.collectedTuples.size());
+    Assert.assertEquals("number emitted tuples", 1, hashSink.collectedTuples.size());
+    HashMap map = (HashMap)hashSink.collectedTuples.get(0);
+    input = (ArrayList)sortSink.collectedTuples.get(0);
+    for (Object o : input) {
+      log.debug(String.format("%s : %s", o.toString(), map.get(o).toString()));
+    }
+    log.debug(String.format("Tested %s type with %d tuples and %d uniques\n", debug, input.size(), map.size()));
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/InvertIndexArrayTest.java
----------------------------------------------------------------------
diff --git a/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/InvertIndexArrayTest.java b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/InvertIndexArrayTest.java
new file mode 100644
index 0000000..d37789d
--- /dev/null
+++ b/contrib/src/test/java/org/apache/apex/malhar/contrib/misc/algo/InvertIndexArrayTest.java
@@ -0,0 +1,101 @@
+/**
+ * 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.contrib.misc.algo;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.datatorrent.api.Sink;
+
+import com.datatorrent.lib.testbench.CollectorTestSink;
+
+/**
+ * @deprecated
+ * Functional tests for {@link InvertIndex} <p>
+ *
+ */
+@Deprecated
+public class InvertIndexArrayTest
+{
+  private static Logger log = LoggerFactory.getLogger(InvertIndexArrayTest.class);
+
+  /**
+   * Test oper logic emits correct results
+   */
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  @Test
+  public void testNodeProcessing() throws Exception
+  {
+    InvertIndexArray<String,String> oper = new InvertIndexArray<String,String>();
+    CollectorTestSink indexSink = new CollectorTestSink();
+
+    Sink inSink = oper.data.getSink();
+    oper.index.setSink(indexSink);
+
+    oper.beginWindow(0);
+
+    HashMap<String, ArrayList> input = new HashMap<String, ArrayList>();
+    ArrayList<String> alist = new ArrayList<String>();
+    alist.add("str");
+    alist.add("str1");
+    input.put("a", alist);
+    input.put("b", alist);
+    inSink.put(input);
+
+    alist = new ArrayList<String>();
+    input = new HashMap<String, ArrayList>();
+    alist.add("blah");
+    alist.add("str1");
+    input.put("c", alist);
+    inSink.put(input);
+
+    oper.endWindow();
+
+    Assert.assertEquals("number emitted tuples", 3, indexSink.collectedTuples.size());
+    for (Object o: indexSink.collectedTuples) {
+      log.debug(o.toString());
+      HashMap<String, ArrayList<String>> output = (HashMap<String, ArrayList<String>>)o;
+      for (Map.Entry<String, ArrayList<String>> e: output.entrySet()) {
+        String key = e.getKey();
+        alist = e.getValue();
+        if (key.equals("str1")) {
+          Assert.assertEquals("Index for \"str1\" contains \"a\"", true, alist.contains("a"));
+          Assert.assertEquals("Index for \"str1\" contains \"b\"", true, alist.contains("b"));
+          Assert.assertEquals("Index for \"str1\" contains \"c\"", true, alist.contains("c"));
+
+        } else if (key.equals("str")) {
+          Assert.assertEquals("Index for \"str1\" contains \"a\"", true, alist.contains("a"));
+          Assert.assertEquals("Index for \"str1\" contains \"b\"", true, alist.contains("b"));
+          Assert.assertEquals("Index for \"str1\" contains \"c\"", false, alist.contains("c"));
+
+        } else if (key.equals("blah")) {
+          Assert.assertEquals("Index for \"str1\" contains \"a\"", false, alist.contains("a"));
+          Assert.assertEquals("Index for \"str1\" contains \"b\"", false, alist.contains("b"));
+          Assert.assertEquals("Index for \"str1\" contains \"c\"", true, alist.contains("c"));
+        }
+      }
+    }
+  }
+}


[10/12] apex-malhar git commit: Updated algo & working on math operators

Posted by th...@apache.org.
http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/AbstractSqlStreamOperator.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/AbstractSqlStreamOperator.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/AbstractSqlStreamOperator.java
new file mode 100644
index 0000000..16f1036
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/AbstractSqlStreamOperator.java
@@ -0,0 +1,192 @@
+/**
+ * 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.contrib.misc.streamquery;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import com.datatorrent.api.DefaultInputPort;
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.api.annotation.InputPortFieldAnnotation;
+import com.datatorrent.api.annotation.OutputPortFieldAnnotation;
+import com.datatorrent.common.util.BaseOperator;
+
+/**
+ * A base implementation of a BaseOperator that is a sql stream operator.&nbsp;  Subclasses should provide the
+   implementation of how to process the tuples.
+ * <p>
+ * Abstract sql db input operator.
+ * <p>
+ * @displayName Abstract Sql Stream
+ * @category Stream Manipulators
+ * @tags sql operator
+ * @since 0.3.2
+ * @deprecated
+ */
+@Deprecated
+public abstract class AbstractSqlStreamOperator extends BaseOperator
+{
+  public static class InputSchema
+  {
+    public static class ColumnInfo
+    {
+      public String type;
+      public int bindIndex = 0;
+      public boolean isColumnIndex = false;
+    }
+
+    /**
+     * the name of the input "table"
+     */
+    public String name;
+    /**
+     * key is the name of the column, and value is the SQL type
+     */
+    public HashMap<String, ColumnInfo> columnInfoMap = new HashMap<String, ColumnInfo>();
+
+    public InputSchema()
+    {
+    }
+
+    public InputSchema(String name)
+    {
+      this.name = name;
+    }
+
+    public void setColumnInfo(String columnName, String columnType, boolean isColumnIndex)
+    {
+      ColumnInfo t = new ColumnInfo();
+      t.type = columnType;
+      t.isColumnIndex = isColumnIndex;
+      columnInfoMap.put(columnName, t);
+    }
+
+  }
+
+  protected String statement;
+  protected ArrayList<InputSchema> inputSchemas = new ArrayList<InputSchema>(5);
+  protected transient ArrayList<Object> bindings;
+
+  /**
+   * Input bindings port that takes an arraylist of objects.
+   */
+  @InputPortFieldAnnotation(optional = true)
+  public final transient DefaultInputPort<ArrayList<Object>> bindingsPort = new DefaultInputPort<ArrayList<Object>>()
+  {
+    @Override
+    public void process(ArrayList<Object> tuple)
+    {
+      bindings = tuple;
+    }
+
+  };
+
+  /**
+   * Input port in1 that takes a hashmap of &lt;string,object&gt;.
+   */
+  public final transient DefaultInputPort<HashMap<String, Object>> in1 = new DefaultInputPort<HashMap<String, Object>>()
+  {
+    @Override
+    public void process(HashMap<String, Object> tuple)
+    {
+      processTuple(0, tuple);
+    }
+
+  };
+
+  /**
+   * Input port in2 that takes a hashmap of &lt;string,object&gt;.
+   */
+  @InputPortFieldAnnotation(optional = true)
+  public final transient DefaultInputPort<HashMap<String, Object>> in2 = new DefaultInputPort<HashMap<String, Object>>()
+  {
+    @Override
+    public void process(HashMap<String, Object> tuple)
+    {
+      processTuple(1, tuple);
+    }
+
+  };
+
+  /**
+   * Input port in3 that takes a hashmap of &lt;string,object&gt;.
+   */
+  @InputPortFieldAnnotation(optional = true)
+  public final transient DefaultInputPort<HashMap<String, Object>> in3 = new DefaultInputPort<HashMap<String, Object>>()
+  {
+    @Override
+    public void process(HashMap<String, Object> tuple)
+    {
+      processTuple(2, tuple);
+    }
+
+  };
+
+  /**
+   * Input port in4 that takes a hashmap of &lt;string,object&gt;.
+   */
+  @InputPortFieldAnnotation(optional = true)
+  public final transient DefaultInputPort<HashMap<String, Object>> in4 = new DefaultInputPort<HashMap<String, Object>>()
+  {
+    @Override
+    public void process(HashMap<String, Object> tuple)
+    {
+      processTuple(3, tuple);
+    }
+
+  };
+
+  /**
+   * Input port in5 that takes a hashmap of &lt;string,object&gt;.
+   */
+  @InputPortFieldAnnotation(optional = true)
+  public final transient DefaultInputPort<HashMap<String, Object>> in5 = new DefaultInputPort<HashMap<String, Object>>()
+  {
+    @Override
+    public void process(HashMap<String, Object> tuple)
+    {
+      processTuple(4, tuple);
+    }
+
+  };
+
+  /**
+   * Output result port that emits a hashmap of &lt;string,object&gt;.
+   */
+  @OutputPortFieldAnnotation(optional = true)
+  public final transient DefaultOutputPort<HashMap<String, Object>> result = new DefaultOutputPort<HashMap<String, Object>>();
+
+  public void setStatement(String statement)
+  {
+    this.statement = statement;
+  }
+
+  public String getStatement()
+  {
+    return this.statement;
+  }
+
+  public void setInputSchema(int inputPortIndex, InputSchema inputSchema)
+  {
+    inputSchemas.add(inputPortIndex, inputSchema);
+  }
+
+  public abstract void processTuple(int tableNum, HashMap<String, Object> tuple);
+
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/DeleteOperator.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/DeleteOperator.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/DeleteOperator.java
new file mode 100644
index 0000000..7faf96d
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/DeleteOperator.java
@@ -0,0 +1,88 @@
+/**
+ * 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.contrib.misc.streamquery;
+
+import java.util.Map;
+
+import com.datatorrent.api.DefaultInputPort;
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.common.util.BaseOperator;
+import com.datatorrent.lib.streamquery.condition.Condition;
+
+/**
+ * An implementation of BaseOperator that provides sql delete query semantic on live data stream. <br>
+ * <p>
+ * Stream rows passing condition are emitted on output port stream. <br>
+ * <br>
+ * <b>StateFull : NO,</b> all row data is processed in current time window. <br>
+ * <b>Partitions : Yes, </b> No Input dependency among input rows. <br>
+ * <br>
+ * <b>Ports</b>:<br>
+ * <b> inport : </b> Input hash map(row) port, expects
+ * HashMap&lt;String,Object&gt;<<br>
+ * <b> outport : </b> Output hash map(row) port, emits
+ * HashMap&lt;String,Object&gt;<br>
+ * <br>
+ * <b> Properties : <b> <br>
+ * <b> condition : </b> Select condition for selecting rows. <br>
+ * <b> columns : </b> Column names/aggregate functions for select. <br>
+ * <br>
+ * @displayName Delete
+ * @category Stream Manipulators
+ * @tags sql delete operator
+ * @since 0.3.3
+ * @deprecated
+ */
+@Deprecated
+public class DeleteOperator extends BaseOperator
+{
+
+  /**
+   * condition.
+   */
+  private Condition condition = null;
+
+  /**
+   * set condition.
+   */
+  public void setCondition(Condition condition)
+  {
+    this.condition = condition;
+  }
+
+  /**
+   * Input port that takes a map of &lt;string,object&gt;.
+   */
+  public final transient DefaultInputPort<Map<String, Object>> inport = new DefaultInputPort<Map<String, Object>>()
+  {
+
+    @Override
+    public void process(Map<String, Object> tuple)
+    {
+      if ((condition != null) && (!condition.isValidRow(tuple))) {
+        outport.emit(tuple);
+      }
+    }
+  };
+
+  /**
+   * Output port emits a map of &lt;string,object&gt;.
+   */
+  public final transient DefaultOutputPort<Map<String, Object>> outport = new DefaultOutputPort<Map<String, Object>>();
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/DerbySqlStreamOperator.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/DerbySqlStreamOperator.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/DerbySqlStreamOperator.java
new file mode 100644
index 0000000..a55c7d7
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/DerbySqlStreamOperator.java
@@ -0,0 +1,200 @@
+/**
+ * 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.contrib.misc.streamquery;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.apex.malhar.contrib.misc.streamquery.AbstractSqlStreamOperator.InputSchema.ColumnInfo;
+
+import com.datatorrent.api.Context.OperatorContext;
+
+/**
+ * An implementation of AbstractSqlStreamOperator that provides embedded derby sql input operator.
+ * <p>
+ * @displayName Derby Sql Stream
+ * @category Stream Manipulators
+ * @tags sql, in-memory, input operator
+ * @since 0.3.2
+ * @deprecated
+ */
+@Deprecated
+public class DerbySqlStreamOperator extends AbstractSqlStreamOperator
+{
+  protected transient ArrayList<PreparedStatement> insertStatements = new ArrayList<PreparedStatement>(5);
+  protected List<String> execStmtStringList = new ArrayList<String>();
+  protected transient ArrayList<PreparedStatement> execStatements = new ArrayList<PreparedStatement>(5);
+  protected transient ArrayList<PreparedStatement> deleteStatements = new ArrayList<PreparedStatement>(5);
+  protected transient Connection db;
+
+  public void addExecStatementString(String stmt)
+  {
+    this.execStmtStringList.add(stmt);
+  }
+
+
+  @Override
+  public void setup(OperatorContext context)
+  {
+    System.setProperty("derby.stream.error.file", "/dev/null");
+    try {
+      Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
+    } catch (Exception ex) {
+      throw new RuntimeException(ex);
+    }
+
+    String connUrl = "jdbc:derby:memory:MALHAR_TEMP;create=true";
+    PreparedStatement st;
+
+    try {
+      db = DriverManager.getConnection(connUrl);
+      // create the temporary tables here
+      for (int i = 0; i < inputSchemas.size(); i++) {
+        InputSchema inputSchema = inputSchemas.get(i);
+        if (inputSchema == null || inputSchema.columnInfoMap.isEmpty()) {
+          continue;
+        }
+        String columnSpec = "";
+        String columnNames = "";
+        String insertQuestionMarks = "";
+        int j = 0;
+        for (Map.Entry<String, ColumnInfo> entry : inputSchema.columnInfoMap.entrySet()) {
+          if (!columnSpec.isEmpty()) {
+            columnSpec += ",";
+            columnNames += ",";
+            insertQuestionMarks += ",";
+          }
+          columnSpec += entry.getKey();
+          columnSpec += " ";
+          columnSpec += entry.getValue().type;
+          columnNames += entry.getKey();
+          insertQuestionMarks += "?";
+          entry.getValue().bindIndex = ++j;
+        }
+        String createTempTableStmt =
+            "DECLARE GLOBAL TEMPORARY TABLE SESSION." + inputSchema.name + "(" + columnSpec + ") NOT LOGGED";
+        st = db.prepareStatement(createTempTableStmt);
+        st.execute();
+        st.close();
+
+        String insertStmt = "INSERT INTO SESSION." + inputSchema.name + " (" + columnNames + ") VALUES ("
+            + insertQuestionMarks + ")";
+
+        insertStatements.add(i, db.prepareStatement(insertStmt));
+        deleteStatements.add(i, db.prepareStatement("DELETE FROM SESSION." + inputSchema.name));
+      }
+      for (String stmtStr : execStmtStringList) {
+        execStatements.add(db.prepareStatement(stmtStr));
+      }
+    } catch (SQLException ex) {
+      throw new RuntimeException(ex);
+    }
+  }
+
+  @Override
+  public void beginWindow(long windowId)
+  {
+    try {
+      db.setAutoCommit(false);
+    } catch (SQLException ex) {
+      throw new RuntimeException(ex);
+    }
+  }
+
+  @Override
+  public void processTuple(int tableNum, HashMap<String, Object> tuple)
+  {
+    InputSchema inputSchema = inputSchemas.get(tableNum);
+
+    PreparedStatement insertStatement = insertStatements.get(tableNum);
+    try {
+      for (Map.Entry<String, Object> entry : tuple.entrySet()) {
+        ColumnInfo t = inputSchema.columnInfoMap.get(entry.getKey());
+        if (t != null && t.bindIndex != 0) {
+          insertStatement.setString(t.bindIndex, entry.getValue().toString());
+        }
+      }
+
+      insertStatement.executeUpdate();
+      insertStatement.clearParameters();
+    } catch (SQLException ex) {
+      throw new RuntimeException(ex);
+    }
+  }
+
+  @Override
+  public void endWindow()
+  {
+    try {
+      db.commit();
+      if (bindings != null) {
+        for (int i = 0; i < bindings.size(); i++) {
+          for (PreparedStatement stmt : execStatements) {
+            stmt.setString(i, bindings.get(i).toString());
+          }
+        }
+      }
+
+      for (PreparedStatement stmt : execStatements) {
+        executePreparedStatement(stmt);
+      }
+      for (PreparedStatement st : deleteStatements) {
+        st.executeUpdate();
+        st.clearParameters();
+      }
+    } catch (SQLException ex) {
+      throw new RuntimeException(ex);
+    }
+    bindings = null;
+  }
+
+  private void executePreparedStatement(PreparedStatement statement) throws SQLException
+  {
+    ResultSet res = statement.executeQuery();
+    ResultSetMetaData resmeta = res.getMetaData();
+    int columnCount = resmeta.getColumnCount();
+    while (res.next()) {
+      HashMap<String, Object> resultRow = new HashMap<String, Object>();
+      for (int i = 1; i <= columnCount; i++) {
+        resultRow.put(resmeta.getColumnName(i), res.getObject(i));
+      }
+      this.result.emit(resultRow);
+    }
+    statement.clearParameters();
+  }
+
+  @Override
+  public void teardown()
+  {
+    try {
+      db.close();
+    } catch (SQLException ex) {
+      throw new RuntimeException(ex);
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/GroupByHavingOperator.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/GroupByHavingOperator.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/GroupByHavingOperator.java
new file mode 100644
index 0000000..9999429
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/GroupByHavingOperator.java
@@ -0,0 +1,230 @@
+/**
+ * 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.contrib.misc.streamquery;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.validation.constraints.NotNull;
+
+import org.apache.apex.malhar.contrib.misc.streamquery.condition.HavingCondition;
+import org.apache.apex.malhar.contrib.misc.streamquery.function.FunctionIndex;
+
+import com.datatorrent.api.DefaultInputPort;
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.common.util.BaseOperator;
+import com.datatorrent.lib.streamquery.index.ColumnIndex;
+import com.datatorrent.lib.streamquery.condition.Condition;
+@Deprecated
+public class GroupByHavingOperator extends BaseOperator
+{
+
+  /**
+   * aggregate indexes.
+   */
+  private ArrayList<FunctionIndex> aggregates = new ArrayList<FunctionIndex>();
+
+  /**
+   * Column, Group by names
+   */
+  private ArrayList<ColumnIndex> columnGroupIndexes = new ArrayList<ColumnIndex>();
+
+  /**
+   * where condition.
+   */
+  private Condition condition;
+
+  /**
+   * having aggregate condtion;
+   */
+  private ArrayList<HavingCondition> havingConditions = new ArrayList<HavingCondition>();
+
+  /**
+   * Table rows.
+   */
+  private ArrayList<Map<String, Object>> rows = new ArrayList<Map<String, Object>>();
+
+  public void addAggregateIndex(@NotNull FunctionIndex index)
+  {
+    aggregates.add(index);
+  }
+
+  public void addColumnGroupByIndex(@NotNull ColumnIndex index)
+  {
+    columnGroupIndexes.add(index);
+  }
+
+  public void addHavingCondition(@NotNull HavingCondition condition)
+  {
+    havingConditions.add(condition);
+  }
+
+  /**
+   * @param condition condition
+   */
+  public void setCondition(Condition condition)
+  {
+    this.condition = condition;
+  }
+
+  /**
+   * Input port that takes a map of &lt;string,object&gt;.
+   */
+  public final transient DefaultInputPort<Map<String, Object>> inport = new DefaultInputPort<Map<String, Object>>()
+  {
+
+    @Override
+    public void process(Map<String, Object> tuple)
+    {
+      if ((condition != null) && (!condition.isValidRow(tuple))) {
+        return;
+      }
+      rows.add(tuple);
+    }
+  };
+
+  /**
+   * Output port that emits a map of &lt;string,object&gt;.
+   */
+  public final transient DefaultOutputPort<Map<String, Object>> outport = new DefaultOutputPort<Map<String, Object>>();
+
+  /**
+   * Create aggregate at end window.
+   */
+  @Override
+  public void endWindow()
+  {
+    // group names
+    if (columnGroupIndexes.size() == 0) {
+      rows = new ArrayList<Map<String, Object>>();
+      return;
+    }
+
+    // group rows
+    HashMap<MultiKeyCompare, ArrayList<Map<String, Object>>> groups = new HashMap<MultiKeyCompare, ArrayList<Map<String, Object>>>();
+    for (Map<String, Object> row : rows) {
+      MultiKeyCompare key = new MultiKeyCompare();
+      for (ColumnIndex index : columnGroupIndexes) {
+        key.addCompareKey(row.get(index.getColumn()));
+      }
+      ArrayList<Map<String, Object>> subRows;
+      if (groups.containsKey(key)) {
+        subRows = groups.get(key);
+      } else {
+        subRows = new ArrayList<Map<String, Object>>();
+        groups.put(key, subRows);
+      }
+      subRows.add(row);
+    }
+
+    // Iterate over groups and emit aggregate values
+    for (Map.Entry<MultiKeyCompare, ArrayList<Map<String, Object>>> entry : groups
+        .entrySet()) {
+      ArrayList<Map<String, Object>> subRows = entry.getValue();
+
+      // get result
+      Map<String, Object> result = new HashMap<String, Object>();
+      for (ColumnIndex index : columnGroupIndexes) {
+        index.filter(subRows.get(0), result);
+      }
+
+      // append aggregate values
+      for (FunctionIndex aggregate : aggregates) {
+        try {
+          aggregate.filter(subRows, result);
+        } catch (Exception e) {
+          e.printStackTrace();
+        }
+      }
+
+      // check valid having aggregate
+      boolean isValidHaving = true;
+      for (HavingCondition condition : havingConditions) {
+        try {
+          isValidHaving &= condition.isValidAggregate(subRows);
+        } catch (Exception e) {
+          e.printStackTrace();
+          return;
+        }
+      }
+      if (isValidHaving) {
+        outport.emit(result);
+      }
+    }
+
+    rows = new ArrayList<Map<String, Object>>();
+  }
+
+  /**
+   * multi key compare class.
+   */
+  @SuppressWarnings("rawtypes")
+  private class MultiKeyCompare implements Comparable
+  {
+
+    /**
+     * compare keys.
+     */
+    ArrayList<Object> compareKeys = new ArrayList<Object>();
+
+    @Override
+    public boolean equals(Object other)
+    {
+      if (other instanceof MultiKeyCompare) {
+        if (compareKeys.size() != ((MultiKeyCompare)other).compareKeys.size()) {
+          return false;
+        }
+      }
+      for (int i = 0; i < compareKeys.size(); i++) {
+        if (!(compareKeys.get(i).equals(((MultiKeyCompare)other).compareKeys.get(i)))) {
+          return false;
+        }
+      }
+      return true;
+    }
+
+    @Override
+    public int hashCode()
+    {
+      int hashCode = 0;
+      for (int i = 0; i < compareKeys.size(); i++) {
+        hashCode += compareKeys.get(i).hashCode();
+      }
+      return hashCode;
+    }
+
+    @Override
+    public int compareTo(Object other)
+    {
+      if (this.equals(other)) {
+        return 0;
+      }
+      return -1;
+    }
+
+    /**
+     * Add compare key.
+     */
+    public void addCompareKey(Object value)
+    {
+      compareKeys.add(value);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/InnerJoinOperator.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/InnerJoinOperator.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/InnerJoinOperator.java
new file mode 100644
index 0000000..d3e11c3
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/InnerJoinOperator.java
@@ -0,0 +1,212 @@
+/**
+ * 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.contrib.misc.streamquery;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.datatorrent.api.Context.OperatorContext;
+import com.datatorrent.api.DefaultInputPort;
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.api.Operator;
+import com.datatorrent.api.annotation.OperatorAnnotation;
+import com.datatorrent.lib.streamquery.condition.Condition;
+import com.datatorrent.lib.streamquery.index.Index;
+
+/**
+ * An implementation of Operator that reads table row data from two table data input ports. <br>
+ * <p>
+ * Operator joins row on given condition and selected names, emits
+ * joined result at output port.
+ *  <br>
+ *  <b>StateFull : Yes,</b> Operator aggregates input over application window. <br>
+ *  <b>Partitions : No, </b> will yield wrong result(s). <br>
+ *  <br>
+ *  <b>Ports : </b> <br>
+ *  <b> inport1 : </b> Input port for table 1, expects HashMap&lt;String, Object&gt; <br>
+ *  <b> inport1 : </b> Input port for table 2, expects HashMap&lt;String, Object&gt; <br>
+ *  <b> outport : </b> Output joined row port, emits HashMap&lt;String, ArrayList&lt;Object&gt;&gt; <br>
+ *  <br>
+ *  <b> Properties : </b>
+ *  <b> joinCondition : </b> Join condition for table rows. <br>
+ *  <b> table1Columns : </b> Columns to be selected from table1. <br>
+ *  <b> table2Columns : </b> Columns to be selected from table2. <br>
+ *  <br>
+ * @displayName Inner join
+ * @category Stream Manipulators
+ * @tags sql, inner join operator
+ *
+ * @since 0.3.3
+ * @deprecated
+ */
+@Deprecated
+@OperatorAnnotation(partitionable = false)
+public class InnerJoinOperator implements Operator
+{
+
+  /**
+   * Join Condition;
+   */
+  protected Condition joinCondition;
+
+  /**
+   * Table1 select columns.
+   */
+  private ArrayList<Index> table1Columns = new ArrayList<Index>();
+
+  /**
+   * Table2 select columns.
+   */
+  private ArrayList<Index> table2Columns = new ArrayList<Index>();
+
+  /**
+   * Collect data rows from input port 1.
+   */
+  protected ArrayList<Map<String, Object>> table1;
+
+  /**
+   * Collect data from input port 2.
+   */
+  protected ArrayList<Map<String, Object>> table2;
+
+  /**
+   * Input port 1 that takes a map of &lt;string,object&gt;.
+   */
+  public final transient DefaultInputPort<Map<String, Object>> inport1 = new DefaultInputPort<Map<String, Object>>()
+  {
+    @Override
+    public void process(Map<String, Object> tuple)
+    {
+      table1.add(tuple);
+      for (int j = 0; j < table2.size(); j++) {
+        if ((joinCondition == null) || (joinCondition.isValidJoin(tuple, table2.get(j)))) {
+          joinRows(tuple, table2.get(j));
+        }
+      }
+    }
+  };
+
+  /**
+   * Input port 2 that takes a map of &lt;string,object&gt;.
+   */
+  public final transient DefaultInputPort<Map<String, Object>> inport2 = new DefaultInputPort<Map<String, Object>>()
+  {
+    @Override
+    public void process(Map<String, Object> tuple)
+    {
+      table2.add(tuple);
+      for (int j = 0; j < table1.size(); j++) {
+        if ((joinCondition == null) || (joinCondition.isValidJoin(table1.get(j), tuple))) {
+          joinRows(table1.get(j), tuple);
+        }
+      }
+    }
+  };
+
+  /**
+   * Output port that emits a map of &lt;string,object&gt;.
+   */
+  public final transient DefaultOutputPort<Map<String, Object>> outport =
+      new DefaultOutputPort<Map<String, Object>>();
+
+  @Override
+  public void setup(OperatorContext arg0)
+  {
+    table1 = new ArrayList<Map<String, Object>>();
+    table2 = new ArrayList<Map<String, Object>>();
+  }
+
+  @Override
+  public void teardown()
+  {
+  }
+
+  @Override
+  public void beginWindow(long arg0)
+  {
+  }
+
+  @Override
+  public void endWindow()
+  {
+    table1.clear();
+    table2.clear();
+  }
+
+  /**
+   * @return the joinCondition
+   */
+  public Condition getJoinCondition()
+  {
+    return joinCondition;
+  }
+
+  /**
+   * Pick the supported condition. Currently only equal join is supported.
+   * @param joinCondition joinCondition
+   */
+  public void setJoinCondition(Condition joinCondition)
+  {
+    this.joinCondition = joinCondition;
+  }
+
+  /**
+   * Select table1 column name.
+   */
+  public void selectTable1Column(Index column)
+  {
+    table1Columns.add(column);
+  }
+
+  /**
+   * Select table2 column name.
+   */
+  public void selectTable2Column(Index column)
+  {
+    table2Columns.add(column);
+  }
+
+  /**
+   * Join row from table1 and table2.
+   */
+  protected void joinRows(Map<String, Object> row1, Map<String, Object> row2)
+  {
+    // joined row
+    Map<String, Object> join = new HashMap<String, Object>();
+
+    // filter table1 columns
+    if (row1 != null) {
+      for (Index index: table1Columns) {
+        index.filter(row1, join);
+      }
+    }
+
+    // filter table1 columns
+    if (row2 != null) {
+      for (Index index: table2Columns) {
+        index.filter(row2, join);
+      }
+    }
+
+    // emit row
+    outport.emit(join);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/OrderByOperator.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/OrderByOperator.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/OrderByOperator.java
new file mode 100644
index 0000000..c7a5b25
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/OrderByOperator.java
@@ -0,0 +1,181 @@
+/**
+ * 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.contrib.misc.streamquery;
+
+import java.util.ArrayList;
+import java.util.Map;
+
+import com.datatorrent.api.Context.OperatorContext;
+import com.datatorrent.api.DefaultInputPort;
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.api.Operator;
+import com.datatorrent.api.Operator.Unifier;
+
+/**
+ *  An implementation of Operator that provides sql order by operator semantic over live stream data. <br>
+ * <p>
+ * Input data rows are ordered by order rules, ordered result is emitted on output port. <br>
+ * <br>
+ *  *  <br>
+ *  <b>StateFull : Yes,</b> Operator aggregates input over application window. <br>
+ *  <b>Partitions : Yes, </b> This operator is also unifier on output port. <br>
+ *  <br>
+ * <b>Ports</b>:<br>
+ * <b> inport : </b> Input hash map(row) port, expects HashMap&lt;String,Object&gt;<<br>
+ * <b> outport : </b> Output hash map(row) port, emits  HashMap&lt;String,Object&gt;<br>
+ * <br>
+ * <b> Properties : </b> <br>
+ * <b> orderByRules : </b>List of order by rules for tuples.
+ * @displayName OrderBy
+ * @category Stream Manipulators
+ * @tags orderby operator
+ * @since 0.3.5
+ * @deprecated
+ */
+@Deprecated
+public class OrderByOperator implements Operator, Unifier<Map<String, Object>>
+{
+  /**
+   * Order by rules.
+   */
+  ArrayList<OrderByRule<?>> orderByRules = new ArrayList<OrderByRule<?>>();
+
+  /**
+   * Descending flag.
+   */
+  private boolean isDescending;
+
+  /**
+   * collected rows.
+   */
+  private ArrayList<Map<String, Object>> rows;
+
+  /**
+   * Add order by rule.
+   */
+  public void addOrderByRule(OrderByRule<?> rule)
+  {
+    orderByRules.add(rule);
+  }
+
+  /**
+   * @return isDescending
+   */
+  public boolean isDescending()
+  {
+    return isDescending;
+  }
+
+  /**
+   * @param isDescending isDescending
+   */
+  public void setDescending(boolean isDescending)
+  {
+    this.isDescending = isDescending;
+  }
+
+  @Override
+  public void process(Map<String, Object> tuple)
+  {
+    rows.add(tuple);
+  }
+
+  @Override
+  public void beginWindow(long arg0)
+  {
+    rows = new ArrayList<Map<String, Object>>();
+  }
+
+  @Override
+  public void endWindow()
+  {
+    for (int i = 0; i < orderByRules.size(); i++) {
+      rows = orderByRules.get(i).sort(rows);
+    }
+    if (isDescending) {
+      for (int i = 0; i < rows.size(); i++) {
+        outport.emit(rows.get(i));
+      }
+    } else {
+      for (int i = rows.size() - 1; i >= 0; i--) {
+        outport.emit(rows.get(i));
+      }
+    }
+  }
+
+  @Override
+  public void setup(OperatorContext arg0)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  @Override
+  public void teardown()
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  /**
+   * Input port that takes a map of &lt;string,object&gt;.
+   */
+  public final transient DefaultInputPort<Map<String, Object>> inport = new DefaultInputPort<Map<String, Object>>()
+  {
+    @Override
+    public void process(Map<String, Object> tuple)
+    {
+      rows.add(tuple);
+    }
+  };
+
+  /**
+   * Output port that emits a map of &lt;string,object&gt;.
+   */
+  public final transient DefaultOutputPort<Map<String, Object>> outport = new DefaultOutputPort<Map<String, Object>>()
+  {
+    @Override
+    public Unifier<Map<String, Object>> getUnifier()
+    {
+      OrderByOperator unifier = new OrderByOperator();
+      for (int i = 0; i < getOrderByRules().size(); i++) {
+        unifier.addOrderByRule(getOrderByRules().get(i));
+      }
+      unifier.setDescending(isDescending);
+      return unifier;
+    }
+  };
+
+  /**
+   * @return the orderByRules
+   */
+  public ArrayList<OrderByRule<?>> getOrderByRules()
+  {
+    return orderByRules;
+  }
+
+  /**
+   * The order by rules used to order incoming tuples.
+   * @param oredrByRules the orderByRules to set
+   */
+  public void setOrderByRules(ArrayList<OrderByRule<?>> oredrByRules)
+  {
+    this.orderByRules = oredrByRules;
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/OrderByRule.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/OrderByRule.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/OrderByRule.java
new file mode 100644
index 0000000..cc90354
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/OrderByRule.java
@@ -0,0 +1,99 @@
+/**
+ * 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.contrib.misc.streamquery;
+
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ * Implements order by key name rule. <br>
+ * <p>
+ * <b>Properties : </b> <br>
+ * <b> columnName : </b> Name of column for ordering tuples. <br>
+ * @displayName OrderBy Rule
+ * @category Stream Manipulators
+ * @tags orderby, sort, comparison
+ * @since 0.3.3
+ * @deprecated
+ */
+@Deprecated
+@SuppressWarnings("rawtypes")
+public class OrderByRule<T extends Comparable>
+{
+
+  /**
+   * column name for ordering tuples.
+   */
+  private String columnName;
+
+  public OrderByRule(String name)
+  {
+
+    columnName = name;
+  }
+
+  /**
+   * sort rows by each rule and emit result on output port.
+   */
+  @SuppressWarnings("unchecked")
+  public ArrayList<Map<String, Object>> sort(ArrayList<Map<String, Object>> rows)
+  {
+
+    TreeMap<T, ArrayList<Map<String, Object>>> sorted = new TreeMap<T, ArrayList<Map<String, Object>>>();
+    for (int i = 0; i < rows.size(); i++) {
+      Map<String, Object> row = rows.get(i);
+      if (row.containsKey(columnName)) {
+        T value = (T)row.get(columnName);
+        ArrayList<Map<String, Object>> list;
+        if (sorted.containsKey(value)) {
+          list = sorted.get(value);
+        } else {
+          list = new ArrayList<Map<String, Object>>();
+          sorted.put(value, list);
+        }
+        list.add(row);
+      }
+    }
+    ArrayList<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
+    for (Map.Entry<T, ArrayList<Map<String, Object>>> entry : sorted.entrySet()) {
+      result.addAll(entry.getValue());
+    }
+    return result;
+  }
+
+  /**
+   * @return the columnName
+   */
+  public String getColumnName()
+  {
+
+    return columnName;
+  }
+
+  /**
+   * @param columnName
+   *          the columnName to set
+   */
+  public void setColumnName(String columnName)
+  {
+
+    this.columnName = columnName;
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/OuterJoinOperator.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/OuterJoinOperator.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/OuterJoinOperator.java
new file mode 100644
index 0000000..9a8fde8
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/OuterJoinOperator.java
@@ -0,0 +1,123 @@
+/**
+ * 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.contrib.misc.streamquery;
+
+/**
+ * An operator that provides sql left,right and full outer join metric semantics on live stream. <br>
+ * <p>
+ * Please refer to {@link org.apache.apex.malhar.lib.misc.streamquery.InnerJoinOperator} for
+ * details.
+ *
+ * <b> Properties : </b> <br>
+ * <b> isLeftJoin : </b> Left join flag. <br>
+ * <b> isFullJoin : </b> Full join flag. <br>
+ * @displayName Outer Join
+ * @category Stream Manipulators
+ * @tags sql, outer join operator
+ * @since 0.3.4
+ * @deprecated
+ */
+@Deprecated
+public class OuterJoinOperator extends InnerJoinOperator
+{
+
+  private boolean isLeftJoin = true;
+  private boolean isFullJoin = false;
+
+  @Override
+  public void endWindow()
+  {
+    // full outer join
+    if (isFullJoin) {
+      for (int i = 0; i < table1.size(); i++) {
+        boolean merged = false;
+        for (int j = 0; j < table2.size(); j++) {
+          if ((joinCondition == null)
+              || (joinCondition.isValidJoin(table1.get(i), table2.get(j)))) {
+            merged = true;
+          }
+        }
+        if (!merged) {
+          joinRows(table1.get(i), null);
+        }
+      }
+      for (int i = 0; i < table2.size(); i++) {
+        boolean merged = false;
+        for (int j = 0; j < table1.size(); j++) {
+          if ((joinCondition == null)
+              || (joinCondition.isValidJoin(table1.get(j), table2.get(i)))) {
+            merged = true;
+          }
+        }
+        if (!merged) { // only output non merged rows
+          joinRows(null, table2.get(i));
+        }
+      }
+      return;
+    }
+
+    // left or right join
+    if (isLeftJoin) {
+      for (int i = 0; i < table1.size(); i++) {
+        boolean merged = false;
+        for (int j = 0; j < table2.size(); j++) {
+          if ((joinCondition == null)
+              || (joinCondition.isValidJoin(table1.get(i), table2.get(j)))) {
+            merged = true;
+          }
+        }
+        if (!merged) {
+          joinRows(table1.get(i), null);
+        }
+      }
+    } else {
+      for (int i = 0; i < table2.size(); i++) {
+        boolean merged = false;
+        for (int j = 0; j < table1.size(); j++) {
+          if ((joinCondition == null) || (joinCondition.isValidJoin(table1.get(j), table2.get(i)))) {
+            merged = true;
+          }
+        }
+        if (!merged) { // only output non merged rows
+          joinRows(null, table2.get(i));
+        }
+      }
+    }
+  }
+
+  public void setLeftJoin()
+  {
+    isLeftJoin = true;
+  }
+
+  public void setRighttJoin()
+  {
+    isLeftJoin = false;
+  }
+
+  public boolean isFullJoin()
+  {
+    return isFullJoin;
+  }
+
+  public void setFullJoin(boolean isFullJoin)
+  {
+    this.isFullJoin = isFullJoin;
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/SelectFunctionOperator.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/SelectFunctionOperator.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/SelectFunctionOperator.java
new file mode 100644
index 0000000..6e8008b
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/SelectFunctionOperator.java
@@ -0,0 +1,129 @@
+/**
+ * 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.contrib.misc.streamquery;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.apex.malhar.contrib.misc.streamquery.function.FunctionIndex;
+
+import com.datatorrent.api.Context.OperatorContext;
+import com.datatorrent.api.DefaultInputPort;
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.api.Operator;
+import com.datatorrent.api.annotation.OperatorAnnotation;
+
+/**
+ *  An implementation of Operator that applies sql top or limit semantics on incoming tuple(s). <br>
+ * <p>
+ * <b>StateFull : Yes,</b> Operator aggregates input over application window. <br>
+ * <b>Partitions : No, </b> will yield wrong result(s). <br>
+ * <br>
+ * <b>Ports : </b> <br>
+ * <b>inport : </b> expect tuple for type T. <br>
+ * <b>outport : </b> emits tuple for type T. <br>
+ * <br>
+ * <b> Properties : </b> <br>
+ * <b> functions : </b> Sql function for rows. <br>
+ * @displayName Select Function
+ * @category Stream Manipulators
+ * @tags sql top, sql limit, sql select operator
+ * @since 0.3.4
+ * @deprecated
+ */
+@Deprecated
+@OperatorAnnotation(partitionable = false)
+public class SelectFunctionOperator implements Operator
+{
+  /**
+   * array of rows.
+   */
+  private ArrayList<Map<String, Object>> rows;
+
+  /**
+   * Aggregate function for rows.
+   */
+  private ArrayList<FunctionIndex> functions = new ArrayList<FunctionIndex>();
+
+  /**
+   * Input port that takes a map of &lt;string,object&gt;.
+   */
+  public final transient DefaultInputPort<Map<String, Object>> inport = new DefaultInputPort<Map<String, Object>>()
+  {
+
+    @Override
+    public void process(Map<String, Object> row)
+    {
+      rows.add(row);
+    }
+  };
+
+  @Override
+  public void setup(OperatorContext context)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  @Override
+  public void teardown()
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  @Override
+  public void beginWindow(long windowId)
+  {
+    rows = new ArrayList<Map<String, Object>>();
+  }
+
+  @Override
+  public void endWindow()
+  {
+    if (functions.size() == 0) {
+      return;
+    }
+    Map<String, Object>  collect = new HashMap<String, Object>();
+    for (FunctionIndex function : functions) {
+      try {
+        function.filter(rows, collect);
+      } catch (Exception e) {
+        e.printStackTrace();
+        return;
+      }
+    }
+    outport.emit(collect);
+  }
+
+  /**
+   * Output port that emits a map of &lt;string,object&gt;.
+   */
+  public final transient DefaultOutputPort<Map<String, Object>> outport = new DefaultOutputPort<Map<String, Object>>();
+
+  /**
+   * Add sql function.
+   * @param function  Sql function for rows.
+   */
+  public void addSqlFunction(FunctionIndex function)
+  {
+    functions.add(function);
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/SelectOperator.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/SelectOperator.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/SelectOperator.java
new file mode 100644
index 0000000..08799cb
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/SelectOperator.java
@@ -0,0 +1,113 @@
+/**
+ * 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.contrib.misc.streamquery;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.datatorrent.api.DefaultInputPort;
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.common.util.BaseOperator;
+import com.datatorrent.lib.streamquery.condition.Condition;
+import com.datatorrent.lib.streamquery.index.Index;
+
+/**
+ * An implementation of that provides sql select query semantics on live data stream. <br>
+ * <p>
+ * Stream rows passing condition are emitted on output port stream. <br>
+ * <br>
+ * <b>StateFull : NO,</b> all row data is processed in current time window. <br>
+ * <b>Partitions : Yes, </b> No Input dependency among input rows. <br>
+ * <br>
+ * <b>Ports</b>:<br>
+ * <b> inport : </b> Input hash map(row) port, expects
+ * HashMap&lt;String,Object&gt;<<br>
+ * <b> outport : </b> Output hash map(row) port, emits
+ * HashMap&lt;String,Object&gt;<br>
+ * <br>
+ * <b> Properties : <b> <br>
+ * <b> condition : </b> Select condition for selecting rows. <br>
+ * <b> columns : </b> Column names/aggregate functions for select. <br>
+ * <br>
+ * @displayName Select
+ * @category Stream Manipulators
+ * @tags sql select operator, index, sql condition
+ * @since 0.3.3
+ * @deprecated
+ */
+@Deprecated
+public class SelectOperator extends BaseOperator
+{
+
+  /**
+   * select columns/expression;
+   */
+  private ArrayList<Index> indexes = new ArrayList<Index>();
+
+  /**
+   * condition.
+   */
+  private Condition condition = null;
+
+  /**
+   * add index.
+   */
+  public void addIndex(Index index)
+  {
+    indexes.add(index);
+  }
+
+  /**
+   * set condition.
+   */
+  public void setCondition(Condition condition)
+  {
+    this.condition = condition;
+  }
+
+  /**
+   * Input port that takes a map of &lt;string,object&gt;.
+   */
+  public final transient DefaultInputPort<Map<String, Object>> inport = new DefaultInputPort<Map<String, Object>>()
+  {
+
+    @Override
+    public void process(Map<String, Object> tuple)
+    {
+      if ((condition != null) && (!condition.isValidRow(tuple))) {
+        return;
+      }
+      if (indexes.size() == 0) {
+        outport.emit(tuple);
+        return;
+      }
+      Map<String, Object> result = new HashMap<String, Object>();
+      for (int i = 0; i < indexes.size(); i++) {
+        indexes.get(i).filter(tuple, result);
+      }
+      outport.emit(result);
+    }
+  };
+
+  /**
+   * Output port that emits a map of &lt;string,object&gt;.
+   */
+  public final transient DefaultOutputPort<Map<String, Object>> outport = new DefaultOutputPort<Map<String, Object>>();
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/SelectTopOperator.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/SelectTopOperator.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/SelectTopOperator.java
new file mode 100644
index 0000000..2880198
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/SelectTopOperator.java
@@ -0,0 +1,131 @@
+/**
+ * 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.contrib.misc.streamquery;
+
+import java.util.ArrayList;
+import java.util.Map;
+
+import com.datatorrent.api.Context.OperatorContext;
+import com.datatorrent.api.DefaultInputPort;
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.api.Operator;
+
+/**
+ * An implementation of Operator that provides sql top select query semantic on live data stream. <br>
+ * <p>
+ * Stream rows passing condition are emitted on output port stream. <br>
+ * <br>
+ * <b>StateFull : NO,</b> all row data is processed in current time window. <br>
+ * <b>Partitions : Yes, </b> No Input dependency among input rows. <br>
+ * <br>
+ * <b>Ports</b>:<br>
+ * <b> inport : </b> Input hash map(row) port, expects
+ * HashMap&lt;String,Object&gt;<<br>
+ * <b> outport : </b> Output hash map(row) port, emits
+ * HashMap&lt;String,Object&gt;<br>
+ * <br>
+ * <b> Properties : <b> <br>
+ * <b> topValue : </b> top values count. <br>
+ * <b> isPercentage : </b> top values count is percentage flag.
+ * <br>
+ * @displayName Select Top
+ * @category Stream Manipulators
+ * @tags sql select, sql top operator
+ *  @since 0.3.4
+ *  @deprecated
+ */
+@Deprecated
+public class SelectTopOperator implements Operator
+{
+  private ArrayList<Map<String, Object>> list;
+  private int topValue = 1;
+  private boolean isPercentage = false;
+
+  /**
+   * Input port that takes a map of &lt;string,object&gt;.
+   */
+  public final transient DefaultInputPort<Map<String, Object>> inport = new DefaultInputPort<Map<String, Object>>()
+  {
+    @Override
+    public void process(Map<String, Object> tuple)
+    {
+      list.add(tuple);
+    }
+  };
+
+  @Override
+  public void setup(OperatorContext context)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  @Override
+  public void teardown()
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  @Override
+  public void beginWindow(long windowId)
+  {
+    list = new ArrayList<Map<String, Object>>();
+  }
+
+  @Override
+  public void endWindow()
+  {
+    int numEmits = topValue;
+    if (isPercentage) {
+      numEmits = list.size() * (topValue / 100);
+    }
+    for (int i = 0; (i < numEmits) && (i < list.size()); i++) {
+      outport.emit(list.get(i));
+    }
+  }
+
+  public int getTopValue()
+  {
+    return topValue;
+  }
+
+  public void setTopValue(int topValue) throws Exception
+  {
+    if (topValue <= 0) {
+      throw new Exception("Top value must be positive number.");
+    }
+    this.topValue = topValue;
+  }
+
+  public boolean isPercentage()
+  {
+    return isPercentage;
+  }
+
+  public void setPercentage(boolean isPercentage)
+  {
+    this.isPercentage = isPercentage;
+  }
+
+  /**
+   * Output port that emits a map of &lt;string,object&gt;.
+   */
+  public final transient DefaultOutputPort<Map<String, Object>> outport =  new DefaultOutputPort<Map<String, Object>>();
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/UpdateOperator.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/UpdateOperator.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/UpdateOperator.java
new file mode 100644
index 0000000..52ddac6
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/UpdateOperator.java
@@ -0,0 +1,111 @@
+/**
+ * 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.contrib.misc.streamquery;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.datatorrent.api.DefaultInputPort;
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.common.util.BaseOperator;
+import com.datatorrent.lib.streamquery.condition.Condition;
+
+/**
+ *  An implementation of BaseOperator that provides sql update query semantic on live data stream. <br>
+ *  <p>
+ *  Stream rows passing condition are emitted on output port stream. <br>
+ *  <br>
+ *  <b>StateFull : NO,</b> all row data is processed in current time window. <br>
+ *  <b>Partitions : Yes, </b> No Input dependency among input rows. <br>
+ *  <br>
+ * <b>Ports</b>:<br>
+ * <b> inport : </b> Input hash map(row) port, expects HashMap&lt;String,Object&gt;<<br>
+ * <b> outport : </b> Output hash map(row) port, emits  HashMap&lt;String,Object&gt;<br>
+ * <br>
+ * <b> Properties : <b> <br>
+ * <b> condition : </b> Select condition for selecting rows. <br>
+ * <b> columns : </b> Column names/aggregate functions for select. <br>
+ * <br>
+ * @displayName Update
+ * @category Stream Manipulators
+ * @tags sql update operator, sql condition
+ * @since 0.3.3
+ * @deprecated
+ */
+@Deprecated
+public class UpdateOperator extends BaseOperator
+{
+  /**
+   * Update value map.
+   */
+  Map<String, Object> updates = new HashMap<String, Object>();
+
+  /**
+   *  condition.
+   */
+  private Condition condition = null;
+
+  /**
+   * set condition.
+   */
+  public void setCondition(Condition condition)
+  {
+    this.condition = condition;
+  }
+
+  /**
+   * Input port that takes a map of &lt;string,object&gt;.
+   */
+  public final transient DefaultInputPort<Map<String, Object>> inport = new DefaultInputPort<Map<String, Object>>()
+  {
+    @Override
+    public void process(Map<String, Object> tuple)
+    {
+      if ((condition != null) && (!condition.isValidRow(tuple))) {
+        return;
+      }
+      if (updates.size() == 0) {
+        outport.emit(tuple);
+        return;
+      }
+      Map<String, Object> result = new HashMap<String, Object>();
+      for (Map.Entry<String, Object> entry : tuple.entrySet()) {
+        if (updates.containsKey(entry.getKey())) {
+          result.put(entry.getKey(), updates.get(entry.getKey()));
+        } else {
+          result.put(entry.getKey(), entry.getValue());
+        }
+      }
+      outport.emit(result);
+    }
+  };
+
+  /**
+   * Output port that emits a map of &lt;string,object&gt;.
+   */
+  public final transient DefaultOutputPort<Map<String, Object>> outport =  new DefaultOutputPort<Map<String, Object>>();
+
+  /**
+   * Add update value.
+   */
+  public void addUpdate(String name, Object value)
+  {
+    updates.put(name, value);
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/condition/BetweenCondition.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/condition/BetweenCondition.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/condition/BetweenCondition.java
new file mode 100644
index 0000000..155470c
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/condition/BetweenCondition.java
@@ -0,0 +1,107 @@
+/**
+ * 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.contrib.misc.streamquery.condition;
+
+import java.util.Map;
+
+import javax.validation.constraints.NotNull;
+
+import com.datatorrent.lib.streamquery.condition.Condition;
+
+/**
+ *  A derivation of Condition that validates row by checking if the given column name value lies between given left,right range. <br>
+ * <p>
+ * <b>Properties : </b> <br>
+ * <b> column : </b> Name of column. <br>
+ * <b> leftValue : </b> left range of column value. <br>
+ * <b> rightValue : </b> right range od column value. <br>
+ * <br>
+ * @displayName Between Condition
+ * @category Stream Manipulators
+ * @tags sql condition
+ * @since 0.3.4
+ * @deprecated
+ */
+@Deprecated
+public class BetweenCondition extends Condition
+{
+  /**
+   * Column name to be checked.
+   */
+  @NotNull
+  private String column;
+
+  /**
+   * Left range value.
+   */
+  @NotNull
+  private Object leftValue;
+
+  /**
+   * Right range value.
+   */
+  @NotNull
+  private Object rightValue;
+
+  /**
+   * @param  column  Name of column, must be non null. <br>
+   * @param  leftValue  Left range for value, mut be non null. <br>
+   * @param  rightValue  right range for value, mut be non null. <br>
+   */
+  public BetweenCondition(@NotNull String column, @NotNull  Object leftValue, @NotNull Object rightValue)
+  {
+    this.column = column;
+    this.leftValue = leftValue;
+    this.rightValue = rightValue;
+  }
+
+  /**
+   * Validate given row.
+   */
+  @SuppressWarnings({"rawtypes", "unchecked"})
+  @Override
+  public boolean isValidRow(@NotNull Map<String, Object> row)
+  {
+    if (!row.containsKey(column)) {
+      return false;
+    }
+    Object value = row.get(column);
+    if (value == null) {
+      return false;
+    }
+    if (((Comparable)value).compareTo((Comparable)leftValue) < 0) {
+      return false;
+    }
+    if (((Comparable)value).compareTo((Comparable)rightValue) > 0) {
+      return false;
+    }
+    return true;
+  }
+
+  /**
+   * Must not be called.
+   */
+  @Override
+  public boolean isValidJoin(@NotNull Map<String, Object> row1, Map<String, Object> row2)
+  {
+    assert (false);
+    return false;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/condition/CompoundCondition.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/condition/CompoundCondition.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/condition/CompoundCondition.java
new file mode 100644
index 0000000..d606991
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/condition/CompoundCondition.java
@@ -0,0 +1,132 @@
+/**
+ * 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.contrib.misc.streamquery.condition;
+
+import java.util.Map;
+
+import javax.validation.constraints.NotNull;
+
+import com.datatorrent.lib.streamquery.condition.Condition;
+
+/**
+ * A derivation of Condition index that implements logical AND/OR select expression. <br>
+ * <p>
+ * Class provides logical OR or AND function specified in parameters. User can implement
+ * complex and/or expression by chaining operator itself.
+ * <br>
+ * <b> Properties : </b> <br>
+ * <b> leftCondition : </b> Left validate row condition . <br>
+ * <b> rightCondition : </b> Right validate row condition. <br>
+ * <b> logicalOr : </b> OR/AND logical metric flag. <br>
+ * <br>
+ * @displayName Compound Condition
+ * @category Stream Manipulators
+ * @tags sql condition, logical
+ * @since 0.3.4
+ * @deprecated
+ */
+@Deprecated
+public class CompoundCondition extends Condition
+{
+  /**
+   * Left validate row condition .
+   */
+  @NotNull
+  private Condition leftCondition;
+
+  /**
+   * Right validate row condition .
+   */
+  @NotNull
+  private Condition rightCondition;
+
+  /**
+   * AND/OR metric flag.
+   */
+  private boolean logicalOr = true;
+
+  /**
+   * Constructor for logical or metric.
+   *
+   * @param leftCondition  Left validate row condition, must be non null. <br>
+   * @param rightCondition Right validate row condition, must be non null. <br>
+   */
+  public CompoundCondition(Condition leftCondition, Condition rightCondition)
+  {
+    this.leftCondition = leftCondition;
+    this.rightCondition = rightCondition;
+  }
+
+  /**
+   * Constructor for logical and metric if logical and parameter is true.
+   * <br>
+   *
+   * @param leftCondition  Left validate row condition, must be non null. <br>
+   * @param rightCondition Right validate row condition, must be non null. <br>
+   * @param isLogicalAnd   Logical AND if true.
+   */
+  public CompoundCondition(Condition leftCondition, Condition rightCondition, boolean isLogicalAnd)
+  {
+    this.leftCondition = leftCondition;
+    this.rightCondition = rightCondition;
+    logicalOr = !isLogicalAnd;
+  }
+
+  @Override
+  public boolean isValidRow(Map<String, Object> row)
+  {
+    if (logicalOr) {
+      return leftCondition.isValidRow(row) || rightCondition.isValidRow(row);
+    } else {
+      return leftCondition.isValidRow(row) && rightCondition.isValidRow(row);
+    }
+  }
+
+  @Override
+  public boolean isValidJoin(Map<String, Object> row1, Map<String, Object> row2)
+  {
+    // TODO Auto-generated method stub
+    return false;
+  }
+
+  public Condition getLeftCondition()
+  {
+    return leftCondition;
+  }
+
+  public void setLeftCondition(Condition leftCondition)
+  {
+    this.leftCondition = leftCondition;
+  }
+
+  public Condition getRightCondition()
+  {
+    return rightCondition;
+  }
+
+  public void setRightCondition(Condition rightCondition)
+  {
+    this.rightCondition = rightCondition;
+  }
+
+  public void setLogicalAnd()
+  {
+    this.logicalOr = false;
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/condition/EqualValueCondition.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/condition/EqualValueCondition.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/condition/EqualValueCondition.java
new file mode 100644
index 0000000..a54960d
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/condition/EqualValueCondition.java
@@ -0,0 +1,99 @@
+/**
+ * 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.contrib.misc.streamquery.condition;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.datatorrent.lib.streamquery.condition.Condition;
+
+/**
+ * An implementation of condition on column equality.
+ * <p>
+ * A valid row must have all key/value map in column name/value map.
+ *
+ * <b> Properties : </b> <br>
+ *  <b> equalMap : </b> Column equal value map store.
+ * @displayName Equal Value Condition
+ * @category Stream Manipulators
+ * @tags sql condition
+ * @since 0.3.4
+ * @deprecated
+ */
+@Deprecated
+public class EqualValueCondition extends Condition
+{
+
+  /**
+   * Equal column map.
+   */
+  private HashMap<String, Object> equalMap = new HashMap<String, Object>();
+
+  /**
+   * Add column equal condition.
+   */
+  public void addEqualValue(String column, Object value)
+  {
+    equalMap.put(column, value);
+  }
+
+  /**
+   * Check valid row.
+   */
+  @Override
+  public boolean isValidRow(Map<String, Object> row)
+  {
+    // no conditions
+    if (equalMap.size() == 0) {
+      return true;
+    }
+
+    // compare each condition value
+    for (Map.Entry<String, Object> entry : equalMap.entrySet()) {
+      if (!row.containsKey(entry.getKey())) {
+        return false;
+      }
+      Object value = row.get(entry.getKey());
+      if (entry.getValue() == null) {
+        if (value == null) {
+          return true;
+        }
+        return false;
+      }
+      if (value == null) {
+        return false;
+      }
+      if (!entry.getValue().equals(value)) {
+        return false;
+      }
+    }
+    return true;
+  }
+
+  /**
+   * check valid join, not implemented
+   *
+   * @return false
+   */
+  @Override
+  public boolean isValidJoin(Map<String, Object> row1, Map<String, Object> row2)
+  {
+    return false;
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/condition/HavingCompareValue.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/condition/HavingCompareValue.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/condition/HavingCompareValue.java
new file mode 100644
index 0000000..6e0400b
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/condition/HavingCompareValue.java
@@ -0,0 +1,79 @@
+/**
+ * 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.contrib.misc.streamquery.condition;
+
+import java.util.ArrayList;
+import java.util.Map;
+
+import javax.validation.constraints.NotNull;
+
+import org.apache.apex.malhar.contrib.misc.streamquery.function.FunctionIndex;
+
+/**
+ *  A derivation of HavingCondition that implements comparison of aggregate index value to input compare value. <br>
+ * <p>
+ * Compare value must implement interface Comparable. <br>
+ * <br>
+ * <b> Properties : </b>
+ *  <b> compareValue : </b>  Value to be compared. <br>
+ *  <b>  compareType : </b> Type of comparison -1 == lt, 0 == eq, 1 == gt. <br>
+ * @displayName Having Compare Value
+ * @category Stream Manipulators
+ * @tags compare, sql condition
+ * @since 0.3.4
+ * @deprecated
+ */
+@Deprecated
+@SuppressWarnings("rawtypes")
+public class HavingCompareValue<T extends Comparable> extends HavingCondition
+{
+  /**
+   * Value to be compared.
+   */
+  private T compareValue;
+
+  /**
+   * Type of comparison -1 == lt, 0 == eq, 1 == gt.
+   */
+  private int compareType;
+
+  /**
+   * @param aggregateIndex   aggregate index for comparison. <br>
+   * @param compareValue     Value to be compared. <br>
+   * @param compareType    Type of comparison -1 == lt, 0 == eq, 1 == gt. <br>
+   */
+  public HavingCompareValue(FunctionIndex aggregateIndex, T compareValue, int compareType)
+  {
+    super(aggregateIndex);
+    this.compareValue = compareValue;
+    this.compareType  = compareType;
+  }
+
+  /**
+   * Validate aggregate override. <br>
+   */
+  @SuppressWarnings("unchecked")
+  @Override
+  public boolean isValidAggregate(@NotNull ArrayList<Map<String, Object>> rows) throws Exception
+  {
+    Object computed = aggregateIndex.compute(rows);
+    return (compareType == compareValue.compareTo(computed));
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/condition/HavingCondition.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/condition/HavingCondition.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/condition/HavingCondition.java
new file mode 100644
index 0000000..66ef35c
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/condition/HavingCondition.java
@@ -0,0 +1,58 @@
+/**
+ * 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.contrib.misc.streamquery.condition;
+
+import java.util.ArrayList;
+import java.util.Map;
+
+import javax.validation.constraints.NotNull;
+
+import org.apache.apex.malhar.contrib.misc.streamquery.function.FunctionIndex;
+
+/**
+ *  A base class for Group,Having operator with aggregate index constraint.&nsbsp; Subclasses should provide the
+    implementation to check if aggregate is valid.
+ * <p>
+ * @displayName Having Condition
+ * @category Stream Manipulators
+ * @tags sql condition, index, group
+ * @since 0.3.4
+ * @deprecated
+ */
+@Deprecated
+public abstract class HavingCondition
+{
+  /**
+   * Aggregate index to be validated.
+   */
+  protected FunctionIndex aggregateIndex = null;
+
+  /**
+   * @param aggregateIndex Aggregate index to be validated.
+   */
+  public HavingCondition(FunctionIndex aggregateIndex)
+  {
+    this.aggregateIndex = aggregateIndex;
+  }
+
+  /**
+   *  Check if aggregate is valid.
+   */
+  public abstract boolean isValidAggregate(@NotNull ArrayList<Map<String, Object>> rows) throws Exception;
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/condition/InCondition.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/condition/InCondition.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/condition/InCondition.java
new file mode 100644
index 0000000..d19bb99
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/condition/InCondition.java
@@ -0,0 +1,94 @@
+/**
+ * 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.contrib.misc.streamquery.condition;
+
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.validation.constraints.NotNull;
+
+import com.datatorrent.lib.streamquery.condition.Condition;
+
+/**
+ * An implementation of condition class to check if a column value is in a given set of values.
+ * <p>
+ * <br>
+ * <b>Properties : </b> <br>
+ * <b> column : </b> Column name for which value is checked in values set. <br>
+ * <b> inValues : </b> Set of values in which column value is checked. <br>
+ * @displayName In Condition
+ * @category Stream Manipulators
+ * @tags sql condition
+ * @since 0.3.4
+ * @deprecated
+ */
+@Deprecated
+public class InCondition extends Condition
+{
+  /**
+   * Column name for which value is checked in values set.
+   */
+  @NotNull
+  private String column;
+
+  /**
+   * Set of values in which column value is checked.
+   */
+  private Set<Object> inValues = new HashSet<Object>();
+
+  /**
+   * @param column Column name for which value is checked in values set.
+   */
+  public InCondition(@NotNull String column)
+  {
+    this.column = column;
+  }
+
+  @Override
+  public boolean isValidRow(@NotNull Map<String, Object> row)
+  {
+    if (!row.containsKey(column)) {
+      return false;
+    }
+    return inValues.contains(row.get(column));
+  }
+
+  @Override
+  public boolean isValidJoin(@NotNull Map<String, Object> row1, @NotNull Map<String, Object> row2)
+  {
+    return false;
+  }
+
+  public String getColumn()
+  {
+    return column;
+  }
+
+  public void setColumn(String column)
+  {
+    this.column = column;
+  }
+
+  public void addInValue(Object value)
+  {
+    this.inValues.add(value);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/condition/LikeCondition.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/condition/LikeCondition.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/condition/LikeCondition.java
new file mode 100644
index 0000000..a8789fa
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/condition/LikeCondition.java
@@ -0,0 +1,105 @@
+/**
+ * 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.contrib.misc.streamquery.condition;
+
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.validation.constraints.NotNull;
+
+import com.datatorrent.lib.streamquery.condition.Condition;
+
+/**
+ * An implementation of condition class to filter rows for which given column name value matches given regular expression. <br>
+ *<p>
+ *<b> Properties : </b> <br>
+ *<b> column : < /b> Column to be matched with regular expression. <br>
+ *<b> pattern : </b> Regular expression pattern.<br>
+ * @displayName Like Condition
+ * @category Stream Manipulators
+ * @tags sql, like condition, regular expression
+ * @since 0.3.4
+ * @deprecated
+ */
+@Deprecated
+public class LikeCondition extends Condition
+{
+  /**
+   * Column to be matched with regular expression.
+   */
+  @NotNull
+  private String column;
+
+  /**
+   * Regular expression pattern.
+   */
+  @NotNull
+  private Pattern pattern;
+
+  /**
+   * @param column Column to be matched with regular expression, must be non-null.
+   * @param pattern Regular expression pattern, must be non-null.
+   */
+  public LikeCondition(@NotNull String column,@NotNull String pattern)
+  {
+    setColumn(column);
+    setPattern(pattern);
+  }
+
+  /**
+   * For valid row column value string must match regular expression.
+   * @return row valid status.
+   */
+  @Override
+  public boolean isValidRow(Map<String, Object> row)
+  {
+    if (!row.containsKey(column)) {
+      return false;
+    }
+    Matcher match = pattern.matcher((CharSequence)row.get(column));
+    return match.find();
+  }
+
+  /**
+   * Must not be called.
+   */
+  @Override
+  public boolean isValidJoin(Map<String, Object> row1, Map<String, Object> row2)
+  {
+    assert (false);
+    return false;
+  }
+
+  public String getColumn()
+  {
+    return column;
+  }
+
+  public void setColumn(String column)
+  {
+    this.column = column;
+  }
+
+  public void setPattern(String pattern)
+  {
+    this.pattern = Pattern.compile(pattern);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/function/AverageFunction.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/function/AverageFunction.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/function/AverageFunction.java
new file mode 100644
index 0000000..72ac59f
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/streamquery/function/AverageFunction.java
@@ -0,0 +1,82 @@
+/**
+ * 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.contrib.misc.streamquery.function;
+
+import java.util.ArrayList;
+import java.util.Map;
+
+import javax.validation.constraints.NotNull;
+
+import org.apache.commons.lang.StringUtils;
+
+/**
+ * An implementation of function index that implements average function semantics. <br>
+ * <p>
+ *   e.g : sql => SELECT AVG(column_name) FROM table_name. <br>
+ *   <br>
+ *   <b> Properties : </b> <br>
+ *   <b> column : </b> Aggregate over given column values.   <br>
+ *   <b> alias  : </b> Alias name for aggregate output. <br>
+ * @displayName Average Function
+ * @category Stream Manipulators
+ * @tags sql average
+ * @since 0.3.4
+ * @deprecated
+ */
+@Deprecated
+public class AverageFunction extends FunctionIndex
+{
+  /**
+   * @param column Aggregate over given column values, must be non null.
+   * @param alias  Alias name for aggregate output.
+   */
+  public AverageFunction(@NotNull String column, String alias)
+  {
+    super(column, alias);
+  }
+
+  /**
+   * Compute average for given column values.
+   */
+  @Override
+  public Object compute(@NotNull ArrayList<Map<String, Object>> rows) throws Exception
+  {
+    if (rows.size() == 0) {
+      return 0.0;
+    }
+    double sum = 0.0;
+    for (Map<String, Object> row : rows) {
+      sum += ((Number)row.get(column)).doubleValue();
+    }
+    return sum / rows.size();
+  }
+
+  /**
+   * Get aggregate name.
+   * @return name.
+   */
+  @Override
+  protected String aggregateName()
+  {
+    if (!StringUtils.isEmpty(alias)) {
+      return alias;
+    }
+    return "AVG(" + column + ")";
+  }
+}


[02/12] apex-malhar git commit: Updated algo & working on math operators

Posted by th...@apache.org.
http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/math/AverageTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/math/AverageTest.java b/library/src/test/java/com/datatorrent/lib/math/AverageTest.java
index 1973bec..712bcdc 100644
--- a/library/src/test/java/com/datatorrent/lib/math/AverageTest.java
+++ b/library/src/test/java/com/datatorrent/lib/math/AverageTest.java
@@ -21,6 +21,8 @@ package com.datatorrent.lib.math;
 import org.junit.Assert;
 import org.junit.Test;
 
+import com.datatorrent.common.util.Pair;
+
 import com.datatorrent.lib.testbench.CollectorTestSink;
 
 /**
@@ -96,7 +98,7 @@ public class AverageTest
 
     Assert.assertEquals("number emitted tuples", 1, averageSink.collectedTuples.size());
     for (Object o : averageSink.collectedTuples) { // count is 12
-      Integer val = ((Number)o).intValue();
+      Number val = ((Pair<? extends Number, Integer>)o).getFirst().intValue();
       Assert.assertEquals("emitted average value was was ", new Integer(1157 / 12), val);
     }
   }

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/math/ChangeAlertKeyValTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/math/ChangeAlertKeyValTest.java b/library/src/test/java/com/datatorrent/lib/math/ChangeAlertKeyValTest.java
deleted file mode 100644
index 7d7842e..0000000
--- a/library/src/test/java/com/datatorrent/lib/math/ChangeAlertKeyValTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/**
- * 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 com.datatorrent.lib.math;
-
-import org.junit.Assert;
-
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.datatorrent.lib.testbench.CollectorTestSink;
-import com.datatorrent.lib.util.KeyValPair;
-
-/**
- *
- * Functional tests for {@link com.datatorrent.lib.math.ChangeAlertKeyVal}.
- * <p>
- *
- */
-public class ChangeAlertKeyValTest
-{
-  private static Logger log = LoggerFactory
-      .getLogger(ChangeAlertKeyValTest.class);
-
-  /**
-   * Test node logic emits correct results.
-   */
-  @Test
-  public void testNodeProcessing() throws Exception
-  {
-    testNodeProcessingSchema(new ChangeAlertKeyVal<String, Integer>());
-    testNodeProcessingSchema(new ChangeAlertKeyVal<String, Double>());
-    testNodeProcessingSchema(new ChangeAlertKeyVal<String, Float>());
-    testNodeProcessingSchema(new ChangeAlertKeyVal<String, Short>());
-    testNodeProcessingSchema(new ChangeAlertKeyVal<String, Long>());
-  }
-
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  public <V extends Number> void testNodeProcessingSchema(
-      ChangeAlertKeyVal<String, V> oper)
-  {
-    CollectorTestSink alertSink = new CollectorTestSink();
-
-    oper.alert.setSink(alertSink);
-    oper.setPercentThreshold(5);
-
-    oper.beginWindow(0);
-    oper.data.process(new KeyValPair<String, V>("a", oper.getValue(200)));
-    oper.data.process(new KeyValPair<String, V>("b", oper.getValue(10)));
-    oper.data.process(new KeyValPair<String, V>("c", oper.getValue(100)));
-
-    oper.data.process(new KeyValPair<String, V>("a", oper.getValue(203)));
-    oper.data.process(new KeyValPair<String, V>("b", oper.getValue(12)));
-    oper.data.process(new KeyValPair<String, V>("c", oper.getValue(101)));
-
-    oper.data.process(new KeyValPair<String, V>("a", oper.getValue(210)));
-    oper.data.process(new KeyValPair<String, V>("b", oper.getValue(12)));
-    oper.data.process(new KeyValPair<String, V>("c", oper.getValue(102)));
-
-    oper.data.process(new KeyValPair<String, V>("a", oper.getValue(231)));
-    oper.data.process(new KeyValPair<String, V>("b", oper.getValue(18)));
-    oper.data.process(new KeyValPair<String, V>("c", oper.getValue(103)));
-    oper.endWindow();
-
-    // One for a, Two for b
-    Assert.assertEquals("number emitted tuples", 3,
-        alertSink.collectedTuples.size());
-
-    double aval = 0;
-    double bval = 0;
-    log.debug("\nLogging tuples");
-    for (Object o : alertSink.collectedTuples) {
-      KeyValPair<String, KeyValPair<Number, Double>> map = (KeyValPair<String, KeyValPair<Number, Double>>)o;
-
-      log.debug(o.toString());
-      if (map.getKey().equals("a")) {
-        KeyValPair<Number, Double> vmap = map.getValue();
-        if (vmap != null) {
-          aval += vmap.getValue().doubleValue();
-        }
-      } else {
-        KeyValPair<Number, Double> vmap = map.getValue();
-        if (vmap != null) {
-          bval += vmap.getValue().doubleValue();
-        }
-      }
-    }
-    Assert.assertEquals("change in a", 10.0, aval,0);
-    Assert.assertEquals("change in a", 70.0, bval,0);
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/math/ChangeAlertMapTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/math/ChangeAlertMapTest.java b/library/src/test/java/com/datatorrent/lib/math/ChangeAlertMapTest.java
deleted file mode 100644
index 51f52f0..0000000
--- a/library/src/test/java/com/datatorrent/lib/math/ChangeAlertMapTest.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/**
- * 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 com.datatorrent.lib.math;
-
-import java.util.HashMap;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-/**
- *
- * Functional tests for {@link com.datatorrent.lib.math.ChangeAlertMap}.
- * <p>
- *
- */
-public class ChangeAlertMapTest
-{
-  private static Logger log = LoggerFactory.getLogger(ChangeAlertMapTest.class);
-
-  /**
-   * Test node logic emits correct results.
-   */
-  @Test
-  public void testNodeProcessing() throws Exception
-  {
-    testNodeProcessingSchema(new ChangeAlertMap<String, Integer>());
-    testNodeProcessingSchema(new ChangeAlertMap<String, Double>());
-    testNodeProcessingSchema(new ChangeAlertMap<String, Float>());
-    testNodeProcessingSchema(new ChangeAlertMap<String, Short>());
-    testNodeProcessingSchema(new ChangeAlertMap<String, Long>());
-  }
-
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  public <V extends Number> void testNodeProcessingSchema(
-      ChangeAlertMap<String, V> oper)
-  {
-    CollectorTestSink alertSink = new CollectorTestSink();
-
-    oper.alert.setSink(alertSink);
-    oper.setPercentThreshold(5);
-
-    oper.beginWindow(0);
-    HashMap<String, V> input = new HashMap<String, V>();
-    input.put("a", oper.getValue(200));
-    input.put("b", oper.getValue(10));
-    input.put("c", oper.getValue(100));
-    oper.data.process(input);
-
-    input.clear();
-    input.put("a", oper.getValue(203));
-    input.put("b", oper.getValue(12));
-    input.put("c", oper.getValue(101));
-    oper.data.process(input);
-
-    input.clear();
-    input.put("a", oper.getValue(210));
-    input.put("b", oper.getValue(12));
-    input.put("c", oper.getValue(102));
-    oper.data.process(input);
-
-    input.clear();
-    input.put("a", oper.getValue(231));
-    input.put("b", oper.getValue(18));
-    input.put("c", oper.getValue(103));
-    oper.data.process(input);
-    oper.endWindow();
-
-    // One for a, Two for b
-    Assert.assertEquals("number emitted tuples", 3,
-        alertSink.collectedTuples.size());
-
-    double aval = 0;
-    double bval = 0;
-    log.debug("\nLogging tuples");
-    for (Object o : alertSink.collectedTuples) {
-      HashMap<String, HashMap<Number, Double>> map = (HashMap<String, HashMap<Number, Double>>)o;
-      Assert.assertEquals("map size", 1, map.size());
-      log.debug(o.toString());
-      HashMap<Number, Double> vmap = map.get("a");
-      if (vmap != null) {
-        aval += vmap.get(231.0).doubleValue();
-      }
-      vmap = map.get("b");
-      if (vmap != null) {
-        if (vmap.get(12.0) != null) {
-          bval += vmap.get(12.0).doubleValue();
-        } else {
-          bval += vmap.get(18.0).doubleValue();
-        }
-      }
-    }
-    Assert.assertEquals("change in a", 10.0, aval,0);
-    Assert.assertEquals("change in a", 70.0, bval,0);
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/math/ChangeAlertTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/math/ChangeAlertTest.java b/library/src/test/java/com/datatorrent/lib/math/ChangeAlertTest.java
deleted file mode 100644
index d127231..0000000
--- a/library/src/test/java/com/datatorrent/lib/math/ChangeAlertTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- * 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 com.datatorrent.lib.math;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.datatorrent.lib.testbench.CollectorTestSink;
-import com.datatorrent.lib.util.KeyValPair;
-
-/**
- *
- * Functional tests for {@link com.datatorrent.lib.math.ChangeAlert}. <p>
- *
- */
-public class ChangeAlertTest
-{
-  private static Logger log = LoggerFactory.getLogger(ChangeAlertTest.class);
-
-  /**
-   * Test node logic emits correct results.
-   */
-  @Test
-  public void testNodeProcessing() throws Exception
-  {
-    testNodeProcessingSchema(new ChangeAlert<Integer>());
-    testNodeProcessingSchema(new ChangeAlert<Double>());
-    testNodeProcessingSchema(new ChangeAlert<Float>());
-    testNodeProcessingSchema(new ChangeAlert<Short>());
-    testNodeProcessingSchema(new ChangeAlert<Long>());
-  }
-
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  public <V extends Number> void testNodeProcessingSchema(ChangeAlert<V> oper)
-  {
-    CollectorTestSink alertSink = new CollectorTestSink();
-
-    oper.alert.setSink(alertSink);
-    oper.setPercentThreshold(5);
-
-    oper.beginWindow(0);
-    oper.data.process(oper.getValue(10));
-    oper.data.process(oper.getValue(12)); // alert
-    oper.data.process(oper.getValue(12));
-    oper.data.process(oper.getValue(18)); // alert
-    oper.data.process(oper.getValue(0));  // alert
-    oper.data.process(oper.getValue(20)); // this will not alert
-    oper.data.process(oper.getValue(30)); // alert
-
-    oper.endWindow();
-
-    // One for a, Two for b
-    Assert.assertEquals("number emitted tuples", 4, alertSink.collectedTuples.size());
-
-    double aval = 0;
-    log.debug("\nLogging tuples");
-    for (Object o: alertSink.collectedTuples) {
-      KeyValPair<Number, Double> map = (KeyValPair<Number, Double>)o;
-      log.debug(o.toString());
-      aval += map.getValue().doubleValue();
-    }
-    Assert.assertEquals("change in a", 220.0, aval,0);
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/math/ChangeKeyValTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/math/ChangeKeyValTest.java b/library/src/test/java/com/datatorrent/lib/math/ChangeKeyValTest.java
deleted file mode 100644
index 6c2151b..0000000
--- a/library/src/test/java/com/datatorrent/lib/math/ChangeKeyValTest.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/**
- * 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 com.datatorrent.lib.math;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.datatorrent.lib.testbench.CollectorTestSink;
-import com.datatorrent.lib.util.KeyValPair;
-
-/**
- *
- * Functional tests for {@link com.datatorrent.lib.math.ChangeKeyVal}.
- * <p>
- *
- */
-public class ChangeKeyValTest
-{
-  private static Logger log = LoggerFactory.getLogger(ChangeKeyValTest.class);
-
-  /**
-   * Test node logic emits correct results.
-   */
-  @Test
-  public void testNodeProcessing() throws Exception
-  {
-    testNodeProcessingSchema(new ChangeKeyVal<String, Integer>());
-    testNodeProcessingSchema(new ChangeKeyVal<String, Double>());
-    testNodeProcessingSchema(new ChangeKeyVal<String, Float>());
-    testNodeProcessingSchema(new ChangeKeyVal<String, Short>());
-    testNodeProcessingSchema(new ChangeKeyVal<String, Long>());
-  }
-
-  /**
-   *
-   * @param oper
-   *          key/value pair for comparison.
-   */
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  public <V extends Number> void testNodeProcessingSchema(
-      ChangeKeyVal<String, V> oper)
-  {
-    CollectorTestSink changeSink = new CollectorTestSink();
-    CollectorTestSink percentSink = new CollectorTestSink();
-
-    oper.change.setSink(changeSink);
-    oper.percent.setSink(percentSink);
-
-    oper.beginWindow(0);
-    oper.base.process(new KeyValPair<String, V>("a", oper.getValue(2)));
-    oper.base.process(new KeyValPair<String, V>("b", oper.getValue(10)));
-    oper.base.process(new KeyValPair<String, V>("c", oper.getValue(100)));
-
-    oper.data.process(new KeyValPair<String, V>("a", oper.getValue(3)));
-    oper.data.process(new KeyValPair<String, V>("b", oper.getValue(2)));
-    oper.data.process(new KeyValPair<String, V>("c", oper.getValue(4)));
-
-    oper.endWindow();
-
-    // One for each key
-    Assert.assertEquals("number emitted tuples", 3,
-        changeSink.collectedTuples.size());
-    Assert.assertEquals("number emitted tuples", 3,
-        percentSink.collectedTuples.size());
-
-    log.debug("\nLogging tuples");
-    for (Object o : changeSink.collectedTuples) {
-      KeyValPair<String, Number> kv = (KeyValPair<String, Number>)o;
-      if (kv.getKey().equals("a")) {
-        Assert.assertEquals("change in a ", 1.0, kv.getValue());
-      }
-      if (kv.getKey().equals("b")) {
-        Assert.assertEquals("change in b ", -8.0, kv.getValue());
-      }
-      if (kv.getKey().equals("c")) {
-        Assert.assertEquals("change in c ", -96.0, kv.getValue());
-      }
-    }
-
-    for (Object o : percentSink.collectedTuples) {
-      KeyValPair<String, Number> kv = (KeyValPair<String, Number>)o;
-      if (kv.getKey().equals("a")) {
-        Assert.assertEquals("change in a ", 50.0, kv.getValue());
-      }
-      if (kv.getKey().equals("b")) {
-        Assert.assertEquals("change in b ", -80.0, kv.getValue());
-      }
-      if (kv.getKey().equals("c")) {
-        Assert.assertEquals("change in c ", -96.0, kv.getValue());
-      }
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/math/ChangeTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/math/ChangeTest.java b/library/src/test/java/com/datatorrent/lib/math/ChangeTest.java
deleted file mode 100644
index 9595a5d..0000000
--- a/library/src/test/java/com/datatorrent/lib/math/ChangeTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/**
- * 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 com.datatorrent.lib.math;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-/**
- *
- * Functional tests for {@link com.datatorrent.lib.math.Change}.
- * <p>
- *
- */
-public class ChangeTest
-{
-  private static Logger log = LoggerFactory.getLogger(ChangeTest.class);
-
-  /**
-   * Test node logic emits correct results.
-   */
-  @Test
-  public void testNodeProcessing() throws Exception
-  {
-    testNodeProcessingSchema(new Change<Integer>());
-    testNodeProcessingSchema(new Change<Double>());
-    testNodeProcessingSchema(new Change<Float>());
-    testNodeProcessingSchema(new Change<Short>());
-    testNodeProcessingSchema(new Change<Long>());
-  }
-
-  /**
-   *
-   * @param oper  Data value for comparison.
-   */
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  public <V extends Number> void testNodeProcessingSchema(Change<V> oper)
-  {
-    CollectorTestSink changeSink = new CollectorTestSink();
-    CollectorTestSink percentSink = new CollectorTestSink();
-
-    oper.change.setSink(changeSink);
-    oper.percent.setSink(percentSink);
-
-    oper.beginWindow(0);
-    oper.base.process(oper.getValue(10));
-    oper.data.process(oper.getValue(5));
-    oper.data.process(oper.getValue(15));
-    oper.data.process(oper.getValue(20));
-    oper.endWindow();
-
-    Assert.assertEquals("number emitted tuples", 3,
-        changeSink.collectedTuples.size());
-    Assert.assertEquals("number emitted tuples", 3,
-        percentSink.collectedTuples.size());
-
-    log.debug("\nLogging tuples");
-    for (Object o : changeSink.collectedTuples) {
-      log.debug(String.format("change %s", o));
-    }
-    for (Object o : percentSink.collectedTuples) {
-      log.debug(String.format("percent change %s", o));
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/math/CompareExceptMapTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/math/CompareExceptMapTest.java b/library/src/test/java/com/datatorrent/lib/math/CompareExceptMapTest.java
deleted file mode 100644
index 46b9609..0000000
--- a/library/src/test/java/com/datatorrent/lib/math/CompareExceptMapTest.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- * 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 com.datatorrent.lib.math;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.datatorrent.lib.testbench.CountAndLastTupleTestSink;
-
-/**
- *
- * Functional tests for {@link com.datatorrent.lib.math.CompareExceptMap}<p>
- *
- */
-public class CompareExceptMapTest
-{
-  /**
-   * Test node logic emits correct results
-   */
-  @Test
-  public void testNodeProcessing() throws Exception
-  {
-    testNodeProcessingSchema(new CompareExceptMap<String, Integer>());
-    testNodeProcessingSchema(new CompareExceptMap<String, Double>());
-    testNodeProcessingSchema(new CompareExceptMap<String, Float>());
-    testNodeProcessingSchema(new CompareExceptMap<String, Short>());
-    testNodeProcessingSchema(new CompareExceptMap<String, Long>());
-  }
-
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  public void testNodeProcessingSchema(CompareExceptMap oper)
-  {
-    CountAndLastTupleTestSink compareSink = new CountAndLastTupleTestSink();
-    CountAndLastTupleTestSink exceptSink = new CountAndLastTupleTestSink();
-    oper.compare.setSink(compareSink);
-    oper.except.setSink(exceptSink);
-
-    oper.setKey("a");
-    oper.setValue(3.0);
-    oper.setTypeEQ();
-
-    oper.beginWindow(0);
-    HashMap<String, Number> input = new HashMap<String, Number>();
-    input.put("a", 2);
-    input.put("b", 20);
-    input.put("c", 1000);
-    oper.data.process(input);
-    input.clear();
-    input.put("a", 3);
-    input.put("b", 21);
-    input.put("c", 30);
-    oper.data.process(input);
-    oper.endWindow();
-
-    // One for each key
-    Assert.assertEquals("number emitted tuples", 1, exceptSink.count);
-    for (Map.Entry<String, Number> e : ((HashMap<String, Number>)exceptSink.tuple).entrySet()) {
-      if (e.getKey().equals("a")) {
-        Assert.assertEquals("emitted value for 'a' was ", new Double(2), e.getValue().doubleValue(), 0);
-      } else if (e.getKey().equals("b")) {
-        Assert.assertEquals("emitted tuple for 'b' was ", new Double(20), e.getValue().doubleValue(), 0);
-      } else if (e.getKey().equals("c")) {
-        Assert.assertEquals("emitted tuple for 'c' was ", new Double(1000), e.getValue().doubleValue(), 0);
-      }
-    }
-
-    Assert.assertEquals("number emitted tuples", 1, compareSink.count);
-    for (Map.Entry<String, Number> e : ((HashMap<String, Number>)compareSink.tuple).entrySet()) {
-      if (e.getKey().equals("a")) {
-        Assert.assertEquals("emitted value for 'a' was ", new Double(3), e.getValue().doubleValue(), 0);
-      } else if (e.getKey().equals("b")) {
-        Assert.assertEquals("emitted tuple for 'b' was ", new Double(21), e.getValue().doubleValue(), 0);
-      } else if (e.getKey().equals("c")) {
-        Assert.assertEquals("emitted tuple for 'c' was ", new Double(30), e.getValue().doubleValue(), 0);
-      }
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/math/CompareMapTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/math/CompareMapTest.java b/library/src/test/java/com/datatorrent/lib/math/CompareMapTest.java
deleted file mode 100644
index c21019b..0000000
--- a/library/src/test/java/com/datatorrent/lib/math/CompareMapTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- * 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 com.datatorrent.lib.math;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.datatorrent.lib.testbench.CountAndLastTupleTestSink;
-
-/**
- *
- * Functional tests for {@link com.datatorrent.lib.math.CompareMap}<p>
- *
- */
-public class CompareMapTest
-{
-  /**
-   * Test node logic emits correct results
-   */
-  @Test
-  public void testNodeProcessing() throws Exception
-  {
-    testNodeProcessingSchema(new CompareMap<String, Integer>());
-    testNodeProcessingSchema(new CompareMap<String, Double>());
-    testNodeProcessingSchema(new CompareMap<String, Float>());
-    testNodeProcessingSchema(new CompareMap<String, Short>());
-    testNodeProcessingSchema(new CompareMap<String, Long>());
-  }
-
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  public void testNodeProcessingSchema(CompareMap oper)
-  {
-    CountAndLastTupleTestSink matchSink = new CountAndLastTupleTestSink();
-    oper.compare.setSink(matchSink);
-    oper.setKey("a");
-    oper.setValue(3.0);
-    oper.setTypeNEQ();
-
-    oper.beginWindow(0);
-    HashMap<String, Number> input = new HashMap<String, Number>();
-
-    input.put("a", 2);
-    input.put("b", 20);
-    input.put("c", 1000);
-    oper.data.process(input);
-    input.clear();
-    input.put("a", 3);
-    oper.data.process(input);
-    oper.endWindow();
-
-    // One for each key
-    Assert.assertEquals("number emitted tuples", 1, matchSink.count);
-    for (Map.Entry<String, Number> e : ((HashMap<String, Number>)matchSink.tuple).entrySet()) {
-      if (e.getKey().equals("a")) {
-        Assert.assertEquals("emitted value for 'a' was ", new Double(2), e.getValue().doubleValue(), 0);
-      } else if (e.getKey().equals("b")) {
-        Assert.assertEquals("emitted tuple for 'b' was ", new Double(20), e.getValue().doubleValue(), 0);
-      } else if (e.getKey().equals("c")) {
-        Assert.assertEquals("emitted tuple for 'c' was ", new Double(1000), e.getValue().doubleValue(), 0);
-      }
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/math/CountKeyValTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/math/CountKeyValTest.java b/library/src/test/java/com/datatorrent/lib/math/CountKeyValTest.java
deleted file mode 100644
index 0b1d9de..0000000
--- a/library/src/test/java/com/datatorrent/lib/math/CountKeyValTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- * 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 com.datatorrent.lib.math;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.datatorrent.lib.testbench.CollectorTestSink;
-import com.datatorrent.lib.util.KeyValPair;
-
-/**
- *
- * Functional tests for {@link com.datatorrent.lib.math.CountKeyVal}. <p>
- *
- */
-public class CountKeyValTest
-{
-  /**
-   * Test operator logic emits correct results.
-   */
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  @Test
-  public void testNodeProcessing()
-  {
-    CountKeyVal<String, Double> oper = new CountKeyVal<String, Double>();
-    CollectorTestSink countSink = new CollectorTestSink();
-    oper.count.setSink(countSink);
-
-    oper.beginWindow(0); //
-
-    oper.data.process(new KeyValPair("a", 2.0));
-    oper.data.process(new KeyValPair("b", 20.0));
-    oper.data.process(new KeyValPair("c", 1000.0));
-    oper.data.process(new KeyValPair("a", 1.0));
-    oper.data.process(new KeyValPair("a", 10.0));
-    oper.data.process(new KeyValPair("b", 5.0));
-    oper.data.process(new KeyValPair("d", 55.0));
-    oper.data.process(new KeyValPair("b", 12.0));
-    oper.data.process(new KeyValPair("d", 22.0));
-    oper.data.process(new KeyValPair("d", 14.2));
-    oper.data.process(new KeyValPair("d", 46.0));
-    oper.data.process(new KeyValPair("e", 2.0));
-    oper.data.process(new KeyValPair("a", 23.0));
-    oper.data.process(new KeyValPair("d", 4.0));
-
-    oper.endWindow(); //
-
-    // payload should be 1 bag of tuples with keys "a", "b", "c", "d", "e"
-    Assert.assertEquals("number emitted tuples", 5, countSink.collectedTuples.size());
-    for (Object o : countSink.collectedTuples) {
-      KeyValPair<String, Integer> e = (KeyValPair<String, Integer>)o;
-      Integer val = (Integer)e.getValue();
-      if (e.getKey().equals("a")) {
-        Assert.assertEquals("emitted value for 'a' was ", 4, val.intValue());
-      } else if (e.getKey().equals("b")) {
-        Assert.assertEquals("emitted tuple for 'b' was ", 3, val.intValue());
-      } else if (e.getKey().equals("c")) {
-        Assert.assertEquals("emitted tuple for 'c' was ", 1, val.intValue());
-      } else if (e.getKey().equals("d")) {
-        Assert.assertEquals("emitted tuple for 'd' was ", 5, val.intValue());
-      } else if (e.getKey().equals("e")) {
-        Assert.assertEquals("emitted tuple for 'e' was ", 1, val.intValue());
-      }
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/math/DivisionTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/math/DivisionTest.java b/library/src/test/java/com/datatorrent/lib/math/DivisionTest.java
index 9fe556f..c7e7c65 100644
--- a/library/src/test/java/com/datatorrent/lib/math/DivisionTest.java
+++ b/library/src/test/java/com/datatorrent/lib/math/DivisionTest.java
@@ -29,6 +29,7 @@ import com.datatorrent.lib.testbench.CollectorTestSink;
  * <p>
  *
  */
+
 public class DivisionTest
 {
   /**

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/math/ExceptMapTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/math/ExceptMapTest.java b/library/src/test/java/com/datatorrent/lib/math/ExceptMapTest.java
deleted file mode 100644
index a113d5f..0000000
--- a/library/src/test/java/com/datatorrent/lib/math/ExceptMapTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
- * 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 com.datatorrent.lib.math;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.datatorrent.lib.testbench.CountAndLastTupleTestSink;
-
-/**
- * Functional tests for {@link com.datatorrent.lib.math.ExceptMap}
- */
-public class ExceptMapTest
-{
-  /**
-   * Test node logic emits correct results
-   */
-  @Test
-  public void testNodeProcessing() throws Exception
-  {
-    testNodeProcessingSchema(new ExceptMap<String, Integer>());
-    testNodeProcessingSchema(new ExceptMap<String, Double>());
-    testNodeProcessingSchema(new ExceptMap<String, Float>());
-    testNodeProcessingSchema(new ExceptMap<String, Short>());
-    testNodeProcessingSchema(new ExceptMap<String, Long>());
-  }
-
-  @SuppressWarnings({"rawtypes", "unchecked"})
-  public void testNodeProcessingSchema(ExceptMap oper)
-  {
-    CountAndLastTupleTestSink exceptSink = new CountAndLastTupleTestSink();
-    oper.except.setSink(exceptSink);
-    oper.setKey("a");
-    oper.setValue(3.0);
-    oper.setTypeEQ();
-
-    oper.beginWindow(0);
-    HashMap<String, Number> input = new HashMap<String, Number>();
-    input.put("a", 2);
-    input.put("b", 20);
-    input.put("c", 1000);
-    oper.data.process(input);
-    input.clear();
-    input.put("a", 3);
-    oper.data.process(input);
-    oper.endWindow();
-
-    // One for each key
-    Assert.assertEquals("number emitted tuples", 1, exceptSink.count);
-    for (Map.Entry<String, Number> e : ((HashMap<String, Number>)exceptSink.tuple)
-        .entrySet()) {
-      if (e.getKey().equals("a")) {
-        Assert.assertEquals("emitted value for 'a' was ", new Double(2), e
-            .getValue().doubleValue(), 0);
-      } else if (e.getKey().equals("b")) {
-        Assert.assertEquals("emitted tuple for 'b' was ", new Double(20), e
-            .getValue().doubleValue(), 0);
-      } else if (e.getKey().equals("c")) {
-        Assert.assertEquals("emitted tuple for 'c' was ", new Double(1000), e
-            .getValue().doubleValue(), 0);
-      }
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/math/MultiplyByConstantTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/math/MultiplyByConstantTest.java b/library/src/test/java/com/datatorrent/lib/math/MultiplyByConstantTest.java
index 68e89eb..4eb6a1b 100644
--- a/library/src/test/java/com/datatorrent/lib/math/MultiplyByConstantTest.java
+++ b/library/src/test/java/com/datatorrent/lib/math/MultiplyByConstantTest.java
@@ -24,8 +24,10 @@ import org.junit.Test;
 import com.datatorrent.lib.testbench.SumTestSink;
 
 /**
+ *
  * Functional tests for {@link com.datatorrent.lib.math.MultiplyByConstant}
  */
+
 public class MultiplyByConstantTest
 {
   /**

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/math/QuotientMapTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/math/QuotientMapTest.java b/library/src/test/java/com/datatorrent/lib/math/QuotientMapTest.java
deleted file mode 100644
index 92c0e77..0000000
--- a/library/src/test/java/com/datatorrent/lib/math/QuotientMapTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
- * 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 com.datatorrent.lib.math;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.datatorrent.lib.testbench.CountAndLastTupleTestSink;
-
-/**
- * Functional tests for {@link com.datatorrent.lib.math.QuotientMap}
- */
-public class QuotientMapTest
-{
-  private static Logger LOG = LoggerFactory.getLogger(QuotientMap.class);
-
-  /**
-   * Test node logic emits correct results
-   */
-  @Test
-  public void testNodeProcessing() throws Exception
-  {
-    testNodeProcessingSchema(new QuotientMap<String, Integer>());
-    testNodeProcessingSchema(new QuotientMap<String, Double>());
-  }
-
-  @SuppressWarnings({ "unchecked", "rawtypes" })
-  public void testNodeProcessingSchema(QuotientMap oper) throws Exception
-  {
-    CountAndLastTupleTestSink quotientSink = new CountAndLastTupleTestSink();
-
-    oper.quotient.setSink(quotientSink);
-    oper.setMult_by(2);
-
-    oper.beginWindow(0); //
-    HashMap<String, Number> input = new HashMap<String, Number>();
-    int numtuples = 100;
-    for (int i = 0; i < numtuples; i++) {
-      input.clear();
-      input.put("a", 2);
-      input.put("b", 20);
-      input.put("c", 1000);
-      oper.numerator.process(input);
-      input.clear();
-      input.put("a", 2);
-      input.put("b", 40);
-      input.put("c", 500);
-      oper.denominator.process(input);
-    }
-
-    oper.endWindow();
-
-    // One for each key
-    Assert.assertEquals("number emitted tuples", 1, quotientSink.count);
-    HashMap<String, Number> output = (HashMap<String, Number>)quotientSink.tuple;
-    for (Map.Entry<String, Number> e : output.entrySet()) {
-      if (e.getKey().equals("a")) {
-        Assert.assertEquals("emitted value for 'a' was ", 2d,
-            e.getValue());
-      } else if (e.getKey().equals("b")) {
-        Assert.assertEquals("emitted tuple for 'b' was ", 1d,
-            e.getValue());
-      } else if (e.getKey().equals("c")) {
-        Assert.assertEquals("emitted tuple for 'c' was ", 4d,
-            e.getValue());
-      } else {
-        LOG.debug(String.format("key was %s", e.getKey()));
-      }
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/math/QuotientTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/math/QuotientTest.java b/library/src/test/java/com/datatorrent/lib/math/QuotientTest.java
deleted file mode 100644
index 604e45f..0000000
--- a/library/src/test/java/com/datatorrent/lib/math/QuotientTest.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/**
- * 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 com.datatorrent.lib.math;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.datatorrent.api.Sink;
-
-/**
- * Functional tests for {@link com.datatorrent.lib.math.Quotient}
- */
-public class QuotientTest
-{
-
-  class TestSink implements Sink<Object>
-  {
-    List<Object> collectedTuples = new ArrayList<Object>();
-
-    @Override
-    public void put(Object payload)
-    {
-      collectedTuples.add(payload);
-    }
-
-    @Override
-    public int getCount(boolean reset)
-    {
-      throw new UnsupportedOperationException("Not supported yet.");
-    }
-  }
-
-  /**
-   * Test oper logic emits correct results.
-   */
-  @Test
-  public void testNodeSchemaProcessing()
-  {
-    Quotient<Double> oper = new Quotient<Double>();
-    TestSink quotientSink = new TestSink();
-    oper.quotient.setSink(quotientSink);
-
-    oper.setMult_by(2);
-
-    oper.beginWindow(0); //
-    Double a = 30.0;
-    Double b = 20.0;
-    Double c = 100.0;
-    oper.denominator.process(a);
-    oper.denominator.process(b);
-    oper.denominator.process(c);
-
-    a = 5.0;
-    oper.numerator.process(a);
-    a = 1.0;
-    oper.numerator.process(a);
-    b = 44.0;
-    oper.numerator.process(b);
-
-    b = 10.0;
-    oper.numerator.process(b);
-    c = 22.0;
-    oper.numerator.process(c);
-    c = 18.0;
-    oper.numerator.process(c);
-
-    a = 0.5;
-    oper.numerator.process(a);
-    b = 41.5;
-    oper.numerator.process(b);
-    a = 8.0;
-    oper.numerator.process(a);
-    oper.endWindow(); //
-
-    // payload should be 1 bag of tuples with keys "a", "b", "c", "d", "e"
-    Assert.assertEquals("number emitted tuples", 1,
-        quotientSink.collectedTuples.size());
-    for (Object o : quotientSink.collectedTuples) { // sum is 1157
-      Double val = (Double)o;
-      Assert.assertEquals("emitted quotient value was ", new Double(2.0), val);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/math/SigmaTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/math/SigmaTest.java b/library/src/test/java/com/datatorrent/lib/math/SigmaTest.java
index e968dba..f74e0c9 100644
--- a/library/src/test/java/com/datatorrent/lib/math/SigmaTest.java
+++ b/library/src/test/java/com/datatorrent/lib/math/SigmaTest.java
@@ -26,11 +26,12 @@ import org.junit.Test;
 import com.datatorrent.lib.testbench.SumTestSink;
 
 /**
- * 
+ *
  * Functional tests for {@link com.datatorrent.lib.math.Sigma}
  * <p>
  * 
  */
+
 public class SigmaTest
 {
   /**

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/math/SumCountMapTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/math/SumCountMapTest.java b/library/src/test/java/com/datatorrent/lib/math/SumCountMapTest.java
deleted file mode 100644
index b0c7b38..0000000
--- a/library/src/test/java/com/datatorrent/lib/math/SumCountMapTest.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/**
- * 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 com.datatorrent.lib.math;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-/**
- * Functional tests for {@link com.datatorrent.lib.math.SumCountMap}.
- */
-public class SumCountMapTest
-{
-  /**
-   * Test operator logic emits correct results.
-   */
-  @Test
-  public void testNodeProcessing()
-  {
-    testNodeSchemaProcessing(true, true);
-    testNodeSchemaProcessing(true, false);
-    testNodeSchemaProcessing(false, true);
-    testNodeSchemaProcessing(false, false);
-  }
-
-  @SuppressWarnings({ "unchecked", "rawtypes" })
-  public void testNodeSchemaProcessing(boolean sum, boolean count)
-  {
-    SumCountMap<String, Double> oper = new SumCountMap<String, Double>();
-    oper.setType(Double.class);
-    CollectorTestSink sumSink = new CollectorTestSink();
-    CollectorTestSink countSink = new CollectorTestSink();
-    if (sum) {
-      oper.sum.setSink(sumSink);
-    }
-    if (count) {
-      oper.count.setSink(countSink);
-    }
-
-    oper.beginWindow(0); //
-
-    HashMap<String, Double> input = new HashMap<String, Double>();
-
-    input.put("a", 2.0);
-    input.put("b", 20.0);
-    input.put("c", 1000.0);
-    oper.data.process(input);
-    input.clear();
-    input.put("a", 1.0);
-    oper.data.process(input);
-    input.clear();
-    input.put("a", 10.0);
-    input.put("b", 5.0);
-    oper.data.process(input);
-    input.clear();
-    input.put("d", 55.0);
-    input.put("b", 12.0);
-    oper.data.process(input);
-    input.clear();
-    input.put("d", 22.0);
-    oper.data.process(input);
-    input.clear();
-    input.put("d", 14.2);
-    oper.data.process(input);
-    input.clear();
-
-    // Mix integers and doubles
-    HashMap<String, Double> inputi = new HashMap<String, Double>();
-    inputi.put("d", 46.0);
-    inputi.put("e", 2.0);
-    oper.data.process(inputi);
-    inputi.clear();
-    inputi.put("a", 23.0);
-    inputi.put("d", 4.0);
-    oper.data.process(inputi);
-    inputi.clear();
-
-    oper.endWindow(); //
-
-    if (sum) {
-      // payload should be 1 bag of tuples with keys "a", "b", "c", "d", "e"
-      Assert.assertEquals("number emitted tuples", 1, sumSink.collectedTuples.size());
-
-      for (Object o : sumSink.collectedTuples) {
-        HashMap<String, Object> output = (HashMap<String, Object>)o;
-        for (Map.Entry<String, Object> e : output.entrySet()) {
-          Double val = (Double)e.getValue();
-          if (e.getKey().equals("a")) {
-            Assert.assertEquals("emitted value for 'a' was ", new Double(36),
-                val);
-          } else if (e.getKey().equals("b")) {
-            Assert.assertEquals("emitted tuple for 'b' was ", new Double(37),
-                val);
-          } else if (e.getKey().equals("c")) {
-            Assert.assertEquals("emitted tuple for 'c' was ", new Double(1000),
-                val);
-          } else if (e.getKey().equals("d")) {
-            Assert.assertEquals("emitted tuple for 'd' was ",
-                new Double(141.2), val);
-          } else if (e.getKey().equals("e")) {
-            Assert.assertEquals("emitted tuple for 'e' was ", new Double(2),
-                val);
-          }
-        }
-      }
-    }
-    if (count) {
-      // payload should be 1 bag of tuples with keys "a", "b", "c", "d", "e"
-      Assert.assertEquals("number emitted tuples", 1, countSink.collectedTuples.size());
-      for (Object o : countSink.collectedTuples) {
-        HashMap<String, Object> output = (HashMap<String, Object>)o;
-        for (Map.Entry<String, Object> e : output.entrySet()) {
-          Integer val = (Integer)e.getValue();
-          if (e.getKey().equals("a")) {
-            Assert
-                .assertEquals("emitted value for 'a' was ", 4, val.intValue());
-          } else if (e.getKey().equals("b")) {
-            Assert
-                .assertEquals("emitted tuple for 'b' was ", 3, val.intValue());
-          } else if (e.getKey().equals("c")) {
-            Assert
-                .assertEquals("emitted tuple for 'c' was ", 1, val.intValue());
-          } else if (e.getKey().equals("d")) {
-            Assert
-                .assertEquals("emitted tuple for 'd' was ", 5, val.intValue());
-          } else if (e.getKey().equals("e")) {
-            Assert
-                .assertEquals("emitted tuple for 'e' was ", 1, val.intValue());
-          }
-        }
-      }
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/streamquery/DeleteOperatorTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/streamquery/DeleteOperatorTest.java b/library/src/test/java/com/datatorrent/lib/streamquery/DeleteOperatorTest.java
deleted file mode 100644
index 1f29d1d..0000000
--- a/library/src/test/java/com/datatorrent/lib/streamquery/DeleteOperatorTest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery;
-
-import java.util.HashMap;
-
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.datatorrent.lib.streamquery.condition.EqualValueCondition;
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-/**
- * Functional test for {@link com.datatorrent.lib.streamquery.DeleteOperator}.
- */
-public class DeleteOperatorTest
-{
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  @Test
-  public void testSqlSelect()
-  {
-    // create operator
-    DeleteOperator oper = new DeleteOperator();
-
-    EqualValueCondition  condition = new EqualValueCondition();
-    condition.addEqualValue("a", 1);
-    oper.setCondition(condition);
-
-    CollectorTestSink sink = new CollectorTestSink();
-    oper.outport.setSink(sink);
-
-    oper.setup(null);
-    oper.beginWindow(1);
-
-    HashMap<String, Object> tuple = new HashMap<String, Object>();
-    tuple.put("a", 0);
-    tuple.put("b", 1);
-    tuple.put("c", 2);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 3);
-    tuple.put("c", 4);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 5);
-    tuple.put("c", 6);
-    oper.inport.process(tuple);
-
-    oper.endWindow();
-    oper.teardown();
-
-    LOG.debug("{}", sink.collectedTuples);
-  }
-
-  private static final Logger LOG = LoggerFactory.getLogger(DeleteOperatorTest.class);
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/streamquery/FullOuterJoinOperatorTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/streamquery/FullOuterJoinOperatorTest.java b/library/src/test/java/com/datatorrent/lib/streamquery/FullOuterJoinOperatorTest.java
deleted file mode 100644
index 728fb96..0000000
--- a/library/src/test/java/com/datatorrent/lib/streamquery/FullOuterJoinOperatorTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery;
-
-import java.util.HashMap;
-
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.datatorrent.lib.streamquery.condition.Condition;
-import com.datatorrent.lib.streamquery.condition.JoinColumnEqualCondition;
-import com.datatorrent.lib.streamquery.index.ColumnIndex;
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-public class FullOuterJoinOperatorTest
-{
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  @Test
-  public void testSqlSelect()
-  {
-    // create operator
-    OuterJoinOperator oper = new OuterJoinOperator();
-    oper.setFullJoin(true);
-    CollectorTestSink sink = new CollectorTestSink();
-    oper.outport.setSink(sink);
-
-    // set column join condition  
-    Condition cond = new JoinColumnEqualCondition("a", "a");
-    oper.setJoinCondition(cond);
-    
-    // add columns  
-    oper.selectTable1Column(new ColumnIndex("b", null));
-    oper.selectTable2Column(new ColumnIndex("c", null));
-
-    oper.setup(null);
-    oper.beginWindow(1);
-
-    HashMap<String, Object> tuple = new HashMap<String, Object>();
-    tuple.put("a", 0);
-    tuple.put("b", 1);
-    tuple.put("c", 2);
-    oper.inport1.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 3);
-    tuple.put("c", 4);
-    oper.inport1.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 2);
-    tuple.put("b", 11);
-    tuple.put("c", 12);
-    oper.inport1.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 0);
-    tuple.put("b", 7);
-    tuple.put("c", 8);
-    oper.inport2.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 5);
-    tuple.put("c", 6);
-    oper.inport2.process(tuple);
-
-    oper.endWindow();
-    oper.teardown();
-
-    LOG.debug("{}", sink.collectedTuples);
-  }
-
-  private static final Logger LOG = LoggerFactory.getLogger(FullOuterJoinOperatorTest.class);
-
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/streamquery/GroupByOperatorTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/streamquery/GroupByOperatorTest.java b/library/src/test/java/com/datatorrent/lib/streamquery/GroupByOperatorTest.java
deleted file mode 100644
index 714f93b..0000000
--- a/library/src/test/java/com/datatorrent/lib/streamquery/GroupByOperatorTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery;
-
-import java.util.HashMap;
-
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.datatorrent.lib.streamquery.condition.EqualValueCondition;
-import com.datatorrent.lib.streamquery.function.SumFunction;
-import com.datatorrent.lib.streamquery.index.ColumnIndex;
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-/**
- * Functional test for {@link com.datatorrent.lib.streamquery.GroupByOperatorTest}.
- */
-public class GroupByOperatorTest
-{
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  @Test
-  public void testSqlGroupBy()
-  {
-    // create operator
-    GroupByHavingOperator oper = new GroupByHavingOperator();
-    oper.addColumnGroupByIndex(new ColumnIndex("b", null));
-    try {
-      oper.addAggregateIndex(new SumFunction("c", null));
-    } catch (Exception e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
-      return;
-    }
-
-    EqualValueCondition  condition = new EqualValueCondition();
-    condition.addEqualValue("a", 1);
-    oper.setCondition(condition);
-
-    CollectorTestSink sink = new CollectorTestSink();
-    oper.outport.setSink(sink);
-
-    oper.setup(null);
-    oper.beginWindow(1);
-
-    HashMap<String, Object> tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 1);
-    tuple.put("c", 2);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 1);
-    tuple.put("c", 4);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 2);
-    tuple.put("c", 6);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 2);
-    tuple.put("c", 7);
-    oper.inport.process(tuple);
-    
-    oper.endWindow();
-    oper.teardown();
-
-    LOG.debug("{}", sink.collectedTuples);
-  }
-
-  private static final Logger LOG = LoggerFactory.getLogger(GroupByOperatorTest.class);
-
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/streamquery/HavingOperatorTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/streamquery/HavingOperatorTest.java b/library/src/test/java/com/datatorrent/lib/streamquery/HavingOperatorTest.java
deleted file mode 100644
index e11723d..0000000
--- a/library/src/test/java/com/datatorrent/lib/streamquery/HavingOperatorTest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery;
-
-import java.util.HashMap;
-
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.datatorrent.lib.streamquery.condition.EqualValueCondition;
-import com.datatorrent.lib.streamquery.condition.HavingCompareValue;
-import com.datatorrent.lib.streamquery.condition.HavingCondition;
-import com.datatorrent.lib.streamquery.function.FunctionIndex;
-import com.datatorrent.lib.streamquery.function.SumFunction;
-import com.datatorrent.lib.streamquery.index.ColumnIndex;
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-/**
- * Functional test for {@link com.datatorrent.lib.streamquery.HavingOperatorTest}.
- */
-public class HavingOperatorTest
-{
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  @Test
-  public void testSqlGroupBy() throws Exception
-  {
-    // create operator
-    GroupByHavingOperator oper = new GroupByHavingOperator();
-    oper.addColumnGroupByIndex(new ColumnIndex("b", null));
-    FunctionIndex sum = new SumFunction("c", null);
-    oper.addAggregateIndex(sum);
-
-    // create having condition
-    HavingCondition having = new HavingCompareValue<Double>(sum, 6.0, 0);
-    oper.addHavingCondition(having);
-
-    EqualValueCondition  condition = new EqualValueCondition();
-    condition.addEqualValue("a", 1);
-    oper.setCondition(condition);
-
-    CollectorTestSink sink = new CollectorTestSink();
-    oper.outport.setSink(sink);
-
-    oper.setup(null);
-    oper.beginWindow(1);
-
-    HashMap<String, Object> tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 1);
-    tuple.put("c", 2);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 1);
-    tuple.put("c", 4);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 2);
-    tuple.put("c", 6);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 2);
-    tuple.put("c", 7);
-    oper.inport.process(tuple);
-    
-    oper.endWindow();
-    oper.teardown();
-
-    LOG.debug("{}", sink.collectedTuples);
-  }
-
-  private static final Logger LOG = LoggerFactory.getLogger(HavingOperatorTest.class);
-
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/streamquery/InnerJoinOperatorTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/streamquery/InnerJoinOperatorTest.java b/library/src/test/java/com/datatorrent/lib/streamquery/InnerJoinOperatorTest.java
deleted file mode 100644
index 8a022ee..0000000
--- a/library/src/test/java/com/datatorrent/lib/streamquery/InnerJoinOperatorTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery;
-
-import java.util.HashMap;
-
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.datatorrent.lib.streamquery.condition.Condition;
-import com.datatorrent.lib.streamquery.condition.JoinColumnEqualCondition;
-import com.datatorrent.lib.streamquery.index.ColumnIndex;
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-/**
- * 
- * Functional test for {@link com.datatorrent.lib.streamquery.InnerJoinOperator }.
- *
- */
-public class InnerJoinOperatorTest
-{
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  @Test
-  public void testSqlSelect()
-  {
-    // create operator
-    InnerJoinOperator oper = new InnerJoinOperator();
-    CollectorTestSink sink = new CollectorTestSink();
-    oper.outport.setSink(sink);
-
-    // set column join condition
-    Condition cond = new JoinColumnEqualCondition("a", "a");
-    oper.setJoinCondition(cond);
-
-    // add columns
-    oper.selectTable1Column(new ColumnIndex("b", null));
-    oper.selectTable2Column(new ColumnIndex("c", null));
-
-    oper.setup(null);
-    oper.beginWindow(1);
-
-    HashMap<String, Object> tuple = new HashMap<String, Object>();
-    tuple.put("a", 0);
-    tuple.put("b", 1);
-    tuple.put("c", 2);
-    oper.inport1.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 3);
-    tuple.put("c", 4);
-    oper.inport1.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 0);
-    tuple.put("b", 7);
-    tuple.put("c", 8);
-    oper.inport2.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 5);
-    tuple.put("c", 6);
-    oper.inport2.process(tuple);
-
-    oper.endWindow();
-    oper.teardown();
-
-    LOG.debug("{}", sink.collectedTuples);
-  }
-
-  private static final Logger LOG = LoggerFactory.getLogger(InnerJoinOperatorTest.class);
-
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/streamquery/LeftOuterJoinOperatorTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/streamquery/LeftOuterJoinOperatorTest.java b/library/src/test/java/com/datatorrent/lib/streamquery/LeftOuterJoinOperatorTest.java
deleted file mode 100644
index aa25e87..0000000
--- a/library/src/test/java/com/datatorrent/lib/streamquery/LeftOuterJoinOperatorTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery;
-
-import java.util.HashMap;
-
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.datatorrent.lib.streamquery.condition.Condition;
-import com.datatorrent.lib.streamquery.condition.JoinColumnEqualCondition;
-import com.datatorrent.lib.streamquery.index.ColumnIndex;
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-public class LeftOuterJoinOperatorTest
-{
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  @Test
-  public void testSqlSelect()
-  {
-    // create operator
-    OuterJoinOperator oper = new OuterJoinOperator();
-    CollectorTestSink sink = new CollectorTestSink();
-    oper.outport.setSink(sink);
-
-    // set column join condition  
-    Condition cond = new JoinColumnEqualCondition("a", "a");
-    oper.setJoinCondition(cond);
-    
-    // add columns  
-    oper.selectTable1Column(new ColumnIndex("b", null));
-    oper.selectTable2Column(new ColumnIndex("c", null));
-
-    oper.setup(null);
-    oper.beginWindow(1);
-
-    HashMap<String, Object> tuple = new HashMap<String, Object>();
-    tuple.put("a", 0);
-    tuple.put("b", 1);
-    tuple.put("c", 2);
-    oper.inport1.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 3);
-    tuple.put("c", 4);
-    oper.inport1.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 2);
-    tuple.put("b", 11);
-    tuple.put("c", 12);
-    oper.inport1.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 0);
-    tuple.put("b", 7);
-    tuple.put("c", 8);
-    oper.inport2.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 5);
-    tuple.put("c", 6);
-    oper.inport2.process(tuple);
-
-    oper.endWindow();
-    oper.teardown();
-
-    LOG.debug("{}", sink.collectedTuples);
-  }
-
-  private static final Logger LOG = LoggerFactory.getLogger(LeftOuterJoinOperatorTest.class);
-
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/streamquery/OrderByOperatorTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/streamquery/OrderByOperatorTest.java b/library/src/test/java/com/datatorrent/lib/streamquery/OrderByOperatorTest.java
deleted file mode 100644
index 2d7ba87..0000000
--- a/library/src/test/java/com/datatorrent/lib/streamquery/OrderByOperatorTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery;
-
-import java.util.HashMap;
-
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-/**
- *  Functional test for {@link com.datatorrent.lib.streamquery.OrderByOperatorTest}.
- */
-public class OrderByOperatorTest
-{
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  @Test
-  public void testSqlSelect()
-  {
-    // craete operator
-    OrderByOperator oper = new OrderByOperator();
-
-    CollectorTestSink sink = new CollectorTestSink();
-    oper.outport.setSink(sink);
-    oper.addOrderByRule(new OrderByRule<Integer>("b"));
-    oper.setDescending(true);
-
-    oper.setup(null);
-    oper.beginWindow(1);
-
-    HashMap<String, Object> tuple = new HashMap<String, Object>();
-    tuple.put("c", 2);
-    tuple.put("a", 0);
-    tuple.put("b", 1);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 2);
-    tuple.put("b", 5);
-    tuple.put("c", 6);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 2);
-    tuple.put("b", 6);
-    tuple.put("c", 6);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 3);
-    tuple.put("c", 4);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 4);
-    tuple.put("c", 4);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 8);
-    tuple.put("c", 4);
-    oper.inport.process(tuple);
-
-    oper.endWindow();
-    oper.teardown();
-
-    LOG.debug("{}", sink.collectedTuples);
-  }
-
-  private static final Logger LOG = LoggerFactory.getLogger(OrderByOperatorTest.class);
-
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/streamquery/RightOuterJoinOperatorTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/streamquery/RightOuterJoinOperatorTest.java b/library/src/test/java/com/datatorrent/lib/streamquery/RightOuterJoinOperatorTest.java
deleted file mode 100644
index 3a57427..0000000
--- a/library/src/test/java/com/datatorrent/lib/streamquery/RightOuterJoinOperatorTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery;
-
-import java.util.HashMap;
-
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.datatorrent.lib.streamquery.condition.Condition;
-import com.datatorrent.lib.streamquery.condition.JoinColumnEqualCondition;
-import com.datatorrent.lib.streamquery.index.ColumnIndex;
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-public class RightOuterJoinOperatorTest
-{
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  @Test
-  public void testSqlSelect()
-  {
-    // create operator
-    OuterJoinOperator oper = new OuterJoinOperator();
-    oper.setRighttJoin();
-    CollectorTestSink sink = new CollectorTestSink();
-    oper.outport.setSink(sink);
-
-    // set column join condition  
-    Condition cond = new JoinColumnEqualCondition("a", "a");
-    oper.setJoinCondition(cond);
-    
-    // add columns  
-    oper.selectTable1Column(new ColumnIndex("b", null));
-    oper.selectTable2Column(new ColumnIndex("c", null));
-
-    oper.setup(null);
-    oper.beginWindow(1);
-
-    HashMap<String, Object> tuple = new HashMap<String, Object>();
-    tuple.put("a", 0);
-    tuple.put("b", 1);
-    tuple.put("c", 2);
-    oper.inport1.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 3);
-    tuple.put("c", 4);
-    oper.inport1.process(tuple);
-
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 0);
-    tuple.put("b", 7);
-    tuple.put("c", 8);
-    oper.inport2.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 5);
-    tuple.put("c", 6);
-    oper.inport2.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 2);
-    tuple.put("b", 11);
-    tuple.put("c", 12);
-    oper.inport2.process(tuple);
-    
-    oper.endWindow();
-    oper.teardown();
-
-    LOG.debug("{}", sink.collectedTuples);
-  }
-
-  private static final Logger LOG = LoggerFactory.getLogger(RightOuterJoinOperatorTest.class);
-
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/streamquery/SelectOperatorTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/streamquery/SelectOperatorTest.java b/library/src/test/java/com/datatorrent/lib/streamquery/SelectOperatorTest.java
deleted file mode 100644
index 8e6620e..0000000
--- a/library/src/test/java/com/datatorrent/lib/streamquery/SelectOperatorTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery;
-
-import java.util.HashMap;
-
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.datatorrent.lib.streamquery.condition.EqualValueCondition;
-import com.datatorrent.lib.streamquery.index.ColumnIndex;
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-/**
- * Functional test for {@link com.datatorrent.lib.streamquery.SelectOperatorTest}.
- */
-public class SelectOperatorTest
-{
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  @Test
-  public void testSqlSelect()
-  {
-    // create operator
-    SelectOperator oper = new SelectOperator();
-    oper.addIndex(new ColumnIndex("b", null));
-    oper.addIndex(new ColumnIndex("c", null));
-
-    EqualValueCondition  condition = new EqualValueCondition();
-    condition.addEqualValue("a", 1);
-    oper.setCondition(condition);
-
-    CollectorTestSink sink = new CollectorTestSink();
-    oper.outport.setSink(sink);
-
-    oper.setup(null);
-    oper.beginWindow(1);
-
-    HashMap<String, Object> tuple = new HashMap<String, Object>();
-    tuple.put("a", 0);
-    tuple.put("b", 1);
-    tuple.put("c", 2);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 3);
-    tuple.put("c", 4);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 5);
-    tuple.put("c", 6);
-    oper.inport.process(tuple);
-
-    oper.endWindow();
-    oper.teardown();
-
-    LOG.debug("{}", sink.collectedTuples);
-  }
-
-  private static final Logger LOG = LoggerFactory.getLogger(SelectOperatorTest.class);
-
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/streamquery/SelectTopOperatorTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/streamquery/SelectTopOperatorTest.java b/library/src/test/java/com/datatorrent/lib/streamquery/SelectTopOperatorTest.java
deleted file mode 100644
index c92c6c1..0000000
--- a/library/src/test/java/com/datatorrent/lib/streamquery/SelectTopOperatorTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery;
-
-import java.util.HashMap;
-
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-public class SelectTopOperatorTest
-{
-  @SuppressWarnings({"rawtypes", "unchecked"})
-  @Test
-  public void testOperator() throws Exception
-  {
-    SelectTopOperator oper = new SelectTopOperator();
-    oper.setTopValue(2);
-    CollectorTestSink sink = new CollectorTestSink();
-    oper.outport.setSink(sink);
-    
-    oper.beginWindow(1);
-    HashMap<String, Object> tuple = new HashMap<String, Object>();
-    tuple.put("a", 0);
-    tuple.put("b", 1);
-    tuple.put("c", 2);
-    oper.inport.process(tuple);
-    
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 3);
-    tuple.put("c", 4);
-    oper.inport.process(tuple);
-    
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 5);
-    tuple.put("c", 6);
-    oper.inport.process(tuple);
-    oper.endWindow();
-
-    LOG.debug("{}", sink.collectedTuples);
-  }
-
-  private static final Logger LOG = LoggerFactory.getLogger(SelectTopOperatorTest.class);
-
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/streamquery/UpdateOperatorTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/streamquery/UpdateOperatorTest.java b/library/src/test/java/com/datatorrent/lib/streamquery/UpdateOperatorTest.java
deleted file mode 100644
index 42af56b..0000000
--- a/library/src/test/java/com/datatorrent/lib/streamquery/UpdateOperatorTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery;
-
-import java.util.HashMap;
-
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.datatorrent.lib.streamquery.condition.EqualValueCondition;
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-public class UpdateOperatorTest
-{
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  @Test
-  public void testSqlSelect()
-  {
-    // create operator
-    UpdateOperator oper = new UpdateOperator();
-
-    EqualValueCondition  condition = new EqualValueCondition();
-    condition.addEqualValue("a", 1);
-    oper.setCondition(condition);
-    oper.addUpdate("c", 100);
-
-    CollectorTestSink sink = new CollectorTestSink();
-    oper.outport.setSink(sink);
-
-    oper.setup(null);
-    oper.beginWindow(1);
-
-    HashMap<String, Object> tuple = new HashMap<String, Object>();
-    tuple.put("a", 0);
-    tuple.put("b", 1);
-    tuple.put("c", 2);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 3);
-    tuple.put("c", 4);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 5);
-    tuple.put("c", 6);
-    oper.inport.process(tuple);
-
-    oper.endWindow();
-    oper.teardown();
-
-    LOG.debug("{}", sink.collectedTuples);
-  }
-
-  private static final Logger LOG = LoggerFactory.getLogger(UpdateOperatorTest.class);
-
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/streamquery/advanced/BetweenConditionTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/streamquery/advanced/BetweenConditionTest.java b/library/src/test/java/com/datatorrent/lib/streamquery/advanced/BetweenConditionTest.java
deleted file mode 100644
index b0500eb..0000000
--- a/library/src/test/java/com/datatorrent/lib/streamquery/advanced/BetweenConditionTest.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery.advanced;
-
-import java.util.HashMap;
-
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.datatorrent.lib.streamquery.SelectOperator;
-import com.datatorrent.lib.streamquery.condition.BetweenCondition;
-import com.datatorrent.lib.streamquery.index.ColumnIndex;
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-/**
- * Functional test for {@link com.datatorrent.lib.streamquery.advanced.BetweenConditionTest}.
- */
-public class BetweenConditionTest
-{
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  @Test
-  public void testSqlSelect()
-  {
-    // create operator
-    SelectOperator oper = new SelectOperator();
-    oper.addIndex(new ColumnIndex("b", null));
-    oper.addIndex(new ColumnIndex("c", null));
-
-    BetweenCondition cond = new BetweenCondition("a", 0, 2);
-    oper.setCondition(cond);
-
-
-    CollectorTestSink sink = new CollectorTestSink();
-    oper.outport.setSink(sink);
-
-    oper.setup(null);
-    oper.beginWindow(1);
-
-    HashMap<String, Object> tuple = new HashMap<String, Object>();
-    tuple.put("a", 0);
-    tuple.put("b", 1);
-    tuple.put("c", 2);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 1);
-    tuple.put("b", 3);
-    tuple.put("c", 4);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 2);
-    tuple.put("b", 5);
-    tuple.put("c", 6);
-    oper.inport.process(tuple);
-
-    tuple = new HashMap<String, Object>();
-    tuple.put("a", 3);
-    tuple.put("b", 7);
-    tuple.put("c", 8);
-    oper.inport.process(tuple);
-    
-    oper.endWindow();
-    oper.teardown();
-
-    LOG.debug("{}", sink.collectedTuples);
-  }
-
-  private static final Logger LOG = LoggerFactory.getLogger(BetweenConditionTest.class);
-}


[06/12] apex-malhar git commit: Updated algo & working on math operators

Posted by th...@apache.org.
http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/algo/FilterKeysHashMap.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/algo/FilterKeysHashMap.java b/library/src/main/java/com/datatorrent/lib/algo/FilterKeysHashMap.java
deleted file mode 100644
index 0f9a738..0000000
--- a/library/src/main/java/com/datatorrent/lib/algo/FilterKeysHashMap.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.validation.constraints.NotNull;
-
-import com.datatorrent.api.DefaultInputPort;
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.api.annotation.OperatorAnnotation;
-import com.datatorrent.api.annotation.Stateless;
-
-import com.datatorrent.lib.util.BaseKeyOperator;
-
-
-/**
- * This operator filters the incoming stream of key value pairs based on the keys specified by property "keys".
- * <p>
- * Filters the incoming stream based of keys specified by property "keys". If
- * property "inverse" is set to "true", then all keys except those specified by "keys" are emitted
- * </p>
- * <p>
- * Operator assumes that the key, val pairs are immutable objects. If this operator has to be used for mutable objects,
- * override "cloneKey()" to make copy of K, and "cloneValue()" to make copy of V.<br>
- * This is a pass through node.<br>
- * <br>
- * <b>StateFull : No, </b> tuple are processed in current window. <br>
- * <b>Partitions : Yes, </b> no dependency among input tuples. <br>
- * <br>
- * <b>Ports</b>:<br>
- * <b>data</b>: Expects Map&lt;K, HashMap&lt;K,V&gt;&gt. Filters are applied only on keys of second hash map.<br>
- * <b>filter</b>: Emits HashMap&lt;K, HashMap&lt;K,V&gt;&gt.<br>
- * <br>
- * <b>Properties</b>:<br>
- * <b>keys</b>: The keys to pass through, rest are filtered/dropped. A comma separated list of keys.<br>
- * <br>
- * </p>
- *
- * @displayName Filter Keyval Pairs By Key HashMap
- * @category Stream Manipulators
- * @tags filter, key value
- *
- * @since 0.3.2
- */
-@Stateless
-@OperatorAnnotation(partitionable = true)
-public class FilterKeysHashMap<K, V> extends BaseKeyOperator<K>
-{
-  /**
-   * Filter keys map.
-   */
-  @NotNull()
-  HashMap<K, V> keys = new HashMap<K, V>();
-
-  /**
-   * Emits key not in filter map.
-   */
-  boolean inverse = false;
-
-  /**
-   * The input port on which key value pairs are received.
-   */
-  public final transient DefaultInputPort<Map<K, HashMap<K, V>>> data = new DefaultInputPort<Map<K, HashMap<K, V>>>()
-  {
-    /**
-     * Processes incoming tuples one key,val at a time. Emits if at least one key makes the cut.
-     * By setting inverse as true, match is changed to un-matched.
-     */
-    @Override
-    public void process(Map<K, HashMap<K, V>> tuple)
-    {
-      HashMap<K, HashMap<K, V>> dtuple = null;
-      for (Map.Entry<K, HashMap<K, V>> e: tuple.entrySet()) {
-        HashMap<K, V> dtuple2 = null;
-        for (Map.Entry<K, V> e2: e.getValue().entrySet()) {
-          boolean contains = keys.containsKey(e2.getKey());
-          if ((contains && !inverse) || (!contains && inverse)) {
-            if (dtuple2 == null) {
-              dtuple2 = new HashMap<K, V>(4); // usually the filter keys are very few, so 4 is just fine
-            }
-            dtuple2.put(cloneKey(e2.getKey()), cloneValue(e2.getValue()));
-          }
-        }
-        if (dtuple == null && dtuple2 != null) {
-          dtuple = new HashMap<K, HashMap<K, V>>();
-        }
-        if (dtuple != null && dtuple2 != null) {
-          dtuple.put(cloneKey(e.getKey()), dtuple2);
-        }
-      }
-      if (dtuple != null) {
-        filter.emit(dtuple);
-      }
-    }
-  };
-
-  /**
-   * The output port on which filtered key value pairs are emitted.
-   */
-  public final transient DefaultOutputPort<HashMap<K, HashMap<K, V>>> filter = new DefaultOutputPort<HashMap<K, HashMap<K, V>>>();
-
-  /**
-   * getter function for parameter inverse
-   *
-   * @return inverse
-   */
-  public boolean getInverse()
-  {
-    return inverse;
-  }
-
-  /**
-   * True means match; False means unmatched
-   *
-   * @param val
-   */
-  public void setInverse(boolean val)
-  {
-    inverse = val;
-  }
-
-  /**
-   * Adds a key to the filter list
-   *
-   * @param str
-   */
-  public void setKey(K str)
-  {
-    keys.put(str, null);
-  }
-
-  /**
-   * Adds the list of keys to the filter list
-   *
-   * @param list
-   */
-  public void setKeys(K[] list)
-  {
-    if (list != null) {
-      for (K e: list) {
-        keys.put(e, null);
-      }
-    }
-  }
-
-  /*
-   * Clears the filter list
-   */
-  public void clearKeys()
-  {
-    keys.clear();
-  }
-
-  /**
-   * Clones V object. By default assumes immutable object (i.e. a copy is not made). If object is mutable, override this method
-   *
-   * @param v value to be cloned
-   * @return returns v as is (assumes immutable object)
-   */
-  public V cloneValue(V v)
-  {
-    return v;
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/algo/FilterKeysMap.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/algo/FilterKeysMap.java b/library/src/main/java/com/datatorrent/lib/algo/FilterKeysMap.java
deleted file mode 100644
index 136a5d4..0000000
--- a/library/src/main/java/com/datatorrent/lib/algo/FilterKeysMap.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.validation.constraints.NotNull;
-
-import com.datatorrent.api.DefaultInputPort;
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.api.annotation.OperatorAnnotation;
-import com.datatorrent.api.annotation.Stateless;
-
-import com.datatorrent.lib.util.BaseKeyOperator;
-import com.datatorrent.lib.util.UnifierHashMap;
-
-/**
- * This operator filters the incoming stream of key value pairs based on the keys specified by property "keys"..
- * <p>
- * Filters the incoming stream based of keys specified by property "keys". If
- * property "inverse" is set to "true", then all keys except those specified by "keys" are emitted
- * </p>
- * <p>
- * Operator assumes that the key, val pairs are immutable objects. If this operator has to be used for mutable objects,
- * override "cloneKey()" to make copy of K, and "cloneValue()" to make copy of V.<br>
- * This is a pass through node<br>
- * <br>
- * <b>StateFull : No, </b> tuple are processed in current window. <br>
- * <b>Partitions : Yes, </b> no dependency among input tuples. <br>
- * <br>
- * <b>Ports</b>:<br>
- * <b>data</b>: Expects Map&lt;K,V&gt;<br>
- * <b>filter</b>: Emits HashMap&lt;K,V&gt;<br>
- * <br>
- * <b>Properties</b>:<br>
- * <b>keys</b>: The keys to pass through, rest are filtered/dropped. A comma separated list of keys<br>
- * <br>
- * </p>
- *
- * @displayName Filter Keyval Pairs By Key Generic
- * @category Rules and Alerts
- * @tags filter, key value
- *
- * @since 0.3.2
- */
-@Stateless
-@OperatorAnnotation(partitionable = true)
-public class FilterKeysMap<K,V> extends BaseKeyOperator<K>
-{
-  /**
-   * Filter keys map.
-   */
-  @NotNull()
-  HashMap<K, V> keys = new HashMap<K, V>();
-
-  /**
-   * Emits key not in filter map.
-   */
-  boolean inverse = false;
-
-  /**
-   * The input port on which key value pairs are received.
-   */
-  public final transient DefaultInputPort<Map<K, V>> data = new DefaultInputPort<Map<K, V>>()
-  {
-    /**
-     * Processes incoming tuples one key,val at a time. Emits if at least one key makes the cut
-     * By setting inverse as true, match is changed to un-matched
-     */
-    @Override
-    public void process(Map<K, V> tuple)
-    {
-      HashMap<K, V> dtuple = null;
-      for (Map.Entry<K, V> e: tuple.entrySet()) {
-        boolean contains = keys.containsKey(e.getKey());
-        if ((contains && !inverse) || (!contains && inverse)) {
-          if (dtuple == null) {
-            dtuple = new HashMap<K, V>(4); // usually the filter keys are very few, so 4 is just fine
-          }
-          dtuple.put(cloneKey(e.getKey()), cloneValue(e.getValue()));
-        }
-      }
-      if (dtuple != null) {
-        filter.emit(dtuple);
-      }
-    }
-  };
-
-  /**
-   * The output port on which filtered key value pairs are emitted.
-   */
-  public final transient DefaultOutputPort<HashMap<K, V>> filter = new DefaultOutputPort<HashMap<K, V>>()
-  {
-    @Override
-    public Unifier<HashMap<K, V>> getUnifier()
-    {
-      return new UnifierHashMap<K, V>();
-    }
-  };
-
-  /**
-   * If true then only matches are emitted. If false then only non matches are emitted.
-   * @return inverse
-   */
-  public boolean getInverse()
-  {
-    return inverse;
-  }
-
-
-  /**
-   * Sets the inverse property. If true then only matches are emitted. If false then only non matches are emitted.
-   * @param val
-   */
-  public void setInverse(boolean val)
-  {
-    inverse = val;
-  }
-
-  /**
-   * Adds a key to the filter list
-   * @param str
-   */
-  public void setKey(K str)
-  {
-    keys.put(str, null);
-  }
-
-  /**
-   * Adds the list of keys to the filter list
-   * @param list
-   */
-  public void setKeys(K[] list)
-  {
-    if (list != null) {
-      for (K e: list) {
-        keys.put(e, null);
-      }
-    }
-  }
-
-  /**
-   * The keys to filter. The values in the map should be null.
-   * @param keys
-   */
-  public void setKeys(HashMap<K, V> keys)
-  {
-    this.keys = keys;
-  }
-
-  /**
-   * Gets the keys to filter.
-   * @return Returns a map containing the keys.
-   */
-  public HashMap<K, V> getKeys()
-  {
-    return keys;
-  }
-
-  /*
-   * Clears the filter list
-   */
-  public void clearKeys()
-  {
-    keys.clear();
-  }
-
-  /**
-   * Clones V object. By default assumes immutable object (i.e. a copy is not made). If object is mutable, override this method
-   * @param v value to be cloned
-   * @return returns v as is (assumes immutable object)
-   */
-  public V cloneValue(V v)
-  {
-    return v;
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/algo/FilterValues.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/algo/FilterValues.java b/library/src/main/java/com/datatorrent/lib/algo/FilterValues.java
index 3b78ac4..c7a70bb 100644
--- a/library/src/main/java/com/datatorrent/lib/algo/FilterValues.java
+++ b/library/src/main/java/com/datatorrent/lib/algo/FilterValues.java
@@ -18,7 +18,8 @@
  */
 package com.datatorrent.lib.algo;
 
-import java.util.HashMap;
+import java.util.Arrays;
+import java.util.HashSet;
 
 import javax.validation.constraints.NotNull;
 
@@ -72,7 +73,7 @@ public class FilterValues<T> extends BaseOperator
     @Override
     public void process(T tuple)
     {
-      boolean contains = values.containsKey(tuple);
+      boolean contains = values.contains(tuple);
       if ((contains && !inverse) || (!contains && inverse)) {
         filter.emit(cloneValue(tuple));
       }
@@ -85,7 +86,7 @@ public class FilterValues<T> extends BaseOperator
   public final transient DefaultOutputPort<T> filter = new DefaultOutputPort<T>();
 
   @NotNull()
-  HashMap<T, Object> values = new HashMap<T, Object>();
+  HashSet<T> values = new HashSet<T>();
   boolean inverse = false;
 
   /**
@@ -114,7 +115,7 @@ public class FilterValues<T> extends BaseOperator
   public void setValue(T val)
   {
     if (val != null) {
-      values.put(val, null);
+      values.add(val);
     }
   }
 
@@ -126,9 +127,7 @@ public class FilterValues<T> extends BaseOperator
   public void setValues(T[] list)
   {
     if (list != null) {
-      for (T e: list) {
-        values.put(e, null);
-      }
+      values.addAll(Arrays.asList(list));
     }
   }
 
@@ -136,7 +135,7 @@ public class FilterValues<T> extends BaseOperator
    * Gets the values to be filtered.
    * @return The values to be filtered.
    */
-  public HashMap<T, Object> getValues()
+  public HashSet<T> getValues()
   {
     return values;
   }
@@ -146,7 +145,7 @@ public class FilterValues<T> extends BaseOperator
    * values are set to be null.
    * @param values The values to be filtered.
    */
-  public void setValues(HashMap<T, Object> values)
+  public void setValues(HashSet<T> values)
   {
     this.values = values;
   }

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/algo/FirstMatchMap.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/algo/FirstMatchMap.java b/library/src/main/java/com/datatorrent/lib/algo/FirstMatchMap.java
deleted file mode 100644
index 991b24b..0000000
--- a/library/src/main/java/com/datatorrent/lib/algo/FirstMatchMap.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import com.datatorrent.api.DefaultInputPort;
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.api.annotation.OperatorAnnotation;
-
-import com.datatorrent.lib.util.BaseMatchOperator;
-
-/**
- * This operator filters the incoming stream of key value pairs by obtaining the values corresponding to a specified key,
- * and comparing those values to a specified number.&nbsp;The first key value pair, in each window, to satisfy the comparison is emitted.
- * <p>
- * A compare metric on a Number tuple based on the property "key", "value", and "cmp"; the first match is emitted.
- *  The comparison is done by getting double value from the Number.
- * </p>
- * <p>
- * This module is a pass through<br>
- * The operators by default assumes immutable keys. If the key is mutable, use cloneKey to make a copy<br>
- * <br>
- * <b>StateFull : Yes, </b> tuple are processed in current window. <br>
- * <b>Partitions : No, </b>will yield wrong results. <br>
- * <br>
- * <br>
- * <b>Ports</b>:<br>
- * <b>data</b>: expects Map&lt;K,V extends Number&gt;<br>
- * <b>first</b>: emits HashMap&lt;K,V&gt;<br>
- * <br>
- * <b>Properties</b>:<br>
- * <b>key</b>: The key on which compare is done<br>
- * <b>value</b>: The value to compare with<br>
- * <b>cmp</b>: The compare function. Supported values are "lte", "lt", "eq", "neq", "gt", "gte". Default is "eq"<br>
- * <br>
- * <b>Specific compile time checks</b>:<br>
- * Key must be non empty<br>
- * Value must be able to convert to a "double"<br>
- * Compare string, if specified, must be one of "lte", "lt", "eq", "neq", "gt", "gte"<br>
- * <br>
- * </p>
- *
- * @displayName Emit First Match (Number)
- * @category Rules and Alerts
- * @tags filter, key value, numeric
- *
- * @since 0.3.2
- */
-
-@OperatorAnnotation(partitionable = false)
-public class FirstMatchMap<K, V extends Number> extends BaseMatchOperator<K,V>
-{
-  /**
-   * Tuple emitted flag.
-   */
-  boolean emitted = false;
-
-  /**
-   * The port on which key value pairs are received.
-   */
-  public final transient DefaultInputPort<Map<K, V>> data = new DefaultInputPort<Map<K, V>>()
-  {
-    /**
-     * Checks if required key,val pair exists in the HashMap. If so tuple is emitted, and emitted flag is set
-     * to true
-     */
-    @Override
-    public void process(Map<K, V> tuple)
-    {
-      if (emitted) {
-        return;
-      }
-      V val = tuple.get(getKey());
-      if (val == null) { // skip if key does not exist
-        return;
-      }
-      if (compareValue(val.doubleValue())) {
-        first.emit(cloneTuple(tuple));
-        emitted = true;
-      }
-    }
-  };
-
-  /**
-   * The output port on which the first satisfying key value pair is emitted.
-   */
-  public final transient DefaultOutputPort<HashMap<K, V>> first = new DefaultOutputPort<HashMap<K, V>>();
-
-  /**
-   * Resets emitted flag to false
-   * @param windowId
-   */
-  @Override
-  public void beginWindow(long windowId)
-  {
-    emitted = false;
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/algo/FirstN.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/algo/FirstN.java b/library/src/main/java/com/datatorrent/lib/algo/FirstN.java
deleted file mode 100644
index d9db3cf..0000000
--- a/library/src/main/java/com/datatorrent/lib/algo/FirstN.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.commons.lang.mutable.MutableInt;
-
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.api.annotation.OperatorAnnotation;
-
-import com.datatorrent.lib.util.AbstractBaseNOperatorMap;
-
-/**
- * This operator filters the incoming stream of key value pairs by emitting the first N key value pairs with a specified key in each window.
- * <p>
- * Emits first N tuples of a particular key.
- * </p>
- * <p>
- * This module is a pass through module<br>
- * <br>
- * <b>StateFull : Yes, </b> tuple are compare across application window(s). <br>
- * <b>Partitions : No, </b> will yield wrong results. <br>
- * <br>
- * <b>Ports</b>:<br>
- * <b>data</b>: Input data port expects HashMap&lt;K,V&gt;<br>
- * <b>bottom</b>: Output data port, emits HashMap&lt;K,V&gt;<br>
- * <br>
- * <b>Properties</b>:<br>
- * <b>N</b>: The number of top values to be emitted per key<br>
- * <br>
- * <b>Specific compile time checks are</b>:<br>
- * N: Has to be >= 1<br>
- * <br>
- * <br>
- * </p>
- *
- * @displayName First N Keyval Pairs Matching Key
- * @category Rules and Alerts
- * @tags filter, key value
- *
- * @since 0.3.2
- */
-@OperatorAnnotation(partitionable = false)
-public class FirstN<K,V> extends AbstractBaseNOperatorMap<K, V>
-{
-  /**
-   * key count map.
-   */
-  HashMap<K, MutableInt> keycount = new HashMap<K, MutableInt>();
-
-  /**
-   * Inserts tuples into the queue
-   * @param tuple to insert in the queue
-   */
-  @Override
-  public void processTuple(Map<K, V> tuple)
-  {
-    for (Map.Entry<K, V> e: tuple.entrySet()) {
-      MutableInt count = keycount.get(e.getKey());
-      if (count == null) {
-        count = new MutableInt(0);
-        keycount.put(e.getKey(), count);
-      }
-      count.increment();
-      if (count.intValue() <= getN()) {
-        first.emit(cloneTuple(e.getKey(), e.getValue()));
-      }
-    }
-  }
-
-  /**
-   * The output port on which the first N key value pairs are emitted.
-   */
-  public final transient DefaultOutputPort<HashMap<K, V>> first = new DefaultOutputPort<HashMap<K, V>>();
-
-  /**
-   * Clears the cache to start anew in a new window
-   */
-  @Override
-  public void endWindow()
-  {
-    keycount.clear();
-  }
-
-  /**
-   * First N number of KeyValue pairs for each Key.
-   *
-   * @param val
-   */
-  public void setN(int val)
-  {
-    super.setN(val);
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/algo/FirstTillMatch.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/algo/FirstTillMatch.java b/library/src/main/java/com/datatorrent/lib/algo/FirstTillMatch.java
deleted file mode 100644
index d6a2615..0000000
--- a/library/src/main/java/com/datatorrent/lib/algo/FirstTillMatch.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-import java.util.HashMap;
-
-import com.datatorrent.api.DefaultInputPort;
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.api.annotation.OperatorAnnotation;
-
-import com.datatorrent.lib.util.BaseMatchOperator;
-
-/**
- * This operator filters the incoming stream of key value pairs by obtaining the values corresponding to a specified key,
- * and comparing those values to a specified number.&nbsp;For each window, all key value pairs are emitted by the operator until a value satisfying the comparison is encountered.
- * <p>
- * All key.val pairs with val sub-classed from Number are emitted till the first match;  A compare metric is done based on the property "key",
- * "value", and "cmp". Then on no tuple is emitted in that window. The comparison is done by getting double value of the Number.
- * </p>
- * <p>
- * This module is a pass through<br>
- * <br>
- * <b>StateFull : Yes, </b> tuple are processed in current window. <br>
- * <b>Partitions : No, </b>will yield wrong results. <br>
- * <br>
- * <br>
- * <b>Ports</b>:<br>
- * <b>data</b>: Input port, expects HashMap&lt;K,V&gt;<br>
- * <b>first</b>: Output port, emits HashMap&lt;K,V&gt; if compare function returns true<br>
- * <br>
- * <b>Properties</b>:<br>
- * <b>key</b>: The key on which compare is done<br>
- * <b>value</b>: The value to compare with<br>
- * <b>cmp</b>: The compare function. Supported values are "lte", "lt", "eq", "neq", "gt", "gte". Default is "eq"<br>
- * <br>
- * <b>Specific compile time checks</b>:<br>
- * Key must be non empty<br>
- * Value must be able to convert to a "double"<br>
- * Compare string, if specified, must be one of "lte", "lt", "eq", "neq", "gt", "gte"<br>
- * <br>
- * </p>
- *
- * @displayName Emit Keyval Pairs Until Match (Number)
- * @category Rules and Alerts
- * @tags filter, key value, numeric
- *
- * @since 0.3.2
- */
-@OperatorAnnotation(partitionable = false)
-public class FirstTillMatch<K, V extends Number> extends BaseMatchOperator<K, V>
-{
-  /**
-   * Tuple emitted flag.
-   */
-  boolean emitted = false;
-
-  /**
-   * The input port on which incoming key value pairs are received.
-   */
-  public final transient DefaultInputPort<HashMap<K, V>> data = new DefaultInputPort<HashMap<K, V>>()
-  {
-    /**
-     * Compares the key,val pair with the match condition. Till a match is found tuples are emitted.
-     * Once a match is found, state is set to emitted, and no more tuples are compared (no more emits).
-     */
-    @Override
-    public void process(HashMap<K, V> tuple)
-    {
-      if (emitted) {
-        return;
-      }
-      V val = tuple.get(getKey());
-      if (val == null) { // skip if the key does not exist
-        return;
-      }
-      if (compareValue(val.doubleValue())) {
-        emitted = true;
-      }
-      if (!emitted) {
-        first.emit(cloneTuple(tuple));
-      }
-    }
-  };
-
-  /**
-   * The output port on which key value pairs are emitted until the first match.
-   */
-  public final transient DefaultOutputPort<HashMap<K, V>> first = new DefaultOutputPort<HashMap<K, V>>();
-
-  /**
-   * Emitted set is reset to false
-   * @param windowId
-   */
-  @Override
-  public void beginWindow(long windowId)
-  {
-    emitted = false;
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/algo/InsertSortDesc.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/algo/InsertSortDesc.java b/library/src/main/java/com/datatorrent/lib/algo/InsertSortDesc.java
deleted file mode 100644
index 4498cfb..0000000
--- a/library/src/main/java/com/datatorrent/lib/algo/InsertSortDesc.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.PriorityQueue;
-
-import com.datatorrent.api.DefaultInputPort;
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.api.annotation.InputPortFieldAnnotation;
-import com.datatorrent.api.annotation.OperatorAnnotation;
-import com.datatorrent.api.annotation.OutputPortFieldAnnotation;
-import com.datatorrent.lib.util.AbstractBaseSortOperator;
-import com.datatorrent.lib.util.ReversibleComparator;
-
-/**
- * This operator takes the values it receives each window and outputs them in ascending order at the end of each window.
- * <p>
- * Incoming tuple is inserted into already existing sorted list in a descending order. At the end of the window the resultant sorted list is emitted on the output ports.
- * </p>
- * <p>
- * <br>
- * <b>StateFull : Yes, </b> tuple are compare across application window(s). <br>
- * <b>Partitions : No, </b> will yield wrong results. <br>
- * <br>
- * <b>Ports</b>:<br>
- * <b>data</b>: expects K<br>
- * <b>datalist</b>: expects ArrayList&lt;K&gt;<br>
- * <b>sortlist</b>: emits ArrayList&lt;K&gt;<br>
- * <b>sorthash</b>: emits HashMap&lt;K,Integer&gt;<br>
- * <br>
- * <br>
- * </p>
- * @displayName Sort Descending
- * @category Stream Manipulators
- * @tags rank, sort
- *
- * @since 0.3.2
- */
-//
-// TODO: Override PriorityQueue and rewrite addAll to insert with location
-//
-@OperatorAnnotation(partitionable = false)
-public class InsertSortDesc<K> extends AbstractBaseSortOperator<K>
-{
-  /**
-   * The input port on which individual tuples are received for sorting.
-   */
-  @InputPortFieldAnnotation(optional = true)
-  public final transient DefaultInputPort<K> data = new DefaultInputPort<K>()
-  {
-    /**
-     * Adds tuple to sorted queue
-     */
-    @Override
-    public void process(K tuple)
-    {
-      processTuple(tuple);
-    }
-  };
-  /**
-   * The input port on which lists of tuples are received for sorting.
-   */
-  @InputPortFieldAnnotation(optional = true)
-  public final transient DefaultInputPort<ArrayList<K>> datalist = new DefaultInputPort<ArrayList<K>>()
-  {
-    /**
-     * Adds tuples to sorted queue
-     */
-    @Override
-    public void process(ArrayList<K> tuple)
-    {
-      processTuple(tuple);
-    }
-  };
-
-  /**
-   * The output port on which a sorted descending list of tuples is emitted.
-   */
-  @OutputPortFieldAnnotation(optional = true)
-  public final transient DefaultOutputPort<ArrayList<K>> sort = new DefaultOutputPort<ArrayList<K>>();
-  @OutputPortFieldAnnotation(optional = true)
-  /**
-   * This output port emits a map from tuples to a count of the number of times each tuple occurred in the application window.
-   */
-  public final transient DefaultOutputPort<HashMap<K, Integer>> sorthash = new DefaultOutputPort<HashMap<K, Integer>>();
-
-  @Override
-  public void initializeQueue()
-  {
-    pqueue = new PriorityQueue<K>(getSize(), new ReversibleComparator<K>(false));
-  }
-
-
-  @Override
-  public void emitToList(ArrayList<K> list)
-  {
-    sort.emit(list);
-  }
-
-  @Override
-  public void emitToHash(HashMap<K,Integer> map)
-  {
-    sorthash.emit(map);
-  }
-
-  @Override
-  public boolean doEmitList()
-  {
-    return sort.isConnected();
-  }
-
-  @Override
-  public boolean doEmitHash()
-  {
-    return sorthash.isConnected();
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/algo/InvertIndex.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/algo/InvertIndex.java b/library/src/main/java/com/datatorrent/lib/algo/InvertIndex.java
deleted file mode 100644
index 821dfb9..0000000
--- a/library/src/main/java/com/datatorrent/lib/algo/InvertIndex.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
-import com.datatorrent.api.DefaultInputPort;
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.api.Operator.Unifier;
-import com.datatorrent.api.annotation.OperatorAnnotation;
-
-import com.datatorrent.lib.util.BaseKeyValueOperator;
-
-/**
- * This operator takes a stream of key value pairs each window,
- * and outputs a set of inverted key value pairs at the end of each window.
- * <p>
- * Inverts the index and sends out the tuple on output port "index" at the end of the window.
- * </p>
- * <p>
- * This is an end of window operator<br>
- * <br>
- * <b>StateFull : Yes, </b> tuple are compare across application window(s). <br>
- * <b>Partitions : Yes, </b> inverted indexes are unified by instance of same operator. <br>
- * <br>
- * <br>
- * <b>Ports</b>:<br>
- * <b>data</b>: expects &lt;K,V&gt;<br>
- * <b>index</b>: emits &lt;V,ArrayList&lt;K&gt;&gt;(1); one HashMap per V<br>
- * <br>
- * </p>
- *
- * @displayName Invert Key Value Pairs
- * @category Stream Manipulators
- * @tags key value
- *
- * @since 0.3.2
- */
-
-@OperatorAnnotation(partitionable = true)
-public class InvertIndex<K, V> extends BaseKeyValueOperator<K, V> implements Unifier<HashMap<V, ArrayList<K>>>
-{
-  /**
-   * Inverted key/value map.
-   */
-  protected HashMap<V, ArrayList<K>> map = new HashMap<V, ArrayList<K>>();
-
-  /**
-   * The input port on which key value pairs are received.
-   */
-  public final transient DefaultInputPort<HashMap<K, V>> data = new DefaultInputPort<HashMap<K, V>>()
-  {
-    /**
-     * Reverse indexes a HashMap<K, ArrayList<V>> tuple
-     */
-    @Override
-    public void process(HashMap<K, V> tuple)
-    {
-      for (Map.Entry<K, V> e: tuple.entrySet()) {
-        if (e.getValue() == null) { // error tuple?
-          continue;
-        }
-        insert(e.getValue(), cloneKey(e.getKey()));
-      }
-    }
-  };
-
-  /**
-   * The output port on which inverted key value pairs are emitted.
-   */
-  public final transient DefaultOutputPort<HashMap<V, ArrayList<K>>> index = new DefaultOutputPort<HashMap<V, ArrayList<K>>>()
-  {
-    @Override
-    public Unifier<HashMap<V, ArrayList<K>>> getUnifier()
-    {
-      return new InvertIndex<K, V>();
-    }
-  };
-
-  /**
-   *
-   * Returns the ArrayList stored for a key
-   *
-   * @param key
-   */
-  void insert(V val, K key)
-  {
-    ArrayList<K> list = map.get(val);
-    if (list == null) {
-      list = new ArrayList<K>(4);
-      map.put(cloneValue(val), list);
-    }
-    list.add(key);
-  }
-
-  /**
-   * Emit all the data and clear the hash
-   * Clears internal data
-   */
-  @Override
-  public void endWindow()
-  {
-    for (Map.Entry<V, ArrayList<K>> e: map.entrySet()) {
-      HashMap<V, ArrayList<K>> tuple = new HashMap<V, ArrayList<K>>(1);
-      tuple.put(e.getKey(), e.getValue());
-      index.emit(tuple);
-    }
-    map.clear();
-  }
-
-  /**
-   * Unifier override.
-   */
-  @Override
-  public void process(HashMap<V, ArrayList<K>> tuple)
-  {
-    for (Map.Entry<V, ArrayList<K>> e: tuple.entrySet()) {
-      ArrayList<K> keys;
-      if (map.containsKey(e.getKey())) {
-        keys = map.remove(e.getKey());
-      } else {
-        keys = new ArrayList<K>();
-      }
-      keys.addAll(e.getValue());
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/algo/InvertIndexArray.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/algo/InvertIndexArray.java b/library/src/main/java/com/datatorrent/lib/algo/InvertIndexArray.java
deleted file mode 100644
index 330049a..0000000
--- a/library/src/main/java/com/datatorrent/lib/algo/InvertIndexArray.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
-import com.datatorrent.api.DefaultInputPort;
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.api.annotation.OperatorAnnotation;
-
-import com.datatorrent.lib.util.BaseKeyValueOperator;
-
-/**
- * This operator takes a stream of key value pairs each window,
- * and outputs a set of inverted key value pairs at the end of each window.&nbsp;
- * The values in the key value pairs received by this operator are an array lists, which may multiple values.
- * <p>
- * Inverts the index and sends out the tuple on output port "index" at the end of the window.
- * </p>
- * <p>
- * This is an end of window operator<br>
- * <br>
- * <b>StateFull : Yes, </b> tuple are compare across application window(s). <br>
- * <b>Partitions : Yes, </b> inverted indexes are unified by instance of same operator. <br>
- * <br>
- * <b>Ports</b>:<br>
- * <b>data</b>: expects HashMap&lt;K,ArrayList&lt;V&gt;&gt;<br>
- * <b>index</b>: emits HashMap&lt;V,ArrayList&lt;K&gt;&gt;(1), one HashMap per V<br>
- * <br>
- * </p>
- *
- * @displayName Invert Key Value Pairs (Array)
- * @category Stream Manipulators
- * @tags key value
- *
- * @since 0.3.2
- */
-
-@OperatorAnnotation(partitionable = true)
-public class InvertIndexArray<K, V> extends BaseKeyValueOperator<K,V>
-{
-  /**
-   * Inverted key/value map.
-   */
-  protected HashMap<V, ArrayList<K>> map = new HashMap<V, ArrayList<K>>();
-
-  /**
-   * The input port on which key value pairs are received.
-   */
-  public final transient DefaultInputPort<HashMap<K, ArrayList<V>>> data = new DefaultInputPort<HashMap<K, ArrayList<V>>>()
-  {
-    /**
-     * Reverse indexes a HashMap<K, ArrayList<V>> tuple
-     */
-    @Override
-    public void process(HashMap<K, ArrayList<V>> tuple)
-    {
-      for (Map.Entry<K, ArrayList<V>> e: tuple.entrySet()) {
-        ArrayList<V> alist = e.getValue();
-        if (alist == null) { // error tuple?
-          continue;
-        }
-        for (V val : alist) {
-          insert(val, cloneKey(e.getKey()));
-        }
-      }
-    }
-  };
-
-  /**
-   * The output port or which inverted key value pairs are emitted.
-   */
-  public final transient DefaultOutputPort<HashMap<V, ArrayList<K>>> index = new DefaultOutputPort<HashMap<V, ArrayList<K>>>()
-  {
-    @Override
-    public Unifier<HashMap<V, ArrayList<K>>> getUnifier()
-    {
-      return new InvertIndex<K, V>();
-    }
-  };
-
-  /**
-   *
-   * Returns the ArrayList stored for a key
-   *
-   * @param key
-   */
-  void insert(V val, K key)
-  {
-    ArrayList<K> list = map.get(val);
-    if (list == null) {
-      list = new ArrayList<K>(4);
-      map.put(cloneValue(val), list);
-    }
-    list.add(key);
-  }
-
-  /**
-   * Emit all the data and clear the hash
-   */
-  @Override
-  public void endWindow()
-  {
-    for (Map.Entry<V, ArrayList<K>> e: map.entrySet()) {
-      HashMap<V, ArrayList<K>> tuple = new HashMap<V, ArrayList<K>>(1);
-      tuple.put(e.getKey(), e.getValue());
-      index.emit(tuple);
-    }
-    map.clear();
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/algo/LastMatchMap.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/algo/LastMatchMap.java b/library/src/main/java/com/datatorrent/lib/algo/LastMatchMap.java
deleted file mode 100644
index 3235105..0000000
--- a/library/src/main/java/com/datatorrent/lib/algo/LastMatchMap.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import com.datatorrent.api.DefaultInputPort;
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.api.annotation.OperatorAnnotation;
-
-import com.datatorrent.lib.util.BaseMatchOperator;
-
-/**
- * This operator filters the incoming stream of key value pairs by obtaining the values corresponding to a specified key,
- * and comparing those values to a specified value.&nbsp;The last key value pair, in each window, to satisfy the comparison is emitted.
- * <p>
- * A compare function is  operated on a tuple value sub-classed from Number based on the property "key", "value", and "cmp". Every tuple
- * is checked and the last one that passes the condition is send during end of window on port "last". The comparison is done by getting double
- * value from the Number.
- * </p>
- * <p>
- * This module is an end of window module<br>
- * <br>
- * <b>StateFull : Yes, </b> tuple are compare across application window(s). <br>
- * <b>Partitions : No, </b> will yield wrong result. <br>
- * <br>
- * <b>Ports</b>:<br>
- * <b>data</b>: expects Map&lt;K,V extends Number&gt;<br>
- * <b>last</b>: emits Map&lt;K,V&gt; in end of window for the last tuple on which the compare function is true<br>
- * <br>
- * <b>Properties</b>:<br>
- * <b>key</b>: The key on which compare is done<br>
- * <b>value</b>: The value to compare with<br>
- * <b>cmp</b>: The compare function. Supported values are "lte", "lt", "eq", "neq", "gt", "gte". Default is "eq"<br>
- * <br>
- * <b>Specific compile time checks</b>:<br>
- * Key must be non empty<br>
- * Value must be able to convert to a "double"<br>
- * Compare string, if specified, must be one of "lte", "lt", "eq", "neq", "gt", "gte"<br>
- * <br>
- * </p>
- *
- * @displayName Emit Last Match (Number)
- * @category Rules and Alerts
- * @tags filter, key value, numeric
- *
- * @since 0.3.2
- */
-@OperatorAnnotation(partitionable = false)
-public class LastMatchMap<K, V extends Number> extends BaseMatchOperator<K,V>
-{
-  /**
-   * Last tuple.
-   */
-  protected HashMap<K, V> ltuple = null;
-
-  /**
-   * The input port on which key value pairs are received.
-   */
-  public final transient DefaultInputPort<Map<K, V>> data = new DefaultInputPort<Map<K, V>>()
-  {
-    /**
-     * Processes tuples and keeps a copy of last matched tuple
-     */
-    @Override
-    public void process(Map<K, V> tuple)
-    {
-      V val = tuple.get(getKey());
-      if (val == null) {
-        return;
-      }
-      if (compareValue(val.doubleValue())) {
-        ltuple = cloneTuple(tuple);
-      }
-    }
-  };
-
-  /**
-   * The output port on which the last key value pair to satisfy the comparison function is emitted.
-   */
-  public final transient DefaultOutputPort<HashMap<K, V>> last = new DefaultOutputPort<HashMap<K, V>>();
-
-  /**
-   * Emits last matching tuple
-   */
-  @Override
-  public void endWindow()
-  {
-    if (ltuple != null) {
-      last.emit(ltuple);
-    }
-    ltuple = null;
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/algo/LeastFrequentKeyMap.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/algo/LeastFrequentKeyMap.java b/library/src/main/java/com/datatorrent/lib/algo/LeastFrequentKeyMap.java
deleted file mode 100644
index 2996b5a..0000000
--- a/library/src/main/java/com/datatorrent/lib/algo/LeastFrequentKeyMap.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
-import com.datatorrent.api.DefaultInputPort;
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.api.annotation.OperatorAnnotation;
-import com.datatorrent.api.annotation.OutputPortFieldAnnotation;
-
-import com.datatorrent.lib.util.AbstractBaseFrequentKey;
-import com.datatorrent.lib.util.UnifierArrayHashMapFrequent;
-import com.datatorrent.lib.util.UnifierHashMapFrequent;
-
-/**
- * This operator filters the incoming stream of key value pairs by finding the key or keys (if there is a tie) that occur the fewest number of times within each window.&nbsp;
- * A list of the corresponding key value pairs are then output to the port named "list" and one of the corresponding key value pairs is output to the port "least", at the end of each window.
- * <p>
- * Occurrences of each key is counted and at the end of window any of the least frequent key is emitted on output port least and all least frequent
- * keys on output port list.
- * </p>
- * <p>
- * This module is an end of window module. In case of a tie any of the least key would be emitted. The list port would however have all the tied keys<br>
- * <br>
- * <b>StateFull : Yes, </b> tuple are compared across application window(s). <br>
- * <b>Partitions : Yes, </b> least keys are unified on output port. <br>
- * <br>
- * <b>Ports</b>:<br>
- * <b>data</b>: expects Map&lt;K,V&gt;, V is ignored/not used<br>
- * <b>least</b>: emits HashMap&lt;K,Integer&gt;(1); where String is the least frequent key, and Integer is the number of its occurrences in the window<br>
- * <b>list</b>: emits ArrayList&lt;HashMap&lt;K,Integer&gt;(1)&gt;; Where the list includes all the keys are least frequent<br>
- * <br>
- * </p>
- *
- * @displayName Emit Least Frequent Tuple Key
- * @category Rules and Alerts
- * @tags filter, key value, count
- *
- * @since 0.3.2
- */
-
-@OperatorAnnotation(partitionable = true)
-public class LeastFrequentKeyMap<K, V> extends AbstractBaseFrequentKey<K>
-{
-  /**
-   * The input port on which key value pairs are received.
-   */
-  public final transient DefaultInputPort<Map<K, V>> data = new DefaultInputPort<Map<K, V>>()
-  {
-    /**
-     * Calls super.processTuple(tuple) for each key in the HashMap
-     */
-    @Override
-    public void process(Map<K, V> tuple)
-    {
-      for (Map.Entry<K, V> e: tuple.entrySet()) {
-        processTuple(e.getKey());
-      }
-    }
-  };
-
-  /**
-   * The output port on which one of the tuples,
-   * which occurred the least number of times,
-   * is emitted.
-   */
-  @OutputPortFieldAnnotation(optional = true)
-  public final transient DefaultOutputPort<HashMap<K, Integer>> least = new DefaultOutputPort<HashMap<K, Integer>>()
-  {
-    @Override
-    public Unifier<HashMap<K, Integer>> getUnifier()
-    {
-      Unifier<HashMap<K, Integer>> ret = new UnifierHashMapFrequent<K>();
-      ((UnifierHashMapFrequent<K>)ret).setLeast(true);
-      return ret;
-    }
-  };
-
-  /**
-   * The output port on which all the tuples,
-   * which occurred the least number of times,
-   * is emitted.
-   */
-  @OutputPortFieldAnnotation(optional = true)
-  public final transient DefaultOutputPort<ArrayList<HashMap<K, Integer>>> list = new DefaultOutputPort<ArrayList<HashMap<K, Integer>>>()
-  {
-    @Override
-    public Unifier<ArrayList<HashMap<K, Integer>>> getUnifier()
-    {
-      Unifier<ArrayList<HashMap<K, Integer>>> ret = new UnifierArrayHashMapFrequent<K>();
-      ((UnifierArrayHashMapFrequent<K>)ret).setLeast(true);
-      return ret;
-    }
-  };
-
-  /**
-   * Emits tuple on port "least"
-   *
-   * @param tuple
-   */
-  @Override
-  public void emitTuple(HashMap<K, Integer> tuple)
-  {
-    least.emit(tuple);
-  }
-
-  /**
-   * Emits tuple on port "list"
-   *
-   * @param tlist
-   */
-  @Override
-  public void emitList(ArrayList<HashMap<K, Integer>> tlist)
-  {
-    list.emit(tlist);
-  }
-
-  /**
-   * returns val1 < val2
-   *
-   * @param val1
-   * @param val2
-   * @return val1 < val2
-   */
-  @Override
-  public boolean compareCount(int val1, int val2)
-  {
-    return val1 < val2;
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/algo/LeastFrequentKeyValueMap.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/algo/LeastFrequentKeyValueMap.java b/library/src/main/java/com/datatorrent/lib/algo/LeastFrequentKeyValueMap.java
deleted file mode 100644
index a94121d..0000000
--- a/library/src/main/java/com/datatorrent/lib/algo/LeastFrequentKeyValueMap.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-import java.util.HashMap;
-
-import com.datatorrent.api.DefaultOutputPort;
-
-import com.datatorrent.lib.util.AbstractBaseFrequentKeyValueMap;
-
-/**
- * This operator filters the incoming stream of key value pairs by finding the value or values (if there is a tie),
- * for each key, that occur the fewest number of times within each window.&nbsp;
- * Each key and its corresponding least values are emitted at the end of each window.
- * <p>
- * Occurrences of all values for each key is counted and at the end of window the least frequent values are emitted on output port least per key.
- * </p>
- * <p>
- * This module is an end of window module<br>
- * <br>
- * <b>Ports</b>:<br>
- * <b>data</b>: expects Map&lt;K,V&gt;<br>
- * <b>least</b>: Output port, emits HashMap&lt;K,HashMap&lt;V,Integer&gt;&gt;(1)<br>
- * <br>
- * <b>Properties</b>: None<br>
- * <br>
- * <b>Compile time checks</b>: None<br>
- * <b>Specific run time checks</b>: None <br>
- * <br>
- * <b>Benchmarks</b>: Blast as many tuples as possible in inline mode<br>
- * <table border="1" cellspacing=1 cellpadding=1 summary="Benchmark table for LeastFrequentKeyValueMap&lt;K,V&gt; operator template">
- * <tr><th>In-Bound</th><th>Out-bound</th><th>Comments</th></tr>
- * <tr><td><b>&gt; 30 Million K,V pairs/s</b></td><td>Emits only 1 tuple per window per key</td><td>In-bound throughput is the main determinant of performance.
- * The benchmark was done with immutable objects. If K or V are mutable the benchmark may be lower</td></tr>
- * </table><br>
- * </p>
- * <p>
- * <b>Function Table (K=String,V=Integer);</b>:
- * <table border="1" cellspacing=1 cellpadding=1 summary="Function table for LeastFrequentKeyValueMap&lt;K,V&gt; operator template">
- * <tr><th rowspan=2>Tuple Type (api)</th><th>In-bound (process)</th><th>Out-bound (emit)</th></tr>
- * <tr><th><i>data</i>(Map&lt;K,V&gt;)</th><th><i>least</i>(HashMap&lt;K,HashMap&lt;Integer&gt;&gt;)</th></tr>
- * <tr><td>Begin Window (beginWindow())</td><td>N/A</td><td>N/A</td></tr>
- * <tr><td>Data (process())</td><td>{a=1,b=5,c=110}</td><td></td></tr>
- * <tr><td>Data (process())</td><td>{a=55,c=2000,b=45}</td><td></td></tr>
- * <tr><td>Data (process())</td><td>{d=2}</td><td></td></tr>
- * <tr><td>Data (process())</td><td>{a=55,b=5,c=22}</td><td></td></tr>
- * <tr><td>Data (process())</td><td>{h=20,a=2,z=5}</td><td></td></tr>
- * <tr><td>Data (process())</td><td>{a=4,c=110}</td><td></td></tr>
- * <tr><td>Data (process())</td><td>{a=4,z=5}</td><td></td></tr>
- * <tr><td>End Window (endWindow())</td><td>N/A</td><td>{a={1=1,2=1},b={45=1},c={2000=1,22=1},d={2=1},h={20=1},z={5=2}</td></tr>
- * </table>
- * <br>
- * <br>
- * </p>
- *
- * @displayName Emit Least Frequent Keyval Pair
- * @category Rules and Alerts
- * @tags filter, key value, count
- *
- * @since 0.3.2
- */
-public class LeastFrequentKeyValueMap<K, V> extends AbstractBaseFrequentKeyValueMap<K, V>
-{
-  /**
-   * The output port on which the least frequent key value pairs are emitted.
-   */
-  public final transient DefaultOutputPort<HashMap<K, HashMap<V, Integer>>> least = new DefaultOutputPort<HashMap<K, HashMap<V, Integer>>>();
-
-  /**
-   * returns val1 < val2
-   * @param val1
-   * @param val2
-   * @return val1 < val2
-   */
-  @Override
-  public boolean compareValue(int val1, int val2)
-  {
-    return (val1 < val2);
-  }
-
-  /**
-   * Emits tuple on port "least"
-   * @param tuple
-   */
-  @Override
-  public void emitTuple(HashMap<K, HashMap<V, Integer>> tuple)
-  {
-    least.emit(tuple);
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/algo/MatchAllMap.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/algo/MatchAllMap.java b/library/src/main/java/com/datatorrent/lib/algo/MatchAllMap.java
index f0c5d0e..0d258f6 100644
--- a/library/src/main/java/com/datatorrent/lib/algo/MatchAllMap.java
+++ b/library/src/main/java/com/datatorrent/lib/algo/MatchAllMap.java
@@ -64,8 +64,9 @@ import com.datatorrent.lib.util.UnifierBooleanAnd;
  * @tags filter, key value
  *
  * @since 0.3.2
+ * @deprecated
  */
-
+@Deprecated
 @OperatorAnnotation(partitionable = true)
 public class MatchAllMap<K, V extends Number> extends BaseMatchOperator<K, V>
 {

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/algo/MatchAnyMap.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/algo/MatchAnyMap.java b/library/src/main/java/com/datatorrent/lib/algo/MatchAnyMap.java
index 41a92ed..f3ed5ae 100644
--- a/library/src/main/java/com/datatorrent/lib/algo/MatchAnyMap.java
+++ b/library/src/main/java/com/datatorrent/lib/algo/MatchAnyMap.java
@@ -66,8 +66,9 @@ import com.datatorrent.lib.util.UnifierBooleanOr;
  * @tags filter, key value
  *
  * @since 0.3.2
+ * @deprecated
  */
-
+@Deprecated
 @OperatorAnnotation(partitionable = true)
 public class MatchAnyMap<K, V extends Number> extends BaseMatchOperator<K,V>
 {

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/algo/MatchMap.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/algo/MatchMap.java b/library/src/main/java/com/datatorrent/lib/algo/MatchMap.java
index e84c88b..c9b171c 100644
--- a/library/src/main/java/com/datatorrent/lib/algo/MatchMap.java
+++ b/library/src/main/java/com/datatorrent/lib/algo/MatchMap.java
@@ -65,7 +65,9 @@ import com.datatorrent.lib.util.UnifierHashMap;
  * @tags filter, key value, numeric
  *
  * @since 0.3.2
+ * @deprecated
  */
+@Deprecated
 @Stateless
 @OperatorAnnotation(partitionable = true)
 public class MatchMap<K,V extends Number> extends BaseMatchOperator<K, V>

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/algo/MergeSort.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/algo/MergeSort.java b/library/src/main/java/com/datatorrent/lib/algo/MergeSort.java
index 9ccf76c..a3f8a0e 100644
--- a/library/src/main/java/com/datatorrent/lib/algo/MergeSort.java
+++ b/library/src/main/java/com/datatorrent/lib/algo/MergeSort.java
@@ -57,7 +57,9 @@ import com.datatorrent.api.annotation.OperatorAnnotation;
  * </p>
  *
  * @since 0.3.3
+ * @deprecated
  */
+@Deprecated
 @OperatorAnnotation(partitionable = true)
 public abstract class MergeSort<K>  implements Operator, Unifier<ArrayList<K>>
 {

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/algo/MergeSortNumber.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/algo/MergeSortNumber.java b/library/src/main/java/com/datatorrent/lib/algo/MergeSortNumber.java
index e9d0eff..5839797 100644
--- a/library/src/main/java/com/datatorrent/lib/algo/MergeSortNumber.java
+++ b/library/src/main/java/com/datatorrent/lib/algo/MergeSortNumber.java
@@ -49,7 +49,9 @@ import com.datatorrent.api.annotation.OperatorAnnotation;
  * @tags rank, numeric
  *
  * @since 0.3.3
+ * @deprecated
  */
+@Deprecated
 @OperatorAnnotation(partitionable = true)
 public class MergeSortNumber<V extends Number> extends MergeSort<V>
 {

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/algo/MostFrequentKeyMap.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/algo/MostFrequentKeyMap.java b/library/src/main/java/com/datatorrent/lib/algo/MostFrequentKeyMap.java
deleted file mode 100644
index c300c24..0000000
--- a/library/src/main/java/com/datatorrent/lib/algo/MostFrequentKeyMap.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
-import com.datatorrent.api.DefaultInputPort;
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.api.annotation.OperatorAnnotation;
-
-import com.datatorrent.lib.util.AbstractBaseFrequentKey;
-import com.datatorrent.lib.util.UnifierArrayHashMapFrequent;
-import com.datatorrent.lib.util.UnifierHashMapFrequent;
-
-/**
- * This operator filters the incoming stream of key value pairs by finding the key or keys (if there is a tie)
- * that occur the largest number of times within each window.&nbsp;
- * A list of the corresponding key value pairs are then output to the port named "list" and one of the corresponding key value pairs is output to the port "most", at the end of each window.
- * <p>
- * Occurrences of each key is counted and at the end of window any of the most frequent key is emitted on output port least and all least frequent
- * keys on output port list.
- * </p>
- * <p>
- * This module is an end of window module. In case of a tie any of the least key would be emitted. The list port would however have all the tied keys<br>
- * <br>
- *  <b>StateFull : Yes</b>, Values are compared all over  application window can be > 1. <br>
- *  <b>Partitions : Yes</b>, Result is unified on output port. <br>
- *  <br>
- * <b>Ports</b>:<br>
- * <b>data</b>: expects Map&lt;K,V&gt;, V is ignored/not used<br>
- * <b>most</b>: emits HashMap&lt;K,Integer&gt;(1); where String is the least frequent key, and Integer is the number of its occurrences in the window<br>
- * <b>list</b>: emits ArrayList&lt;HashMap&lt;K,Integer&gt;(1)&gt;; Where the list includes all the keys are least frequent<br>
- * <br>
- * </p>
- *
- * @displayName Emit Most Frequent Key
- * @category Rules and Alerts
- * @tags filter, key value, count
- *
- * @since 0.3.2
- */
-
-@OperatorAnnotation(partitionable = true)
-public class MostFrequentKeyMap<K,V> extends AbstractBaseFrequentKey<K>
-{
-  /**
-   * The input port which receives incoming key value pairs.
-   */
-  public final transient DefaultInputPort<Map<K,V>> data = new DefaultInputPort<Map<K,V>>()
-  {
-    /**
-     * Calls super.processTuple(tuple) for each key in the HashMap
-     */
-    @Override
-    public void process(Map<K,V> tuple)
-    {
-      for (Map.Entry<K, V> e: tuple.entrySet()) {
-        processTuple(e.getKey());
-      }
-    }
-  };
-  /**
-   * The output port on which all the tuples,
-   * which occurred the most number of times,
-   * is emitted.
-   */
-  public final transient DefaultOutputPort<HashMap<K, Integer>> most = new DefaultOutputPort<HashMap<K, Integer>>()
-  {
-    @Override
-    public Unifier<HashMap<K, Integer>> getUnifier()
-    {
-      Unifier<HashMap<K, Integer>> ret = new UnifierHashMapFrequent<K>();
-      ((UnifierHashMapFrequent<K>)ret).setLeast(false);
-      return ret;
-    }
-  };
-
-
-  public final transient DefaultOutputPort<ArrayList<HashMap<K, Integer>>> list = new DefaultOutputPort<ArrayList<HashMap<K, Integer>>>()
-  {
-    @SuppressWarnings({"rawtypes", "ConstantConditions"})
-    @Override
-    public Unifier<ArrayList<HashMap<K, Integer>>> getUnifier()
-    {
-      Unifier<ArrayList<HashMap<K, Integer>>> ret = new UnifierArrayHashMapFrequent<K>();
-      ((UnifierHashMapFrequent)ret).setLeast(false);
-      return ret;
-    }
-  };
-
-
-  /**
-   * Emits tuple on port "most"
-   * @param tuple
-   */
-  @Override
-  public void emitTuple(HashMap<K, Integer> tuple)
-  {
-    most.emit(tuple);
-  }
-
-  /**
-   * Emits tuple on port "list"
-   * @param tlist
-   */
-  @Override
-  public void emitList(ArrayList<HashMap<K, Integer>> tlist)
-  {
-    list.emit(tlist);
-  }
-
-  /**
-   * returns val1 < val2
-   * @param val1
-   * @param val2
-   * @return val1 > val2
-   */
-  @Override
-  public boolean compareCount(int val1, int val2)
-  {
-    return val1 > val2;
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/algo/MostFrequentKeyValueMap.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/algo/MostFrequentKeyValueMap.java b/library/src/main/java/com/datatorrent/lib/algo/MostFrequentKeyValueMap.java
deleted file mode 100644
index 40a4372..0000000
--- a/library/src/main/java/com/datatorrent/lib/algo/MostFrequentKeyValueMap.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-import java.util.HashMap;
-
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.api.annotation.OperatorAnnotation;
-
-import com.datatorrent.lib.util.AbstractBaseFrequentKeyValueMap;
-
-/**
- * This operator filters the incoming stream of key value pairs by finding the value or values (if there is a tie),
- * for each key, that occur the largest number of times within each window.&nbsp;
- * Each key and its corresponding most values are emitted at the end of each window.
- * <p>
- * Occurrences of all values for each key is counted and at the end of window the most frequent values are emitted on output port least per key
- * </p>
- * <p>
- * This module is an end of window module<br>
- * <br>
- * <b>Ports</b>:<br>
- * <b>data</b>: expects HashMap&lt;K,V&gt;<br>
- * <b>most</b>: emits HashMap&lt;String, HashMap&lt;String, Integer&gt;&gt;(1)<br>
- * <br>
- * <br>
- * <b>Properties</b>: None<br>
- * <br>
- * <b>Compile time checks</b>: None<br>
- * <b>Specific run time checks</b>: None <br>
- * <br>
- * <b>Benchmarks</b>: Blast as many tuples as possible in inline mode<br>
- * <table border="1" cellspacing=1 cellpadding=1 summary="Benchmark table for MostFrequentKeyValueMap&lt;K,V&gt; operator template">
- * <tr><th>In-Bound</th><th>Out-bound</th><th>Comments</th></tr>
- * <tr><td><b>&gt; 30 Million K,V pairs/s</b></td><td>Emits only 1 tuple per window per key</td><td>In-bound throughput is the main determinant of performance.
- * The benchmark was done with immutable objects. If K or V are mutable the benchmark may be lower</td></tr>
- * </table><br>
- * </p>
- * <p>
- * <b>Function Table (K=String,V=Integer);</b>:
- * <table border="1" cellspacing=1 cellpadding=1 summary="Function table for MostFrequentKeyValueMap&lt;K,V&gt; operator template">
- * <tr><th rowspan=2>Tuple Type (api)</th><th>In-bound (process)</th><th>Out-bound (emit)</th></tr>
- * <tr><th><i>data</i>(HashMap&lt;K,V&gt;)</th><th><i>most</i>(HashMap&lt;K,HashMap&lt;Integer&gt;&gt;)</th></tr>
- * <tr><td>Begin Window (beginWindow())</td><td>N/A</td><td>N/A</td></tr>
- * <tr><td>Data (process())</td><td>{a=1,b=5,c=110}</td><td></td></tr>
- * <tr><td>Data (process())</td><td>{a=55,c=2000,b=45}</td><td></td></tr>
- * <tr><td>Data (process())</td><td>{d=2}</td><td></td></tr>
- * <tr><td>Data (process())</td><td>{a=55,b=5,c=22}</td><td></td></tr>
- * <tr><td>Data (process())</td><td>{h=20,a=2,z=5}</td><td></td></tr>
- * <tr><td>Data (process())</td><td>{a=4,c=110}</td><td></td></tr>
- * <tr><td>Data (process())</td><td>{a=4,z=5}</td><td></td></tr>
- * <tr><td>End Window (endWindow())</td><td>N/A</td><td>{a={4=2,55=2},b={5=2},c={110=2},d={2=1},h={20=1},z={5=2}</td></tr>
- * </table>
- * <br>
- * <br>
- * </p>
- *
- * @displayName Emit Most Frequent Keyval Pair
- * @category Rules and Alerts
- * @tags filter, key value, count
- *
- * @since 0.3.2
- */
-
-@OperatorAnnotation(partitionable = false)
-public class MostFrequentKeyValueMap<K, V> extends AbstractBaseFrequentKeyValueMap<K, V>
-{
-  /**
-   * The output port which emits a map from keys to their most values.
-   */
-  public final transient DefaultOutputPort<HashMap<K, HashMap<V, Integer>>> most = new DefaultOutputPort<HashMap<K, HashMap<V, Integer>>>();
-
-  /**
-   * returns val1 < val2
-   * @param val1
-   * @param val2
-   * @return val1 > val2
-   */
-  @Override
-  public boolean compareValue(int val1, int val2)
-  {
-    return (val1 > val2);
-  }
-
-  /**
-   * Emits tuple on port "most"
-   * @param tuple is emitted on port "most"
-   */
-  @Override
-  public void emitTuple(HashMap<K, HashMap<V, Integer>> tuple)
-  {
-    most.emit(tuple);
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/algo/Sampler.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/algo/Sampler.java b/library/src/main/java/com/datatorrent/lib/algo/Sampler.java
deleted file mode 100644
index b087c9e..0000000
--- a/library/src/main/java/com/datatorrent/lib/algo/Sampler.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-import java.util.Random;
-
-import javax.validation.constraints.Max;
-import javax.validation.constraints.Min;
-
-import com.datatorrent.api.DefaultInputPort;
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.api.annotation.OperatorAnnotation;
-import com.datatorrent.api.annotation.Stateless;
-
-import com.datatorrent.lib.util.BaseKeyOperator;
-
-/**
- * This operator takes a stream of tuples as input, and emits each tuple with a specified probability.
- * <p>
- * Emits the tuple as per probability of pass rate out of total rate. <br>
- * <br>
- * An efficient filter to allow sample analysis of a stream. Very useful is the incoming stream has high throughput.
- * </p>
- * <p>
- * <br>
- * <b> StateFull : No, </b> tuple is processed in current window. <br>
- * <b> Partitions : Yes. </b> No state dependency among input tuples. <br>
- * <b>Ports</b>:<br>
- * <b>data</b>: expects K<br>
- * <b>sample</b>: emits K<br>
- * <br>
- * <b>Properties</b>:<br>
- * <b>passrate</b>: Sample rate out of a total of totalrate. Default is 1<br>
- * <b>totalrate</b>: Total rate (divisor). Default is 100<br>
- * <br>
- * <b>Specific compile time checks are</b>: None<br>
- * passrate is positive integer<br>
- * totalrate is positive integer<br>
- * passrate and totalrate are not compared (i.e. passrate &lt; totalrate) check is not done to allow users to make this operator a passthrough (all) during testing<br>
- * <br>
- * <b>Specific run time checks are</b>: None<br>
- * <br>
- * </p>
- *
- * @displayName Sampler
- * @category Stats and Aggregations
- * @tags filter
- *
- * @since 0.3.2
- */
-@Stateless
-@OperatorAnnotation(partitionable = true)
-public class Sampler<K> extends BaseKeyOperator<K>
-{
-  /**
-   * This is the input port which receives tuples.
-   */
-  public final transient DefaultInputPort<K> data = new DefaultInputPort<K>()
-  {
-    /**
-     * Emits tuples at a rate corresponding to the given samplingPercentage.
-     */
-    @Override
-    public void process(K tuple)
-    {
-      double val = random.nextDouble();
-      if (val > samplingPercentage) {
-        return;
-      }
-      sample.emit(cloneKey(tuple));
-    }
-  };
-
-  /**
-   * This is the output port which emits the sampled tuples.
-   */
-  public final transient DefaultOutputPort<K> sample = new DefaultOutputPort<K>();
-
-  @Min(0)
-  @Max(1)
-  private double samplingPercentage = 1.0;
-
-  private transient Random random = new Random();
-
-  /**
-   * Gets the samplingPercentage.
-   * @return the samplingPercentage
-   */
-  public double getSamplingPercentage()
-  {
-    return samplingPercentage;
-  }
-
-  /**
-   * The percentage of tuples to allow to pass through this operator. This percentage should be
-   * a number between 0 and 1 inclusive.
-   * @param samplingPercentage the samplingPercentage to set
-   */
-  public void setSamplingPercentage(double samplingPercentage)
-  {
-    this.samplingPercentage = samplingPercentage;
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/algo/TopNUnique.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/algo/TopNUnique.java b/library/src/main/java/com/datatorrent/lib/algo/TopNUnique.java
index 3c6a9f5..d80f1c1 100644
--- a/library/src/main/java/com/datatorrent/lib/algo/TopNUnique.java
+++ b/library/src/main/java/com/datatorrent/lib/algo/TopNUnique.java
@@ -54,8 +54,9 @@ import com.datatorrent.lib.util.AbstractBaseNUniqueOperatorMap;
  * @tags filter, rank
  *
  * @since 0.3.2
+ * @deprecated
  */
-
+@Deprecated
 @OperatorAnnotation(partitionable = false)
 public class TopNUnique<K, V> extends AbstractBaseNUniqueOperatorMap<K, V>
 {

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/join/AntiJoinOperator.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/join/AntiJoinOperator.java b/library/src/main/java/com/datatorrent/lib/join/AntiJoinOperator.java
index 382a0d6..1eb7957 100644
--- a/library/src/main/java/com/datatorrent/lib/join/AntiJoinOperator.java
+++ b/library/src/main/java/com/datatorrent/lib/join/AntiJoinOperator.java
@@ -24,6 +24,7 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.hadoop.classification.InterfaceStability.Evolving;
+
 import com.datatorrent.api.Context.OperatorContext;
 import com.datatorrent.api.DefaultInputPort;
 import com.datatorrent.api.DefaultOutputPort;
@@ -32,7 +33,6 @@ import com.datatorrent.api.annotation.OperatorAnnotation;
 import com.datatorrent.lib.streamquery.condition.Condition;
 import com.datatorrent.lib.streamquery.index.Index;
 
-
 /**
  * An implementation of Operator that reads table row data from two table data input ports. <br>
  * <p>

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/math/Average.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/math/Average.java b/library/src/main/java/com/datatorrent/lib/math/Average.java
index 4dfdf1f..ff7a9d7 100644
--- a/library/src/main/java/com/datatorrent/lib/math/Average.java
+++ b/library/src/main/java/com/datatorrent/lib/math/Average.java
@@ -20,14 +20,14 @@ package com.datatorrent.lib.math;
 
 import com.datatorrent.api.DefaultInputPort;
 import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.common.util.Pair;
 import com.datatorrent.lib.util.BaseNumberValueOperator;
 
 /**
  *
  * Emits the average of values at the end of window.
  * <p>
- * This is an end window operator. This can not be partitioned. Partitioning
- * this will yield incorrect result.<br>
+ * This is an end window operator. <br>
  * <b>Ports</b>:<br>
  * <b>data</b>: expects V extends Number<br>
  * <b>average</b>: emits V extends Number<br>
@@ -63,7 +63,14 @@ public class Average<V extends Number> extends BaseNumberValueOperator<V>
   /**
    * Output port that emits average as a number.
    */
-  public final transient DefaultOutputPort<V> average = new DefaultOutputPort<V>();
+  public final transient DefaultOutputPort<Pair<V,Long>> average = new DefaultOutputPort<Pair<V, Long>>()
+  {
+    @Override
+    public Unifier<Pair<V, Long>> getUnifier()
+    {
+      return new AvgUnifier<V>();
+    }
+  };
 
   protected double sums = 0;
   protected long counts = 0;
@@ -75,13 +82,27 @@ public class Average<V extends Number> extends BaseNumberValueOperator<V>
   public void endWindow()
   {
     // May want to send out only if count != 0
+
     if (counts != 0) {
-      average.emit(getAverage());
+      Pair<V,Long> pair = new Pair<>(getAverage(),counts);
+      average.emit(pair);
     }
+
     sums = 0;
     counts = 0;
   }
 
+  public static class AvgUnifier<V extends Number> extends Average<V> implements Unifier<Pair<V, Long>>
+  {
+
+    @Override
+    public void process(Pair<V, Long> pair)
+    {
+      sums += pair.getFirst().doubleValue() * pair.getSecond();
+      counts += pair.getSecond();
+    }
+  }
+
   /**
    * Calculate average based on number type.
    */

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/math/Change.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/math/Change.java b/library/src/main/java/com/datatorrent/lib/math/Change.java
deleted file mode 100644
index 57bad6b..0000000
--- a/library/src/main/java/com/datatorrent/lib/math/Change.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/**
- * 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 com.datatorrent.lib.math;
-
-import com.datatorrent.api.DefaultInputPort;
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.api.annotation.OutputPortFieldAnnotation;
-import com.datatorrent.lib.util.BaseNumberValueOperator;
-
-/**
- * Operator compares data values arriving on input port with base value input operator.
- * 
- * <p>
- * Arriving base value is stored in operator for comparison, old base value is overwritten.&nbsp;
- * This emits &lt;change in value,percentage change&gt;.
- * Operator expects values arriving on data input port and base value input operator.
- * Change in value and percentage change in values are emitted on separate ports.<br>
- * This operator can not be partitioned, since copies won't get consecutive operators. <br>
- * This is StateFull operator, tuples that arrive on base port are kept in
- * cache forever.<br>
- * <br>
- * <b>Input Ports</b>:<br>
- * <b>data</b>: expects V extends Number, Data values<br>
- * <b>base</b>: expects V extends Number, Base Value stored for comparison<br>
- *
- * <b>Output Ports</b>:<br>
- * <b>change</b>: emits V extends Number,  Diff from base value<br>
- * <b>percent</b>: emits Doubl, percent change in value compared to base value.<br>
- * <br>
- * <br>
- * <b>Properties</b>:<br>
- * <b>inverse</b>: if set to true the key in the filter will block tuple<br>
- * <b>filterBy</b>: List of keys to filter on<br>
- * <br>
- * <b>Specific compile time checks</b>: None<br>
- * <b>Specific run time checks</b>: None<br>
- * <br>
- *
- * <br>
- * @displayName Change
- * @category Math
- * @tags change, key value, numeric, percentage
- * @since 0.3.3
- */
-public class Change<V extends Number> extends BaseNumberValueOperator<V>
-{
-        /**
-   * Input data port that takes a number.
-   */
-  public final transient DefaultInputPort<V> data = new DefaultInputPort<V>()
-  {
-    /**
-     * Process each key, compute change or percent, and emit it.
-     */
-    @Override
-    public void process(V tuple)
-    {
-      if (baseValue != 0) { // Avoid divide by zero, Emit an error tuple?
-        double cval = tuple.doubleValue() - baseValue;
-        change.emit(getValue(cval));
-        percent.emit((cval / baseValue) * 100);
-      }
-    }
-  };
-        
-        /**
-   * Input port that takes a number&nbsp; It stores the value for base comparison.
-   */
-  public final transient DefaultInputPort<V> base = new DefaultInputPort<V>()
-  {
-    /**
-     * Process each key to store the value. If same key appears again update
-     * with latest value.
-     */
-    @Override
-    public void process(V tuple)
-    {
-      if (tuple.doubleValue() != 0.0) { // Avoid divide by zero, Emit an error
-                                        // tuple?
-        baseValue = tuple.doubleValue();
-      }
-    }
-  };
-
-  /**
-   * Output port that emits change in value compared to base value.
-   */
-  @OutputPortFieldAnnotation(optional = true)
-  public final transient DefaultOutputPort<V> change = new DefaultOutputPort<V>();
-
-  /**
-   * Output port that emits percent change in data value compared to base value.
-   */
-  @OutputPortFieldAnnotation(optional = true)
-  public final transient DefaultOutputPort<Double> percent = new DefaultOutputPort<Double>();
-
-  /**
-   * baseValue is a state full field. It is retained across windows.
-   */
-  private double baseValue = 0;
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/math/ChangeAlert.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/math/ChangeAlert.java b/library/src/main/java/com/datatorrent/lib/math/ChangeAlert.java
deleted file mode 100644
index 3c48016..0000000
--- a/library/src/main/java/com/datatorrent/lib/math/ChangeAlert.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/**
- * 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 com.datatorrent.lib.math;
-
-import javax.validation.constraints.Min;
-
-import com.datatorrent.api.DefaultInputPort;
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.lib.util.BaseNumberValueOperator;
-import com.datatorrent.lib.util.KeyValPair;
-
-/**
- * Compares consecutive input data values, emits &lt;value,percent change value&gt; pair on alert output port, if percent change exceeds certain thresh hold value.
- * <p>
- * Operator is StateFull since current value is stored for comparison in next window. <br>
- * This operator can not be partitioned, partitioning will result in inconsistent base value
- * across replicated copies.
- * <br>
- *
- * <b>Ports</b>:<br>
- * <b>data</b>: expects KeyValPair&lt;K,V extends Number&gt;<br>
- * <b>alert</b>: emits KeyValPair&lt;K,KeyValPair&lt;V,Double&gt;&gt;(1)<br>
- * <br>
- * <b>Properties</b>:<br>
- * <b>threshold</b>: The threshold of change between consecutive tuples of the
- * same key that triggers an alert tuple<br>
- * <b>inverse</b>: if set to true the key in the filter will block tuple<br>
- * <b>filterBy</b>: List of keys to filter on<br>
- * <br>
- * <b>Specific compile time checks</b>: None<br>
- * <b>Specific run time checks</b>: None<br>
- * <br>
- * @displayName Change Alert
- * @category Rules and Alerts
- * @tags change, key value, numeric, percentage
- * @since 0.3.3
- */
-public class ChangeAlert<V extends Number> extends BaseNumberValueOperator<V>
-{
-  /**
-   * Input port that takes in a number.
-   */
-  public final transient DefaultInputPort<V> data = new DefaultInputPort<V>()
-  {
-    /**
-     * Process each key, compute change or percent, and emit it. If we get 0 as
-     * tuple next will be skipped.
-     */
-    @Override
-    public void process(V tuple)
-    {
-      double tval = tuple.doubleValue();
-      if (baseValue == 0) { // Avoid divide by zero, Emit an error tuple?
-        baseValue = tval;
-        return;
-      }
-      double change = tval - baseValue;
-      double percent = (change / baseValue) * 100;
-      if (percent < 0.0) {
-        percent = 0.0 - percent;
-      }
-      if (percent > percentThreshold) {
-        KeyValPair<V, Double> kv = new KeyValPair<V, Double>(cloneKey(tuple),
-            percent);
-        alert.emit(kv);
-      }
-      baseValue = tval;
-    }
-  };
-
-
-  /**
-   * Output port which emits a key value pair.
-   */
-  public final transient DefaultOutputPort<KeyValPair<V, Double>> alert = new DefaultOutputPort<KeyValPair<V, Double>>();
-
-  /**
-   * baseValue is a state full field. It is retained across windows
-   */
-  private double baseValue = 0;
-  @Min(1)
-  private double percentThreshold = 0.0;
-
-  /**
-   * getter function for threshold value
-   *
-   * @return threshold value
-   */
-  @Min(1)
-  public double getPercentThreshold()
-  {
-    return percentThreshold;
-  }
-
-  /**
-   * setter function for threshold value
-   */
-  public void setPercentThreshold(double d)
-  {
-    percentThreshold = d;
-  }
-}


[05/12] apex-malhar git commit: Updated algo & working on math operators

Posted by th...@apache.org.
http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/math/ChangeAlertKeyVal.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/math/ChangeAlertKeyVal.java b/library/src/main/java/com/datatorrent/lib/math/ChangeAlertKeyVal.java
deleted file mode 100644
index b0d2e77..0000000
--- a/library/src/main/java/com/datatorrent/lib/math/ChangeAlertKeyVal.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/**
- * 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 com.datatorrent.lib.math;
-
-import java.util.HashMap;
-
-import javax.validation.constraints.Min;
-
-import org.apache.commons.lang.mutable.MutableDouble;
-
-import com.datatorrent.api.DefaultInputPort;
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.lib.util.BaseNumberKeyValueOperator;
-import com.datatorrent.lib.util.KeyValPair;
-
-/**
- * Operator compares consecutive values arriving at input port mapped by keys, emits &lt;key,percent change&gt; pair on output alert port if percent change exceeds percentage threshold set in operator.
- * <p>
- * StateFull : Yes, current key/value is stored in operator for comparison in
- * next successive windows. <br>
- * Partition(s): No, base comparison value will be inconsistent across
- * instantiated copies. <br>
- * <br>
- * <b>Ports</b>:<br>
- * <b>data</b>: expects KeyValPair&lt;K,V extends Number&gt;<br>
- * <b>alert</b>: emits KeyValPair&lt;K,KeyValPair&lt;V,Double&gt;&gt;(1)<br>
- * <br>
- * <b>Properties</b>:<br>
- * <b>threshold</b>: The threshold of change between consecutive tuples of the
- * same key that triggers an alert tuple<br>
- * <b>inverse</b>: if set to true the key in the filter will block tuple<br>
- * <b>filterBy</b>: List of keys to filter on<br>
- * @displayName Change Alert Key Value
- * @category Rules and Alerts
- * @tags change, key value, numeric, percentage
- * @since 0.3.3
- */
-public class ChangeAlertKeyVal<K, V extends Number> extends
-    BaseNumberKeyValueOperator<K, V>
-{
-  /**
-   * Base map is a StateFull field. It is retained across windows
-   */
-  private HashMap<K, MutableDouble> basemap = new HashMap<K, MutableDouble>();
-
-  /**
-   * Input data port that takes a key value pair.
-   */
-  public final transient DefaultInputPort<KeyValPair<K, V>> data = new DefaultInputPort<KeyValPair<K, V>>()
-  {
-    /**
-     * Process each key, compute change or percent, and emit it.
-     */
-    @Override
-    public void process(KeyValPair<K, V> tuple)
-    {
-      K key = tuple.getKey();
-      double tval = tuple.getValue().doubleValue();
-      MutableDouble val = basemap.get(key);
-      if (!doprocessKey(key)) {
-        return;
-      }
-      if (val == null) { // Only process keys that are in the basemap
-        val = new MutableDouble(tval);
-        basemap.put(cloneKey(key), val);
-        return;
-      }
-      double change = tval - val.doubleValue();
-      double percent = (change / val.doubleValue()) * 100;
-      if (percent < 0.0) {
-        percent = 0.0 - percent;
-      }
-      if (percent > percentThreshold) {
-        KeyValPair<V, Double> dmap = new KeyValPair<V, Double>(
-            cloneValue(tuple.getValue()), percent);
-        KeyValPair<K, KeyValPair<V, Double>> otuple = new KeyValPair<K, KeyValPair<V, Double>>(
-            cloneKey(key), dmap);
-        alert.emit(otuple);
-      }
-      val.setValue(tval);
-    }
-  };
-
-  /**
-   * Key,Percent Change output port.
-   */
-  public final transient DefaultOutputPort<KeyValPair<K, KeyValPair<V, Double>>> alert = new DefaultOutputPort<KeyValPair<K, KeyValPair<V, Double>>>();
-
-  /**
-   * Alert thresh hold percentage set by application.
-   */
-  @Min(1)
-  private double percentThreshold = 0.0;
-
-  /**
-   * getter function for threshold value
-   *
-   * @return threshold value
-   */
-  @Min(1)
-  public double getPercentThreshold()
-  {
-    return percentThreshold;
-  }
-
-  /**
-   * setter function for threshold value
-   */
-  public void setPercentThreshold(double d)
-  {
-    percentThreshold = d;
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/math/ChangeAlertMap.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/math/ChangeAlertMap.java b/library/src/main/java/com/datatorrent/lib/math/ChangeAlertMap.java
deleted file mode 100644
index e212a2d..0000000
--- a/library/src/main/java/com/datatorrent/lib/math/ChangeAlertMap.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/**
- * 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 com.datatorrent.lib.math;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.validation.constraints.Min;
-
-import org.apache.commons.lang.mutable.MutableDouble;
-
-import com.datatorrent.api.DefaultInputPort;
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.lib.util.BaseNumberKeyValueOperator;
-
-/**
- * Operator stores  &lt;key,value&gt; pair in hash map across the windows for comparison and emits hash map of &lt;key,percent change in value for each key&gt; if percent change
- * exceeds preset threshold.
- * <p>
- *
- * StateFull : Yes, key/value pair in current window are stored for comparison in next window. <br>
- * Partition : No, will yield wrong result, base value won't be consistent across instances. <br>
- *
- * <b>Ports</b>:<br>
- * <b>data</b>: expects Map&lt;K,V extends Number&gt;<br>
- * <b>alert</b>: emits HashMap&lt;K,HashMap&lt;V,Double&gt;&gt;(1)<br>
- * <br>
- * <b>Properties</b>:<br>
- * <b>threshold</b>: The threshold of change between consecutive tuples of the same key that triggers an alert tuple<br>
- * <b>inverse</b>: if set to true the key in the filter will block tuple<br>
- * <b>filterBy</b>: List of keys to filter on<br>
- * @displayName Change Alert Map
- * @category Rules and Alerts
- * @tags change, key value, numeric, percentage, map
- * @since 0.3.2
- */
-public class ChangeAlertMap<K, V extends Number> extends BaseNumberKeyValueOperator<K, V>
-{
-  /**
-   * Input data port that takes a map of &lt;key,value&gt;.
-   */
-  public final transient DefaultInputPort<Map<K, V>> data = new DefaultInputPort<Map<K, V>>()
-  {
-    /**
-     * Process each key, compute change or percent, and emits it.
-     */
-    @Override
-    public void process(Map<K, V> tuple)
-    {
-      for (Map.Entry<K, V> e: tuple.entrySet()) {
-        MutableDouble val = basemap.get(e.getKey());
-        if (!doprocessKey(e.getKey())) {
-          continue;
-        }
-        if (val == null) { // Only process keys that are in the basemap
-          val = new MutableDouble(e.getValue().doubleValue());
-          basemap.put(cloneKey(e.getKey()), val);
-          continue;
-        }
-        double change = e.getValue().doubleValue() - val.doubleValue();
-        double percent = (change / val.doubleValue()) * 100;
-        if (percent < 0.0) {
-          percent = 0.0 - percent;
-        }
-        if (percent > percentThreshold) {
-          HashMap<V,Double> dmap = new HashMap<V,Double>(1);
-          dmap.put(cloneValue(e.getValue()), percent);
-          HashMap<K,HashMap<V,Double>> otuple = new HashMap<K,HashMap<V,Double>>(1);
-          otuple.put(cloneKey(e.getKey()), dmap);
-          alert.emit(otuple);
-        }
-        val.setValue(e.getValue().doubleValue());
-      }
-    }
-  };
-
-  // Default "pass through" unifier works as tuple is emitted as pass through
-  /**
-   * Output port which emits a hashmap of key, percentage change.
-   */
-  public final transient DefaultOutputPort<HashMap<K, HashMap<V,Double>>> alert = new DefaultOutputPort<HashMap<K, HashMap<V,Double>>>();
-
-  /**
-   * basemap is a statefull field. It is retained across windows
-   */
-  private HashMap<K,MutableDouble> basemap = new HashMap<K,MutableDouble>();
-  @Min(1)
-  private double percentThreshold = 0.0;
-
-  /**
-   * getter function for threshold value
-   * @return threshold value
-   */
-  @Min(1)
-  public double getPercentThreshold()
-  {
-    return percentThreshold;
-  }
-
-  /**
-   * setter function for threshold value
-   */
-  public void setPercentThreshold(double d)
-  {
-    percentThreshold = d;
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/math/ChangeKeyVal.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/math/ChangeKeyVal.java b/library/src/main/java/com/datatorrent/lib/math/ChangeKeyVal.java
deleted file mode 100644
index 3f77052..0000000
--- a/library/src/main/java/com/datatorrent/lib/math/ChangeKeyVal.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/**
- * 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 com.datatorrent.lib.math;
-
-import java.util.HashMap;
-
-import org.apache.commons.lang.mutable.MutableDouble;
-
-import com.datatorrent.api.DefaultInputPort;
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.api.annotation.OutputPortFieldAnnotation;
-
-import com.datatorrent.lib.util.BaseNumberKeyValueOperator;
-import com.datatorrent.lib.util.KeyValPair;
-
-/**
- * Operator compares &lt;key,value&gt; pairs arriving at data and base input ports and stores &lt;key,value&gt; pairs arriving at base port in hash map across the windows.
- * <p/>
- * The &lt;key,value&gt; pairs that arrive at data port are compared with base value if the key exists in the hash map.&nbsp;
- * Change value and percentage are emitted on separate ports.
- * StateFull : Yes, base map values are stored across windows. <br>
- * Partitions : Yes, values on the base port are replicated across all partitions. However the order of tuples on the
- * output stream may change.
- * <br>
- * <b>Ports</b>:<br>
- * <b>data</b>: expects KeyValPair&lt;K,V extends Number&gt;<br>
- * <b>base</b>: expects KeyValPair&lt;K,V extends Number&gt;<br>
- * <b>change</b>: emits KeyValPair&lt;K,V&gt;(1)<br>
- * <b>percent</b>: emits KeyValPair&lt;K,Double&gt;(1)<br>
- * <br>
- * <br>
- * <b>Properties</b>:<br>
- * <b>inverse</b>: if set to true the key in the filter will block tuple<br>
- * <b>filterBy</b>: List of keys to filter on<br>
- *
- * @displayName Change Key Value
- * @category Math
- * @tags change, key value
- * @since 0.3.3
- */
-public class ChangeKeyVal<K, V extends Number> extends BaseNumberKeyValueOperator<K, V>
-{
-  /**
-   * basemap is a stateful field. It is retained across windows
-   */
-  private HashMap<K, MutableDouble> basemap = new HashMap<K, MutableDouble>();
-
-  /**
-   * Input data port that takes key value pairs.
-   */
-  public final transient DefaultInputPort<KeyValPair<K, V>> data = new DefaultInputPort<KeyValPair<K, V>>()
-  {
-    /**
-     * Process each key, compute change or percent, and emit it.
-     */
-    @Override
-    public void process(KeyValPair<K, V> tuple)
-    {
-      K key = tuple.getKey();
-      if (!doprocessKey(key)) {
-        return;
-      }
-      MutableDouble bval = basemap.get(key);
-      if (bval != null) { // Only process keys that are in the basemap
-        double cval = tuple.getValue().doubleValue() - bval.doubleValue();
-        change.emit(new KeyValPair<K, V>(cloneKey(key), getValue(cval)));
-        percent.emit(new KeyValPair<K, Double>(cloneKey(key), (cval / bval.doubleValue()) * 100));
-      }
-    }
-  };
-
-  /**
-   * Base value input port, stored in base map for comparison.
-   */
-  public final transient DefaultInputPort<KeyValPair<K, V>> base = new DefaultInputPort<KeyValPair<K, V>>()
-  {
-    /**
-     * Process each key to store the value. If same key appears again update
-     * with latest value.
-     */
-    @Override
-    public void process(KeyValPair<K, V> tuple)
-    {
-      if (tuple.getValue().doubleValue() != 0.0) { // Avoid divide by zero, Emit
-        // an error tuple?
-        MutableDouble val = basemap.get(tuple.getKey());
-        if (val == null) {
-          val = new MutableDouble(0.0);
-          basemap.put(cloneKey(tuple.getKey()), val);
-        }
-        val.setValue(tuple.getValue().doubleValue());
-      }
-    }
-  };
-
-  /**
-   * Key, Change output port.
-   */
-  @OutputPortFieldAnnotation(optional = true)
-  public final transient DefaultOutputPort<KeyValPair<K, V>> change = new DefaultOutputPort<KeyValPair<K, V>>();
-
-  /**
-   * Key, Percentage Change pair output port.
-   */
-  @OutputPortFieldAnnotation(optional = true)
-  public final transient DefaultOutputPort<KeyValPair<K, Double>> percent = new DefaultOutputPort<KeyValPair<K, Double>>();
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/math/CompareExceptMap.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/math/CompareExceptMap.java b/library/src/main/java/com/datatorrent/lib/math/CompareExceptMap.java
deleted file mode 100644
index 66bd7da..0000000
--- a/library/src/main/java/com/datatorrent/lib/math/CompareExceptMap.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/**
- * 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 com.datatorrent.lib.math;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.api.annotation.OutputPortFieldAnnotation;
-import com.datatorrent.api.annotation.Stateless;
-import com.datatorrent.lib.algo.MatchMap;
-import com.datatorrent.lib.util.UnifierHashMap;
-
-/**
- * Operator compares based on the property "key", "value", and "compare".
- * <p>
- * The comparison is done by getting double value from the Number.
- * Passed tuples are emitted on the output port "compare".&nbsp; 
- * Failed tuples are emitted on port "except".
- * Both output ports are optional, but at least one has to be connected.
- * This module is a pass through<br>
- * <br>
- * <b>Ports</b>:<br>
- * <b>data</b>: expects Map&lt;K,V&gt;<br>
- * <b>compare</b>: emits HashMap&lt;K,V&gt;<br>
- * <b>except</b>: emits HashMap&lt;K,V&gt;<br>
- * <br>
- * <b>Properties</b>:<br>
- * <b>key</b>: The key on which compare is done<br>
- * <b>value</b>: The value to compare with<br>
- * <b>cmp</b>: The compare function. Supported values are "lte", "lt", "eq", "neq", "gt", "gte". Default is "eq"<br>
- * <br>
- * Compile time checks<br>
- * Key must be non empty<br>
- * Value must be able to convert to a "double"<br>
- * Compare string, if specified, must be one of "lte", "lt", "eq", "neq", "gt", "gte"<br>
- * <b>Specific run time checks</b>:<br>
- * Does the incoming HashMap have the key<br>
- * Is the value of the key a number<br>
- * <p>
- * <b>Benchmarks</b>: Blast as many tuples as possible in inline mode<br>
- * <table border="1" cellspacing=1 cellpadding=1 summary="Benchmark table for CompareExceptMap&lt;K,V extends Number&gt; operator template">
- * <tr><th>In-Bound</th><th>Out-bound</th><th>Comments</th></tr>
- * <tr><td><b>5 Million K,V pairs/s</b></td><td>Each tuple is emitted if emitError is set to true</td><td>In-bound rate determines performance as every tuple is emitted.
- * Immutable tuples were used in the benchmarking. If you use mutable tuples and have lots of keys, the benchmarks may be lower</td></tr>
- * </table><br>
- * <p>
- * <b>Function Table (K=String, V=Integer); emitError=true; key=a; value=3; cmp=eq)</b>:
- * <table border="1" cellspacing=1 cellpadding=1 summary="Function table for CompareExceptMap&lt;K,V extends Number&gt; operator template">
- * <tr><th rowspan=2>Tuple Type (api)</th><th>In-bound (process)</th><th colspan=2>Out-bound (emit)</th></tr>
- * <tr><th><i>data</i>(HashMap&lt;K,V&gt;)</th><th><i>compare</i>(HashMap&lt;K,V&gt;)</th><th><i>except</i>(HashMap&lt;K,V&gt;)</th></tr>
- * <tr><td>Begin Window (beginWindow())</td><td>N/A</td><td>N/A</td><td>N/A</td></tr>
- * <tr><td>Data (process())</td><td>{a=2,b=20,c=1000}</td><td></td><td>{a=2,b=20,c=1000}</td></tr>
- * <tr><td>Data (process())</td><td>{a=3,b=40,c=2}</td><td>{a=3,b=40,c=2}</td><td></td></tr>
- * <tr><td>Data (process())</td><td>{a=10,b=5}</td><td></td><td>{a=10,b=5}</td></tr>
- * <tr><td>Data (process())</td><td>{d=55,b=12}</td><td></td><td>{d=55,b=12}</td></tr>
- * <tr><td>Data (process())</td><td>{d=22,a=4}</td><td></td><td>{d=22,a=4}</td></tr>
- * <tr><td>Data (process())</td><td>{d=4,a=3,g=5,h=44}</td><td>{d=4,a=3,g=5,h=44}</td><td></td></tr>
- * <tr><td>End Window (endWindow())</td><td>N/A</td><td>N/A</td><td>N/A</td></tr>
- * </table>
- * <br>
- * <br>
- * @displayName Compare Except Map
- * @category Math
- * @tags comparison, key value, number, hash map
- * @since 0.3.2
- */
-@Stateless
-public class CompareExceptMap<K, V extends Number> extends MatchMap<K, V>
-{
-  /**
-   * Output port that emits a hashmap of matched tuples after comparison.
-   */
-  @OutputPortFieldAnnotation(optional = true)
-  public final transient DefaultOutputPort<HashMap<K, V>> compare = match;
-  
-  /**
-   * Output port that emits a hashmap of non matching tuples after comparison.
-   */
-  @OutputPortFieldAnnotation(optional = true)
-  public final transient DefaultOutputPort<HashMap<K, V>> except = new DefaultOutputPort<HashMap<K, V>>()
-  {
-    @Override
-    public Unifier<HashMap<K, V>> getUnifier()
-    {
-      return new UnifierHashMap<K, V>();
-    }
-  };
-
-  /**
-   * Emits if compare port is connected
-   * @param tuple
-   */
-  @Override
-  public void tupleMatched(Map<K, V> tuple)
-  {
-    if (compare.isConnected()) {
-      compare.emit(cloneTuple(tuple));
-    }
-  }
-
-  /**
-   * Emits if except port is connected
-   * @param tuple
-   */
-  @Override
-  public void tupleNotMatched(Map<K, V> tuple)
-  {
-    if (except.isConnected()) {
-      except.emit(cloneTuple(tuple));
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/math/CompareMap.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/math/CompareMap.java b/library/src/main/java/com/datatorrent/lib/math/CompareMap.java
deleted file mode 100644
index 3636207..0000000
--- a/library/src/main/java/com/datatorrent/lib/math/CompareMap.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- * 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 com.datatorrent.lib.math;
-
-import java.util.HashMap;
-
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.api.annotation.Stateless;
-import com.datatorrent.lib.algo.MatchMap;
-
-/**
- * This operator compares tuples subclassed from Number based on the property "key", "value", and "cmp", and matching tuples are emitted.
- * <p>
- * If the tuple passed the test, it is emitted on the output port "compare".&nbsp; The comparison is done by getting double value from the Number.
- * Both output ports are optional, but at least one has to be connected.
- * This module is a pass through<br>
- * <br>
- * <b>Ports</b>:<br>
- * <b>data</b>: expects Map&lt;K,V extends Number&gt;<br>
- * <b>compare</b>: emits HashMap&lt;K,V&gt;<br>
- * <br>
- * <b>Properties</b>:<br>
- * <b>key</b>: The key on which compare is done<br>
- * <b>value</b>: The value to compare with<br>
- * <b>cmp</b>: The compare function. Supported values are "lte", "lt", "eq", "neq", "gt", "gte". Default is "eq"<br>
- * <br>
- * <b>Compile time checks</b>:<br>
- * Key must be non empty<br>
- * Value must be able to convert to a "double"<br>
- * CompareMap string, if specified, must be one of "lte", "lt", "eq", "neq", "gt", "gte"<br>
- * <br>
- * <b>Specific run time checks</b>:<br>
- * Does the incoming HashMap have the key<br>
- * Is the value of the key a number<br>
- * <p>
- * <b>Benchmarks</b>: Blast as many tuples as possible in inline mode<br>
- * <table border="1" cellspacing=1 cellpadding=1 summary="Benchmark table for CompareMap&lt;K,V extends Number&gt; operator template">
- * <tr><th>In-Bound</th><th>Out-bound</th><th>Comments</th></tr>
- * <tr><td><b>8 Million K,V pairs/s</b></td><td>Each matched tuple is emitted</td><td>In-bound rate and number of tuples that match determine performance.
- * Immutable tuples were used in the benchmarking. If you use mutable tuples and have lots of keys, the benchmarks may be lower</td></tr>
- * </table><br>
- * <p>
- * <b>Function Table (K=String,V=Integer); emitError=true; key=a; value=3; cmp=eq)</b>:
- * <table border="1" cellspacing=1 cellpadding=1 summary="Function table for CompareMap&lt;K,V extends Number&gt; operator template">
- * <tr><th rowspan=2>Tuple Type (api)</th><th>In-bound (process)</th><th>Out-bound (emit)</th></tr>
- * <tr><th><i>data</i>(Map&lt;K,V&gt;)</th><th><i>compare</i>(HashMap&lt;K,V&gt;)</th></tr>
- * <tr><td>Begin Window (beginWindow())</td><td>N/A</td><td>N/A</td></tr>
- * <tr><td>Data (process())</td><td>{a=2,b=20,c=1000}</td><td></td></tr>
- * <tr><td>Data (process())</td><td>{a=3,b=40,c=2}</td><td>{a=3,b=40,c=2}</td></tr>
- * <tr><td>Data (process())</td><td>{a=10,b=5}</td><td></td></tr>
- * <tr><td>Data (process())</td><td>{d=55,b=12}</td><td></td></tr>
- * <tr><td>Data (process())</td><td>{d=22,a=4}</td><td></td></tr>
- * <tr><td>Data (process())</td><td>{d=4,a=3,g=5,h=44}</td><td>{d=4,a=3,g=5,h=44}</td></tr>
- * <tr><td>End Window (endWindow())</td><td>N/A</td><td>N/A</td></tr>
- * </table>
- * <br>
- * <br>
- * @displayName Compare Map
- * @category Math
- * @tags comparison, key value, numeric, map
- * @since 0.3.2
- */
-@Stateless
-public class CompareMap<K, V extends Number> extends MatchMap<K,V>
-{
-  /**
-   * Output port that emits a hashmap of matching number tuples after comparison.
-   */
-  public final transient DefaultOutputPort<HashMap<K, V>> compare = match;
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/math/CountKeyVal.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/math/CountKeyVal.java b/library/src/main/java/com/datatorrent/lib/math/CountKeyVal.java
deleted file mode 100644
index d593020..0000000
--- a/library/src/main/java/com/datatorrent/lib/math/CountKeyVal.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/**
- * 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 com.datatorrent.lib.math;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.commons.lang.mutable.MutableInt;
-
-import com.datatorrent.api.DefaultInputPort;
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.api.StreamCodec;
-import com.datatorrent.api.annotation.OutputPortFieldAnnotation;
-import com.datatorrent.lib.util.BaseKeyValueOperator;
-import com.datatorrent.lib.util.KeyValPair;
-import com.datatorrent.lib.util.UnifierCountOccurKey;
-
-/**
- * This Operator aggregates occurrence of keys in &lt;key,value&gt; pair at input port.&lt;Key,Occurrence count&gt; pair is emitted for each input on output port.
- * <p>
- * <br>
- * StateFull : Yes, key occurrence is aggregated over windows. <br>
- * Partitions : Yes, count occurrence unifier at output port. <br>
- * <br>
- * <b>Ports</b>:<br>
- * <b>data</b>: expects KeyValPair&lt;K,V&gt;<br>
- * <b>count</b>: emits KeyValPair&lt;K,Integer&gt;</b><br>
- * <br>
- * @displayName Count Key Value
- * @category Math
- * @tags count, key value, aggregate
- * @since 0.3.3
- */
-public class CountKeyVal<K, V> extends BaseKeyValueOperator<K, V>
-{
-
-  /**
-   * Key occurrence count map.
-   */
-  protected HashMap<K, MutableInt> counts = new HashMap<K, MutableInt>();
-
-  /**
-   * Input data port that takes key value pair.
-   */
-  public final transient DefaultInputPort<KeyValPair<K, V>> data = new DefaultInputPort<KeyValPair<K, V>>()
-  {
-    /**
-     * For each tuple (a key value pair): Adds the values for each key, Counts
-     * the number of occurrence of each key
-     */
-    @Override
-    public void process(KeyValPair<K, V> tuple)
-    {
-      K key = tuple.getKey();
-      MutableInt count = counts.get(key);
-      if (count == null) {
-        count = new MutableInt(0);
-        counts.put(cloneKey(key), count);
-      }
-      count.increment();
-    }
-
-    @Override
-    public StreamCodec<KeyValPair<K, V>> getStreamCodec()
-    {
-      return getKeyValPairStreamCodec();
-    }
-  };
-
-  /**
-   * Key, occurrence value pair output port.
-   */
-  @OutputPortFieldAnnotation(optional = true)
-  public final transient DefaultOutputPort<KeyValPair<K, Integer>> count = new DefaultOutputPort<KeyValPair<K, Integer>>()
-  {
-    @Override
-    public UnifierCountOccurKey<K> getUnifier()
-    {
-      return new UnifierCountOccurKey<K>();
-    }
-  };
-
-  /**
-   * Emits on all ports that are connected. Data is computed during process on
-   * input port and endWindow just emits it for each key. Clears the internal
-   * data if resetAtEndWindow is true.
-   */
-  @SuppressWarnings({ "unchecked", "rawtypes" })
-  @Override
-  public void endWindow()
-  {
-    for (Map.Entry<K, MutableInt> e : counts.entrySet()) {
-      count.emit(new KeyValPair(e.getKey(),
-          new Integer(e.getValue().intValue())));
-    }
-    counts.clear();
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/math/ExceptMap.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/math/ExceptMap.java b/library/src/main/java/com/datatorrent/lib/math/ExceptMap.java
deleted file mode 100644
index ddef880..0000000
--- a/library/src/main/java/com/datatorrent/lib/math/ExceptMap.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/**
- * 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 com.datatorrent.lib.math;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.api.annotation.Stateless;
-import com.datatorrent.lib.algo.MatchMap;
-import com.datatorrent.lib.util.UnifierHashMap;
-
-/**
- * This operator does comparison on tuple sub-classed from Number based on the property "key", "value", and "cmp", and not matched tuples are emitted.
- * <p>
- * The comparison is done by getting double value from the Number. Both output ports
- * are optional, but at least one has to be connected
- * <p>
- * This module is a pass through<br>
- * <br>
- * <br>
- * StateFull : No, output is emitted in current window. <br>
- * Partitions : Yes, No state dependency among input tuples. <br>
- * <br>
- * <b>Ports</b>:<br>
- * <b>data</b>: expects Map&lt;K,V extends Number&gt;<br>
- * <b>except</b>: emits HashMap&lt;K,V&gt;<br>
- * <br>
- * <b>Properties</b>:<br>
- * <b>key</b>: The key on which compare is done<br>
- * <b>value</b>: The value to compare with<br>
- * <b>cmp</b>: The compare function. Supported values are "lte", "lt", "eq",
- * "neq", "gt", "gte". Default is "eq"<br>
- * <br>
- * <b>Compile time checks</b>:<br>
- * Key must be non empty<br>
- * Value must be able to convert to a "double"<br>
- * Compare string, if specified, must be one of "lte", "lt", "eq", "neq", "gt",
- * "gte"<br>
- * <br>
- * <b>Run time checks</b>:<br>
- * Does the incoming HashMap have the key, Is the value of the key a number<br>
- * <br>
- * @displayName Except Map
- * @category Math
- * @tags comparison, Number
- * @since 0.3.3
- */
-@Stateless
-public class ExceptMap<K, V extends Number> extends MatchMap<K, V>
-{       
-        /**
-         * Output port that emits non matching number tuples.
-         */
-  public final transient DefaultOutputPort<HashMap<K, V>> except = new DefaultOutputPort<HashMap<K, V>>()
-  {
-    @Override
-    public Unifier<HashMap<K, V>> getUnifier()
-    {
-      return new UnifierHashMap<K, V>();
-    }
-  };
-
-  /**
-   * Does nothing. Overrides base as call super.tupleMatched() would emit the
-   * tuple
-   *
-   * @param tuple
-   */
-  @Override
-  public void tupleMatched(Map<K, V> tuple)
-  {
-  }
-
-  /**
-   * Emits the tuple. Calls cloneTuple to get a copy, allowing users to override
-   * in case objects are mutable
-   *
-   * @param tuple
-   */
-  @Override
-  public void tupleNotMatched(Map<K, V> tuple)
-  {
-    except.emit(cloneTuple(tuple));
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/math/Quotient.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/math/Quotient.java b/library/src/main/java/com/datatorrent/lib/math/Quotient.java
deleted file mode 100644
index ed08e86..0000000
--- a/library/src/main/java/com/datatorrent/lib/math/Quotient.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/**
- * 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 com.datatorrent.lib.math;
-
-import com.datatorrent.api.DefaultInputPort;
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.api.annotation.OperatorAnnotation;
-import com.datatorrent.lib.util.BaseNumberValueOperator;
-
-/**
- * This operator adds all the values on "numerator" and "denominator" and emits quotient at end of window. 
- * <p>
- * <br>
- * <b>StateFull : Yes </b>, Sum of values is taken over application window. <br>
- * <b>Partitions : No </b>, will yield wrong results, since values are
- * accumulated over application window. <br>
- * <br>
- * <b>Ports</b>:<br>
- * <b>numerator</b>: expects V extends Number<br>
- * <b>denominator</b>: expects V extends Number<br>
- * <b>quotient</b>: emits Double<br>
- * <br>
- * <b>Properties : </b> <br>
- * <b>mult_by : </b>Multiply by value(default = 1). <br>
- * <br>
- * @displayName Quotient
- * @category Math
- * @tags division, sum, numeric
- * @since 0.3.3
- */
-@OperatorAnnotation(partitionable = false)
-public class Quotient<V extends Number> extends BaseNumberValueOperator<V>
-{
-  protected double nval = 0.0;
-  protected double dval = 0.0;
-  int mult_by = 1;
-
-  /**
-   * Numerator values input port.
-   */
-  public final transient DefaultInputPort<V> numerator = new DefaultInputPort<V>()
-  {
-    /**
-     * Adds to the numerator value
-     */
-    @Override
-    public void process(V tuple)
-    {
-      nval += tuple.doubleValue();
-    }
-  };
-
-  /**
-   * Denominator values input port.
-   */
-  public final transient DefaultInputPort<V> denominator = new DefaultInputPort<V>()
-  {
-    /**
-     * Adds to the denominator value
-     */
-    @Override
-    public void process(V tuple)
-    {
-      dval += tuple.doubleValue();
-    }
-  };
-
-  /**
-   * Quotient output port.
-   */
-  public final transient DefaultOutputPort<V> quotient = new DefaultOutputPort<V>();
-
-  public void setMult_by(int i)
-  {
-    mult_by = i;
-  }
-
-  /**
-   * Generates tuple emits it as long as denominator is not 0. Clears internal
-   * data
-   */
-  @Override
-  public void endWindow()
-  {
-    if (dval == 0) {
-      return;
-    }
-    double val = (nval / dval) * mult_by;
-    quotient.emit(getValue(val));
-    nval = 0.0;
-    dval = 0.0;
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/math/QuotientMap.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/math/QuotientMap.java b/library/src/main/java/com/datatorrent/lib/math/QuotientMap.java
deleted file mode 100644
index a10fe95..0000000
--- a/library/src/main/java/com/datatorrent/lib/math/QuotientMap.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/**
- * 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 com.datatorrent.lib.math;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.validation.constraints.Min;
-
-import org.apache.commons.lang.mutable.MutableDouble;
-
-import com.datatorrent.api.DefaultInputPort;
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.api.annotation.OperatorAnnotation;
-import com.datatorrent.lib.util.BaseNumberKeyValueOperator;
-
-/**
- * Add all the values for each key on "numerator" and "denominator" and emits quotient at end of window for all keys in the denominator. 
- * <p>
- * <br>
- * Application can set multiplication value for quotient(default = 1). <br>
- * Operator will calculate quotient of occurrence of key in numerator divided by
- * occurrence of key in denominator if countKey flag is true. <br>
- * Application can allow or block keys by setting filter key and inverse flag. <br>
- * <br>
- * <b>StateFull : Yes</b>, numerator/denominator values are summed over
- * application window. <br>
- * <b>Partitions : No, </b>, will yield wrong results, since values are summed
- * over app window. <br>
- * <br>
- * <b>Ports</b>:<br>
- * <b>numerator</b>: expects Map&lt;K,V extends Number&gt;<br>
- * <b>denominator</b>: expects Map&lt;K,V extends Number&gt;<br>
- * <b>quotient</b>: emits HashMap&lt;K,Double&gt;<br>
- * <br>
- * <b>Properties</b>:<br>
- * <b>inverse :</b> if set to true the key in the filter will block tuple<br>
- * <b>filterBy :</b> List of keys to filter on<br>
- * <b>countkey :</b> Get quotient of occurrence of keys in numerator and
- * denominator. <br>
- * <b>mult_by :</b> Set multiply by constant value. <br>
- * <br>
- * @displayName Quotient Map
- * @category Math
- * @tags division, sum, map
- * @since 0.3.3
- */
-@OperatorAnnotation(partitionable = false)
-public class QuotientMap<K, V extends Number> extends
-    BaseNumberKeyValueOperator<K, V>
-{
-  /**
-   * Numerator key/sum value map.
-   */
-  protected HashMap<K, MutableDouble> numerators = new HashMap<K, MutableDouble>();
-
-  /**
-   * Denominator key/sum value map.
-   */
-  protected HashMap<K, MutableDouble> denominators = new HashMap<K, MutableDouble>();
-
-  /**
-   * Count occurrence of keys if set to true.
-   */
-  boolean countkey = false;
-
-  /**
-   * Quotient multiply by value.
-   */
-  int mult_by = 1;
-
-  /**
-   * Numerator input port.
-   */
-  public final transient DefaultInputPort<Map<K, V>> numerator = new DefaultInputPort<Map<K, V>>()
-  {
-    /**
-     * Added tuple to the numerator hash
-     */
-    @Override
-    public void process(Map<K, V> tuple)
-    {
-      addTuple(tuple, numerators);
-    }
-  };
-
-  /**
-   * Denominator input port.
-   */
-  public final transient DefaultInputPort<Map<K, V>> denominator = new DefaultInputPort<Map<K, V>>()
-  {
-    /**
-     * Added tuple to the denominator hash
-     */
-    @Override
-    public void process(Map<K, V> tuple)
-    {
-      addTuple(tuple, denominators);
-    }
-  };
-
-  /**
-   * Quotient output port.
-   */
-  public final transient DefaultOutputPort<HashMap<K, Double>> quotient = new DefaultOutputPort<HashMap<K, Double>>();
-
-  /**
-   * Add tuple to nval/dval map.
-   *
-   * @param tuple
-   *          key/value map on input port.
-   * @param map
-   *          key/summed value map.
-   */
-  public void addTuple(Map<K, V> tuple, Map<K, MutableDouble> map)
-  {
-    for (Map.Entry<K, V> e : tuple.entrySet()) {
-      addEntry(e.getKey(), e.getValue(), map);
-    }
-  }
-
-  /**
-   * Add/Update entry to key/sum value map.
-   *
-   * @param key
-   *          name.
-   * @param value
-   *          value for key.
-   * @param map
-   *          numerator/denominator key/sum map.
-   */
-  public void addEntry(K key, V value, Map<K, MutableDouble> map)
-  {
-    if (!doprocessKey(key) || (value == null)) {
-      return;
-    }
-    MutableDouble val = map.get(key);
-    if (val == null) {
-      if (countkey) {
-        val = new MutableDouble(1.00);
-      } else {
-        val = new MutableDouble(value.doubleValue());
-      }
-    } else {
-      if (countkey) {
-        val.increment();
-      } else {
-        val.add(value.doubleValue());
-      }
-    }
-    map.put(cloneKey(key), val);
-  }
-
-  /**
-   * getter for mult_by
-   *
-   * @return mult_by
-   */
-
-  @Min(0)
-  public int getMult_by()
-  {
-    return mult_by;
-  }
-
-  /**
-   * getter for countkey
-   *
-   * @return countkey
-   */
-  public boolean getCountkey()
-  {
-    return countkey;
-  }
-
-  /**
-   * Setter for mult_by
-   *
-   * @param i
-   */
-  public void setMult_by(int i)
-  {
-    mult_by = i;
-  }
-
-  /**
-   * setter for countkey
-   *
-   * @param i
-   *          sets countkey
-   */
-  public void setCountkey(boolean i)
-  {
-    countkey = i;
-  }
-
-  /**
-   * Generates tuples for each key and emits them. Only keys that are in the
-   * denominator are iterated on If the key is only in the numerator, it gets
-   * ignored (cannot do divide by 0) Clears internal data
-   */
-  @Override
-  public void endWindow()
-  {
-    HashMap<K, Double> tuples = new HashMap<K, Double>();
-    for (Map.Entry<K, MutableDouble> e : denominators.entrySet()) {
-      MutableDouble nval = numerators.get(e.getKey());
-      if (nval == null) {
-        tuples.put(e.getKey(), new Double(0.0));
-      } else {
-        tuples.put(e.getKey(), new Double((nval.doubleValue() / e.getValue()
-            .doubleValue()) * mult_by));
-      }
-    }
-    if (!tuples.isEmpty()) {
-      quotient.emit(tuples);
-    }
-    numerators.clear();
-    denominators.clear();
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/math/SumCountMap.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/math/SumCountMap.java b/library/src/main/java/com/datatorrent/lib/math/SumCountMap.java
deleted file mode 100644
index c2d8465..0000000
--- a/library/src/main/java/com/datatorrent/lib/math/SumCountMap.java
+++ /dev/null
@@ -1,303 +0,0 @@
-/**
- * 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 com.datatorrent.lib.math;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.commons.lang.mutable.MutableDouble;
-import org.apache.commons.lang.mutable.MutableInt;
-
-import com.datatorrent.api.DefaultInputPort;
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.api.annotation.OutputPortFieldAnnotation;
-import com.datatorrent.lib.util.BaseNumberKeyValueOperator;
-import com.datatorrent.lib.util.UnifierHashMapInteger;
-import com.datatorrent.lib.util.UnifierHashMapSumKeys;
-
-/**
- * Emits the sum and count of values for each key at the end of window.
- * <p>
- * Application accumulate sum across streaming window by setting cumulative flag
- * to true. <br>
- * This is an end of window operator<br>
- * <br>
- * <b>StateFull : Yes</b>, Sum is computed over application window and streaming
- * window. <br>
- * <b>Partitions : Yes</b>, Sum is unified at output port. <br>
- * <br>
- * <b>Ports</b>:<br>
- * <b>data</b>: expects Map&lt;K,V extends Number&gt;<br>
- * <b>sum</b>: emits HashMap&lt;K,V&gt;<br>
- * <b>count</b>: emits HashMap&lt;K,Integer&gt;</b><br>
- * <br>
- * <b>Properties</b>:<br>
- * <b>inverse</b>: if set to true the key in the filter will block tuple<br>
- * <b>filterBy</b>: List of keys to filter on<br>
- * <b>cumulative</b>: boolean flag, if set the sum is not cleared at the end of
- * window, <br>
- * hence generating cumulative sum across streaming windows. Default is false.<br>
- * <br>
- * @displayName Sum Count Map
- * @category Math
- * @tags  number, sum, counting, map
- * @since 0.3.3
- */
-public class SumCountMap<K, V extends Number> extends
-    BaseNumberKeyValueOperator<K, V>
-{
-  /**
-   * Key/double sum map.
-   */
-  protected HashMap<K, MutableDouble> sums = new HashMap<K, MutableDouble>();
-
-  /**
-   * Key/integer sum map.
-   */
-  protected HashMap<K, MutableInt> counts = new HashMap<K, MutableInt>();
-
-  /**
-   * Cumulative sum flag.
-   */
-  protected boolean cumulative = false;
-
-  /**
-   * Input port that takes a map.&nbsp; It adds the values for each key and counts the number of occurrences for each key.
-   */
-  public final transient DefaultInputPort<Map<K, V>> data = new DefaultInputPort<Map<K, V>>()
-  {
-    /**
-     * For each tuple (a HashMap of keys,val pairs) Adds the values for each
-     * key, Counts the number of occurrences of each key
-     */
-    @Override
-    public void process(Map<K, V> tuple)
-    {
-      for (Map.Entry<K, V> e : tuple.entrySet()) {
-        K key = e.getKey();
-        if (!doprocessKey(key)) {
-          continue;
-        }
-        if (sum.isConnected()) {
-          MutableDouble val = sums.get(key);
-          if (val == null) {
-            val = new MutableDouble(e.getValue().doubleValue());
-          } else {
-            val.add(e.getValue().doubleValue());
-          }
-          sums.put(cloneKey(key), val);
-        }
-        if (SumCountMap.this.count.isConnected()) {
-          MutableInt count = counts.get(key);
-          if (count == null) {
-            count = new MutableInt(0);
-            counts.put(cloneKey(key), count);
-          }
-          count.increment();
-        }
-      }
-    }
-  };
-
-  /**
-   * Key,sum map output port.
-   */
-  @OutputPortFieldAnnotation(optional = true)
-  public final transient DefaultOutputPort<HashMap<K, V>> sum = new DefaultOutputPort<HashMap<K, V>>()
-  {
-    @Override
-    public Unifier<HashMap<K, V>> getUnifier()
-    {
-      return new UnifierHashMapSumKeys<K, V>();
-    }
-  };
-
-  /**
-   * Key,double sum map output port.
-   */
-  @OutputPortFieldAnnotation(optional = true)
-  public final transient DefaultOutputPort<HashMap<K, Double>> sumDouble = new DefaultOutputPort<HashMap<K, Double>>()
-  {
-    @SuppressWarnings({ "rawtypes", "unchecked" })
-    @Override
-    public Unifier<HashMap<K, Double>> getUnifier()
-    {
-      UnifierHashMapSumKeys ret = new UnifierHashMapSumKeys<K, Double>();
-      ret.setType(Double.class);
-      return ret;
-    }
-  };
-
-  /**
-   * Key,integer sum output port.
-   */
-  @OutputPortFieldAnnotation(optional = true)
-  public final transient DefaultOutputPort<HashMap<K, Integer>> sumInteger = new DefaultOutputPort<HashMap<K, Integer>>()
-  {
-    @SuppressWarnings({ "rawtypes", "unchecked" })
-    @Override
-    public Unifier<HashMap<K, Integer>> getUnifier()
-    {
-      UnifierHashMapSumKeys ret = new UnifierHashMapSumKeys<K, Integer>();
-      ret.setType(Integer.class);
-      return ret;
-    }
-  };
-
-
-        /**
-   * Key,long sum output port.
-   */
-  @OutputPortFieldAnnotation(optional = true)
-  public final transient DefaultOutputPort<HashMap<K, Long>> sumLong = new DefaultOutputPort<HashMap<K, Long>>()
-  {
-    @SuppressWarnings({ "rawtypes", "unchecked" })
-    @Override
-    public Unifier<HashMap<K, Long>> getUnifier()
-    {
-      UnifierHashMapSumKeys ret = new UnifierHashMapSumKeys<K, Long>();
-      ret.setType(Long.class);
-      return ret;
-    }
-  };
-        
-        /**
-   * Key,short sum output port.
-   */
-  @OutputPortFieldAnnotation(optional = true)
-  public final transient DefaultOutputPort<HashMap<K, Short>> sumShort = new DefaultOutputPort<HashMap<K, Short>>()
-  {
-    @SuppressWarnings({ "rawtypes", "unchecked" })
-    @Override
-    public Unifier<HashMap<K, Short>> getUnifier()
-    {
-      UnifierHashMapSumKeys ret = new UnifierHashMapSumKeys<K, Short>();
-      ret.setType(Short.class);
-      return ret;
-    }
-  };
-        
-        /**
-   * Key,float sum output port.
-   */
-  @OutputPortFieldAnnotation(optional = true)
-  public final transient DefaultOutputPort<HashMap<K, Float>> sumFloat = new DefaultOutputPort<HashMap<K, Float>>()
-  {
-    @SuppressWarnings({ "rawtypes", "unchecked" })
-    @Override
-    public Unifier<HashMap<K, Float>> getUnifier()
-    {
-      UnifierHashMapSumKeys ret = new UnifierHashMapSumKeys<K, Float>();
-      ret.setType(Float.class);
-      return ret;
-    }
-  };
-        
-        /**
-   * Key,integer sum output port.
-   */
-  @OutputPortFieldAnnotation(optional = true)
-  public final transient DefaultOutputPort<HashMap<K, Integer>> count = new DefaultOutputPort<HashMap<K, Integer>>()
-  {
-    @Override
-    public Unifier<HashMap<K, Integer>> getUnifier()
-    {
-      return new UnifierHashMapInteger<K>();
-    }
-  };
-
-  /**
-   * Get cumulative flag.
-   *
-   * @return cumulative flag
-   */
-  public boolean isCumulative()
-  {
-    return cumulative;
-  }
-
-  /**
-   * set cumulative flag.
-   *
-   * @param cumulative
-   *          input flag
-   */
-  public void setCumulative(boolean cumulative)
-  {
-    this.cumulative = cumulative;
-  }
-
-  /**
-   * Emits on all ports that are connected. Data is precomputed during process
-   * on input port endWindow just emits it for each key Clears the internal data
-   * before return
-   */
-  @Override
-  public void endWindow()
-  {
-
-    // Should allow users to send each key as a separate tuple to load balance
-    // This is an aggregate node, so load balancing would most likely not be
-    // needed
-
-    HashMap<K, V> tuples = new HashMap<K, V>();
-    HashMap<K, Integer> ctuples = new HashMap<K, Integer>();
-    HashMap<K, Double> dtuples = new HashMap<K, Double>();
-    HashMap<K, Integer> ituples = new HashMap<K, Integer>();
-    HashMap<K, Float> ftuples = new HashMap<K, Float>();
-    HashMap<K, Long> ltuples = new HashMap<K, Long>();
-    HashMap<K, Short> stuples = new HashMap<K, Short>();
-
-    for (Map.Entry<K, MutableDouble> e : sums.entrySet()) {
-      K key = e.getKey();
-      MutableDouble val = e.getValue();
-      tuples.put(key, getValue(val.doubleValue()));
-      dtuples.put(key, val.doubleValue());
-      ituples.put(key, val.intValue());
-      ftuples.put(key, val.floatValue());
-      ltuples.put(key, val.longValue());
-      stuples.put(key, val.shortValue());
-      // ctuples.put(key, counts.get(e.getKey()).toInteger());
-      MutableInt c = counts.get(e.getKey());
-      if (c != null) {
-        ctuples.put(key, c.toInteger());
-      }
-    }
-
-    sum.emit(tuples);
-    sumDouble.emit(dtuples);
-    sumInteger.emit(ituples);
-    sumLong.emit(ltuples);
-    sumShort.emit(stuples);
-    sumFloat.emit(ftuples);
-    count.emit(ctuples);
-    clearCache();
-  }
-
-  /**
-   * Clear sum maps.
-   */
-  private void clearCache()
-  {
-    if (!cumulative) {
-      sums.clear();
-      counts.clear();
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/streamquery/AbstractSqlStreamOperator.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/streamquery/AbstractSqlStreamOperator.java b/library/src/main/java/com/datatorrent/lib/streamquery/AbstractSqlStreamOperator.java
deleted file mode 100644
index e3bba8a..0000000
--- a/library/src/main/java/com/datatorrent/lib/streamquery/AbstractSqlStreamOperator.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-
-import com.datatorrent.api.DefaultInputPort;
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.api.annotation.InputPortFieldAnnotation;
-import com.datatorrent.api.annotation.OutputPortFieldAnnotation;
-import com.datatorrent.common.util.BaseOperator;
-
-/**
- * A base implementation of a BaseOperator that is a sql stream operator.&nbsp;  Subclasses should provide the
-   implementation of how to process the tuples.
- * <p>
- * Abstract sql db input operator.
- * <p>
- * @displayName Abstract Sql Stream
- * @category Stream Manipulators
- * @tags sql operator
- * @since 0.3.2
- */
-public abstract class AbstractSqlStreamOperator extends BaseOperator
-{
-  public static class InputSchema
-  {
-    public static class ColumnInfo
-    {
-      public String type;
-      public int bindIndex = 0;
-      public boolean isColumnIndex = false;
-    }
-
-    /**
-     * the name of the input "table"
-     */
-    public String name;
-    /**
-     * key is the name of the column, and value is the SQL type
-     */
-    public HashMap<String, ColumnInfo> columnInfoMap = new HashMap<String, ColumnInfo>();
-
-    public InputSchema()
-    {
-    }
-
-    public InputSchema(String name)
-    {
-      this.name = name;
-    }
-
-    public void setColumnInfo(String columnName, String columnType, boolean isColumnIndex)
-    {
-      ColumnInfo t = new ColumnInfo();
-      t.type = columnType;
-      t.isColumnIndex = isColumnIndex;
-      columnInfoMap.put(columnName, t);
-    }
-
-  }
-
-  protected String statement;
-  protected ArrayList<InputSchema> inputSchemas = new ArrayList<InputSchema>(5);
-  protected transient ArrayList<Object> bindings;
-
-  /**
-   * Input bindings port that takes an arraylist of objects.
-   */
-  @InputPortFieldAnnotation(optional = true)
-  public final transient DefaultInputPort<ArrayList<Object>> bindingsPort = new DefaultInputPort<ArrayList<Object>>()
-  {
-    @Override
-    public void process(ArrayList<Object> tuple)
-    {
-      bindings = tuple;
-    }
-
-  };
-
-  /**
-   * Input port in1 that takes a hashmap of &lt;string,object&gt;.
-   */
-  public final transient DefaultInputPort<HashMap<String, Object>> in1 = new DefaultInputPort<HashMap<String, Object>>()
-  {
-    @Override
-    public void process(HashMap<String, Object> tuple)
-    {
-      processTuple(0, tuple);
-    }
-
-  };
-
-  /**
-   * Input port in2 that takes a hashmap of &lt;string,object&gt;.
-   */
-  @InputPortFieldAnnotation(optional = true)
-  public final transient DefaultInputPort<HashMap<String, Object>> in2 = new DefaultInputPort<HashMap<String, Object>>()
-  {
-    @Override
-    public void process(HashMap<String, Object> tuple)
-    {
-      processTuple(1, tuple);
-    }
-
-  };
-
-  /**
-   * Input port in3 that takes a hashmap of &lt;string,object&gt;.
-   */
-  @InputPortFieldAnnotation(optional = true)
-  public final transient DefaultInputPort<HashMap<String, Object>> in3 = new DefaultInputPort<HashMap<String, Object>>()
-  {
-    @Override
-    public void process(HashMap<String, Object> tuple)
-    {
-      processTuple(2, tuple);
-    }
-
-  };
-
-  /**
-   * Input port in4 that takes a hashmap of &lt;string,object&gt;.
-   */
-  @InputPortFieldAnnotation(optional = true)
-  public final transient DefaultInputPort<HashMap<String, Object>> in4 = new DefaultInputPort<HashMap<String, Object>>()
-  {
-    @Override
-    public void process(HashMap<String, Object> tuple)
-    {
-      processTuple(3, tuple);
-    }
-
-  };
-
-  /**
-   * Input port in5 that takes a hashmap of &lt;string,object&gt;.
-   */
-  @InputPortFieldAnnotation(optional = true)
-  public final transient DefaultInputPort<HashMap<String, Object>> in5 = new DefaultInputPort<HashMap<String, Object>>()
-  {
-    @Override
-    public void process(HashMap<String, Object> tuple)
-    {
-      processTuple(4, tuple);
-    }
-
-  };
-
-  /**
-   * Output result port that emits a hashmap of &lt;string,object&gt;.
-   */
-  @OutputPortFieldAnnotation(optional = true)
-  public final transient DefaultOutputPort<HashMap<String, Object>> result = new DefaultOutputPort<HashMap<String, Object>>();
-
-  public void setStatement(String statement)
-  {
-    this.statement = statement;
-  }
-
-  public String getStatement()
-  {
-    return this.statement;
-  }
-
-  public void setInputSchema(int inputPortIndex, InputSchema inputSchema)
-  {
-    inputSchemas.add(inputPortIndex, inputSchema);
-  }
-
-  public abstract void processTuple(int tableNum, HashMap<String, Object> tuple);
-
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/streamquery/DeleteOperator.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/streamquery/DeleteOperator.java b/library/src/main/java/com/datatorrent/lib/streamquery/DeleteOperator.java
deleted file mode 100644
index 77c7522..0000000
--- a/library/src/main/java/com/datatorrent/lib/streamquery/DeleteOperator.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery;
-
-import java.util.Map;
-
-import com.datatorrent.api.DefaultInputPort;
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.common.util.BaseOperator;
-import com.datatorrent.lib.streamquery.condition.Condition;
-
-/**
- * An implementation of BaseOperator that provides sql delete query semantic on live data stream. <br>
- * <p>
- * Stream rows passing condition are emitted on output port stream. <br>
- * <br>
- * <b>StateFull : NO,</b> all row data is processed in current time window. <br>
- * <b>Partitions : Yes, </b> No Input dependency among input rows. <br>
- * <br>
- * <b>Ports</b>:<br>
- * <b> inport : </b> Input hash map(row) port, expects
- * HashMap&lt;String,Object&gt;<<br>
- * <b> outport : </b> Output hash map(row) port, emits
- * HashMap&lt;String,Object&gt;<br>
- * <br>
- * <b> Properties : <b> <br>
- * <b> condition : </b> Select condition for selecting rows. <br>
- * <b> columns : </b> Column names/aggregate functions for select. <br>
- * <br>
- * @displayName Delete
- * @category Stream Manipulators
- * @tags sql delete operator
- * @since 0.3.3
- */
-public class DeleteOperator extends BaseOperator
-{
-
-  /**
-   * condition.
-   */
-  private Condition condition = null;
-
-  /**
-   * set condition.
-   */
-  public void setCondition(Condition condition)
-  {
-    this.condition = condition;
-  }
-
-  /**
-   * Input port that takes a map of &lt;string,object&gt;.
-   */
-  public final transient DefaultInputPort<Map<String, Object>> inport = new DefaultInputPort<Map<String, Object>>()
-  {
-
-    @Override
-    public void process(Map<String, Object> tuple)
-    {
-      if ((condition != null) && (!condition.isValidRow(tuple))) {
-        outport.emit(tuple);
-      }
-    }
-  };
-
-  /**
-   * Output port emits a map of &lt;string,object&gt;.
-   */
-  public final transient DefaultOutputPort<Map<String, Object>> outport = new DefaultOutputPort<Map<String, Object>>();
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/streamquery/DerbySqlStreamOperator.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/streamquery/DerbySqlStreamOperator.java b/library/src/main/java/com/datatorrent/lib/streamquery/DerbySqlStreamOperator.java
deleted file mode 100644
index 2fe8bc3..0000000
--- a/library/src/main/java/com/datatorrent/lib/streamquery/DerbySqlStreamOperator.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import com.datatorrent.api.Context.OperatorContext;
-import com.datatorrent.lib.streamquery.AbstractSqlStreamOperator.InputSchema.ColumnInfo;
-
-/**
- * An implementation of AbstractSqlStreamOperator that provides embedded derby sql input operator.
- * <p>
- * @displayName Derby Sql Stream
- * @category Stream Manipulators
- * @tags sql, in-memory, input operator
- * @since 0.3.2
- */
-public class DerbySqlStreamOperator extends AbstractSqlStreamOperator
-{
-  protected transient ArrayList<PreparedStatement> insertStatements = new ArrayList<PreparedStatement>(5);
-  protected List<String> execStmtStringList = new ArrayList<String>();
-  protected transient ArrayList<PreparedStatement> execStatements = new ArrayList<PreparedStatement>(5);
-  protected transient ArrayList<PreparedStatement> deleteStatements = new ArrayList<PreparedStatement>(5);
-  protected transient Connection db;
-
-  public void addExecStatementString(String stmt)
-  {
-    this.execStmtStringList.add(stmt);
-  }
-
-
-  @Override
-  public void setup(OperatorContext context)
-  {
-    System.setProperty("derby.stream.error.file", "/dev/null");
-    try {
-      Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
-    } catch (Exception ex) {
-      throw new RuntimeException(ex);
-    }
-
-    String connUrl = "jdbc:derby:memory:MALHAR_TEMP;create=true";
-    PreparedStatement st;
-
-    try {
-      db = DriverManager.getConnection(connUrl);
-      // create the temporary tables here
-      for (int i = 0; i < inputSchemas.size(); i++) {
-        InputSchema inputSchema = inputSchemas.get(i);
-        if (inputSchema == null || inputSchema.columnInfoMap.isEmpty()) {
-          continue;
-        }
-        String columnSpec = "";
-        String columnNames = "";
-        String insertQuestionMarks = "";
-        int j = 0;
-        for (Map.Entry<String, ColumnInfo> entry : inputSchema.columnInfoMap.entrySet()) {
-          if (!columnSpec.isEmpty()) {
-            columnSpec += ",";
-            columnNames += ",";
-            insertQuestionMarks += ",";
-          }
-          columnSpec += entry.getKey();
-          columnSpec += " ";
-          columnSpec += entry.getValue().type;
-          columnNames += entry.getKey();
-          insertQuestionMarks += "?";
-          entry.getValue().bindIndex = ++j;
-        }
-        String createTempTableStmt =
-            "DECLARE GLOBAL TEMPORARY TABLE SESSION." + inputSchema.name + "(" + columnSpec + ") NOT LOGGED";
-        st = db.prepareStatement(createTempTableStmt);
-        st.execute();
-        st.close();
-
-        String insertStmt = "INSERT INTO SESSION." + inputSchema.name + " (" + columnNames + ") VALUES ("
-            + insertQuestionMarks + ")";
-
-        insertStatements.add(i, db.prepareStatement(insertStmt));
-        deleteStatements.add(i, db.prepareStatement("DELETE FROM SESSION." + inputSchema.name));
-      }
-      for (String stmtStr : execStmtStringList) {
-        execStatements.add(db.prepareStatement(stmtStr));
-      }
-    } catch (SQLException ex) {
-      throw new RuntimeException(ex);
-    }
-  }
-
-  @Override
-  public void beginWindow(long windowId)
-  {
-    try {
-      db.setAutoCommit(false);
-    } catch (SQLException ex) {
-      throw new RuntimeException(ex);
-    }
-  }
-
-  @Override
-  public void processTuple(int tableNum, HashMap<String, Object> tuple)
-  {
-    InputSchema inputSchema = inputSchemas.get(tableNum);
-
-    PreparedStatement insertStatement = insertStatements.get(tableNum);
-    try {
-      for (Map.Entry<String, Object> entry : tuple.entrySet()) {
-        ColumnInfo t = inputSchema.columnInfoMap.get(entry.getKey());
-        if (t != null && t.bindIndex != 0) {
-          insertStatement.setString(t.bindIndex, entry.getValue().toString());
-        }
-      }
-
-      insertStatement.executeUpdate();
-      insertStatement.clearParameters();
-    } catch (SQLException ex) {
-      throw new RuntimeException(ex);
-    }
-  }
-
-  @Override
-  public void endWindow()
-  {
-    try {
-      db.commit();
-      if (bindings != null) {
-        for (int i = 0; i < bindings.size(); i++) {
-          for (PreparedStatement stmt : execStatements) {
-            stmt.setString(i, bindings.get(i).toString());
-          }
-        }
-      }
-
-      for (PreparedStatement stmt : execStatements) {
-        executePreparedStatement(stmt);
-      }
-      for (PreparedStatement st : deleteStatements) {
-        st.executeUpdate();
-        st.clearParameters();
-      }
-    } catch (SQLException ex) {
-      throw new RuntimeException(ex);
-    }
-    bindings = null;
-  }
-
-  private void executePreparedStatement(PreparedStatement statement) throws SQLException
-  {
-    ResultSet res = statement.executeQuery();
-    ResultSetMetaData resmeta = res.getMetaData();
-    int columnCount = resmeta.getColumnCount();
-    while (res.next()) {
-      HashMap<String, Object> resultRow = new HashMap<String, Object>();
-      for (int i = 1; i <= columnCount; i++) {
-        resultRow.put(resmeta.getColumnName(i), res.getObject(i));
-      }
-      this.result.emit(resultRow);
-    }
-    statement.clearParameters();
-  }
-
-  @Override
-  public void teardown()
-  {
-    try {
-      db.close();
-    } catch (SQLException ex) {
-      throw new RuntimeException(ex);
-    }
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/streamquery/GroupByHavingOperator.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/streamquery/GroupByHavingOperator.java b/library/src/main/java/com/datatorrent/lib/streamquery/GroupByHavingOperator.java
deleted file mode 100644
index 1821953..0000000
--- a/library/src/main/java/com/datatorrent/lib/streamquery/GroupByHavingOperator.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.validation.constraints.NotNull;
-
-import com.datatorrent.api.DefaultInputPort;
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.api.annotation.OperatorAnnotation;
-import com.datatorrent.common.util.BaseOperator;
-import com.datatorrent.lib.streamquery.condition.Condition;
-import com.datatorrent.lib.streamquery.condition.HavingCondition;
-import com.datatorrent.lib.streamquery.function.FunctionIndex;
-import com.datatorrent.lib.streamquery.index.ColumnIndex;
-
-/**
- * An implementation of BaseOperator that provides sql group by querying semantics on live data stream. <br>
- * <p>
- * Stream rows satisfying given select condition are processed by group by
- * column names and aggregate column function. <br>
- * If having condition is specified for aggregate index(s), it must also be
- * satisfied by row. HashMap of column name(s) and aggregate alias is emitted on
- * output port. <br>
- * <br>
- * <b>StateFull : Yes,</b> Operator aggregates input over application window. <br>
- * <b>Partitions : No, </b> will yield wrong result(s). <br>
- * <br>
- * <b>Ports</b>:<br>
- * <b> inport : </b> Input hash map(row) port, expects
- * HashMap&lt;String,Object&gt;<<br>
- * <b> outport : </b> Output hash map(row) port, emits
- * HashMap&lt;String,Object&gt;<br>
- * <br>
- * <b> Properties : <b> <br>
- * <b> condition : </b> Select condition for deleting rows. <br>
- * <b> columnGroupIndexes : </b> Group by names list. <br>
- * <b> indexes : </b> Select column indexes. <br>
- * <b> havingConditions : </b> Having filter conditions for aggregate(s). <br>
- * <br>
- * @displayName GroupBy Having Operator
- * @category Stream Manipulators
- * @tags sql, groupby operator, condition, index
- * @since 0.3.4
- */
-@OperatorAnnotation(partitionable = false)
-public class GroupByHavingOperator extends BaseOperator
-{
-
-  /**
-   * aggregate indexes.
-   */
-  private ArrayList<FunctionIndex> aggregates = new ArrayList<FunctionIndex>();
-
-  /**
-   * Column, Group by names
-   */
-  private ArrayList<ColumnIndex> columnGroupIndexes = new ArrayList<ColumnIndex>();
-
-  /**
-   * where condition.
-   */
-  private Condition condition;
-
-  /**
-   * having aggregate condtion;
-   */
-  private ArrayList<HavingCondition> havingConditions = new ArrayList<HavingCondition>();
-
-  /**
-   * Table rows.
-   */
-  private ArrayList<Map<String, Object>> rows = new ArrayList<Map<String, Object>>();
-
-  public void addAggregateIndex(@NotNull FunctionIndex index)
-  {
-    aggregates.add(index);
-  }
-
-  public void addColumnGroupByIndex(@NotNull ColumnIndex index)
-  {
-    columnGroupIndexes.add(index);
-  }
-
-  public void addHavingCondition(@NotNull HavingCondition condition)
-  {
-    havingConditions.add(condition);
-  }
-
-  /**
-   * @param condition condition
-   */
-  public void setCondition(Condition condition)
-  {
-    this.condition = condition;
-  }
-
-  /**
-   * Input port that takes a map of &lt;string,object&gt;.
-   */
-  public final transient DefaultInputPort<Map<String, Object>> inport = new DefaultInputPort<Map<String, Object>>()
-  {
-
-    @Override
-    public void process(Map<String, Object> tuple)
-    {
-      if ((condition != null) && (!condition.isValidRow(tuple))) {
-        return;
-      }
-      rows.add(tuple);
-    }
-  };
-
-  /**
-   * Output port that emits a map of &lt;string,object&gt;.
-   */
-  public final transient DefaultOutputPort<Map<String, Object>> outport = new DefaultOutputPort<Map<String, Object>>();
-
-  /**
-   * Create aggregate at end window.
-   */
-  @Override
-  public void endWindow()
-  {
-    // group names
-    if (columnGroupIndexes.size() == 0) {
-      rows = new ArrayList<Map<String, Object>>();
-      return;
-    }
-
-    // group rows
-    HashMap<MultiKeyCompare, ArrayList<Map<String, Object>>> groups = new HashMap<MultiKeyCompare, ArrayList<Map<String, Object>>>();
-    for (Map<String, Object> row : rows) {
-      MultiKeyCompare key = new MultiKeyCompare();
-      for (ColumnIndex index : columnGroupIndexes) {
-        key.addCompareKey(row.get(index.getColumn()));
-      }
-      ArrayList<Map<String, Object>> subRows;
-      if (groups.containsKey(key)) {
-        subRows = groups.get(key);
-      } else {
-        subRows = new ArrayList<Map<String, Object>>();
-        groups.put(key, subRows);
-      }
-      subRows.add(row);
-    }
-
-    // Iterate over groups and emit aggregate values
-    for (Map.Entry<MultiKeyCompare, ArrayList<Map<String, Object>>> entry : groups
-        .entrySet()) {
-      ArrayList<Map<String, Object>> subRows = entry.getValue();
-
-      // get result
-      Map<String, Object> result = new HashMap<String, Object>();
-      for (ColumnIndex index : columnGroupIndexes) {
-        index.filter(subRows.get(0), result);
-      }
-
-      // append aggregate values
-      for (FunctionIndex aggregate : aggregates) {
-        try {
-          aggregate.filter(subRows, result);
-        } catch (Exception e) {
-          e.printStackTrace();
-        }
-      }
-
-      // check valid having aggregate
-      boolean isValidHaving = true;
-      for (HavingCondition condition : havingConditions) {
-        try {
-          isValidHaving &= condition.isValidAggregate(subRows);
-        } catch (Exception e) {
-          e.printStackTrace();
-          return;
-        }
-      }
-      if (isValidHaving) {
-        outport.emit(result);
-      }
-    }
-
-    rows = new ArrayList<Map<String, Object>>();
-  }
-
-  /**
-   * multi key compare class.
-   */
-  @SuppressWarnings("rawtypes")
-  private class MultiKeyCompare implements Comparable
-  {
-
-    /**
-     * compare keys.
-     */
-    ArrayList<Object> compareKeys = new ArrayList<Object>();
-
-    @Override
-    public boolean equals(Object other)
-    {
-      if (other instanceof MultiKeyCompare) {
-        if (compareKeys.size() != ((MultiKeyCompare)other).compareKeys.size()) {
-          return false;
-        }
-      }
-      for (int i = 0; i < compareKeys.size(); i++) {
-        if (!(compareKeys.get(i).equals(((MultiKeyCompare)other).compareKeys.get(i)))) {
-          return false;
-        }
-      }
-      return true;
-    }
-
-    @Override
-    public int hashCode()
-    {
-      int hashCode = 0;
-      for (int i = 0; i < compareKeys.size(); i++) {
-        hashCode += compareKeys.get(i).hashCode();
-      }
-      return hashCode;
-    }
-
-    @Override
-    public int compareTo(Object other)
-    {
-      if (this.equals(other)) {
-        return 0;
-      }
-      return -1;
-    }
-
-    /**
-     * Add compare key.
-     */
-    public void addCompareKey(Object value)
-    {
-      compareKeys.add(value);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/streamquery/InnerJoinOperator.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/streamquery/InnerJoinOperator.java b/library/src/main/java/com/datatorrent/lib/streamquery/InnerJoinOperator.java
deleted file mode 100644
index 883329e..0000000
--- a/library/src/main/java/com/datatorrent/lib/streamquery/InnerJoinOperator.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
-import com.datatorrent.api.Context.OperatorContext;
-import com.datatorrent.api.DefaultInputPort;
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.api.Operator;
-import com.datatorrent.api.annotation.OperatorAnnotation;
-import com.datatorrent.lib.streamquery.condition.Condition;
-import com.datatorrent.lib.streamquery.index.Index;
-
-/**
- * An implementation of Operator that reads table row data from two table data input ports. <br>
- * <p>
- * Operator joins row on given condition and selected names, emits
- * joined result at output port.
- *  <br>
- *  <b>StateFull : Yes,</b> Operator aggregates input over application window. <br>
- *  <b>Partitions : No, </b> will yield wrong result(s). <br>
- *  <br>
- *  <b>Ports : </b> <br>
- *  <b> inport1 : </b> Input port for table 1, expects HashMap&lt;String, Object&gt; <br>
- *  <b> inport1 : </b> Input port for table 2, expects HashMap&lt;String, Object&gt; <br>
- *  <b> outport : </b> Output joined row port, emits HashMap&lt;String, ArrayList&lt;Object&gt;&gt; <br>
- *  <br>
- *  <b> Properties : </b>
- *  <b> joinCondition : </b> Join condition for table rows. <br>
- *  <b> table1Columns : </b> Columns to be selected from table1. <br>
- *  <b> table2Columns : </b> Columns to be selected from table2. <br>
- *  <br>
- * @displayName Inner join
- * @category Stream Manipulators
- * @tags sql, inner join operator
- *
- * @since 0.3.3
- */
-@OperatorAnnotation(partitionable = false)
-public class InnerJoinOperator implements Operator
-{
-
-  /**
-   * Join Condition;
-   */
-  protected Condition joinCondition;
-
-  /**
-   * Table1 select columns.
-   */
-  private ArrayList<Index> table1Columns = new ArrayList<Index>();
-
-  /**
-   * Table2 select columns.
-   */
-  private ArrayList<Index> table2Columns = new ArrayList<Index>();
-
-  /**
-   * Collect data rows from input port 1.
-   */
-  protected ArrayList<Map<String, Object>> table1;
-
-  /**
-   * Collect data from input port 2.
-   */
-  protected ArrayList<Map<String, Object>> table2;
-
-  /**
-   * Input port 1 that takes a map of &lt;string,object&gt;.
-   */
-  public final transient DefaultInputPort<Map<String, Object>> inport1 = new DefaultInputPort<Map<String, Object>>()
-  {
-    @Override
-    public void process(Map<String, Object> tuple)
-    {
-      table1.add(tuple);
-      for (int j = 0; j < table2.size(); j++) {
-        if ((joinCondition == null) || (joinCondition.isValidJoin(tuple, table2.get(j)))) {
-          joinRows(tuple, table2.get(j));
-        }
-      }
-    }
-  };
-
-  /**
-   * Input port 2 that takes a map of &lt;string,object&gt;.
-   */
-  public final transient DefaultInputPort<Map<String, Object>> inport2 = new DefaultInputPort<Map<String, Object>>()
-  {
-    @Override
-    public void process(Map<String, Object> tuple)
-    {
-      table2.add(tuple);
-      for (int j = 0; j < table1.size(); j++) {
-        if ((joinCondition == null) || (joinCondition.isValidJoin(table1.get(j), tuple))) {
-          joinRows(table1.get(j), tuple);
-        }
-      }
-    }
-  };
-
-  /**
-   * Output port that emits a map of &lt;string,object&gt;.
-   */
-  public final transient DefaultOutputPort<Map<String, Object>> outport =
-      new DefaultOutputPort<Map<String, Object>>();
-
-  @Override
-  public void setup(OperatorContext arg0)
-  {
-    table1 = new ArrayList<Map<String, Object>>();
-    table2 = new ArrayList<Map<String, Object>>();
-  }
-
-  @Override
-  public void teardown()
-  {
-  }
-
-  @Override
-  public void beginWindow(long arg0)
-  {
-  }
-
-  @Override
-  public void endWindow()
-  {
-    table1.clear();
-    table2.clear();
-  }
-
-  /**
-   * @return the joinCondition
-   */
-  public Condition getJoinCondition()
-  {
-    return joinCondition;
-  }
-
-  /**
-   * Pick the supported condition. Currently only equal join is supported.
-   * @param joinCondition joinCondition
-   */
-  public void setJoinCondition(Condition joinCondition)
-  {
-    this.joinCondition = joinCondition;
-  }
-
-  /**
-   * Select table1 column name.
-   */
-  public void selectTable1Column(Index column)
-  {
-    table1Columns.add(column);
-  }
-
-  /**
-   * Select table2 column name.
-   */
-  public void selectTable2Column(Index column)
-  {
-    table2Columns.add(column);
-  }
-
-  /**
-   * Join row from table1 and table2.
-   */
-  protected void joinRows(Map<String, Object> row1, Map<String, Object> row2)
-  {
-    // joined row
-    Map<String, Object> join = new HashMap<String, Object>();
-
-    // filter table1 columns
-    if (row1 != null) {
-      for (Index index: table1Columns) {
-        index.filter(row1, join);
-      }
-    }
-
-    // filter table1 columns
-    if (row2 != null) {
-      for (Index index: table2Columns) {
-        index.filter(row2, join);
-      }
-    }
-
-    // emit row
-    outport.emit(join);
-  }
-
-}


[12/12] apex-malhar git commit: Updated algo & working on math operators

Posted by th...@apache.org.
Updated algo & working on math operators


Project: http://git-wip-us.apache.org/repos/asf/apex-malhar/repo
Commit: http://git-wip-us.apache.org/repos/asf/apex-malhar/commit/8f00cefa
Tree: http://git-wip-us.apache.org/repos/asf/apex-malhar/tree/8f00cefa
Diff: http://git-wip-us.apache.org/repos/asf/apex-malhar/diff/8f00cefa

Branch: refs/heads/master
Commit: 8f00cefa2a14756a65e0baad48db0d52e2fe66a3
Parents: 2e47b4c
Author: Lakshmi Prasanna Velineni <la...@datatorrent.com>
Authored: Wed Aug 24 20:54:53 2016 -0700
Committer: Lakshmi Prasanna Velineni <la...@datatorrent.com>
Committed: Thu Sep 1 09:12:43 2016 -0700

----------------------------------------------------------------------
 .../datatorrent/apps/logstream/Application.java |   5 +-
 .../contrib/sqlite/SqliteStreamOperator.java    |   4 +-
 .../misc/algo/AbstractStreamPatternMatcher.java | 174 +++++++++++
 .../contrib/misc/algo/AllAfterMatchMap.java     | 120 ++++++++
 .../malhar/contrib/misc/algo/DistinctMap.java   | 113 +++++++
 .../malhar/contrib/misc/algo/FilterKeyVals.java | 163 ++++++++++
 .../contrib/misc/algo/FilterKeysHashMap.java    | 184 +++++++++++
 .../malhar/contrib/misc/algo/FilterKeysMap.java | 196 ++++++++++++
 .../malhar/contrib/misc/algo/FirstMatchMap.java | 117 +++++++
 .../apex/malhar/contrib/misc/algo/FirstN.java   | 113 +++++++
 .../contrib/misc/algo/FirstTillMatch.java       | 116 +++++++
 .../contrib/misc/algo/InsertSortDesc.java       | 136 +++++++++
 .../malhar/contrib/misc/algo/InvertIndex.java   | 146 +++++++++
 .../contrib/misc/algo/InvertIndexArray.java     | 130 ++++++++
 .../malhar/contrib/misc/algo/LastMatchMap.java  | 112 +++++++
 .../contrib/misc/algo/LeastFrequentKeyMap.java  | 149 +++++++++
 .../misc/algo/LeastFrequentKeyValueMap.java     | 107 +++++++
 .../contrib/misc/algo/MostFrequentKeyMap.java   | 142 +++++++++
 .../misc/algo/MostFrequentKeyValueMap.java      | 110 +++++++
 .../apex/malhar/contrib/misc/algo/Sampler.java  | 121 ++++++++
 .../apex/malhar/contrib/misc/math/Change.java   | 119 ++++++++
 .../malhar/contrib/misc/math/ChangeAlert.java   | 120 ++++++++
 .../contrib/misc/math/ChangeAlertKeyVal.java    | 131 ++++++++
 .../contrib/misc/math/ChangeAlertMap.java       | 125 ++++++++
 .../malhar/contrib/misc/math/ChangeKeyVal.java  | 125 ++++++++
 .../contrib/misc/math/CompareExceptMap.java     | 131 ++++++++
 .../malhar/contrib/misc/math/CompareMap.java    |  88 ++++++
 .../malhar/contrib/misc/math/CountKeyVal.java   | 116 +++++++
 .../malhar/contrib/misc/math/ExceptMap.java     | 104 +++++++
 .../apex/malhar/contrib/misc/math/Quotient.java | 111 +++++++
 .../malhar/contrib/misc/math/QuotientMap.java   | 239 +++++++++++++++
 .../malhar/contrib/misc/math/SumCountMap.java   | 305 +++++++++++++++++++
 .../streamquery/AbstractSqlStreamOperator.java  | 192 ++++++++++++
 .../misc/streamquery/DeleteOperator.java        |  88 ++++++
 .../streamquery/DerbySqlStreamOperator.java     | 200 ++++++++++++
 .../misc/streamquery/GroupByHavingOperator.java | 230 ++++++++++++++
 .../misc/streamquery/InnerJoinOperator.java     | 212 +++++++++++++
 .../misc/streamquery/OrderByOperator.java       | 181 +++++++++++
 .../contrib/misc/streamquery/OrderByRule.java   |  99 ++++++
 .../misc/streamquery/OuterJoinOperator.java     | 123 ++++++++
 .../streamquery/SelectFunctionOperator.java     | 129 ++++++++
 .../misc/streamquery/SelectOperator.java        | 113 +++++++
 .../misc/streamquery/SelectTopOperator.java     | 131 ++++++++
 .../misc/streamquery/UpdateOperator.java        | 111 +++++++
 .../streamquery/condition/BetweenCondition.java | 107 +++++++
 .../condition/CompoundCondition.java            | 132 ++++++++
 .../condition/EqualValueCondition.java          |  99 ++++++
 .../condition/HavingCompareValue.java           |  79 +++++
 .../streamquery/condition/HavingCondition.java  |  58 ++++
 .../misc/streamquery/condition/InCondition.java |  94 ++++++
 .../streamquery/condition/LikeCondition.java    | 105 +++++++
 .../streamquery/function/AverageFunction.java   |  82 +++++
 .../streamquery/function/CountFunction.java     |  87 ++++++
 .../streamquery/function/FirstLastFunction.java | 113 +++++++
 .../streamquery/function/FunctionIndex.java     |  95 ++++++
 .../streamquery/function/MaxMinFunction.java    | 105 +++++++
 .../misc/streamquery/function/SumFunction.java  |  64 ++++
 .../streamquery/index/BinaryExpression.java     |  75 +++++
 .../misc/streamquery/index/MidIndex.java        |  82 +++++
 .../streamquery/index/NegateExpression.java     |  61 ++++
 .../streamquery/index/RoundDoubleIndex.java     |  64 ++++
 .../misc/streamquery/index/StringCaseIndex.java |  66 ++++
 .../misc/streamquery/index/StringLenIndex.java  |  60 ++++
 .../misc/streamquery/index/SumExpression.java   |  65 ++++
 .../misc/streamquery/index/UnaryExpression.java |  78 +++++
 .../contrib/misc/streamquery/package-info.java  |  23 ++
 .../algo/AbstractStreamPatternMatcherTest.java  | 173 +++++++++++
 .../contrib/misc/algo/AllAfterMatchMapTest.java |  93 ++++++
 .../contrib/misc/algo/DistinctMapTest.java      | 111 +++++++
 .../contrib/misc/algo/FilterKeyValsTest.java    | 127 ++++++++
 .../misc/algo/FilterKeysHashMapTest.java        | 151 +++++++++
 .../contrib/misc/algo/FilterKeysMapTest.java    | 121 ++++++++
 .../contrib/misc/algo/FirstMatchMapTest.java    | 103 +++++++
 .../malhar/contrib/misc/algo/FirstNTest.java    | 123 ++++++++
 .../contrib/misc/algo/FirstTillMatchTest.java   | 110 +++++++
 .../contrib/misc/algo/InsertSortDescTest.java   |  97 ++++++
 .../contrib/misc/algo/InvertIndexArrayTest.java | 101 ++++++
 .../contrib/misc/algo/InvertIndexTest.java      | 104 +++++++
 .../contrib/misc/algo/LastMatchMapTest.java     | 105 +++++++
 .../misc/algo/LeastFrequentKeyMapTest.java      | 117 +++++++
 .../misc/algo/LeastFrequentKeyValueMapTest.java | 109 +++++++
 .../malhar/contrib/misc/algo/MatchMapTest.java  |  83 +++++
 .../misc/algo/MostFrequentKeyMapTest.java       | 118 +++++++
 .../misc/algo/MostFrequentKeyValueMapTest.java  | 109 +++++++
 .../malhar/contrib/misc/algo/SamplerTest.java   |  64 ++++
 .../misc/math/ChangeAlertKeyValTest.java        | 108 +++++++
 .../contrib/misc/math/ChangeAlertMapTest.java   | 116 +++++++
 .../contrib/misc/math/ChangeAlertTest.java      |  83 +++++
 .../contrib/misc/math/ChangeKeyValTest.java     | 112 +++++++
 .../malhar/contrib/misc/math/ChangeTest.java    |  85 ++++++
 .../contrib/misc/math/CompareExceptMapTest.java |  98 ++++++
 .../contrib/misc/math/CompareMapTest.java       |  83 +++++
 .../contrib/misc/math/CountKeyValTest.java      |  83 +++++
 .../malhar/contrib/misc/math/ExceptMapTest.java |  85 ++++++
 .../contrib/misc/math/QuotientMapTest.java      |  94 ++++++
 .../malhar/contrib/misc/math/QuotientTest.java  | 104 +++++++
 .../contrib/misc/math/SumCountMapTest.java      | 156 ++++++++++
 .../misc/streamquery/DeleteOperatorTest.java    |  80 +++++
 .../streamquery/FullOuterJoinOperatorTest.java  |  93 ++++++
 .../misc/streamquery/GroupByOperatorTest.java   |  97 ++++++
 .../misc/streamquery/HavingOperatorTest.java    |  99 ++++++
 .../misc/streamquery/InnerJoinOperatorTest.java |  92 ++++++
 .../streamquery/LeftOuterJoinOperatorTest.java  |  93 ++++++
 .../misc/streamquery/OrderByOperatorTest.java   |  95 ++++++
 .../streamquery/RightOuterJoinOperatorTest.java |  95 ++++++
 .../misc/streamquery/SelectOperatorTest.java    |  84 +++++
 .../misc/streamquery/SelectTopOperatorTest.java |  66 ++++
 .../misc/streamquery/UpdateOperatorTest.java    |  78 +++++
 .../advanced/BetweenConditionTest.java          |  90 ++++++
 .../advanced/CompoundConditionTest.java         |  95 ++++++
 .../streamquery/advanced/InConditionTest.java   |  93 ++++++
 .../streamquery/advanced/LikeConditionTest.java |  84 +++++
 .../streamquery/advanced/NegateIndexTest.java   |  78 +++++
 .../streamquery/advanced/SelectAverageTest.java |  78 +++++
 .../streamquery/advanced/SelectCountTest.java   |  79 +++++
 .../advanced/SelectFirstLastTest.java           |  79 +++++
 .../streamquery/advanced/SelectMaxMinTest.java  |  79 +++++
 .../misc/streamquery/advanced/SumIndexTest.java |  79 +++++
 demos/yahoofinance/pom.xml                      |  11 +
 .../yahoofinance/ApplicationWithDerbySQL.java   |   4 +-
 .../lib/algo/AbstractStreamPatternMatcher.java  | 173 -----------
 .../datatorrent/lib/algo/AllAfterMatchMap.java  | 118 -------
 .../lib/algo/CompareExceptCountMap.java         |   3 +-
 .../java/com/datatorrent/lib/algo/Distinct.java |   5 +-
 .../com/datatorrent/lib/algo/DistinctMap.java   | 111 -------
 .../com/datatorrent/lib/algo/FilterKeyVals.java | 161 ----------
 .../datatorrent/lib/algo/FilterKeysHashMap.java | 182 -----------
 .../com/datatorrent/lib/algo/FilterKeysMap.java | 194 ------------
 .../com/datatorrent/lib/algo/FilterValues.java  |  17 +-
 .../com/datatorrent/lib/algo/FirstMatchMap.java | 116 -------
 .../java/com/datatorrent/lib/algo/FirstN.java   | 112 -------
 .../datatorrent/lib/algo/FirstTillMatch.java    | 115 -------
 .../datatorrent/lib/algo/InsertSortDesc.java    | 135 --------
 .../com/datatorrent/lib/algo/InvertIndex.java   | 145 ---------
 .../datatorrent/lib/algo/InvertIndexArray.java  | 129 --------
 .../com/datatorrent/lib/algo/LastMatchMap.java  | 111 -------
 .../lib/algo/LeastFrequentKeyMap.java           | 149 ---------
 .../lib/algo/LeastFrequentKeyValueMap.java      | 106 -------
 .../com/datatorrent/lib/algo/MatchAllMap.java   |   3 +-
 .../com/datatorrent/lib/algo/MatchAnyMap.java   |   3 +-
 .../java/com/datatorrent/lib/algo/MatchMap.java |   2 +
 .../com/datatorrent/lib/algo/MergeSort.java     |   2 +
 .../datatorrent/lib/algo/MergeSortNumber.java   |   2 +
 .../lib/algo/MostFrequentKeyMap.java            | 141 ---------
 .../lib/algo/MostFrequentKeyValueMap.java       | 110 -------
 .../java/com/datatorrent/lib/algo/Sampler.java  | 119 --------
 .../com/datatorrent/lib/algo/TopNUnique.java    |   3 +-
 .../datatorrent/lib/join/AntiJoinOperator.java  |   2 +-
 .../java/com/datatorrent/lib/math/Average.java  |  29 +-
 .../java/com/datatorrent/lib/math/Change.java   | 117 -------
 .../com/datatorrent/lib/math/ChangeAlert.java   | 118 -------
 .../datatorrent/lib/math/ChangeAlertKeyVal.java | 129 --------
 .../datatorrent/lib/math/ChangeAlertMap.java    | 123 --------
 .../com/datatorrent/lib/math/ChangeKeyVal.java  | 123 --------
 .../datatorrent/lib/math/CompareExceptMap.java  | 129 --------
 .../com/datatorrent/lib/math/CompareMap.java    |  86 ------
 .../com/datatorrent/lib/math/CountKeyVal.java   | 114 -------
 .../com/datatorrent/lib/math/ExceptMap.java     | 102 -------
 .../java/com/datatorrent/lib/math/Quotient.java | 109 -------
 .../com/datatorrent/lib/math/QuotientMap.java   | 237 --------------
 .../com/datatorrent/lib/math/SumCountMap.java   | 303 ------------------
 .../streamquery/AbstractSqlStreamOperator.java  | 190 ------------
 .../lib/streamquery/DeleteOperator.java         |  86 ------
 .../lib/streamquery/DerbySqlStreamOperator.java | 197 ------------
 .../lib/streamquery/GroupByHavingOperator.java  | 260 ----------------
 .../lib/streamquery/InnerJoinOperator.java      | 210 -------------
 .../lib/streamquery/OrderByOperator.java        | 179 -----------
 .../lib/streamquery/OrderByRule.java            |  97 ------
 .../lib/streamquery/OuterJoinOperator.java      | 121 --------
 .../lib/streamquery/SelectFunctionOperator.java | 126 --------
 .../lib/streamquery/SelectOperator.java         | 111 -------
 .../lib/streamquery/SelectTopOperator.java      | 129 --------
 .../lib/streamquery/UpdateOperator.java         | 109 -------
 .../streamquery/condition/BetweenCondition.java | 103 -------
 .../condition/CompoundCondition.java            | 128 --------
 .../condition/EqualValueCondition.java          |  96 ------
 .../condition/HavingCompareValue.java           |  77 -----
 .../streamquery/condition/HavingCondition.java  |  56 ----
 .../lib/streamquery/condition/InCondition.java  |  90 ------
 .../condition/JoinColumnEqualCondition.java     |   1 -
 .../streamquery/condition/LikeCondition.java    | 102 -------
 .../streamquery/function/AverageFunction.java   |  80 -----
 .../lib/streamquery/function/CountFunction.java |  85 ------
 .../streamquery/function/FirstLastFunction.java | 111 -------
 .../lib/streamquery/function/FunctionIndex.java |  93 ------
 .../streamquery/function/MaxMinFunction.java    | 103 -------
 .../lib/streamquery/function/SumFunction.java   |  62 ----
 .../lib/streamquery/index/BinaryExpression.java |  72 -----
 .../lib/streamquery/index/MidIndex.java         |  78 -----
 .../lib/streamquery/index/NegateExpression.java |  59 ----
 .../lib/streamquery/index/RoundDoubleIndex.java |  60 ----
 .../lib/streamquery/index/StringCaseIndex.java  |  62 ----
 .../lib/streamquery/index/StringLenIndex.java   |  56 ----
 .../lib/streamquery/index/SumExpression.java    |  63 ----
 .../lib/streamquery/index/UnaryExpression.java  |  75 -----
 .../lib/streamquery/package-info.java           |  23 --
 .../algo/AbstractStreamPatternMatcherTest.java  | 173 -----------
 .../lib/algo/AllAfterMatchMapTest.java          |  92 ------
 .../lib/algo/CompareExceptCountMapTest.java     |   6 +-
 .../datatorrent/lib/algo/DistinctMapTest.java   | 110 -------
 .../datatorrent/lib/algo/FilterKeyValsTest.java | 126 --------
 .../lib/algo/FilterKeysHashMapTest.java         | 150 ---------
 .../datatorrent/lib/algo/FilterKeysMapTest.java | 120 --------
 .../datatorrent/lib/algo/FirstMatchMapTest.java | 102 -------
 .../com/datatorrent/lib/algo/FirstNTest.java    | 122 --------
 .../lib/algo/FirstTillMatchTest.java            | 109 -------
 .../lib/algo/InsertSortDescTest.java            |  96 ------
 .../lib/algo/InvertIndexArrayTest.java          | 100 ------
 .../datatorrent/lib/algo/InvertIndexTest.java   | 103 -------
 .../datatorrent/lib/algo/LastMatchMapTest.java  | 104 -------
 .../lib/algo/LeastFrequentKeyMapTest.java       | 116 -------
 .../lib/algo/LeastFrequentKeyValueMapTest.java  | 108 -------
 .../datatorrent/lib/algo/MatchAllMapTest.java   |   5 +-
 .../datatorrent/lib/algo/MatchAnyMapTest.java   |   6 +-
 .../com/datatorrent/lib/algo/MatchMapTest.java  |  81 -----
 .../lib/algo/MergeSortNumberTest.java           |   4 +-
 .../lib/algo/MostFrequentKeyMapTest.java        | 117 -------
 .../lib/algo/MostFrequentKeyValueMapTest.java   | 108 -------
 .../com/datatorrent/lib/algo/SamplerTest.java   |  63 ----
 .../datatorrent/lib/algo/TopNUniqueTest.java    |   5 +-
 .../lib/join/AntiJoinOperatorTest.java          |   1 +
 .../com/datatorrent/lib/math/AverageTest.java   |   4 +-
 .../lib/math/ChangeAlertKeyValTest.java         | 107 -------
 .../lib/math/ChangeAlertMapTest.java            | 115 -------
 .../datatorrent/lib/math/ChangeAlertTest.java   |  82 -----
 .../datatorrent/lib/math/ChangeKeyValTest.java  | 111 -------
 .../com/datatorrent/lib/math/ChangeTest.java    |  84 -----
 .../lib/math/CompareExceptMapTest.java          |  97 ------
 .../datatorrent/lib/math/CompareMapTest.java    |  82 -----
 .../datatorrent/lib/math/CountKeyValTest.java   |  82 -----
 .../com/datatorrent/lib/math/DivisionTest.java  |   1 +
 .../com/datatorrent/lib/math/ExceptMapTest.java |  83 -----
 .../lib/math/MultiplyByConstantTest.java        |   2 +
 .../datatorrent/lib/math/QuotientMapTest.java   |  92 ------
 .../com/datatorrent/lib/math/QuotientTest.java  | 102 -------
 .../com/datatorrent/lib/math/SigmaTest.java     |   3 +-
 .../datatorrent/lib/math/SumCountMapTest.java   | 154 ----------
 .../lib/streamquery/DeleteOperatorTest.java     |  77 -----
 .../streamquery/FullOuterJoinOperatorTest.java  |  93 ------
 .../lib/streamquery/GroupByOperatorTest.java    |  94 ------
 .../lib/streamquery/HavingOperatorTest.java     |  96 ------
 .../lib/streamquery/InnerJoinOperatorTest.java  |  91 ------
 .../streamquery/LeftOuterJoinOperatorTest.java  |  92 ------
 .../lib/streamquery/OrderByOperatorTest.java    |  93 ------
 .../streamquery/RightOuterJoinOperatorTest.java |  94 ------
 .../lib/streamquery/SelectOperatorTest.java     |  81 -----
 .../lib/streamquery/SelectTopOperatorTest.java  |  65 ----
 .../lib/streamquery/UpdateOperatorTest.java     |  76 -----
 .../advanced/BetweenConditionTest.java          |  87 ------
 .../advanced/CompoundConditionTest.java         |  92 ------
 .../streamquery/advanced/InConditionTest.java   |  90 ------
 .../streamquery/advanced/LikeConditionTest.java |  81 -----
 .../streamquery/advanced/NegateIndexTest.java   |  75 -----
 .../streamquery/advanced/SelectAverageTest.java |  75 -----
 .../streamquery/advanced/SelectCountTest.java   |  76 -----
 .../advanced/SelectFirstLastTest.java           |  76 -----
 .../streamquery/advanced/SelectMaxMinTest.java  |  76 -----
 .../lib/streamquery/advanced/SumIndexTest.java  |  76 -----
 samples/pom.xml                                 |   4 +-
 .../lib/algo/AllAfterMatchMapSample.java        |   4 +-
 .../samples/lib/math/ChangeSample.java          |   4 +-
 .../samples/lib/math/CompreMapSample.java       |   4 +-
 .../samples/lib/math/CountKeyValSample.java     |   4 +-
 263 files changed, 12997 insertions(+), 12767 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/apps/logstream/src/main/java/com/datatorrent/apps/logstream/Application.java
----------------------------------------------------------------------
diff --git a/apps/logstream/src/main/java/com/datatorrent/apps/logstream/Application.java b/apps/logstream/src/main/java/com/datatorrent/apps/logstream/Application.java
index 0cd3f79..98dfebd 100644
--- a/apps/logstream/src/main/java/com/datatorrent/apps/logstream/Application.java
+++ b/apps/logstream/src/main/java/com/datatorrent/apps/logstream/Application.java
@@ -25,6 +25,9 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
+import org.apache.apex.malhar.contrib.misc.streamquery.SelectOperator;
+import org.apache.apex.malhar.contrib.misc.streamquery.condition.EqualValueCondition;
+
 import org.apache.commons.lang.StringUtils;
 import org.apache.hadoop.conf.Configuration;
 
@@ -36,8 +39,6 @@ import com.datatorrent.lib.logs.MultiWindowDimensionAggregation;
 import com.datatorrent.lib.logs.MultiWindowDimensionAggregation.AggregateOperation;
 import com.datatorrent.lib.stream.Counter;
 import com.datatorrent.lib.stream.JsonByteArrayOperator;
-import com.datatorrent.lib.streamquery.SelectOperator;
-import com.datatorrent.lib.streamquery.condition.EqualValueCondition;
 import com.datatorrent.lib.streamquery.index.ColumnIndex;
 import com.datatorrent.lib.util.AbstractDimensionTimeBucketOperator;
 import com.datatorrent.lib.util.DimensionTimeBucketSumOperator;

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/com/datatorrent/contrib/sqlite/SqliteStreamOperator.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/com/datatorrent/contrib/sqlite/SqliteStreamOperator.java b/contrib/src/main/java/com/datatorrent/contrib/sqlite/SqliteStreamOperator.java
index ee06272..2cb33e4 100644
--- a/contrib/src/main/java/com/datatorrent/contrib/sqlite/SqliteStreamOperator.java
+++ b/contrib/src/main/java/com/datatorrent/contrib/sqlite/SqliteStreamOperator.java
@@ -21,8 +21,8 @@ package com.datatorrent.contrib.sqlite;
 import com.almworks.sqlite4java.SQLiteConnection;
 import com.almworks.sqlite4java.SQLiteException;
 import com.almworks.sqlite4java.SQLiteStatement;
-import com.datatorrent.lib.streamquery.AbstractSqlStreamOperator;
-import com.datatorrent.lib.streamquery.AbstractSqlStreamOperator.InputSchema.ColumnInfo;
+import org.apache.apex.malhar.contrib.misc.streamquery.AbstractSqlStreamOperator;
+import org.apache.apex.malhar.contrib.misc.streamquery.AbstractSqlStreamOperator.InputSchema.ColumnInfo;
 import com.datatorrent.api.Context.OperatorContext;
 import java.io.File;
 import java.util.ArrayList;

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/AbstractStreamPatternMatcher.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/AbstractStreamPatternMatcher.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/AbstractStreamPatternMatcher.java
new file mode 100644
index 0000000..38b176c
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/AbstractStreamPatternMatcher.java
@@ -0,0 +1,174 @@
+/**
+ * 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.contrib.misc.algo;
+
+import java.util.Iterator;
+import java.util.List;
+
+import javax.validation.constraints.NotNull;
+
+import org.apache.commons.lang3.mutable.MutableInt;
+
+import com.google.common.collect.Lists;
+
+import com.datatorrent.api.Context;
+import com.datatorrent.api.DefaultInputPort;
+import com.datatorrent.api.annotation.OperatorAnnotation;
+import com.datatorrent.common.util.BaseOperator;
+@Deprecated
+/**
+ * <p>
+ * This operator searches for a given pattern in the input stream.<br>
+ * For e.g. If the pattern is defined as \u201caa\u201d and your input events arrive in following manner \u201ca\u201d, \u201ca\u201d, \u201ca\u201d, then this operator
+ * will emit 2 matches for the given pattern. One matching event 1 and 2 and other matching 2 and 3.
+ * </p>
+ *
+ * <br>
+ * <b> StateFull : Yes, </b> Pattern is found over application window(s). <br>
+ * <b> Partitionable : No, </b> will yield wrong result. <br>
+ *
+ * <br>
+ * <b>Ports</b>:<br>
+ * <b>inputPort</b>: the port to receive input<br>
+ *
+ * <br>
+ * <b>Properties</b>:<br>
+ * <b>pattern</b>: The pattern that needs to be searched<br>
+ *
+ * @param <T> event type
+ *
+ * @since 2.0.0
+ * @deprecated
+ */
+
+@OperatorAnnotation(partitionable = false)
+public abstract class AbstractStreamPatternMatcher<T> extends BaseOperator
+{
+  /**
+   * The pattern to be searched in the input stream of events
+   */
+  @NotNull
+  private Pattern<T> pattern;
+
+  // this stores the index of the partial matches found so far
+  private List<MutableInt> partialMatches = Lists.newLinkedList();
+  private transient MutableInt patternLength;
+
+  /**
+   * Set the pattern that needs to be searched in the input stream of events
+   *
+   * @param pattern The pattern to be searched
+   */
+  public void setPattern(Pattern<T> pattern)
+  {
+    this.pattern = pattern;
+    partialMatches.clear();
+    patternLength = new MutableInt(pattern.getStates().length - 1);
+  }
+
+  @Override
+  public void setup(Context.OperatorContext context)
+  {
+    super.setup(context);
+    patternLength = new MutableInt(pattern.getStates().length - 1);
+  }
+
+  /**
+   * Get the pattern that is searched in the input stream of events
+   *
+   * @return Returns the pattern searched
+   */
+  public Pattern<T> getPattern()
+  {
+    return pattern;
+  }
+
+  public transient DefaultInputPort<T> inputPort = new DefaultInputPort<T>()
+  {
+    @Override
+    public void process(T t)
+    {
+      if (pattern.checkState(t, 0)) {
+        partialMatches.add(new MutableInt(-1));
+      }
+      if (partialMatches.size() > 0) {
+        MutableInt tempInt;
+        Iterator<MutableInt> itr = partialMatches.iterator();
+        while (itr.hasNext()) {
+          tempInt = itr.next();
+          tempInt.increment();
+          if (!pattern.checkState(t, tempInt.intValue())) {
+            itr.remove();
+          } else if (tempInt.equals(patternLength)) {
+            itr.remove();
+            processPatternFound();
+          }
+        }
+      }
+    }
+  };
+
+  /**
+   * This function determines how to process the pattern found
+   */
+  public abstract void processPatternFound();
+
+  public static class Pattern<T>
+  {
+    /**
+     * The states of the pattern
+     */
+    @NotNull
+    private final T[] states;
+
+    //for kryo
+    private Pattern()
+    {
+      states = null;
+    }
+
+    public Pattern(@NotNull T[] states)
+    {
+      this.states = states;
+    }
+
+    /**
+     * Checks if the input state matches the state at index "index" of the pattern
+     *
+     * @param t     The input state
+     * @param index The index to match in the pattern
+     * @return True if the state exists at index "index" else false
+     */
+    public boolean checkState(T t, int index)
+    {
+      return states[index].equals(t);
+    }
+
+    /**
+     * Get the states of the pattern
+     *
+     * @return The states of the pattern
+     */
+    public T[] getStates()
+    {
+      return states;
+    }
+
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/AllAfterMatchMap.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/AllAfterMatchMap.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/AllAfterMatchMap.java
new file mode 100644
index 0000000..44118d5
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/AllAfterMatchMap.java
@@ -0,0 +1,120 @@
+/**
+ * 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.contrib.misc.algo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.datatorrent.api.DefaultInputPort;
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.api.annotation.OperatorAnnotation;
+
+import com.datatorrent.lib.util.BaseMatchOperator;
+
+/**
+ * This operator takes Maps, whose values are numbers, as input tuples.&nbsp;
+ * It then performs a numeric comparison on the values corresponding to one of the keys in the input tuple maps.&nbsp;
+ * All tuples processed by the operator before the first successful comparison are not output by the operator,
+ * all tuples processed by the operator after and including a successful comparison are output by the operator.
+ *
+ * <p>
+ * A compare metric is done on input tuple based on the property "key",
+ * "value", and "cmp" type. All tuples are emitted (inclusive) once a match is made.
+ * The comparison is done by getting double value from the Number.
+ * This module is a pass through<br>
+ * <br>
+ * <b> StateFull : Yes, </b> Count is aggregated over application window(s). <br>
+ * <b> Partitions : No, </b> will yield wrong result. <br>
+ * <br>
+ * <br>
+ * <b>Ports</b>:<br>
+ * <b>data</b>: expects Map&lt;K,V extends Number&gt;<br>
+ * <b>allafter</b>: emits Map&lt;K,V extends Number&gt; if compare function
+ * returns true<br>
+ * <br>
+ * <b>Properties</b>:<br>
+ * <b>key</b>: The key on which compare is done<br>
+ * <b>value</b>: The value to compare with<br>
+ * <b>cmp</b>: The compare function. Supported values are "lte", "lt", "eq",
+ * "neq", "gt", "gte". Default is "eq"<br>
+ * <br>
+ * <b>Specific compile time checks</b>:<br>
+ * Key must be non empty<br>
+ * Value must be able to convert to a "double"<br>
+ * Compare string, if specified, must be one of "lte", "lt", "eq", "neq", "gt",
+ * "gte"<br>
+ * <b>Specific run time checks</b>: None<br>
+ * <br>
+ * </p>
+ *
+ * @displayName Emit All After Match (Number)
+ * @category Rules and Alerts
+ * @tags filter, compare, numeric, key value
+ *
+ * @since 0.3.2
+ * @deprecated
+ */
+@Deprecated
+@OperatorAnnotation(partitionable = false)
+public class AllAfterMatchMap<K, V extends Number> extends
+    BaseMatchOperator<K, V>
+{
+  /**
+   * The input port on which tuples are received.
+   */
+  public final transient DefaultInputPort<Map<K, V>> data = new DefaultInputPort<Map<K, V>>()
+  {
+    /**
+     * Process HashMap<K,V> and emit all tuples at and after match
+     */
+    @Override
+    public void process(Map<K, V> tuple)
+    {
+      if (doemit) {
+        allafter.emit(cloneTuple(tuple));
+        return;
+      }
+      V v = tuple.get(getKey());
+      if (v == null) { // error tuple
+        return;
+      }
+      if (compareValue(v.doubleValue())) {
+        doemit = true;
+        allafter.emit(cloneTuple(tuple));
+      }
+    }
+  };
+
+  /**
+   * The output port on which all tuples after a match are emitted.
+   */
+  public final transient DefaultOutputPort<HashMap<K, V>> allafter = new DefaultOutputPort<HashMap<K, V>>();
+  boolean doemit = false;
+
+  /**
+   * Resets the matched variable
+   *
+   * @param windowId
+   */
+  @Override
+  public void beginWindow(long windowId)
+  {
+    doemit = false;
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/DistinctMap.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/DistinctMap.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/DistinctMap.java
new file mode 100644
index 0000000..426c2e5
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/DistinctMap.java
@@ -0,0 +1,113 @@
+/**
+ * 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.contrib.misc.algo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.datatorrent.api.DefaultInputPort;
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.api.annotation.OperatorAnnotation;
+
+import com.datatorrent.lib.util.BaseKeyValueOperator;
+import com.datatorrent.lib.util.UnifierHashMap;
+
+/**
+ * This operator computes and emits distinct key,val pairs (i.e drops duplicates).
+ * <p>
+ * Computes and emits distinct key,val pairs (i.e drops duplicates)
+ * </p>
+ * <p>
+ * This is a pass through operator<br>
+ * <br>
+ * This module is same as a "FirstOf" metric on any key,val pair. At end of window all data is flushed.<br>
+ * <br>
+ * <b>StateFull : Yes, </b> tuple are compare across application window(s). <br>
+ * <b>Partitions : Yes, </b> distinct output is unified by unifier hash map operator. <br>
+ * <br>
+ * <b>Ports</b>:<br>
+ * <b>data</b>: Input data port expects Map&lt;K,V&gt;<br>
+ * <b>distinct</b>: Output data port, emits HashMap&lt;K,V&gt;(1)<br>
+ * <br>
+ * </p>
+ *
+ * @displayName Distinct Key Value Merge
+ * @category Stream Manipulators
+ * @tags filter, unique, key value
+ *
+ * @since 0.3.2
+ * @deprecated
+ */
+
+@Deprecated
+@OperatorAnnotation(partitionable = true)
+public class DistinctMap<K, V> extends BaseKeyValueOperator<K, V>
+{
+  /**
+   * The input port on which key value pairs are received.
+   */
+  public final transient DefaultInputPort<Map<K, V>> data = new DefaultInputPort<Map<K, V>>()
+  {
+    /**
+     * Process HashMap<K,V> tuple on input port data, and emits if match not found. Updates the cache
+     * with new key,val pair
+     */
+    @Override
+    public void process(Map<K, V> tuple)
+    {
+      for (Map.Entry<K, V> e: tuple.entrySet()) {
+        HashMap<V, Object> vals = mapkeyval.get(e.getKey());
+        if ((vals == null) || !vals.containsKey(e.getValue())) {
+          HashMap<K, V> otuple = new HashMap<K, V>(1);
+          otuple.put(cloneKey(e.getKey()), cloneValue(e.getValue()));
+          distinct.emit(otuple);
+          if (vals == null) {
+            vals = new HashMap<V, Object>();
+            mapkeyval.put(cloneKey(e.getKey()), vals);
+          }
+          vals.put(cloneValue(e.getValue()), null);
+        }
+      }
+    }
+  };
+
+  /**
+   * The output port on which distinct key value pairs are emitted.
+   */
+  public final transient DefaultOutputPort<HashMap<K, V>> distinct = new DefaultOutputPort<HashMap<K, V>>()
+  {
+    @Override
+    public Unifier<HashMap<K, V>> getUnifier()
+    {
+      return new UnifierHashMap<K, V>();
+    }
+  };
+
+
+  protected HashMap<K, HashMap<V, Object>> mapkeyval = new HashMap<K, HashMap<V, Object>>();
+
+  /**
+   * Clears the cache/hash
+   */
+  @Override
+  public void endWindow()
+  {
+    mapkeyval.clear();
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/FilterKeyVals.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/FilterKeyVals.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/FilterKeyVals.java
new file mode 100644
index 0000000..9925d69
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/FilterKeyVals.java
@@ -0,0 +1,163 @@
+/**
+ * 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.contrib.misc.algo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.validation.constraints.NotNull;
+
+import com.datatorrent.api.DefaultInputPort;
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.api.annotation.OperatorAnnotation;
+import com.datatorrent.api.annotation.Stateless;
+
+import com.datatorrent.lib.util.BaseKeyOperator;
+
+/**
+ * This operator filters the incoming stream of tuples using a set of specified key value pairs.&nbsp;
+ * Tuples that match the filter are emitted by the operator.
+ * <p>
+ * Filters the incoming stream based of specified key,val pairs, and emits those that match the filter. If
+ * property "inverse" is set to "true", then all key,val pairs except those specified by in keyvals parameter are emitted
+ * </p>
+ * <p>
+ * Operator assumes that the key, val pairs are immutable objects. If this operator has to be used for mutable objects,
+ * override "cloneKey()" to make copy of K, and "cloneValue()" to make copy of V.<br>
+ * This is a pass through node<br>
+ * <br>
+ * <b>StateFull : No, </b> tuple are processed in current window. <br>
+ * <b>Partitions : Yes, </b> no dependency among input tuples. <br>
+ * <br>
+ * <b>Ports</b>:<br>
+ * <b>data</b>: expects HashMap&lt;K,V&gt;<br>
+ * <b>filter</b>: emits HashMap&lt;K,V&gt;(1)<br>
+ * <br>
+ * <b>Properties</b>:<br>
+ * <b>keyvals</b>: The keyvals is key,val pairs to pass through, rest are filtered/dropped.<br>
+ * <br>
+ * </p>
+ *
+ * @displayName Filter Keyval Pairs
+ * @category Rules and Alerts
+ * @tags filter, key value
+ *
+ * @since 0.3.2
+ * @deprecated
+ */
+@Deprecated
+@Stateless
+@OperatorAnnotation(partitionable = true)
+public class FilterKeyVals<K,V> extends BaseKeyOperator<K>
+{
+  /**
+   * The input port on which key value pairs are received.
+   */
+  public final transient DefaultInputPort<HashMap<K, V>> data = new DefaultInputPort<HashMap<K, V>>()
+  {
+    /**
+     * Processes incoming tuples one key,val at a time. Emits if at least one key makes the cut
+     * By setting inverse as true, match is changed to un-matched
+     */
+    @Override
+    public void process(HashMap<K, V> tuple)
+    {
+      for (Map.Entry<K, V> e: tuple.entrySet()) {
+        entry.clear();
+        entry.put(e.getKey(),e.getValue());
+        boolean contains = keyvals.containsKey(entry);
+        if ((contains && !inverse) || (!contains && inverse)) {
+          HashMap<K, V> dtuple = new HashMap<K,V>(1);
+          dtuple.put(cloneKey(e.getKey()), cloneValue(e.getValue()));
+          filter.emit(dtuple);
+        }
+      }
+    }
+  };
+
+  /**
+   * The output port on which filtered key value pairs are emitted.
+   */
+  public final transient DefaultOutputPort<HashMap<K, V>> filter = new DefaultOutputPort<HashMap<K, V>>();
+
+  @NotNull()
+  HashMap<HashMap<K,V>,Object> keyvals = new HashMap<HashMap<K,V>,Object>();
+  boolean inverse = false;
+  private transient HashMap<K,V> entry = new HashMap<K,V>(1);
+
+  /**
+   * Gets the inverse property.
+   * @return inverse
+   */
+  public boolean getInverse()
+  {
+    return inverse;
+  }
+
+  /**
+   * If true then only matches are emitted. If false then only non matches are emitted.
+   * @param val
+   */
+  public void setInverse(boolean val)
+  {
+    inverse = val;
+  }
+
+  /**
+   * True means match; False means unmatched
+   * @return keyvals hash
+   */
+  @NotNull()
+  public HashMap<HashMap<K,V>,Object> getKeyVals()
+  {
+    return keyvals;
+  }
+
+  /**
+   * Adds a key to the filter list
+   * @param map with key,val pairs to set as filters
+   */
+  @SuppressWarnings({ "unchecked", "rawtypes" })
+  public void setKeyVals(HashMap<K,V> map)
+  {
+    for (Map.Entry<K, V> e: map.entrySet()) {
+      HashMap kvpair = new HashMap<K,V>(1);
+      kvpair.put(cloneKey(e.getKey()), cloneValue(e.getValue()));
+      keyvals.put(kvpair, null);
+    }
+  }
+
+  /*
+   * Clears the filter list
+   */
+  public void clearKeys()
+  {
+    keyvals.clear();
+  }
+
+  /**
+   * Clones V object. By default assumes immutable object (i.e. a copy is not made). If object is mutable, override this method
+   * @param v value to be cloned
+   * @return returns v as is (assumes immutable object)
+   */
+  public V cloneValue(V v)
+  {
+    return v;
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/FilterKeysHashMap.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/FilterKeysHashMap.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/FilterKeysHashMap.java
new file mode 100644
index 0000000..cfee74c
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/FilterKeysHashMap.java
@@ -0,0 +1,184 @@
+/**
+ * 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.contrib.misc.algo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.validation.constraints.NotNull;
+
+import com.datatorrent.api.DefaultInputPort;
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.api.annotation.OperatorAnnotation;
+import com.datatorrent.api.annotation.Stateless;
+
+import com.datatorrent.lib.util.BaseKeyOperator;
+
+
+/**
+ * This operator filters the incoming stream of key value pairs based on the keys specified by property "keys".
+ * <p>
+ * Filters the incoming stream based of keys specified by property "keys". If
+ * property "inverse" is set to "true", then all keys except those specified by "keys" are emitted
+ * </p>
+ * <p>
+ * Operator assumes that the key, val pairs are immutable objects. If this operator has to be used for mutable objects,
+ * override "cloneKey()" to make copy of K, and "cloneValue()" to make copy of V.<br>
+ * This is a pass through node.<br>
+ * <br>
+ * <b>StateFull : No, </b> tuple are processed in current window. <br>
+ * <b>Partitions : Yes, </b> no dependency among input tuples. <br>
+ * <br>
+ * <b>Ports</b>:<br>
+ * <b>data</b>: Expects Map&lt;K, HashMap&lt;K,V&gt;&gt. Filters are applied only on keys of second hash map.<br>
+ * <b>filter</b>: Emits HashMap&lt;K, HashMap&lt;K,V&gt;&gt.<br>
+ * <br>
+ * <b>Properties</b>:<br>
+ * <b>keys</b>: The keys to pass through, rest are filtered/dropped. A comma separated list of keys.<br>
+ * <br>
+ * </p>
+ *
+ * @displayName Filter Keyval Pairs By Key HashMap
+ * @category Stream Manipulators
+ * @tags filter, key value
+ *
+ * @since 0.3.2
+ * @deprecated
+ */
+@Deprecated
+@Stateless
+@OperatorAnnotation(partitionable = true)
+public class FilterKeysHashMap<K, V> extends BaseKeyOperator<K>
+{
+  /**
+   * Filter keys map.
+   */
+  @NotNull()
+  HashMap<K, V> keys = new HashMap<K, V>();
+
+  /**
+   * Emits key not in filter map.
+   */
+  boolean inverse = false;
+
+  /**
+   * The input port on which key value pairs are received.
+   */
+  public final transient DefaultInputPort<Map<K, HashMap<K, V>>> data = new DefaultInputPort<Map<K, HashMap<K, V>>>()
+  {
+    /**
+     * Processes incoming tuples one key,val at a time. Emits if at least one key makes the cut.
+     * By setting inverse as true, match is changed to un-matched.
+     */
+    @Override
+    public void process(Map<K, HashMap<K, V>> tuple)
+    {
+      HashMap<K, HashMap<K, V>> dtuple = null;
+      for (Map.Entry<K, HashMap<K, V>> e: tuple.entrySet()) {
+        HashMap<K, V> dtuple2 = null;
+        for (Map.Entry<K, V> e2: e.getValue().entrySet()) {
+          boolean contains = keys.containsKey(e2.getKey());
+          if ((contains && !inverse) || (!contains && inverse)) {
+            if (dtuple2 == null) {
+              dtuple2 = new HashMap<K, V>(4); // usually the filter keys are very few, so 4 is just fine
+            }
+            dtuple2.put(cloneKey(e2.getKey()), cloneValue(e2.getValue()));
+          }
+        }
+        if (dtuple == null && dtuple2 != null) {
+          dtuple = new HashMap<K, HashMap<K, V>>();
+        }
+        if (dtuple != null && dtuple2 != null) {
+          dtuple.put(cloneKey(e.getKey()), dtuple2);
+        }
+      }
+      if (dtuple != null) {
+        filter.emit(dtuple);
+      }
+    }
+  };
+
+  /**
+   * The output port on which filtered key value pairs are emitted.
+   */
+  public final transient DefaultOutputPort<HashMap<K, HashMap<K, V>>> filter = new DefaultOutputPort<HashMap<K, HashMap<K, V>>>();
+
+  /**
+   * getter function for parameter inverse
+   *
+   * @return inverse
+   */
+  public boolean getInverse()
+  {
+    return inverse;
+  }
+
+  /**
+   * True means match; False means unmatched
+   *
+   * @param val
+   */
+  public void setInverse(boolean val)
+  {
+    inverse = val;
+  }
+
+  /**
+   * Adds a key to the filter list
+   *
+   * @param str
+   */
+  public void setKey(K str)
+  {
+    keys.put(str, null);
+  }
+
+  /**
+   * Adds the list of keys to the filter list
+   *
+   * @param list
+   */
+  public void setKeys(K[] list)
+  {
+    if (list != null) {
+      for (K e: list) {
+        keys.put(e, null);
+      }
+    }
+  }
+
+  /*
+   * Clears the filter list
+   */
+  public void clearKeys()
+  {
+    keys.clear();
+  }
+
+  /**
+   * Clones V object. By default assumes immutable object (i.e. a copy is not made). If object is mutable, override this method
+   *
+   * @param v value to be cloned
+   * @return returns v as is (assumes immutable object)
+   */
+  public V cloneValue(V v)
+  {
+    return v;
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/FilterKeysMap.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/FilterKeysMap.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/FilterKeysMap.java
new file mode 100644
index 0000000..43386f0
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/FilterKeysMap.java
@@ -0,0 +1,196 @@
+/**
+ * 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.contrib.misc.algo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.validation.constraints.NotNull;
+
+import com.datatorrent.api.DefaultInputPort;
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.api.annotation.OperatorAnnotation;
+import com.datatorrent.api.annotation.Stateless;
+
+import com.datatorrent.lib.util.BaseKeyOperator;
+import com.datatorrent.lib.util.UnifierHashMap;
+
+/**
+ * This operator filters the incoming stream of key value pairs based on the keys specified by property "keys"..
+ * <p>
+ * Filters the incoming stream based of keys specified by property "keys". If
+ * property "inverse" is set to "true", then all keys except those specified by "keys" are emitted
+ * </p>
+ * <p>
+ * Operator assumes that the key, val pairs are immutable objects. If this operator has to be used for mutable objects,
+ * override "cloneKey()" to make copy of K, and "cloneValue()" to make copy of V.<br>
+ * This is a pass through node<br>
+ * <br>
+ * <b>StateFull : No, </b> tuple are processed in current window. <br>
+ * <b>Partitions : Yes, </b> no dependency among input tuples. <br>
+ * <br>
+ * <b>Ports</b>:<br>
+ * <b>data</b>: Expects Map&lt;K,V&gt;<br>
+ * <b>filter</b>: Emits HashMap&lt;K,V&gt;<br>
+ * <br>
+ * <b>Properties</b>:<br>
+ * <b>keys</b>: The keys to pass through, rest are filtered/dropped. A comma separated list of keys<br>
+ * <br>
+ * </p>
+ *
+ * @displayName Filter Keyval Pairs By Key Generic
+ * @category Rules and Alerts
+ * @tags filter, key value
+ *
+ * @since 0.3.2
+ * @deprecated
+ */
+@Deprecated
+@Stateless
+@OperatorAnnotation(partitionable = true)
+public class FilterKeysMap<K,V> extends BaseKeyOperator<K>
+{
+  /**
+   * Filter keys map.
+   */
+  @NotNull()
+  HashMap<K, V> keys = new HashMap<K, V>();
+
+  /**
+   * Emits key not in filter map.
+   */
+  boolean inverse = false;
+
+  /**
+   * The input port on which key value pairs are received.
+   */
+  public final transient DefaultInputPort<Map<K, V>> data = new DefaultInputPort<Map<K, V>>()
+  {
+    /**
+     * Processes incoming tuples one key,val at a time. Emits if at least one key makes the cut
+     * By setting inverse as true, match is changed to un-matched
+     */
+    @Override
+    public void process(Map<K, V> tuple)
+    {
+      HashMap<K, V> dtuple = null;
+      for (Map.Entry<K, V> e: tuple.entrySet()) {
+        boolean contains = keys.containsKey(e.getKey());
+        if ((contains && !inverse) || (!contains && inverse)) {
+          if (dtuple == null) {
+            dtuple = new HashMap<K, V>(4); // usually the filter keys are very few, so 4 is just fine
+          }
+          dtuple.put(cloneKey(e.getKey()), cloneValue(e.getValue()));
+        }
+      }
+      if (dtuple != null) {
+        filter.emit(dtuple);
+      }
+    }
+  };
+
+  /**
+   * The output port on which filtered key value pairs are emitted.
+   */
+  public final transient DefaultOutputPort<HashMap<K, V>> filter = new DefaultOutputPort<HashMap<K, V>>()
+  {
+    @Override
+    public Unifier<HashMap<K, V>> getUnifier()
+    {
+      return new UnifierHashMap<K, V>();
+    }
+  };
+
+  /**
+   * If true then only matches are emitted. If false then only non matches are emitted.
+   * @return inverse
+   */
+  public boolean getInverse()
+  {
+    return inverse;
+  }
+
+
+  /**
+   * Sets the inverse property. If true then only matches are emitted. If false then only non matches are emitted.
+   * @param val
+   */
+  public void setInverse(boolean val)
+  {
+    inverse = val;
+  }
+
+  /**
+   * Adds a key to the filter list
+   * @param str
+   */
+  public void setKey(K str)
+  {
+    keys.put(str, null);
+  }
+
+  /**
+   * Adds the list of keys to the filter list
+   * @param list
+   */
+  public void setKeys(K[] list)
+  {
+    if (list != null) {
+      for (K e: list) {
+        keys.put(e, null);
+      }
+    }
+  }
+
+  /**
+   * The keys to filter. The values in the map should be null.
+   * @param keys
+   */
+  public void setKeys(HashMap<K, V> keys)
+  {
+    this.keys = keys;
+  }
+
+  /**
+   * Gets the keys to filter.
+   * @return Returns a map containing the keys.
+   */
+  public HashMap<K, V> getKeys()
+  {
+    return keys;
+  }
+
+  /*
+   * Clears the filter list
+   */
+  public void clearKeys()
+  {
+    keys.clear();
+  }
+
+  /**
+   * Clones V object. By default assumes immutable object (i.e. a copy is not made). If object is mutable, override this method
+   * @param v value to be cloned
+   * @return returns v as is (assumes immutable object)
+   */
+  public V cloneValue(V v)
+  {
+    return v;
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/FirstMatchMap.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/FirstMatchMap.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/FirstMatchMap.java
new file mode 100644
index 0000000..7649706
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/FirstMatchMap.java
@@ -0,0 +1,117 @@
+/**
+ * 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.contrib.misc.algo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.datatorrent.api.DefaultInputPort;
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.api.annotation.OperatorAnnotation;
+
+import com.datatorrent.lib.util.BaseMatchOperator;
+
+/**
+ * This operator filters the incoming stream of key value pairs by obtaining the values corresponding to a specified key,
+ * and comparing those values to a specified number.&nbsp;The first key value pair, in each window, to satisfy the comparison is emitted.
+ * <p>
+ * A compare metric on a Number tuple based on the property "key", "value", and "cmp"; the first match is emitted.
+ *  The comparison is done by getting double value from the Number.
+ * </p>
+ * <p>
+ * This module is a pass through<br>
+ * The operators by default assumes immutable keys. If the key is mutable, use cloneKey to make a copy<br>
+ * <br>
+ * <b>StateFull : Yes, </b> tuple are processed in current window. <br>
+ * <b>Partitions : No, </b>will yield wrong results. <br>
+ * <br>
+ * <br>
+ * <b>Ports</b>:<br>
+ * <b>data</b>: expects Map&lt;K,V extends Number&gt;<br>
+ * <b>first</b>: emits HashMap&lt;K,V&gt;<br>
+ * <br>
+ * <b>Properties</b>:<br>
+ * <b>key</b>: The key on which compare is done<br>
+ * <b>value</b>: The value to compare with<br>
+ * <b>cmp</b>: The compare function. Supported values are "lte", "lt", "eq", "neq", "gt", "gte". Default is "eq"<br>
+ * <br>
+ * <b>Specific compile time checks</b>:<br>
+ * Key must be non empty<br>
+ * Value must be able to convert to a "double"<br>
+ * Compare string, if specified, must be one of "lte", "lt", "eq", "neq", "gt", "gte"<br>
+ * <br>
+ * </p>
+ *
+ * @displayName Emit First Match (Number)
+ * @category Rules and Alerts
+ * @tags filter, key value, numeric
+ *
+ * @since 0.3.2
+ * @deprecated
+ */
+@Deprecated
+@OperatorAnnotation(partitionable = false)
+public class FirstMatchMap<K, V extends Number> extends BaseMatchOperator<K,V>
+{
+  /**
+   * Tuple emitted flag.
+   */
+  boolean emitted = false;
+
+  /**
+   * The port on which key value pairs are received.
+   */
+  public final transient DefaultInputPort<Map<K, V>> data = new DefaultInputPort<Map<K, V>>()
+  {
+    /**
+     * Checks if required key,val pair exists in the HashMap. If so tuple is emitted, and emitted flag is set
+     * to true
+     */
+    @Override
+    public void process(Map<K, V> tuple)
+    {
+      if (emitted) {
+        return;
+      }
+      V val = tuple.get(getKey());
+      if (val == null) { // skip if key does not exist
+        return;
+      }
+      if (compareValue(val.doubleValue())) {
+        first.emit(cloneTuple(tuple));
+        emitted = true;
+      }
+    }
+  };
+
+  /**
+   * The output port on which the first satisfying key value pair is emitted.
+   */
+  public final transient DefaultOutputPort<HashMap<K, V>> first = new DefaultOutputPort<HashMap<K, V>>();
+
+  /**
+   * Resets emitted flag to false
+   * @param windowId
+   */
+  @Override
+  public void beginWindow(long windowId)
+  {
+    emitted = false;
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/FirstN.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/FirstN.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/FirstN.java
new file mode 100644
index 0000000..f067fbb
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/FirstN.java
@@ -0,0 +1,113 @@
+/**
+ * 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.contrib.misc.algo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.lang.mutable.MutableInt;
+
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.api.annotation.OperatorAnnotation;
+
+import com.datatorrent.lib.util.AbstractBaseNOperatorMap;
+
+/**
+ * This operator filters the incoming stream of key value pairs by emitting the first N key value pairs with a specified key in each window.
+ * <p>
+ * Emits first N tuples of a particular key.
+ * </p>
+ * <p>
+ * This module is a pass through module<br>
+ * <br>
+ * <b>StateFull : Yes, </b> tuple are compare across application window(s). <br>
+ * <b>Partitions : No, </b> will yield wrong results. <br>
+ * <br>
+ * <b>Ports</b>:<br>
+ * <b>data</b>: Input data port expects HashMap&lt;K,V&gt;<br>
+ * <b>bottom</b>: Output data port, emits HashMap&lt;K,V&gt;<br>
+ * <br>
+ * <b>Properties</b>:<br>
+ * <b>N</b>: The number of top values to be emitted per key<br>
+ * <br>
+ * <b>Specific compile time checks are</b>:<br>
+ * N: Has to be >= 1<br>
+ * <br>
+ * <br>
+ * </p>
+ *
+ * @displayName First N Keyval Pairs Matching Key
+ * @category Rules and Alerts
+ * @tags filter, key value
+ * @deprecated
+ * @since 0.3.2
+ */
+@Deprecated
+@OperatorAnnotation(partitionable = false)
+public class FirstN<K,V> extends AbstractBaseNOperatorMap<K, V>
+{
+  /**
+   * key count map.
+   */
+  HashMap<K, MutableInt> keycount = new HashMap<K, MutableInt>();
+
+  /**
+   * Inserts tuples into the queue
+   * @param tuple to insert in the queue
+   */
+  @Override
+  public void processTuple(Map<K, V> tuple)
+  {
+    for (Map.Entry<K, V> e: tuple.entrySet()) {
+      MutableInt count = keycount.get(e.getKey());
+      if (count == null) {
+        count = new MutableInt(0);
+        keycount.put(e.getKey(), count);
+      }
+      count.increment();
+      if (count.intValue() <= getN()) {
+        first.emit(cloneTuple(e.getKey(), e.getValue()));
+      }
+    }
+  }
+
+  /**
+   * The output port on which the first N key value pairs are emitted.
+   */
+  public final transient DefaultOutputPort<HashMap<K, V>> first = new DefaultOutputPort<HashMap<K, V>>();
+
+  /**
+   * Clears the cache to start anew in a new window
+   */
+  @Override
+  public void endWindow()
+  {
+    keycount.clear();
+  }
+
+  /**
+   * First N number of KeyValue pairs for each Key.
+   *
+   * @param val
+   */
+  public void setN(int val)
+  {
+    super.setN(val);
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/FirstTillMatch.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/FirstTillMatch.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/FirstTillMatch.java
new file mode 100644
index 0000000..c32a0f2
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/FirstTillMatch.java
@@ -0,0 +1,116 @@
+/**
+ * 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.contrib.misc.algo;
+
+import java.util.HashMap;
+
+import com.datatorrent.api.DefaultInputPort;
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.api.annotation.OperatorAnnotation;
+
+import com.datatorrent.lib.util.BaseMatchOperator;
+
+/**
+ * This operator filters the incoming stream of key value pairs by obtaining the values corresponding to a specified key,
+ * and comparing those values to a specified number.&nbsp;For each window, all key value pairs are emitted by the operator until a value satisfying the comparison is encountered.
+ * <p>
+ * All key.val pairs with val sub-classed from Number are emitted till the first match;  A compare metric is done based on the property "key",
+ * "value", and "cmp". Then on no tuple is emitted in that window. The comparison is done by getting double value of the Number.
+ * </p>
+ * <p>
+ * This module is a pass through<br>
+ * <br>
+ * <b>StateFull : Yes, </b> tuple are processed in current window. <br>
+ * <b>Partitions : No, </b>will yield wrong results. <br>
+ * <br>
+ * <br>
+ * <b>Ports</b>:<br>
+ * <b>data</b>: Input port, expects HashMap&lt;K,V&gt;<br>
+ * <b>first</b>: Output port, emits HashMap&lt;K,V&gt; if compare function returns true<br>
+ * <br>
+ * <b>Properties</b>:<br>
+ * <b>key</b>: The key on which compare is done<br>
+ * <b>value</b>: The value to compare with<br>
+ * <b>cmp</b>: The compare function. Supported values are "lte", "lt", "eq", "neq", "gt", "gte". Default is "eq"<br>
+ * <br>
+ * <b>Specific compile time checks</b>:<br>
+ * Key must be non empty<br>
+ * Value must be able to convert to a "double"<br>
+ * Compare string, if specified, must be one of "lte", "lt", "eq", "neq", "gt", "gte"<br>
+ * <br>
+ * </p>
+ *
+ * @displayName Emit Keyval Pairs Until Match (Number)
+ * @category Rules and Alerts
+ * @tags filter, key value, numeric
+ * @deprecated
+ * @since 0.3.2
+ */
+@Deprecated
+@OperatorAnnotation(partitionable = false)
+public class FirstTillMatch<K, V extends Number> extends BaseMatchOperator<K, V>
+{
+  /**
+   * Tuple emitted flag.
+   */
+  boolean emitted = false;
+
+  /**
+   * The input port on which incoming key value pairs are received.
+   */
+  public final transient DefaultInputPort<HashMap<K, V>> data = new DefaultInputPort<HashMap<K, V>>()
+  {
+    /**
+     * Compares the key,val pair with the match condition. Till a match is found tuples are emitted.
+     * Once a match is found, state is set to emitted, and no more tuples are compared (no more emits).
+     */
+    @Override
+    public void process(HashMap<K, V> tuple)
+    {
+      if (emitted) {
+        return;
+      }
+      V val = tuple.get(getKey());
+      if (val == null) { // skip if the key does not exist
+        return;
+      }
+      if (compareValue(val.doubleValue())) {
+        emitted = true;
+      }
+      if (!emitted) {
+        first.emit(cloneTuple(tuple));
+      }
+    }
+  };
+
+  /**
+   * The output port on which key value pairs are emitted until the first match.
+   */
+  public final transient DefaultOutputPort<HashMap<K, V>> first = new DefaultOutputPort<HashMap<K, V>>();
+
+  /**
+   * Emitted set is reset to false
+   * @param windowId
+   */
+  @Override
+  public void beginWindow(long windowId)
+  {
+    emitted = false;
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/InsertSortDesc.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/InsertSortDesc.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/InsertSortDesc.java
new file mode 100644
index 0000000..4af9091
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/InsertSortDesc.java
@@ -0,0 +1,136 @@
+/**
+ * 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.contrib.misc.algo;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.PriorityQueue;
+
+import com.datatorrent.api.DefaultInputPort;
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.api.annotation.InputPortFieldAnnotation;
+import com.datatorrent.api.annotation.OperatorAnnotation;
+import com.datatorrent.api.annotation.OutputPortFieldAnnotation;
+import com.datatorrent.lib.util.AbstractBaseSortOperator;
+import com.datatorrent.lib.util.ReversibleComparator;
+
+/**
+ * This operator takes the values it receives each window and outputs them in ascending order at the end of each window.
+ * <p>
+ * Incoming tuple is inserted into already existing sorted list in a descending order. At the end of the window the resultant sorted list is emitted on the output ports.
+ * </p>
+ * <p>
+ * <br>
+ * <b>StateFull : Yes, </b> tuple are compare across application window(s). <br>
+ * <b>Partitions : No, </b> will yield wrong results. <br>
+ * <br>
+ * <b>Ports</b>:<br>
+ * <b>data</b>: expects K<br>
+ * <b>datalist</b>: expects ArrayList&lt;K&gt;<br>
+ * <b>sortlist</b>: emits ArrayList&lt;K&gt;<br>
+ * <b>sorthash</b>: emits HashMap&lt;K,Integer&gt;<br>
+ * <br>
+ * <br>
+ * </p>
+ * @displayName Sort Descending
+ * @category Stream Manipulators
+ * @tags rank, sort
+ * @deprecated
+ * @since 0.3.2
+ */
+@Deprecated
+//
+// TODO: Override PriorityQueue and rewrite addAll to insert with location
+//
+@OperatorAnnotation(partitionable = false)
+public class InsertSortDesc<K> extends AbstractBaseSortOperator<K>
+{
+  /**
+   * The input port on which individual tuples are received for sorting.
+   */
+  @InputPortFieldAnnotation(optional = true)
+  public final transient DefaultInputPort<K> data = new DefaultInputPort<K>()
+  {
+    /**
+     * Adds tuple to sorted queue
+     */
+    @Override
+    public void process(K tuple)
+    {
+      processTuple(tuple);
+    }
+  };
+  /**
+   * The input port on which lists of tuples are received for sorting.
+   */
+  @InputPortFieldAnnotation(optional = true)
+  public final transient DefaultInputPort<ArrayList<K>> datalist = new DefaultInputPort<ArrayList<K>>()
+  {
+    /**
+     * Adds tuples to sorted queue
+     */
+    @Override
+    public void process(ArrayList<K> tuple)
+    {
+      processTuple(tuple);
+    }
+  };
+
+  /**
+   * The output port on which a sorted descending list of tuples is emitted.
+   */
+  @OutputPortFieldAnnotation(optional = true)
+  public final transient DefaultOutputPort<ArrayList<K>> sort = new DefaultOutputPort<ArrayList<K>>();
+  @OutputPortFieldAnnotation(optional = true)
+  /**
+   * This output port emits a map from tuples to a count of the number of times each tuple occurred in the application window.
+   */
+  public final transient DefaultOutputPort<HashMap<K, Integer>> sorthash = new DefaultOutputPort<HashMap<K, Integer>>();
+
+  @Override
+  public void initializeQueue()
+  {
+    pqueue = new PriorityQueue<K>(getSize(), new ReversibleComparator<K>(false));
+  }
+
+
+  @Override
+  public void emitToList(ArrayList<K> list)
+  {
+    sort.emit(list);
+  }
+
+  @Override
+  public void emitToHash(HashMap<K,Integer> map)
+  {
+    sorthash.emit(map);
+  }
+
+  @Override
+  public boolean doEmitList()
+  {
+    return sort.isConnected();
+  }
+
+  @Override
+  public boolean doEmitHash()
+  {
+    return sorthash.isConnected();
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/InvertIndex.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/InvertIndex.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/InvertIndex.java
new file mode 100644
index 0000000..7964ed7
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/InvertIndex.java
@@ -0,0 +1,146 @@
+/**
+ * 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.contrib.misc.algo;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.datatorrent.api.DefaultInputPort;
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.api.Operator.Unifier;
+import com.datatorrent.api.annotation.OperatorAnnotation;
+
+import com.datatorrent.lib.util.BaseKeyValueOperator;
+
+/**
+ * This operator takes a stream of key value pairs each window,
+ * and outputs a set of inverted key value pairs at the end of each window.
+ * <p>
+ * Inverts the index and sends out the tuple on output port "index" at the end of the window.
+ * </p>
+ * <p>
+ * This is an end of window operator<br>
+ * <br>
+ * <b>StateFull : Yes, </b> tuple are compare across application window(s). <br>
+ * <b>Partitions : Yes, </b> inverted indexes are unified by instance of same operator. <br>
+ * <br>
+ * <br>
+ * <b>Ports</b>:<br>
+ * <b>data</b>: expects &lt;K,V&gt;<br>
+ * <b>index</b>: emits &lt;V,ArrayList&lt;K&gt;&gt;(1); one HashMap per V<br>
+ * <br>
+ * </p>
+ *
+ * @displayName Invert Key Value Pairs
+ * @category Stream Manipulators
+ * @tags key value
+ *
+ * @since 0.3.2
+ * @deprecated
+ */
+@Deprecated
+@OperatorAnnotation(partitionable = true)
+public class InvertIndex<K, V> extends BaseKeyValueOperator<K, V> implements Unifier<HashMap<V, ArrayList<K>>>
+{
+  /**
+   * Inverted key/value map.
+   */
+  protected HashMap<V, ArrayList<K>> map = new HashMap<V, ArrayList<K>>();
+
+  /**
+   * The input port on which key value pairs are received.
+   */
+  public final transient DefaultInputPort<HashMap<K, V>> data = new DefaultInputPort<HashMap<K, V>>()
+  {
+    /**
+     * Reverse indexes a HashMap<K, ArrayList<V>> tuple
+     */
+    @Override
+    public void process(HashMap<K, V> tuple)
+    {
+      for (Map.Entry<K, V> e: tuple.entrySet()) {
+        if (e.getValue() == null) { // error tuple?
+          continue;
+        }
+        insert(e.getValue(), cloneKey(e.getKey()));
+      }
+    }
+  };
+
+  /**
+   * The output port on which inverted key value pairs are emitted.
+   */
+  public final transient DefaultOutputPort<HashMap<V, ArrayList<K>>> index = new DefaultOutputPort<HashMap<V, ArrayList<K>>>()
+  {
+    @Override
+    public Unifier<HashMap<V, ArrayList<K>>> getUnifier()
+    {
+      return new InvertIndex<K, V>();
+    }
+  };
+
+  /**
+   *
+   * Returns the ArrayList stored for a key
+   *
+   * @param key
+   */
+  void insert(V val, K key)
+  {
+    ArrayList<K> list = map.get(val);
+    if (list == null) {
+      list = new ArrayList<K>(4);
+      map.put(cloneValue(val), list);
+    }
+    list.add(key);
+  }
+
+  /**
+   * Emit all the data and clear the hash
+   * Clears internal data
+   */
+  @Override
+  public void endWindow()
+  {
+    for (Map.Entry<V, ArrayList<K>> e: map.entrySet()) {
+      HashMap<V, ArrayList<K>> tuple = new HashMap<V, ArrayList<K>>(1);
+      tuple.put(e.getKey(), e.getValue());
+      index.emit(tuple);
+    }
+    map.clear();
+  }
+
+  /**
+   * Unifier override.
+   */
+  @Override
+  public void process(HashMap<V, ArrayList<K>> tuple)
+  {
+    for (Map.Entry<V, ArrayList<K>> e: tuple.entrySet()) {
+      ArrayList<K> keys;
+      if (map.containsKey(e.getKey())) {
+        keys = map.remove(e.getKey());
+      } else {
+        keys = new ArrayList<K>();
+      }
+      keys.addAll(e.getValue());
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/InvertIndexArray.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/InvertIndexArray.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/InvertIndexArray.java
new file mode 100644
index 0000000..26b77ac
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/InvertIndexArray.java
@@ -0,0 +1,130 @@
+/**
+ * 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.contrib.misc.algo;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.datatorrent.api.DefaultInputPort;
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.api.annotation.OperatorAnnotation;
+
+import com.datatorrent.lib.util.BaseKeyValueOperator;
+
+/**
+ * This operator takes a stream of key value pairs each window,
+ * and outputs a set of inverted key value pairs at the end of each window.&nbsp;
+ * The values in the key value pairs received by this operator are an array lists, which may multiple values.
+ * <p>
+ * Inverts the index and sends out the tuple on output port "index" at the end of the window.
+ * </p>
+ * <p>
+ * This is an end of window operator<br>
+ * <br>
+ * <b>StateFull : Yes, </b> tuple are compare across application window(s). <br>
+ * <b>Partitions : Yes, </b> inverted indexes are unified by instance of same operator. <br>
+ * <br>
+ * <b>Ports</b>:<br>
+ * <b>data</b>: expects HashMap&lt;K,ArrayList&lt;V&gt;&gt;<br>
+ * <b>index</b>: emits HashMap&lt;V,ArrayList&lt;K&gt;&gt;(1), one HashMap per V<br>
+ * <br>
+ * </p>
+ *
+ * @displayName Invert Key Value Pairs (Array)
+ * @category Stream Manipulators
+ * @tags key value
+ *
+ * @since 0.3.2
+ * @deprecated
+ */
+@Deprecated
+@OperatorAnnotation(partitionable = true)
+public class InvertIndexArray<K, V> extends BaseKeyValueOperator<K,V>
+{
+  /**
+   * Inverted key/value map.
+   */
+  protected HashMap<V, ArrayList<K>> map = new HashMap<V, ArrayList<K>>();
+
+  /**
+   * The input port on which key value pairs are received.
+   */
+  public final transient DefaultInputPort<HashMap<K, ArrayList<V>>> data = new DefaultInputPort<HashMap<K, ArrayList<V>>>()
+  {
+    /**
+     * Reverse indexes a HashMap<K, ArrayList<V>> tuple
+     */
+    @Override
+    public void process(HashMap<K, ArrayList<V>> tuple)
+    {
+      for (Map.Entry<K, ArrayList<V>> e: tuple.entrySet()) {
+        ArrayList<V> alist = e.getValue();
+        if (alist == null) { // error tuple?
+          continue;
+        }
+        for (V val : alist) {
+          insert(val, cloneKey(e.getKey()));
+        }
+      }
+    }
+  };
+
+  /**
+   * The output port or which inverted key value pairs are emitted.
+   */
+  public final transient DefaultOutputPort<HashMap<V, ArrayList<K>>> index = new DefaultOutputPort<HashMap<V, ArrayList<K>>>()
+  {
+    @Override
+    public Unifier<HashMap<V, ArrayList<K>>> getUnifier()
+    {
+      return new InvertIndex<K, V>();
+    }
+  };
+
+  /**
+   *
+   * Returns the ArrayList stored for a key
+   *
+   * @param key
+   */
+  void insert(V val, K key)
+  {
+    ArrayList<K> list = map.get(val);
+    if (list == null) {
+      list = new ArrayList<K>(4);
+      map.put(cloneValue(val), list);
+    }
+    list.add(key);
+  }
+
+  /**
+   * Emit all the data and clear the hash
+   */
+  @Override
+  public void endWindow()
+  {
+    for (Map.Entry<V, ArrayList<K>> e: map.entrySet()) {
+      HashMap<V, ArrayList<K>> tuple = new HashMap<V, ArrayList<K>>(1);
+      tuple.put(e.getKey(), e.getValue());
+      index.emit(tuple);
+    }
+    map.clear();
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/LastMatchMap.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/LastMatchMap.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/LastMatchMap.java
new file mode 100644
index 0000000..188c9b1
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/LastMatchMap.java
@@ -0,0 +1,112 @@
+/**
+ * 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.contrib.misc.algo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.datatorrent.api.DefaultInputPort;
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.api.annotation.OperatorAnnotation;
+
+import com.datatorrent.lib.util.BaseMatchOperator;
+
+/**
+ * This operator filters the incoming stream of key value pairs by obtaining the values corresponding to a specified key,
+ * and comparing those values to a specified value.&nbsp;The last key value pair, in each window, to satisfy the comparison is emitted.
+ * <p>
+ * A compare function is  operated on a tuple value sub-classed from Number based on the property "key", "value", and "cmp". Every tuple
+ * is checked and the last one that passes the condition is send during end of window on port "last". The comparison is done by getting double
+ * value from the Number.
+ * </p>
+ * <p>
+ * This module is an end of window module<br>
+ * <br>
+ * <b>StateFull : Yes, </b> tuple are compare across application window(s). <br>
+ * <b>Partitions : No, </b> will yield wrong result. <br>
+ * <br>
+ * <b>Ports</b>:<br>
+ * <b>data</b>: expects Map&lt;K,V extends Number&gt;<br>
+ * <b>last</b>: emits Map&lt;K,V&gt; in end of window for the last tuple on which the compare function is true<br>
+ * <br>
+ * <b>Properties</b>:<br>
+ * <b>key</b>: The key on which compare is done<br>
+ * <b>value</b>: The value to compare with<br>
+ * <b>cmp</b>: The compare function. Supported values are "lte", "lt", "eq", "neq", "gt", "gte". Default is "eq"<br>
+ * <br>
+ * <b>Specific compile time checks</b>:<br>
+ * Key must be non empty<br>
+ * Value must be able to convert to a "double"<br>
+ * Compare string, if specified, must be one of "lte", "lt", "eq", "neq", "gt", "gte"<br>
+ * <br>
+ * </p>
+ *
+ * @displayName Emit Last Match (Number)
+ * @category Rules and Alerts
+ * @tags filter, key value, numeric
+ * @deprecated
+ * @since 0.3.2
+ */
+@Deprecated
+@OperatorAnnotation(partitionable = false)
+public class LastMatchMap<K, V extends Number> extends BaseMatchOperator<K,V>
+{
+  /**
+   * Last tuple.
+   */
+  protected HashMap<K, V> ltuple = null;
+
+  /**
+   * The input port on which key value pairs are received.
+   */
+  public final transient DefaultInputPort<Map<K, V>> data = new DefaultInputPort<Map<K, V>>()
+  {
+    /**
+     * Processes tuples and keeps a copy of last matched tuple
+     */
+    @Override
+    public void process(Map<K, V> tuple)
+    {
+      V val = tuple.get(getKey());
+      if (val == null) {
+        return;
+      }
+      if (compareValue(val.doubleValue())) {
+        ltuple = cloneTuple(tuple);
+      }
+    }
+  };
+
+  /**
+   * The output port on which the last key value pair to satisfy the comparison function is emitted.
+   */
+  public final transient DefaultOutputPort<HashMap<K, V>> last = new DefaultOutputPort<HashMap<K, V>>();
+
+  /**
+   * Emits last matching tuple
+   */
+  @Override
+  public void endWindow()
+  {
+    if (ltuple != null) {
+      last.emit(ltuple);
+    }
+    ltuple = null;
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/LeastFrequentKeyMap.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/LeastFrequentKeyMap.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/LeastFrequentKeyMap.java
new file mode 100644
index 0000000..af5229c
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/LeastFrequentKeyMap.java
@@ -0,0 +1,149 @@
+/**
+ * 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.contrib.misc.algo;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.datatorrent.api.DefaultInputPort;
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.api.annotation.OperatorAnnotation;
+import com.datatorrent.api.annotation.OutputPortFieldAnnotation;
+
+import com.datatorrent.lib.util.AbstractBaseFrequentKey;
+import com.datatorrent.lib.util.UnifierArrayHashMapFrequent;
+import com.datatorrent.lib.util.UnifierHashMapFrequent;
+
+/**
+ * This operator filters the incoming stream of key value pairs by finding the key or keys (if there is a tie) that occur the fewest number of times within each window.&nbsp;
+ * A list of the corresponding key value pairs are then output to the port named "list" and one of the corresponding key value pairs is output to the port "least", at the end of each window.
+ * <p>
+ * Occurrences of each key is counted and at the end of window any of the least frequent key is emitted on output port least and all least frequent
+ * keys on output port list.
+ * </p>
+ * <p>
+ * This module is an end of window module. In case of a tie any of the least key would be emitted. The list port would however have all the tied keys<br>
+ * <br>
+ * <b>StateFull : Yes, </b> tuple are compared across application window(s). <br>
+ * <b>Partitions : Yes, </b> least keys are unified on output port. <br>
+ * <br>
+ * <b>Ports</b>:<br>
+ * <b>data</b>: expects Map&lt;K,V&gt;, V is ignored/not used<br>
+ * <b>least</b>: emits HashMap&lt;K,Integer&gt;(1); where String is the least frequent key, and Integer is the number of its occurrences in the window<br>
+ * <b>list</b>: emits ArrayList&lt;HashMap&lt;K,Integer&gt;(1)&gt;; Where the list includes all the keys are least frequent<br>
+ * <br>
+ * </p>
+ *
+ * @displayName Emit Least Frequent Tuple Key
+ * @category Rules and Alerts
+ * @tags filter, key value, count
+ * @deprecated
+ * @since 0.3.2
+ */
+@Deprecated
+@OperatorAnnotation(partitionable = true)
+public class LeastFrequentKeyMap<K, V> extends AbstractBaseFrequentKey<K>
+{
+  /**
+   * The input port on which key value pairs are received.
+   */
+  public final transient DefaultInputPort<Map<K, V>> data = new DefaultInputPort<Map<K, V>>()
+  {
+    /**
+     * Calls super.processTuple(tuple) for each key in the HashMap
+     */
+    @Override
+    public void process(Map<K, V> tuple)
+    {
+      for (Map.Entry<K, V> e: tuple.entrySet()) {
+        processTuple(e.getKey());
+      }
+    }
+  };
+
+  /**
+   * The output port on which one of the tuples,
+   * which occurred the least number of times,
+   * is emitted.
+   */
+  @OutputPortFieldAnnotation(optional = true)
+  public final transient DefaultOutputPort<HashMap<K, Integer>> least = new DefaultOutputPort<HashMap<K, Integer>>()
+  {
+    @Override
+    public Unifier<HashMap<K, Integer>> getUnifier()
+    {
+      Unifier<HashMap<K, Integer>> ret = new UnifierHashMapFrequent<K>();
+      ((UnifierHashMapFrequent<K>)ret).setLeast(true);
+      return ret;
+    }
+  };
+
+  /**
+   * The output port on which all the tuples,
+   * which occurred the least number of times,
+   * is emitted.
+   */
+  @OutputPortFieldAnnotation(optional = true)
+  public final transient DefaultOutputPort<ArrayList<HashMap<K, Integer>>> list = new DefaultOutputPort<ArrayList<HashMap<K, Integer>>>()
+  {
+    @Override
+    public Unifier<ArrayList<HashMap<K, Integer>>> getUnifier()
+    {
+      Unifier<ArrayList<HashMap<K, Integer>>> ret = new UnifierArrayHashMapFrequent<K>();
+      ((UnifierArrayHashMapFrequent<K>)ret).setLeast(true);
+      return ret;
+    }
+  };
+
+  /**
+   * Emits tuple on port "least"
+   *
+   * @param tuple
+   */
+  @Override
+  public void emitTuple(HashMap<K, Integer> tuple)
+  {
+    least.emit(tuple);
+  }
+
+  /**
+   * Emits tuple on port "list"
+   *
+   * @param tlist
+   */
+  @Override
+  public void emitList(ArrayList<HashMap<K, Integer>> tlist)
+  {
+    list.emit(tlist);
+  }
+
+  /**
+   * returns val1 < val2
+   *
+   * @param val1
+   * @param val2
+   * @return val1 < val2
+   */
+  @Override
+  public boolean compareCount(int val1, int val2)
+  {
+    return val1 < val2;
+  }
+}


[11/12] apex-malhar git commit: Updated algo & working on math operators

Posted by th...@apache.org.
http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/LeastFrequentKeyValueMap.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/LeastFrequentKeyValueMap.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/LeastFrequentKeyValueMap.java
new file mode 100644
index 0000000..78eb6d9
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/LeastFrequentKeyValueMap.java
@@ -0,0 +1,107 @@
+/**
+ * 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.contrib.misc.algo;
+
+import java.util.HashMap;
+
+import com.datatorrent.api.DefaultOutputPort;
+
+import com.datatorrent.lib.util.AbstractBaseFrequentKeyValueMap;
+
+/**
+ * This operator filters the incoming stream of key value pairs by finding the value or values (if there is a tie),
+ * for each key, that occur the fewest number of times within each window.&nbsp;
+ * Each key and its corresponding least values are emitted at the end of each window.
+ * <p>
+ * Occurrences of all values for each key is counted and at the end of window the least frequent values are emitted on output port least per key.
+ * </p>
+ * <p>
+ * This module is an end of window module<br>
+ * <br>
+ * <b>Ports</b>:<br>
+ * <b>data</b>: expects Map&lt;K,V&gt;<br>
+ * <b>least</b>: Output port, emits HashMap&lt;K,HashMap&lt;V,Integer&gt;&gt;(1)<br>
+ * <br>
+ * <b>Properties</b>: None<br>
+ * <br>
+ * <b>Compile time checks</b>: None<br>
+ * <b>Specific run time checks</b>: None <br>
+ * <br>
+ * <b>Benchmarks</b>: Blast as many tuples as possible in inline mode<br>
+ * <table border="1" cellspacing=1 cellpadding=1 summary="Benchmark table for LeastFrequentKeyValueMap&lt;K,V&gt; operator template">
+ * <tr><th>In-Bound</th><th>Out-bound</th><th>Comments</th></tr>
+ * <tr><td><b>&gt; 30 Million K,V pairs/s</b></td><td>Emits only 1 tuple per window per key</td><td>In-bound throughput is the main determinant of performance.
+ * The benchmark was done with immutable objects. If K or V are mutable the benchmark may be lower</td></tr>
+ * </table><br>
+ * </p>
+ * <p>
+ * <b>Function Table (K=String,V=Integer);</b>:
+ * <table border="1" cellspacing=1 cellpadding=1 summary="Function table for LeastFrequentKeyValueMap&lt;K,V&gt; operator template">
+ * <tr><th rowspan=2>Tuple Type (api)</th><th>In-bound (process)</th><th>Out-bound (emit)</th></tr>
+ * <tr><th><i>data</i>(Map&lt;K,V&gt;)</th><th><i>least</i>(HashMap&lt;K,HashMap&lt;Integer&gt;&gt;)</th></tr>
+ * <tr><td>Begin Window (beginWindow())</td><td>N/A</td><td>N/A</td></tr>
+ * <tr><td>Data (process())</td><td>{a=1,b=5,c=110}</td><td></td></tr>
+ * <tr><td>Data (process())</td><td>{a=55,c=2000,b=45}</td><td></td></tr>
+ * <tr><td>Data (process())</td><td>{d=2}</td><td></td></tr>
+ * <tr><td>Data (process())</td><td>{a=55,b=5,c=22}</td><td></td></tr>
+ * <tr><td>Data (process())</td><td>{h=20,a=2,z=5}</td><td></td></tr>
+ * <tr><td>Data (process())</td><td>{a=4,c=110}</td><td></td></tr>
+ * <tr><td>Data (process())</td><td>{a=4,z=5}</td><td></td></tr>
+ * <tr><td>End Window (endWindow())</td><td>N/A</td><td>{a={1=1,2=1},b={45=1},c={2000=1,22=1},d={2=1},h={20=1},z={5=2}</td></tr>
+ * </table>
+ * <br>
+ * <br>
+ * </p>
+ *
+ * @displayName Emit Least Frequent Keyval Pair
+ * @category Rules and Alerts
+ * @tags filter, key value, count
+ * @deprecated
+ * @since 0.3.2
+ */
+@Deprecated
+public class LeastFrequentKeyValueMap<K, V> extends AbstractBaseFrequentKeyValueMap<K, V>
+{
+  /**
+   * The output port on which the least frequent key value pairs are emitted.
+   */
+  public final transient DefaultOutputPort<HashMap<K, HashMap<V, Integer>>> least = new DefaultOutputPort<HashMap<K, HashMap<V, Integer>>>();
+
+  /**
+   * returns val1 < val2
+   * @param val1
+   * @param val2
+   * @return val1 < val2
+   */
+  @Override
+  public boolean compareValue(int val1, int val2)
+  {
+    return (val1 < val2);
+  }
+
+  /**
+   * Emits tuple on port "least"
+   * @param tuple
+   */
+  @Override
+  public void emitTuple(HashMap<K, HashMap<V, Integer>> tuple)
+  {
+    least.emit(tuple);
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/MostFrequentKeyMap.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/MostFrequentKeyMap.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/MostFrequentKeyMap.java
new file mode 100644
index 0000000..f1ab968
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/MostFrequentKeyMap.java
@@ -0,0 +1,142 @@
+/**
+ * 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.contrib.misc.algo;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.datatorrent.api.DefaultInputPort;
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.api.annotation.OperatorAnnotation;
+
+import com.datatorrent.lib.util.AbstractBaseFrequentKey;
+import com.datatorrent.lib.util.UnifierArrayHashMapFrequent;
+import com.datatorrent.lib.util.UnifierHashMapFrequent;
+
+/**
+ * This operator filters the incoming stream of key value pairs by finding the key or keys (if there is a tie)
+ * that occur the largest number of times within each window.&nbsp;
+ * A list of the corresponding key value pairs are then output to the port named "list" and one of the corresponding key value pairs is output to the port "most", at the end of each window.
+ * <p>
+ * Occurrences of each key is counted and at the end of window any of the most frequent key is emitted on output port least and all least frequent
+ * keys on output port list.
+ * </p>
+ * <p>
+ * This module is an end of window module. In case of a tie any of the least key would be emitted. The list port would however have all the tied keys<br>
+ * <br>
+ *  <b>StateFull : Yes</b>, Values are compared all over  application window can be > 1. <br>
+ *  <b>Partitions : Yes</b>, Result is unified on output port. <br>
+ *  <br>
+ * <b>Ports</b>:<br>
+ * <b>data</b>: expects Map&lt;K,V&gt;, V is ignored/not used<br>
+ * <b>most</b>: emits HashMap&lt;K,Integer&gt;(1); where String is the least frequent key, and Integer is the number of its occurrences in the window<br>
+ * <b>list</b>: emits ArrayList&lt;HashMap&lt;K,Integer&gt;(1)&gt;; Where the list includes all the keys are least frequent<br>
+ * <br>
+ * </p>
+ *
+ * @displayName Emit Most Frequent Key
+ * @category Rules and Alerts
+ * @tags filter, key value, count
+ *
+ * @since 0.3.2
+ * @deprecated
+ */
+@Deprecated
+@OperatorAnnotation(partitionable = true)
+public class MostFrequentKeyMap<K,V> extends AbstractBaseFrequentKey<K>
+{
+  /**
+   * The input port which receives incoming key value pairs.
+   */
+  public final transient DefaultInputPort<Map<K,V>> data = new DefaultInputPort<Map<K,V>>()
+  {
+    /**
+     * Calls super.processTuple(tuple) for each key in the HashMap
+     */
+    @Override
+    public void process(Map<K,V> tuple)
+    {
+      for (Map.Entry<K, V> e: tuple.entrySet()) {
+        processTuple(e.getKey());
+      }
+    }
+  };
+  /**
+   * The output port on which all the tuples,
+   * which occurred the most number of times,
+   * is emitted.
+   */
+  public final transient DefaultOutputPort<HashMap<K, Integer>> most = new DefaultOutputPort<HashMap<K, Integer>>()
+  {
+    @Override
+    public Unifier<HashMap<K, Integer>> getUnifier()
+    {
+      Unifier<HashMap<K, Integer>> ret = new UnifierHashMapFrequent<K>();
+      ((UnifierHashMapFrequent<K>)ret).setLeast(false);
+      return ret;
+    }
+  };
+
+
+  public final transient DefaultOutputPort<ArrayList<HashMap<K, Integer>>> list = new DefaultOutputPort<ArrayList<HashMap<K, Integer>>>()
+  {
+    @SuppressWarnings({"rawtypes", "ConstantConditions"})
+    @Override
+    public Unifier<ArrayList<HashMap<K, Integer>>> getUnifier()
+    {
+      Unifier<ArrayList<HashMap<K, Integer>>> ret = new UnifierArrayHashMapFrequent<K>();
+      ((UnifierHashMapFrequent)ret).setLeast(false);
+      return ret;
+    }
+  };
+
+
+  /**
+   * Emits tuple on port "most"
+   * @param tuple
+   */
+  @Override
+  public void emitTuple(HashMap<K, Integer> tuple)
+  {
+    most.emit(tuple);
+  }
+
+  /**
+   * Emits tuple on port "list"
+   * @param tlist
+   */
+  @Override
+  public void emitList(ArrayList<HashMap<K, Integer>> tlist)
+  {
+    list.emit(tlist);
+  }
+
+  /**
+   * returns val1 < val2
+   * @param val1
+   * @param val2
+   * @return val1 > val2
+   */
+  @Override
+  public boolean compareCount(int val1, int val2)
+  {
+    return val1 > val2;
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/MostFrequentKeyValueMap.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/MostFrequentKeyValueMap.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/MostFrequentKeyValueMap.java
new file mode 100644
index 0000000..4fb6472
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/MostFrequentKeyValueMap.java
@@ -0,0 +1,110 @@
+/**
+ * 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.contrib.misc.algo;
+
+import java.util.HashMap;
+
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.api.annotation.OperatorAnnotation;
+
+import com.datatorrent.lib.util.AbstractBaseFrequentKeyValueMap;
+
+/**
+ * This operator filters the incoming stream of key value pairs by finding the value or values (if there is a tie),
+ * for each key, that occur the largest number of times within each window.&nbsp;
+ * Each key and its corresponding most values are emitted at the end of each window.
+ * <p>
+ * Occurrences of all values for each key is counted and at the end of window the most frequent values are emitted on output port least per key
+ * </p>
+ * <p>
+ * This module is an end of window module<br>
+ * <br>
+ * <b>Ports</b>:<br>
+ * <b>data</b>: expects HashMap&lt;K,V&gt;<br>
+ * <b>most</b>: emits HashMap&lt;String, HashMap&lt;String, Integer&gt;&gt;(1)<br>
+ * <br>
+ * <br>
+ * <b>Properties</b>: None<br>
+ * <br>
+ * <b>Compile time checks</b>: None<br>
+ * <b>Specific run time checks</b>: None <br>
+ * <br>
+ * <b>Benchmarks</b>: Blast as many tuples as possible in inline mode<br>
+ * <table border="1" cellspacing=1 cellpadding=1 summary="Benchmark table for MostFrequentKeyValueMap&lt;K,V&gt; operator template">
+ * <tr><th>In-Bound</th><th>Out-bound</th><th>Comments</th></tr>
+ * <tr><td><b>&gt; 30 Million K,V pairs/s</b></td><td>Emits only 1 tuple per window per key</td><td>In-bound throughput is the main determinant of performance.
+ * The benchmark was done with immutable objects. If K or V are mutable the benchmark may be lower</td></tr>
+ * </table><br>
+ * </p>
+ * <p>
+ * <b>Function Table (K=String,V=Integer);</b>:
+ * <table border="1" cellspacing=1 cellpadding=1 summary="Function table for MostFrequentKeyValueMap&lt;K,V&gt; operator template">
+ * <tr><th rowspan=2>Tuple Type (api)</th><th>In-bound (process)</th><th>Out-bound (emit)</th></tr>
+ * <tr><th><i>data</i>(HashMap&lt;K,V&gt;)</th><th><i>most</i>(HashMap&lt;K,HashMap&lt;Integer&gt;&gt;)</th></tr>
+ * <tr><td>Begin Window (beginWindow())</td><td>N/A</td><td>N/A</td></tr>
+ * <tr><td>Data (process())</td><td>{a=1,b=5,c=110}</td><td></td></tr>
+ * <tr><td>Data (process())</td><td>{a=55,c=2000,b=45}</td><td></td></tr>
+ * <tr><td>Data (process())</td><td>{d=2}</td><td></td></tr>
+ * <tr><td>Data (process())</td><td>{a=55,b=5,c=22}</td><td></td></tr>
+ * <tr><td>Data (process())</td><td>{h=20,a=2,z=5}</td><td></td></tr>
+ * <tr><td>Data (process())</td><td>{a=4,c=110}</td><td></td></tr>
+ * <tr><td>Data (process())</td><td>{a=4,z=5}</td><td></td></tr>
+ * <tr><td>End Window (endWindow())</td><td>N/A</td><td>{a={4=2,55=2},b={5=2},c={110=2},d={2=1},h={20=1},z={5=2}</td></tr>
+ * </table>
+ * <br>
+ * <br>
+ * </p>
+ *
+ * @displayName Emit Most Frequent Keyval Pair
+ * @category Rules and Alerts
+ * @tags filter, key value, count
+ * @deprecated
+ * @since 0.3.2
+ */
+@Deprecated
+@OperatorAnnotation(partitionable = false)
+public class MostFrequentKeyValueMap<K, V> extends AbstractBaseFrequentKeyValueMap<K, V>
+{
+  /**
+   * The output port which emits a map from keys to their most values.
+   */
+  public final transient DefaultOutputPort<HashMap<K, HashMap<V, Integer>>> most = new DefaultOutputPort<HashMap<K, HashMap<V, Integer>>>();
+
+  /**
+   * returns val1 < val2
+   * @param val1
+   * @param val2
+   * @return val1 > val2
+   */
+  @Override
+  public boolean compareValue(int val1, int val2)
+  {
+    return (val1 > val2);
+  }
+
+  /**
+   * Emits tuple on port "most"
+   * @param tuple is emitted on port "most"
+   */
+  @Override
+  public void emitTuple(HashMap<K, HashMap<V, Integer>> tuple)
+  {
+    most.emit(tuple);
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/Sampler.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/Sampler.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/Sampler.java
new file mode 100644
index 0000000..7caf523
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/algo/Sampler.java
@@ -0,0 +1,121 @@
+/**
+ * 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.contrib.misc.algo;
+
+import java.util.Random;
+
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+
+import com.datatorrent.api.DefaultInputPort;
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.api.annotation.OperatorAnnotation;
+import com.datatorrent.api.annotation.Stateless;
+
+import com.datatorrent.lib.util.BaseKeyOperator;
+
+/**
+ * This operator takes a stream of tuples as input, and emits each tuple with a specified probability.
+ * <p>
+ * Emits the tuple as per probability of pass rate out of total rate. <br>
+ * <br>
+ * An efficient filter to allow sample analysis of a stream. Very useful is the incoming stream has high throughput.
+ * </p>
+ * <p>
+ * <br>
+ * <b> StateFull : No, </b> tuple is processed in current window. <br>
+ * <b> Partitions : Yes. </b> No state dependency among input tuples. <br>
+ * <b>Ports</b>:<br>
+ * <b>data</b>: expects K<br>
+ * <b>sample</b>: emits K<br>
+ * <br>
+ * <b>Properties</b>:<br>
+ * <b>passrate</b>: Sample rate out of a total of totalrate. Default is 1<br>
+ * <b>totalrate</b>: Total rate (divisor). Default is 100<br>
+ * <br>
+ * <b>Specific compile time checks are</b>: None<br>
+ * passrate is positive integer<br>
+ * totalrate is positive integer<br>
+ * passrate and totalrate are not compared (i.e. passrate &lt; totalrate) check is not done to allow users to make this operator a passthrough (all) during testing<br>
+ * <br>
+ * <b>Specific run time checks are</b>: None<br>
+ * <br>
+ * </p>
+ *
+ * @displayName Sampler
+ * @category Stats and Aggregations
+ * @tags filter
+ *
+ * @since 0.3.2
+ * @deprecated
+ */
+@Deprecated
+@Stateless
+@OperatorAnnotation(partitionable = true)
+public class Sampler<K> extends BaseKeyOperator<K>
+{
+  /**
+   * This is the input port which receives tuples.
+   */
+  public final transient DefaultInputPort<K> data = new DefaultInputPort<K>()
+  {
+    /**
+     * Emits tuples at a rate corresponding to the given samplingPercentage.
+     */
+    @Override
+    public void process(K tuple)
+    {
+      double val = random.nextDouble();
+      if (val > samplingPercentage) {
+        return;
+      }
+      sample.emit(cloneKey(tuple));
+    }
+  };
+
+  /**
+   * This is the output port which emits the sampled tuples.
+   */
+  public final transient DefaultOutputPort<K> sample = new DefaultOutputPort<K>();
+
+  @Min(0)
+  @Max(1)
+  private double samplingPercentage = 1.0;
+
+  private transient Random random = new Random();
+
+  /**
+   * Gets the samplingPercentage.
+   * @return the samplingPercentage
+   */
+  public double getSamplingPercentage()
+  {
+    return samplingPercentage;
+  }
+
+  /**
+   * The percentage of tuples to allow to pass through this operator. This percentage should be
+   * a number between 0 and 1 inclusive.
+   * @param samplingPercentage the samplingPercentage to set
+   */
+  public void setSamplingPercentage(double samplingPercentage)
+  {
+    this.samplingPercentage = samplingPercentage;
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/Change.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/Change.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/Change.java
new file mode 100644
index 0000000..146a65d
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/Change.java
@@ -0,0 +1,119 @@
+/**
+ * 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.contrib.misc.math;
+
+import com.datatorrent.api.DefaultInputPort;
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.api.annotation.OutputPortFieldAnnotation;
+import com.datatorrent.lib.util.BaseNumberValueOperator;
+
+/**
+ * Operator compares data values arriving on input port with base value input operator.
+ * 
+ * <p>
+ * Arriving base value is stored in operator for comparison, old base value is overwritten.&nbsp;
+ * This emits &lt;change in value,percentage change&gt;.
+ * Operator expects values arriving on data input port and base value input operator.
+ * Change in value and percentage change in values are emitted on separate ports.<br>
+ * This operator can not be partitioned, since copies won't get consecutive operators. <br>
+ * This is StateFull operator, tuples that arrive on base port are kept in
+ * cache forever.<br>
+ * <br>
+ * <b>Input Ports</b>:<br>
+ * <b>data</b>: expects V extends Number, Data values<br>
+ * <b>base</b>: expects V extends Number, Base Value stored for comparison<br>
+ *
+ * <b>Output Ports</b>:<br>
+ * <b>change</b>: emits V extends Number,  Diff from base value<br>
+ * <b>percent</b>: emits Doubl, percent change in value compared to base value.<br>
+ * <br>
+ * <br>
+ * <b>Properties</b>:<br>
+ * <b>inverse</b>: if set to true the key in the filter will block tuple<br>
+ * <b>filterBy</b>: List of keys to filter on<br>
+ * <br>
+ * <b>Specific compile time checks</b>: None<br>
+ * <b>Specific run time checks</b>: None<br>
+ * <br>
+ *
+ * <br>
+ * @displayName Change
+ * @category Math
+ * @tags change, key value, numeric, percentage
+ * @since 0.3.3
+ * @deprecated
+ */
+@Deprecated
+public class Change<V extends Number> extends BaseNumberValueOperator<V>
+{
+        /**
+   * Input data port that takes a number.
+   */
+  public final transient DefaultInputPort<V> data = new DefaultInputPort<V>()
+  {
+    /**
+     * Process each key, compute change or percent, and emit it.
+     */
+    @Override
+    public void process(V tuple)
+    {
+      if (baseValue != 0) { // Avoid divide by zero, Emit an error tuple?
+        double cval = tuple.doubleValue() - baseValue;
+        change.emit(getValue(cval));
+        percent.emit((cval / baseValue) * 100);
+      }
+    }
+  };
+        
+        /**
+   * Input port that takes a number&nbsp; It stores the value for base comparison.
+   */
+  public final transient DefaultInputPort<V> base = new DefaultInputPort<V>()
+  {
+    /**
+     * Process each key to store the value. If same key appears again update
+     * with latest value.
+     */
+    @Override
+    public void process(V tuple)
+    {
+      if (tuple.doubleValue() != 0.0) { // Avoid divide by zero, Emit an error
+                                        // tuple?
+        baseValue = tuple.doubleValue();
+      }
+    }
+  };
+
+  /**
+   * Output port that emits change in value compared to base value.
+   */
+  @OutputPortFieldAnnotation(optional = true)
+  public final transient DefaultOutputPort<V> change = new DefaultOutputPort<V>();
+
+  /**
+   * Output port that emits percent change in data value compared to base value.
+   */
+  @OutputPortFieldAnnotation(optional = true)
+  public final transient DefaultOutputPort<Double> percent = new DefaultOutputPort<Double>();
+
+  /**
+   * baseValue is a state full field. It is retained across windows.
+   */
+  private double baseValue = 0;
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/ChangeAlert.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/ChangeAlert.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/ChangeAlert.java
new file mode 100644
index 0000000..c554ead
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/ChangeAlert.java
@@ -0,0 +1,120 @@
+/**
+ * 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.contrib.misc.math;
+
+import javax.validation.constraints.Min;
+
+import com.datatorrent.api.DefaultInputPort;
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.lib.util.BaseNumberValueOperator;
+import com.datatorrent.lib.util.KeyValPair;
+
+/**
+ * Compares consecutive input data values, emits &lt;value,percent change value&gt; pair on alert output port, if percent change exceeds certain thresh hold value.
+ * <p>
+ * Operator is StateFull since current value is stored for comparison in next window. <br>
+ * This operator can not be partitioned, partitioning will result in inconsistent base value
+ * across replicated copies.
+ * <br>
+ *
+ * <b>Ports</b>:<br>
+ * <b>data</b>: expects KeyValPair&lt;K,V extends Number&gt;<br>
+ * <b>alert</b>: emits KeyValPair&lt;K,KeyValPair&lt;V,Double&gt;&gt;(1)<br>
+ * <br>
+ * <b>Properties</b>:<br>
+ * <b>threshold</b>: The threshold of change between consecutive tuples of the
+ * same key that triggers an alert tuple<br>
+ * <b>inverse</b>: if set to true the key in the filter will block tuple<br>
+ * <b>filterBy</b>: List of keys to filter on<br>
+ * <br>
+ * <b>Specific compile time checks</b>: None<br>
+ * <b>Specific run time checks</b>: None<br>
+ * <br>
+ * @displayName Change Alert
+ * @category Rules and Alerts
+ * @tags change, key value, numeric, percentage
+ * @since 0.3.3
+ * @deprecated
+ */
+@Deprecated
+public class ChangeAlert<V extends Number> extends BaseNumberValueOperator<V>
+{
+  /**
+   * Input port that takes in a number.
+   */
+  public final transient DefaultInputPort<V> data = new DefaultInputPort<V>()
+  {
+    /**
+     * Process each key, compute change or percent, and emit it. If we get 0 as
+     * tuple next will be skipped.
+     */
+    @Override
+    public void process(V tuple)
+    {
+      double tval = tuple.doubleValue();
+      if (baseValue == 0) { // Avoid divide by zero, Emit an error tuple?
+        baseValue = tval;
+        return;
+      }
+      double change = tval - baseValue;
+      double percent = (change / baseValue) * 100;
+      if (percent < 0.0) {
+        percent = 0.0 - percent;
+      }
+      if (percent > percentThreshold) {
+        KeyValPair<V, Double> kv = new KeyValPair<V, Double>(cloneKey(tuple),
+            percent);
+        alert.emit(kv);
+      }
+      baseValue = tval;
+    }
+  };
+
+
+  /**
+   * Output port which emits a key value pair.
+   */
+  public final transient DefaultOutputPort<KeyValPair<V, Double>> alert = new DefaultOutputPort<KeyValPair<V, Double>>();
+
+  /**
+   * baseValue is a state full field. It is retained across windows
+   */
+  private double baseValue = 0;
+  @Min(1)
+  private double percentThreshold = 0.0;
+
+  /**
+   * getter function for threshold value
+   *
+   * @return threshold value
+   */
+  @Min(1)
+  public double getPercentThreshold()
+  {
+    return percentThreshold;
+  }
+
+  /**
+   * setter function for threshold value
+   */
+  public void setPercentThreshold(double d)
+  {
+    percentThreshold = d;
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/ChangeAlertKeyVal.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/ChangeAlertKeyVal.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/ChangeAlertKeyVal.java
new file mode 100644
index 0000000..8d75ab4
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/ChangeAlertKeyVal.java
@@ -0,0 +1,131 @@
+/**
+ * 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.contrib.misc.math;
+
+import java.util.HashMap;
+
+import javax.validation.constraints.Min;
+
+import org.apache.commons.lang.mutable.MutableDouble;
+
+import com.datatorrent.api.DefaultInputPort;
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.lib.util.BaseNumberKeyValueOperator;
+import com.datatorrent.lib.util.KeyValPair;
+
+/**
+ * Operator compares consecutive values arriving at input port mapped by keys, emits &lt;key,percent change&gt; pair on output alert port if percent change exceeds percentage threshold set in operator.
+ * <p>
+ * StateFull : Yes, current key/value is stored in operator for comparison in
+ * next successive windows. <br>
+ * Partition(s): No, base comparison value will be inconsistent across
+ * instantiated copies. <br>
+ * <br>
+ * <b>Ports</b>:<br>
+ * <b>data</b>: expects KeyValPair&lt;K,V extends Number&gt;<br>
+ * <b>alert</b>: emits KeyValPair&lt;K,KeyValPair&lt;V,Double&gt;&gt;(1)<br>
+ * <br>
+ * <b>Properties</b>:<br>
+ * <b>threshold</b>: The threshold of change between consecutive tuples of the
+ * same key that triggers an alert tuple<br>
+ * <b>inverse</b>: if set to true the key in the filter will block tuple<br>
+ * <b>filterBy</b>: List of keys to filter on<br>
+ * @displayName Change Alert Key Value
+ * @category Rules and Alerts
+ * @tags change, key value, numeric, percentage
+ * @since 0.3.3
+ * @deprecated
+ */
+@Deprecated
+public class ChangeAlertKeyVal<K, V extends Number> extends
+    BaseNumberKeyValueOperator<K, V>
+{
+  /**
+   * Base map is a StateFull field. It is retained across windows
+   */
+  private HashMap<K, MutableDouble> basemap = new HashMap<K, MutableDouble>();
+
+  /**
+   * Input data port that takes a key value pair.
+   */
+  public final transient DefaultInputPort<KeyValPair<K, V>> data = new DefaultInputPort<KeyValPair<K, V>>()
+  {
+    /**
+     * Process each key, compute change or percent, and emit it.
+     */
+    @Override
+    public void process(KeyValPair<K, V> tuple)
+    {
+      K key = tuple.getKey();
+      double tval = tuple.getValue().doubleValue();
+      MutableDouble val = basemap.get(key);
+      if (!doprocessKey(key)) {
+        return;
+      }
+      if (val == null) { // Only process keys that are in the basemap
+        val = new MutableDouble(tval);
+        basemap.put(cloneKey(key), val);
+        return;
+      }
+      double change = tval - val.doubleValue();
+      double percent = (change / val.doubleValue()) * 100;
+      if (percent < 0.0) {
+        percent = 0.0 - percent;
+      }
+      if (percent > percentThreshold) {
+        KeyValPair<V, Double> dmap = new KeyValPair<V, Double>(
+            cloneValue(tuple.getValue()), percent);
+        KeyValPair<K, KeyValPair<V, Double>> otuple = new KeyValPair<K, KeyValPair<V, Double>>(
+            cloneKey(key), dmap);
+        alert.emit(otuple);
+      }
+      val.setValue(tval);
+    }
+  };
+
+  /**
+   * Key,Percent Change output port.
+   */
+  public final transient DefaultOutputPort<KeyValPair<K, KeyValPair<V, Double>>> alert = new DefaultOutputPort<KeyValPair<K, KeyValPair<V, Double>>>();
+
+  /**
+   * Alert thresh hold percentage set by application.
+   */
+  @Min(1)
+  private double percentThreshold = 0.0;
+
+  /**
+   * getter function for threshold value
+   *
+   * @return threshold value
+   */
+  @Min(1)
+  public double getPercentThreshold()
+  {
+    return percentThreshold;
+  }
+
+  /**
+   * setter function for threshold value
+   */
+  public void setPercentThreshold(double d)
+  {
+    percentThreshold = d;
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/ChangeAlertMap.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/ChangeAlertMap.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/ChangeAlertMap.java
new file mode 100644
index 0000000..e8add80
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/ChangeAlertMap.java
@@ -0,0 +1,125 @@
+/**
+ * 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.contrib.misc.math;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.validation.constraints.Min;
+
+import org.apache.commons.lang.mutable.MutableDouble;
+
+import com.datatorrent.api.DefaultInputPort;
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.lib.util.BaseNumberKeyValueOperator;
+
+/**
+ * Operator stores  &lt;key,value&gt; pair in hash map across the windows for comparison and emits hash map of &lt;key,percent change in value for each key&gt; if percent change
+ * exceeds preset threshold.
+ * <p>
+ *
+ * StateFull : Yes, key/value pair in current window are stored for comparison in next window. <br>
+ * Partition : No, will yield wrong result, base value won't be consistent across instances. <br>
+ *
+ * <b>Ports</b>:<br>
+ * <b>data</b>: expects Map&lt;K,V extends Number&gt;<br>
+ * <b>alert</b>: emits HashMap&lt;K,HashMap&lt;V,Double&gt;&gt;(1)<br>
+ * <br>
+ * <b>Properties</b>:<br>
+ * <b>threshold</b>: The threshold of change between consecutive tuples of the same key that triggers an alert tuple<br>
+ * <b>inverse</b>: if set to true the key in the filter will block tuple<br>
+ * <b>filterBy</b>: List of keys to filter on<br>
+ * @displayName Change Alert Map
+ * @category Rules and Alerts
+ * @tags change, key value, numeric, percentage, map
+ * @since 0.3.2
+ * @deprecated
+ */
+@Deprecated
+public class ChangeAlertMap<K, V extends Number> extends BaseNumberKeyValueOperator<K, V>
+{
+  /**
+   * Input data port that takes a map of &lt;key,value&gt;.
+   */
+  public final transient DefaultInputPort<Map<K, V>> data = new DefaultInputPort<Map<K, V>>()
+  {
+    /**
+     * Process each key, compute change or percent, and emits it.
+     */
+    @Override
+    public void process(Map<K, V> tuple)
+    {
+      for (Map.Entry<K, V> e: tuple.entrySet()) {
+        MutableDouble val = basemap.get(e.getKey());
+        if (!doprocessKey(e.getKey())) {
+          continue;
+        }
+        if (val == null) { // Only process keys that are in the basemap
+          val = new MutableDouble(e.getValue().doubleValue());
+          basemap.put(cloneKey(e.getKey()), val);
+          continue;
+        }
+        double change = e.getValue().doubleValue() - val.doubleValue();
+        double percent = (change / val.doubleValue()) * 100;
+        if (percent < 0.0) {
+          percent = 0.0 - percent;
+        }
+        if (percent > percentThreshold) {
+          HashMap<V,Double> dmap = new HashMap<V,Double>(1);
+          dmap.put(cloneValue(e.getValue()), percent);
+          HashMap<K,HashMap<V,Double>> otuple = new HashMap<K,HashMap<V,Double>>(1);
+          otuple.put(cloneKey(e.getKey()), dmap);
+          alert.emit(otuple);
+        }
+        val.setValue(e.getValue().doubleValue());
+      }
+    }
+  };
+
+  // Default "pass through" unifier works as tuple is emitted as pass through
+  /**
+   * Output port which emits a hashmap of key, percentage change.
+   */
+  public final transient DefaultOutputPort<HashMap<K, HashMap<V,Double>>> alert = new DefaultOutputPort<HashMap<K, HashMap<V,Double>>>();
+
+  /**
+   * basemap is a statefull field. It is retained across windows
+   */
+  private HashMap<K,MutableDouble> basemap = new HashMap<K,MutableDouble>();
+  @Min(1)
+  private double percentThreshold = 0.0;
+
+  /**
+   * getter function for threshold value
+   * @return threshold value
+   */
+  @Min(1)
+  public double getPercentThreshold()
+  {
+    return percentThreshold;
+  }
+
+  /**
+   * setter function for threshold value
+   */
+  public void setPercentThreshold(double d)
+  {
+    percentThreshold = d;
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/ChangeKeyVal.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/ChangeKeyVal.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/ChangeKeyVal.java
new file mode 100644
index 0000000..0600e6a
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/ChangeKeyVal.java
@@ -0,0 +1,125 @@
+/**
+ * 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.contrib.misc.math;
+
+import java.util.HashMap;
+
+import org.apache.commons.lang.mutable.MutableDouble;
+
+import com.datatorrent.api.DefaultInputPort;
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.api.annotation.OutputPortFieldAnnotation;
+
+import com.datatorrent.lib.util.BaseNumberKeyValueOperator;
+import com.datatorrent.lib.util.KeyValPair;
+
+/**
+ * Operator compares &lt;key,value&gt; pairs arriving at data and base input ports and stores &lt;key,value&gt; pairs arriving at base port in hash map across the windows.
+ * <p/>
+ * The &lt;key,value&gt; pairs that arrive at data port are compared with base value if the key exists in the hash map.&nbsp;
+ * Change value and percentage are emitted on separate ports.
+ * StateFull : Yes, base map values are stored across windows. <br>
+ * Partitions : Yes, values on the base port are replicated across all partitions. However the order of tuples on the
+ * output stream may change.
+ * <br>
+ * <b>Ports</b>:<br>
+ * <b>data</b>: expects KeyValPair&lt;K,V extends Number&gt;<br>
+ * <b>base</b>: expects KeyValPair&lt;K,V extends Number&gt;<br>
+ * <b>change</b>: emits KeyValPair&lt;K,V&gt;(1)<br>
+ * <b>percent</b>: emits KeyValPair&lt;K,Double&gt;(1)<br>
+ * <br>
+ * <br>
+ * <b>Properties</b>:<br>
+ * <b>inverse</b>: if set to true the key in the filter will block tuple<br>
+ * <b>filterBy</b>: List of keys to filter on<br>
+ *
+ * @displayName Change Key Value
+ * @category Math
+ * @tags change, key value
+ * @since 0.3.3
+ * @deprecated
+ */
+@Deprecated
+public class ChangeKeyVal<K, V extends Number> extends BaseNumberKeyValueOperator<K, V>
+{
+  /**
+   * basemap is a stateful field. It is retained across windows
+   */
+  private HashMap<K, MutableDouble> basemap = new HashMap<K, MutableDouble>();
+
+  /**
+   * Input data port that takes key value pairs.
+   */
+  public final transient DefaultInputPort<KeyValPair<K, V>> data = new DefaultInputPort<KeyValPair<K, V>>()
+  {
+    /**
+     * Process each key, compute change or percent, and emit it.
+     */
+    @Override
+    public void process(KeyValPair<K, V> tuple)
+    {
+      K key = tuple.getKey();
+      if (!doprocessKey(key)) {
+        return;
+      }
+      MutableDouble bval = basemap.get(key);
+      if (bval != null) { // Only process keys that are in the basemap
+        double cval = tuple.getValue().doubleValue() - bval.doubleValue();
+        change.emit(new KeyValPair<K, V>(cloneKey(key), getValue(cval)));
+        percent.emit(new KeyValPair<K, Double>(cloneKey(key), (cval / bval.doubleValue()) * 100));
+      }
+    }
+  };
+
+  /**
+   * Base value input port, stored in base map for comparison.
+   */
+  public final transient DefaultInputPort<KeyValPair<K, V>> base = new DefaultInputPort<KeyValPair<K, V>>()
+  {
+    /**
+     * Process each key to store the value. If same key appears again update
+     * with latest value.
+     */
+    @Override
+    public void process(KeyValPair<K, V> tuple)
+    {
+      if (tuple.getValue().doubleValue() != 0.0) { // Avoid divide by zero, Emit
+        // an error tuple?
+        MutableDouble val = basemap.get(tuple.getKey());
+        if (val == null) {
+          val = new MutableDouble(0.0);
+          basemap.put(cloneKey(tuple.getKey()), val);
+        }
+        val.setValue(tuple.getValue().doubleValue());
+      }
+    }
+  };
+
+  /**
+   * Key, Change output port.
+   */
+  @OutputPortFieldAnnotation(optional = true)
+  public final transient DefaultOutputPort<KeyValPair<K, V>> change = new DefaultOutputPort<KeyValPair<K, V>>();
+
+  /**
+   * Key, Percentage Change pair output port.
+   */
+  @OutputPortFieldAnnotation(optional = true)
+  public final transient DefaultOutputPort<KeyValPair<K, Double>> percent = new DefaultOutputPort<KeyValPair<K, Double>>();
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/CompareExceptMap.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/CompareExceptMap.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/CompareExceptMap.java
new file mode 100644
index 0000000..155cb23
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/CompareExceptMap.java
@@ -0,0 +1,131 @@
+/**
+ * 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.contrib.misc.math;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.api.annotation.OutputPortFieldAnnotation;
+import com.datatorrent.api.annotation.Stateless;
+import com.datatorrent.lib.algo.MatchMap;
+import com.datatorrent.lib.util.UnifierHashMap;
+
+/**
+ * Operator compares based on the property "key", "value", and "compare".
+ * <p>
+ * The comparison is done by getting double value from the Number.
+ * Passed tuples are emitted on the output port "compare".&nbsp; 
+ * Failed tuples are emitted on port "except".
+ * Both output ports are optional, but at least one has to be connected.
+ * This module is a pass through<br>
+ * <br>
+ * <b>Ports</b>:<br>
+ * <b>data</b>: expects Map&lt;K,V&gt;<br>
+ * <b>compare</b>: emits HashMap&lt;K,V&gt;<br>
+ * <b>except</b>: emits HashMap&lt;K,V&gt;<br>
+ * <br>
+ * <b>Properties</b>:<br>
+ * <b>key</b>: The key on which compare is done<br>
+ * <b>value</b>: The value to compare with<br>
+ * <b>cmp</b>: The compare function. Supported values are "lte", "lt", "eq", "neq", "gt", "gte". Default is "eq"<br>
+ * <br>
+ * Compile time checks<br>
+ * Key must be non empty<br>
+ * Value must be able to convert to a "double"<br>
+ * Compare string, if specified, must be one of "lte", "lt", "eq", "neq", "gt", "gte"<br>
+ * <b>Specific run time checks</b>:<br>
+ * Does the incoming HashMap have the key<br>
+ * Is the value of the key a number<br>
+ * <p>
+ * <b>Benchmarks</b>: Blast as many tuples as possible in inline mode<br>
+ * <table border="1" cellspacing=1 cellpadding=1 summary="Benchmark table for CompareExceptMap&lt;K,V extends Number&gt; operator template">
+ * <tr><th>In-Bound</th><th>Out-bound</th><th>Comments</th></tr>
+ * <tr><td><b>5 Million K,V pairs/s</b></td><td>Each tuple is emitted if emitError is set to true</td><td>In-bound rate determines performance as every tuple is emitted.
+ * Immutable tuples were used in the benchmarking. If you use mutable tuples and have lots of keys, the benchmarks may be lower</td></tr>
+ * </table><br>
+ * <p>
+ * <b>Function Table (K=String, V=Integer); emitError=true; key=a; value=3; cmp=eq)</b>:
+ * <table border="1" cellspacing=1 cellpadding=1 summary="Function table for CompareExceptMap&lt;K,V extends Number&gt; operator template">
+ * <tr><th rowspan=2>Tuple Type (api)</th><th>In-bound (process)</th><th colspan=2>Out-bound (emit)</th></tr>
+ * <tr><th><i>data</i>(HashMap&lt;K,V&gt;)</th><th><i>compare</i>(HashMap&lt;K,V&gt;)</th><th><i>except</i>(HashMap&lt;K,V&gt;)</th></tr>
+ * <tr><td>Begin Window (beginWindow())</td><td>N/A</td><td>N/A</td><td>N/A</td></tr>
+ * <tr><td>Data (process())</td><td>{a=2,b=20,c=1000}</td><td></td><td>{a=2,b=20,c=1000}</td></tr>
+ * <tr><td>Data (process())</td><td>{a=3,b=40,c=2}</td><td>{a=3,b=40,c=2}</td><td></td></tr>
+ * <tr><td>Data (process())</td><td>{a=10,b=5}</td><td></td><td>{a=10,b=5}</td></tr>
+ * <tr><td>Data (process())</td><td>{d=55,b=12}</td><td></td><td>{d=55,b=12}</td></tr>
+ * <tr><td>Data (process())</td><td>{d=22,a=4}</td><td></td><td>{d=22,a=4}</td></tr>
+ * <tr><td>Data (process())</td><td>{d=4,a=3,g=5,h=44}</td><td>{d=4,a=3,g=5,h=44}</td><td></td></tr>
+ * <tr><td>End Window (endWindow())</td><td>N/A</td><td>N/A</td><td>N/A</td></tr>
+ * </table>
+ * <br>
+ * <br>
+ * @displayName Compare Except Map
+ * @category Math
+ * @tags comparison, key value, number, hash map
+ * @since 0.3.2
+ * @deprecated
+ */
+@Deprecated
+@Stateless
+public class CompareExceptMap<K, V extends Number> extends MatchMap<K, V>
+{
+  /**
+   * Output port that emits a hashmap of matched tuples after comparison.
+   */
+  @OutputPortFieldAnnotation(optional = true)
+  public final transient DefaultOutputPort<HashMap<K, V>> compare = match;
+  
+  /**
+   * Output port that emits a hashmap of non matching tuples after comparison.
+   */
+  @OutputPortFieldAnnotation(optional = true)
+  public final transient DefaultOutputPort<HashMap<K, V>> except = new DefaultOutputPort<HashMap<K, V>>()
+  {
+    @Override
+    public Unifier<HashMap<K, V>> getUnifier()
+    {
+      return new UnifierHashMap<K, V>();
+    }
+  };
+
+  /**
+   * Emits if compare port is connected
+   * @param tuple
+   */
+  @Override
+  public void tupleMatched(Map<K, V> tuple)
+  {
+    if (compare.isConnected()) {
+      compare.emit(cloneTuple(tuple));
+    }
+  }
+
+  /**
+   * Emits if except port is connected
+   * @param tuple
+   */
+  @Override
+  public void tupleNotMatched(Map<K, V> tuple)
+  {
+    if (except.isConnected()) {
+      except.emit(cloneTuple(tuple));
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/CompareMap.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/CompareMap.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/CompareMap.java
new file mode 100644
index 0000000..e263d3f
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/CompareMap.java
@@ -0,0 +1,88 @@
+/**
+ * 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.contrib.misc.math;
+
+import java.util.HashMap;
+
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.api.annotation.Stateless;
+import com.datatorrent.lib.algo.MatchMap;
+
+/**
+ * This operator compares tuples subclassed from Number based on the property "key", "value", and "cmp", and matching tuples are emitted.
+ * <p>
+ * If the tuple passed the test, it is emitted on the output port "compare".&nbsp; The comparison is done by getting double value from the Number.
+ * Both output ports are optional, but at least one has to be connected.
+ * This module is a pass through<br>
+ * <br>
+ * <b>Ports</b>:<br>
+ * <b>data</b>: expects Map&lt;K,V extends Number&gt;<br>
+ * <b>compare</b>: emits HashMap&lt;K,V&gt;<br>
+ * <br>
+ * <b>Properties</b>:<br>
+ * <b>key</b>: The key on which compare is done<br>
+ * <b>value</b>: The value to compare with<br>
+ * <b>cmp</b>: The compare function. Supported values are "lte", "lt", "eq", "neq", "gt", "gte". Default is "eq"<br>
+ * <br>
+ * <b>Compile time checks</b>:<br>
+ * Key must be non empty<br>
+ * Value must be able to convert to a "double"<br>
+ * CompareMap string, if specified, must be one of "lte", "lt", "eq", "neq", "gt", "gte"<br>
+ * <br>
+ * <b>Specific run time checks</b>:<br>
+ * Does the incoming HashMap have the key<br>
+ * Is the value of the key a number<br>
+ * <p>
+ * <b>Benchmarks</b>: Blast as many tuples as possible in inline mode<br>
+ * <table border="1" cellspacing=1 cellpadding=1 summary="Benchmark table for CompareMap&lt;K,V extends Number&gt; operator template">
+ * <tr><th>In-Bound</th><th>Out-bound</th><th>Comments</th></tr>
+ * <tr><td><b>8 Million K,V pairs/s</b></td><td>Each matched tuple is emitted</td><td>In-bound rate and number of tuples that match determine performance.
+ * Immutable tuples were used in the benchmarking. If you use mutable tuples and have lots of keys, the benchmarks may be lower</td></tr>
+ * </table><br>
+ * <p>
+ * <b>Function Table (K=String,V=Integer); emitError=true; key=a; value=3; cmp=eq)</b>:
+ * <table border="1" cellspacing=1 cellpadding=1 summary="Function table for CompareMap&lt;K,V extends Number&gt; operator template">
+ * <tr><th rowspan=2>Tuple Type (api)</th><th>In-bound (process)</th><th>Out-bound (emit)</th></tr>
+ * <tr><th><i>data</i>(Map&lt;K,V&gt;)</th><th><i>compare</i>(HashMap&lt;K,V&gt;)</th></tr>
+ * <tr><td>Begin Window (beginWindow())</td><td>N/A</td><td>N/A</td></tr>
+ * <tr><td>Data (process())</td><td>{a=2,b=20,c=1000}</td><td></td></tr>
+ * <tr><td>Data (process())</td><td>{a=3,b=40,c=2}</td><td>{a=3,b=40,c=2}</td></tr>
+ * <tr><td>Data (process())</td><td>{a=10,b=5}</td><td></td></tr>
+ * <tr><td>Data (process())</td><td>{d=55,b=12}</td><td></td></tr>
+ * <tr><td>Data (process())</td><td>{d=22,a=4}</td><td></td></tr>
+ * <tr><td>Data (process())</td><td>{d=4,a=3,g=5,h=44}</td><td>{d=4,a=3,g=5,h=44}</td></tr>
+ * <tr><td>End Window (endWindow())</td><td>N/A</td><td>N/A</td></tr>
+ * </table>
+ * <br>
+ * <br>
+ * @displayName Compare Map
+ * @category Math
+ * @tags comparison, key value, numeric, map
+ * @since 0.3.2
+ * @deprecated
+ */
+@Deprecated
+@Stateless
+public class CompareMap<K, V extends Number> extends MatchMap<K,V>
+{
+  /**
+   * Output port that emits a hashmap of matching number tuples after comparison.
+   */
+  public final transient DefaultOutputPort<HashMap<K, V>> compare = match;
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/CountKeyVal.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/CountKeyVal.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/CountKeyVal.java
new file mode 100644
index 0000000..a229796
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/CountKeyVal.java
@@ -0,0 +1,116 @@
+/**
+ * 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.contrib.misc.math;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.lang.mutable.MutableInt;
+
+import com.datatorrent.api.DefaultInputPort;
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.api.StreamCodec;
+import com.datatorrent.api.annotation.OutputPortFieldAnnotation;
+import com.datatorrent.lib.util.BaseKeyValueOperator;
+import com.datatorrent.lib.util.KeyValPair;
+import com.datatorrent.lib.util.UnifierCountOccurKey;
+
+/**
+ * This Operator aggregates occurrence of keys in &lt;key,value&gt; pair at input port.&lt;Key,Occurrence count&gt; pair is emitted for each input on output port.
+ * <p>
+ * <br>
+ * StateFull : Yes, key occurrence is aggregated over windows. <br>
+ * Partitions : Yes, count occurrence unifier at output port. <br>
+ * <br>
+ * <b>Ports</b>:<br>
+ * <b>data</b>: expects KeyValPair&lt;K,V&gt;<br>
+ * <b>count</b>: emits KeyValPair&lt;K,Integer&gt;</b><br>
+ * <br>
+ * @displayName Count Key Value
+ * @category Math
+ * @tags count, key value, aggregate
+ * @since 0.3.3
+ * @deprecated
+ */
+@Deprecated
+public class CountKeyVal<K, V> extends BaseKeyValueOperator<K, V>
+{
+
+  /**
+   * Key occurrence count map.
+   */
+  protected HashMap<K, MutableInt> counts = new HashMap<K, MutableInt>();
+
+  /**
+   * Input data port that takes key value pair.
+   */
+  public final transient DefaultInputPort<KeyValPair<K, V>> data = new DefaultInputPort<KeyValPair<K, V>>()
+  {
+    /**
+     * For each tuple (a key value pair): Adds the values for each key, Counts
+     * the number of occurrence of each key
+     */
+    @Override
+    public void process(KeyValPair<K, V> tuple)
+    {
+      K key = tuple.getKey();
+      MutableInt count = counts.get(key);
+      if (count == null) {
+        count = new MutableInt(0);
+        counts.put(cloneKey(key), count);
+      }
+      count.increment();
+    }
+
+    @Override
+    public StreamCodec<KeyValPair<K, V>> getStreamCodec()
+    {
+      return getKeyValPairStreamCodec();
+    }
+  };
+
+  /**
+   * Key, occurrence value pair output port.
+   */
+  @OutputPortFieldAnnotation(optional = true)
+  public final transient DefaultOutputPort<KeyValPair<K, Integer>> count = new DefaultOutputPort<KeyValPair<K, Integer>>()
+  {
+    @Override
+    public UnifierCountOccurKey<K> getUnifier()
+    {
+      return new UnifierCountOccurKey<K>();
+    }
+  };
+
+  /**
+   * Emits on all ports that are connected. Data is computed during process on
+   * input port and endWindow just emits it for each key. Clears the internal
+   * data if resetAtEndWindow is true.
+   */
+  @SuppressWarnings({ "unchecked", "rawtypes" })
+  @Override
+  public void endWindow()
+  {
+    for (Map.Entry<K, MutableInt> e : counts.entrySet()) {
+      count.emit(new KeyValPair(e.getKey(),
+          new Integer(e.getValue().intValue())));
+    }
+    counts.clear();
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/ExceptMap.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/ExceptMap.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/ExceptMap.java
new file mode 100644
index 0000000..3dcae74
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/ExceptMap.java
@@ -0,0 +1,104 @@
+/**
+ * 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.contrib.misc.math;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.api.annotation.Stateless;
+import com.datatorrent.lib.algo.MatchMap;
+import com.datatorrent.lib.util.UnifierHashMap;
+
+/**
+ * This operator does comparison on tuple sub-classed from Number based on the property "key", "value", and "cmp", and not matched tuples are emitted.
+ * <p>
+ * The comparison is done by getting double value from the Number. Both output ports
+ * are optional, but at least one has to be connected
+ * <p>
+ * This module is a pass through<br>
+ * <br>
+ * <br>
+ * StateFull : No, output is emitted in current window. <br>
+ * Partitions : Yes, No state dependency among input tuples. <br>
+ * <br>
+ * <b>Ports</b>:<br>
+ * <b>data</b>: expects Map&lt;K,V extends Number&gt;<br>
+ * <b>except</b>: emits HashMap&lt;K,V&gt;<br>
+ * <br>
+ * <b>Properties</b>:<br>
+ * <b>key</b>: The key on which compare is done<br>
+ * <b>value</b>: The value to compare with<br>
+ * <b>cmp</b>: The compare function. Supported values are "lte", "lt", "eq",
+ * "neq", "gt", "gte". Default is "eq"<br>
+ * <br>
+ * <b>Compile time checks</b>:<br>
+ * Key must be non empty<br>
+ * Value must be able to convert to a "double"<br>
+ * Compare string, if specified, must be one of "lte", "lt", "eq", "neq", "gt",
+ * "gte"<br>
+ * <br>
+ * <b>Run time checks</b>:<br>
+ * Does the incoming HashMap have the key, Is the value of the key a number<br>
+ * <br>
+ * @displayName Except Map
+ * @category Math
+ * @tags comparison, Number
+ * @since 0.3.3
+ * @deprecated
+ */
+@Deprecated
+@Stateless
+public class ExceptMap<K, V extends Number> extends MatchMap<K, V>
+{       
+        /**
+         * Output port that emits non matching number tuples.
+         */
+  public final transient DefaultOutputPort<HashMap<K, V>> except = new DefaultOutputPort<HashMap<K, V>>()
+  {
+    @Override
+    public Unifier<HashMap<K, V>> getUnifier()
+    {
+      return new UnifierHashMap<K, V>();
+    }
+  };
+
+  /**
+   * Does nothing. Overrides base as call super.tupleMatched() would emit the
+   * tuple
+   *
+   * @param tuple
+   */
+  @Override
+  public void tupleMatched(Map<K, V> tuple)
+  {
+  }
+
+  /**
+   * Emits the tuple. Calls cloneTuple to get a copy, allowing users to override
+   * in case objects are mutable
+   *
+   * @param tuple
+   */
+  @Override
+  public void tupleNotMatched(Map<K, V> tuple)
+  {
+    except.emit(cloneTuple(tuple));
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/Quotient.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/Quotient.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/Quotient.java
new file mode 100644
index 0000000..e1deb9d
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/Quotient.java
@@ -0,0 +1,111 @@
+/**
+ * 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.contrib.misc.math;
+
+import com.datatorrent.api.DefaultInputPort;
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.api.annotation.OperatorAnnotation;
+import com.datatorrent.lib.util.BaseNumberValueOperator;
+
+/**
+ * This operator adds all the values on "numerator" and "denominator" and emits quotient at end of window. 
+ * <p>
+ * <br>
+ * <b>StateFull : Yes </b>, Sum of values is taken over application window. <br>
+ * <b>Partitions : No </b>, will yield wrong results, since values are
+ * accumulated over application window. <br>
+ * <br>
+ * <b>Ports</b>:<br>
+ * <b>numerator</b>: expects V extends Number<br>
+ * <b>denominator</b>: expects V extends Number<br>
+ * <b>quotient</b>: emits Double<br>
+ * <br>
+ * <b>Properties : </b> <br>
+ * <b>mult_by : </b>Multiply by value(default = 1). <br>
+ * <br>
+ * @displayName Quotient
+ * @category Math
+ * @tags division, sum, numeric
+ * @since 0.3.3
+ * @deprecated
+ */
+@Deprecated
+@OperatorAnnotation(partitionable = false)
+public class Quotient<V extends Number> extends BaseNumberValueOperator<V>
+{
+  protected double nval = 0.0;
+  protected double dval = 0.0;
+  int mult_by = 1;
+
+  /**
+   * Numerator values input port.
+   */
+  public final transient DefaultInputPort<V> numerator = new DefaultInputPort<V>()
+  {
+    /**
+     * Adds to the numerator value
+     */
+    @Override
+    public void process(V tuple)
+    {
+      nval += tuple.doubleValue();
+    }
+  };
+
+  /**
+   * Denominator values input port.
+   */
+  public final transient DefaultInputPort<V> denominator = new DefaultInputPort<V>()
+  {
+    /**
+     * Adds to the denominator value
+     */
+    @Override
+    public void process(V tuple)
+    {
+      dval += tuple.doubleValue();
+    }
+  };
+
+  /**
+   * Quotient output port.
+   */
+  public final transient DefaultOutputPort<V> quotient = new DefaultOutputPort<V>();
+
+  public void setMult_by(int i)
+  {
+    mult_by = i;
+  }
+
+  /**
+   * Generates tuple emits it as long as denominator is not 0. Clears internal
+   * data
+   */
+  @Override
+  public void endWindow()
+  {
+    if (dval == 0) {
+      return;
+    }
+    double val = (nval / dval) * mult_by;
+    quotient.emit(getValue(val));
+    nval = 0.0;
+    dval = 0.0;
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/QuotientMap.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/QuotientMap.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/QuotientMap.java
new file mode 100644
index 0000000..3581b81
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/QuotientMap.java
@@ -0,0 +1,239 @@
+/**
+ * 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.contrib.misc.math;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.validation.constraints.Min;
+
+import org.apache.commons.lang.mutable.MutableDouble;
+
+import com.datatorrent.api.DefaultInputPort;
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.api.annotation.OperatorAnnotation;
+import com.datatorrent.lib.util.BaseNumberKeyValueOperator;
+
+/**
+ * Add all the values for each key on "numerator" and "denominator" and emits quotient at end of window for all keys in the denominator. 
+ * <p>
+ * <br>
+ * Application can set multiplication value for quotient(default = 1). <br>
+ * Operator will calculate quotient of occurrence of key in numerator divided by
+ * occurrence of key in denominator if countKey flag is true. <br>
+ * Application can allow or block keys by setting filter key and inverse flag. <br>
+ * <br>
+ * <b>StateFull : Yes</b>, numerator/denominator values are summed over
+ * application window. <br>
+ * <b>Partitions : No, </b>, will yield wrong results, since values are summed
+ * over app window. <br>
+ * <br>
+ * <b>Ports</b>:<br>
+ * <b>numerator</b>: expects Map&lt;K,V extends Number&gt;<br>
+ * <b>denominator</b>: expects Map&lt;K,V extends Number&gt;<br>
+ * <b>quotient</b>: emits HashMap&lt;K,Double&gt;<br>
+ * <br>
+ * <b>Properties</b>:<br>
+ * <b>inverse :</b> if set to true the key in the filter will block tuple<br>
+ * <b>filterBy :</b> List of keys to filter on<br>
+ * <b>countkey :</b> Get quotient of occurrence of keys in numerator and
+ * denominator. <br>
+ * <b>mult_by :</b> Set multiply by constant value. <br>
+ * <br>
+ * @displayName Quotient Map
+ * @category Math
+ * @tags division, sum, map
+ * @since 0.3.3
+ * @deprecated
+ */
+@Deprecated
+@OperatorAnnotation(partitionable = false)
+public class QuotientMap<K, V extends Number> extends
+    BaseNumberKeyValueOperator<K, V>
+{
+  /**
+   * Numerator key/sum value map.
+   */
+  protected HashMap<K, MutableDouble> numerators = new HashMap<K, MutableDouble>();
+
+  /**
+   * Denominator key/sum value map.
+   */
+  protected HashMap<K, MutableDouble> denominators = new HashMap<K, MutableDouble>();
+
+  /**
+   * Count occurrence of keys if set to true.
+   */
+  boolean countkey = false;
+
+  /**
+   * Quotient multiply by value.
+   */
+  int mult_by = 1;
+
+  /**
+   * Numerator input port.
+   */
+  public final transient DefaultInputPort<Map<K, V>> numerator = new DefaultInputPort<Map<K, V>>()
+  {
+    /**
+     * Added tuple to the numerator hash
+     */
+    @Override
+    public void process(Map<K, V> tuple)
+    {
+      addTuple(tuple, numerators);
+    }
+  };
+
+  /**
+   * Denominator input port.
+   */
+  public final transient DefaultInputPort<Map<K, V>> denominator = new DefaultInputPort<Map<K, V>>()
+  {
+    /**
+     * Added tuple to the denominator hash
+     */
+    @Override
+    public void process(Map<K, V> tuple)
+    {
+      addTuple(tuple, denominators);
+    }
+  };
+
+  /**
+   * Quotient output port.
+   */
+  public final transient DefaultOutputPort<HashMap<K, Double>> quotient = new DefaultOutputPort<HashMap<K, Double>>();
+
+  /**
+   * Add tuple to nval/dval map.
+   *
+   * @param tuple
+   *          key/value map on input port.
+   * @param map
+   *          key/summed value map.
+   */
+  public void addTuple(Map<K, V> tuple, Map<K, MutableDouble> map)
+  {
+    for (Map.Entry<K, V> e : tuple.entrySet()) {
+      addEntry(e.getKey(), e.getValue(), map);
+    }
+  }
+
+  /**
+   * Add/Update entry to key/sum value map.
+   *
+   * @param key
+   *          name.
+   * @param value
+   *          value for key.
+   * @param map
+   *          numerator/denominator key/sum map.
+   */
+  public void addEntry(K key, V value, Map<K, MutableDouble> map)
+  {
+    if (!doprocessKey(key) || (value == null)) {
+      return;
+    }
+    MutableDouble val = map.get(key);
+    if (val == null) {
+      if (countkey) {
+        val = new MutableDouble(1.00);
+      } else {
+        val = new MutableDouble(value.doubleValue());
+      }
+    } else {
+      if (countkey) {
+        val.increment();
+      } else {
+        val.add(value.doubleValue());
+      }
+    }
+    map.put(cloneKey(key), val);
+  }
+
+  /**
+   * getter for mult_by
+   *
+   * @return mult_by
+   */
+
+  @Min(0)
+  public int getMult_by()
+  {
+    return mult_by;
+  }
+
+  /**
+   * getter for countkey
+   *
+   * @return countkey
+   */
+  public boolean getCountkey()
+  {
+    return countkey;
+  }
+
+  /**
+   * Setter for mult_by
+   *
+   * @param i
+   */
+  public void setMult_by(int i)
+  {
+    mult_by = i;
+  }
+
+  /**
+   * setter for countkey
+   *
+   * @param i
+   *          sets countkey
+   */
+  public void setCountkey(boolean i)
+  {
+    countkey = i;
+  }
+
+  /**
+   * Generates tuples for each key and emits them. Only keys that are in the
+   * denominator are iterated on If the key is only in the numerator, it gets
+   * ignored (cannot do divide by 0) Clears internal data
+   */
+  @Override
+  public void endWindow()
+  {
+    HashMap<K, Double> tuples = new HashMap<K, Double>();
+    for (Map.Entry<K, MutableDouble> e : denominators.entrySet()) {
+      MutableDouble nval = numerators.get(e.getKey());
+      if (nval == null) {
+        tuples.put(e.getKey(), new Double(0.0));
+      } else {
+        tuples.put(e.getKey(), new Double((nval.doubleValue() / e.getValue()
+            .doubleValue()) * mult_by));
+      }
+    }
+    if (!tuples.isEmpty()) {
+      quotient.emit(tuples);
+    }
+    numerators.clear();
+    denominators.clear();
+  }
+}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/SumCountMap.java
----------------------------------------------------------------------
diff --git a/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/SumCountMap.java b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/SumCountMap.java
new file mode 100644
index 0000000..048eff7
--- /dev/null
+++ b/contrib/src/main/java/org/apache/apex/malhar/contrib/misc/math/SumCountMap.java
@@ -0,0 +1,305 @@
+/**
+ * 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.contrib.misc.math;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.lang.mutable.MutableDouble;
+import org.apache.commons.lang.mutable.MutableInt;
+
+import com.datatorrent.api.DefaultInputPort;
+import com.datatorrent.api.DefaultOutputPort;
+import com.datatorrent.api.annotation.OutputPortFieldAnnotation;
+import com.datatorrent.lib.util.BaseNumberKeyValueOperator;
+import com.datatorrent.lib.util.UnifierHashMapInteger;
+import com.datatorrent.lib.util.UnifierHashMapSumKeys;
+
+/**
+ * Emits the sum and count of values for each key at the end of window.
+ * <p>
+ * Application accumulate sum across streaming window by setting cumulative flag
+ * to true. <br>
+ * This is an end of window operator<br>
+ * <br>
+ * <b>StateFull : Yes</b>, Sum is computed over application window and streaming
+ * window. <br>
+ * <b>Partitions : Yes</b>, Sum is unified at output port. <br>
+ * <br>
+ * <b>Ports</b>:<br>
+ * <b>data</b>: expects Map&lt;K,V extends Number&gt;<br>
+ * <b>sum</b>: emits HashMap&lt;K,V&gt;<br>
+ * <b>count</b>: emits HashMap&lt;K,Integer&gt;</b><br>
+ * <br>
+ * <b>Properties</b>:<br>
+ * <b>inverse</b>: if set to true the key in the filter will block tuple<br>
+ * <b>filterBy</b>: List of keys to filter on<br>
+ * <b>cumulative</b>: boolean flag, if set the sum is not cleared at the end of
+ * window, <br>
+ * hence generating cumulative sum across streaming windows. Default is false.<br>
+ * <br>
+ * @displayName Sum Count Map
+ * @category Math
+ * @tags  number, sum, counting, map
+ * @since 0.3.3
+ * @deprecated
+ */
+@Deprecated
+public class SumCountMap<K, V extends Number> extends
+    BaseNumberKeyValueOperator<K, V>
+{
+  /**
+   * Key/double sum map.
+   */
+  protected HashMap<K, MutableDouble> sums = new HashMap<K, MutableDouble>();
+
+  /**
+   * Key/integer sum map.
+   */
+  protected HashMap<K, MutableInt> counts = new HashMap<K, MutableInt>();
+
+  /**
+   * Cumulative sum flag.
+   */
+  protected boolean cumulative = false;
+
+  /**
+   * Input port that takes a map.&nbsp; It adds the values for each key and counts the number of occurrences for each key.
+   */
+  public final transient DefaultInputPort<Map<K, V>> data = new DefaultInputPort<Map<K, V>>()
+  {
+    /**
+     * For each tuple (a HashMap of keys,val pairs) Adds the values for each
+     * key, Counts the number of occurrences of each key
+     */
+    @Override
+    public void process(Map<K, V> tuple)
+    {
+      for (Map.Entry<K, V> e : tuple.entrySet()) {
+        K key = e.getKey();
+        if (!doprocessKey(key)) {
+          continue;
+        }
+        if (sum.isConnected()) {
+          MutableDouble val = sums.get(key);
+          if (val == null) {
+            val = new MutableDouble(e.getValue().doubleValue());
+          } else {
+            val.add(e.getValue().doubleValue());
+          }
+          sums.put(cloneKey(key), val);
+        }
+        if (SumCountMap.this.count.isConnected()) {
+          MutableInt count = counts.get(key);
+          if (count == null) {
+            count = new MutableInt(0);
+            counts.put(cloneKey(key), count);
+          }
+          count.increment();
+        }
+      }
+    }
+  };
+
+  /**
+   * Key,sum map output port.
+   */
+  @OutputPortFieldAnnotation(optional = true)
+  public final transient DefaultOutputPort<HashMap<K, V>> sum = new DefaultOutputPort<HashMap<K, V>>()
+  {
+    @Override
+    public Unifier<HashMap<K, V>> getUnifier()
+    {
+      return new UnifierHashMapSumKeys<K, V>();
+    }
+  };
+
+  /**
+   * Key,double sum map output port.
+   */
+  @OutputPortFieldAnnotation(optional = true)
+  public final transient DefaultOutputPort<HashMap<K, Double>> sumDouble = new DefaultOutputPort<HashMap<K, Double>>()
+  {
+    @SuppressWarnings({ "rawtypes", "unchecked" })
+    @Override
+    public Unifier<HashMap<K, Double>> getUnifier()
+    {
+      UnifierHashMapSumKeys ret = new UnifierHashMapSumKeys<K, Double>();
+      ret.setType(Double.class);
+      return ret;
+    }
+  };
+
+  /**
+   * Key,integer sum output port.
+   */
+  @OutputPortFieldAnnotation(optional = true)
+  public final transient DefaultOutputPort<HashMap<K, Integer>> sumInteger = new DefaultOutputPort<HashMap<K, Integer>>()
+  {
+    @SuppressWarnings({ "rawtypes", "unchecked" })
+    @Override
+    public Unifier<HashMap<K, Integer>> getUnifier()
+    {
+      UnifierHashMapSumKeys ret = new UnifierHashMapSumKeys<K, Integer>();
+      ret.setType(Integer.class);
+      return ret;
+    }
+  };
+
+
+        /**
+   * Key,long sum output port.
+   */
+  @OutputPortFieldAnnotation(optional = true)
+  public final transient DefaultOutputPort<HashMap<K, Long>> sumLong = new DefaultOutputPort<HashMap<K, Long>>()
+  {
+    @SuppressWarnings({ "rawtypes", "unchecked" })
+    @Override
+    public Unifier<HashMap<K, Long>> getUnifier()
+    {
+      UnifierHashMapSumKeys ret = new UnifierHashMapSumKeys<K, Long>();
+      ret.setType(Long.class);
+      return ret;
+    }
+  };
+        
+        /**
+   * Key,short sum output port.
+   */
+  @OutputPortFieldAnnotation(optional = true)
+  public final transient DefaultOutputPort<HashMap<K, Short>> sumShort = new DefaultOutputPort<HashMap<K, Short>>()
+  {
+    @SuppressWarnings({ "rawtypes", "unchecked" })
+    @Override
+    public Unifier<HashMap<K, Short>> getUnifier()
+    {
+      UnifierHashMapSumKeys ret = new UnifierHashMapSumKeys<K, Short>();
+      ret.setType(Short.class);
+      return ret;
+    }
+  };
+        
+        /**
+   * Key,float sum output port.
+   */
+  @OutputPortFieldAnnotation(optional = true)
+  public final transient DefaultOutputPort<HashMap<K, Float>> sumFloat = new DefaultOutputPort<HashMap<K, Float>>()
+  {
+    @SuppressWarnings({ "rawtypes", "unchecked" })
+    @Override
+    public Unifier<HashMap<K, Float>> getUnifier()
+    {
+      UnifierHashMapSumKeys ret = new UnifierHashMapSumKeys<K, Float>();
+      ret.setType(Float.class);
+      return ret;
+    }
+  };
+        
+        /**
+   * Key,integer sum output port.
+   */
+  @OutputPortFieldAnnotation(optional = true)
+  public final transient DefaultOutputPort<HashMap<K, Integer>> count = new DefaultOutputPort<HashMap<K, Integer>>()
+  {
+    @Override
+    public Unifier<HashMap<K, Integer>> getUnifier()
+    {
+      return new UnifierHashMapInteger<K>();
+    }
+  };
+
+  /**
+   * Get cumulative flag.
+   *
+   * @return cumulative flag
+   */
+  public boolean isCumulative()
+  {
+    return cumulative;
+  }
+
+  /**
+   * set cumulative flag.
+   *
+   * @param cumulative
+   *          input flag
+   */
+  public void setCumulative(boolean cumulative)
+  {
+    this.cumulative = cumulative;
+  }
+
+  /**
+   * Emits on all ports that are connected. Data is precomputed during process
+   * on input port endWindow just emits it for each key Clears the internal data
+   * before return
+   */
+  @Override
+  public void endWindow()
+  {
+
+    // Should allow users to send each key as a separate tuple to load balance
+    // This is an aggregate node, so load balancing would most likely not be
+    // needed
+
+    HashMap<K, V> tuples = new HashMap<K, V>();
+    HashMap<K, Integer> ctuples = new HashMap<K, Integer>();
+    HashMap<K, Double> dtuples = new HashMap<K, Double>();
+    HashMap<K, Integer> ituples = new HashMap<K, Integer>();
+    HashMap<K, Float> ftuples = new HashMap<K, Float>();
+    HashMap<K, Long> ltuples = new HashMap<K, Long>();
+    HashMap<K, Short> stuples = new HashMap<K, Short>();
+
+    for (Map.Entry<K, MutableDouble> e : sums.entrySet()) {
+      K key = e.getKey();
+      MutableDouble val = e.getValue();
+      tuples.put(key, getValue(val.doubleValue()));
+      dtuples.put(key, val.doubleValue());
+      ituples.put(key, val.intValue());
+      ftuples.put(key, val.floatValue());
+      ltuples.put(key, val.longValue());
+      stuples.put(key, val.shortValue());
+      // ctuples.put(key, counts.get(e.getKey()).toInteger());
+      MutableInt c = counts.get(e.getKey());
+      if (c != null) {
+        ctuples.put(key, c.toInteger());
+      }
+    }
+
+    sum.emit(tuples);
+    sumDouble.emit(dtuples);
+    sumInteger.emit(ituples);
+    sumLong.emit(ltuples);
+    sumShort.emit(stuples);
+    sumFloat.emit(ftuples);
+    count.emit(ctuples);
+    clearCache();
+  }
+
+  /**
+   * Clear sum maps.
+   */
+  private void clearCache()
+  {
+    if (!cumulative) {
+      sums.clear();
+      counts.clear();
+    }
+  }
+}


[03/12] apex-malhar git commit: Updated algo & working on math operators

Posted by th...@apache.org.
http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/streamquery/index/UnaryExpression.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/streamquery/index/UnaryExpression.java b/library/src/main/java/com/datatorrent/lib/streamquery/index/UnaryExpression.java
deleted file mode 100644
index 45e90ec..0000000
--- a/library/src/main/java/com/datatorrent/lib/streamquery/index/UnaryExpression.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery.index;
-
-import javax.validation.constraints.NotNull;
-
-
-/**
- * A base implementation of an index that filters row by unary expression.&nbsp; Subclasses should provide the
-   implementation of filter/getExpressionName functions.
- * <p>
- * Sub class will implement filter/getExpressionName functions.
- * @displayName Unary Expression
- * @category Stream Manipulators
- * @tags unary, alias
- * @since 0.3.4
- */
-public abstract class UnaryExpression  implements Index
-{
-  /**
-   * Column name argument for unary expression.
-   */
-  @NotNull
-  protected String column;
-
-  /**
-   *  Alias name for output field.
-   */
-  protected String alias;
-
-  /**
-   * @param column name argument for unary expression.
-   * @param alias name for output field.
-   */
-  public UnaryExpression(@NotNull String column, String alias)
-  {
-    this.column = column;
-  }
-
-  public String getColumn()
-  {
-    return column;
-  }
-
-  public void setColumn(String column)
-  {
-    this.column = column;
-  }
-
-  public String getAlias()
-  {
-    return alias;
-  }
-
-  public void setAlias(String alias)
-  {
-    this.alias = alias;
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/streamquery/package-info.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/streamquery/package-info.java b/library/src/main/java/com/datatorrent/lib/streamquery/package-info.java
deleted file mode 100644
index 489915f..0000000
--- a/library/src/main/java/com/datatorrent/lib/streamquery/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- * 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.
- */
-/**
- * Library of operators for streaming query language.
- */
-@org.apache.hadoop.classification.InterfaceStability.Evolving
-package com.datatorrent.lib.streamquery;

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/algo/AbstractStreamPatternMatcherTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/algo/AbstractStreamPatternMatcherTest.java b/library/src/test/java/com/datatorrent/lib/algo/AbstractStreamPatternMatcherTest.java
deleted file mode 100644
index a3d3019..0000000
--- a/library/src/test/java/com/datatorrent/lib/algo/AbstractStreamPatternMatcherTest.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-/**
- *
- * Functional tests for {@link com.datatorrent.lib.algo.AbstractStreamPatternMatcher}<p>
- *
- */
-
-import java.util.Random;
-
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-
-
-public class AbstractStreamPatternMatcherTest
-{
-
-  public static class StreamPatternMatcher<T> extends AbstractStreamPatternMatcher<T>
-  {
-    @Override
-    public void processPatternFound()
-    {
-      outputPort.emit(getPattern().getStates());
-    }
-
-    public transient DefaultOutputPort<T[]> outputPort = new DefaultOutputPort<T[]>();
-  }
-
-  private StreamPatternMatcher<Integer> streamPatternMatcher;
-  private AbstractStreamPatternMatcher.Pattern<Integer> pattern;
-  private Integer[] inputPattern;
-  private CollectorTestSink<Object> sink;
-
-  @Before
-  public void setup()
-  {
-    streamPatternMatcher = new StreamPatternMatcher<Integer>();
-    sink = new CollectorTestSink<Object>();
-    streamPatternMatcher.outputPort.setSink(sink);
-  }
-
-  @After
-  public void cleanup()
-  {
-    streamPatternMatcher.teardown();
-    sink.collectedTuples.clear();
-  }
-
-  @Test
-  public void test() throws Exception
-  {
-    inputPattern = new Integer[]{0, 1, 0, 1, 2};
-    pattern = new AbstractStreamPatternMatcher.Pattern<Integer>(inputPattern);
-    streamPatternMatcher.setPattern(pattern);
-    streamPatternMatcher.setup(null);
-    streamPatternMatcher.beginWindow(0);
-    streamPatternMatcher.inputPort.process(0);
-    streamPatternMatcher.inputPort.process(1);
-    streamPatternMatcher.inputPort.process(1);
-    streamPatternMatcher.inputPort.process(0);
-    streamPatternMatcher.inputPort.process(1);
-    streamPatternMatcher.inputPort.process(0);
-    streamPatternMatcher.inputPort.process(1);
-    streamPatternMatcher.inputPort.process(2);
-    streamPatternMatcher.inputPort.process(1);
-    streamPatternMatcher.endWindow();
-    Assert.assertEquals("The number of tuples emitted is one", 1, sink.collectedTuples.size());
-    Assert.assertEquals("Matching the output pattern with input pattern", inputPattern, sink.collectedTuples.get(0));
-  }
-
-  @Test
-  public void testSimplePattern() throws Exception
-  {
-    inputPattern = new Integer[]{0, 0};
-    pattern = new AbstractStreamPatternMatcher.Pattern<Integer>(inputPattern);
-    streamPatternMatcher.setPattern(pattern);
-    streamPatternMatcher.setup(null);
-    streamPatternMatcher.beginWindow(0);
-    streamPatternMatcher.inputPort.process(0);
-    streamPatternMatcher.inputPort.process(0);
-    streamPatternMatcher.inputPort.process(0);
-    streamPatternMatcher.inputPort.process(1);
-    streamPatternMatcher.inputPort.process(0);
-    streamPatternMatcher.inputPort.process(0);
-    streamPatternMatcher.endWindow();
-    Assert.assertEquals("The number of tuples emitted are three", 3, sink.collectedTuples.size());
-    for (Object object : sink.collectedTuples) {
-      Assert.assertEquals("Matching the output pattern with input pattern", inputPattern, object);
-    }
-  }
-
-  @Test
-  public void testPatternWithSingleState() throws Exception
-  {
-    inputPattern = new Integer[]{0};
-    pattern = new AbstractStreamPatternMatcher.Pattern<Integer>(inputPattern);
-    streamPatternMatcher.setPattern(pattern);
-    streamPatternMatcher.setup(null);
-    streamPatternMatcher.beginWindow(0);
-    streamPatternMatcher.inputPort.process(0);
-    streamPatternMatcher.inputPort.process(0);
-    streamPatternMatcher.inputPort.process(0);
-    streamPatternMatcher.inputPort.process(1);
-    streamPatternMatcher.inputPort.process(0);
-    streamPatternMatcher.inputPort.process(0);
-    streamPatternMatcher.endWindow();
-    Assert.assertEquals("The number of tuples emitted are three", 5, sink.collectedTuples.size());
-    for (Object object : sink.collectedTuples) {
-      Assert.assertEquals("Matching the output pattern with input pattern", inputPattern, object);
-    }
-  }
-
-  @Test
-  public void testAutoGeneratedPattern() throws Exception
-  {
-    Random random = new Random();
-    int patternSize = 15;
-    inputPattern = new Integer[patternSize];
-    int max = 10;
-    int min = 1;
-    int primeNumber = 5;
-    for (int i = 0; i < patternSize; i++) {
-      inputPattern[i] = (min + random.nextInt(max));
-    }
-    pattern = new AbstractStreamPatternMatcher.Pattern<Integer>(inputPattern);
-    streamPatternMatcher.setPattern(pattern);
-    streamPatternMatcher.setup(null);
-    streamPatternMatcher.beginWindow(0);
-    int numberOfIterations = 20;
-    for (int i = 0; i < patternSize; i++) {
-      for (int j = 0; j <= i; j++) {
-        streamPatternMatcher.inputPort.process(inputPattern[j]);
-      }
-      for (int k = 0; k < numberOfIterations; k++) {
-        streamPatternMatcher.inputPort.process(max + min + random.nextInt(max));
-      }
-      if (i % primeNumber == 0) {
-        for (int j = 0; j < patternSize; j++) {
-          streamPatternMatcher.inputPort.process(inputPattern[j]);
-        }
-      }
-    }
-    streamPatternMatcher.endWindow();
-    Assert.assertEquals("The number of tuples emitted ", 1 + patternSize / primeNumber, sink.collectedTuples.size());
-    for (Object output : sink.collectedTuples) {
-      Assert.assertEquals("Matching the output pattern with input pattern", inputPattern, output);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/algo/AllAfterMatchMapTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/algo/AllAfterMatchMapTest.java b/library/src/test/java/com/datatorrent/lib/algo/AllAfterMatchMapTest.java
deleted file mode 100644
index d3d69cf..0000000
--- a/library/src/test/java/com/datatorrent/lib/algo/AllAfterMatchMapTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-/**
- *
- * Functional tests for {@link com.datatorrent.lib.algo.AllAfterMatchMapTest}
- * <p>
- */
-public class AllAfterMatchMapTest
-{
-  /**
-   * Test node logic emits correct results
-   */
-  @Test
-  public void testNodeProcessing() throws Exception
-  {
-    testNodeProcessingSchema(new AllAfterMatchMap<String, Integer>());
-    testNodeProcessingSchema(new AllAfterMatchMap<String, Double>());
-    testNodeProcessingSchema(new AllAfterMatchMap<String, Float>());
-    testNodeProcessingSchema(new AllAfterMatchMap<String, Short>());
-    testNodeProcessingSchema(new AllAfterMatchMap<String, Long>());
-  }
-
-  @SuppressWarnings({ "unchecked", "rawtypes", "unchecked" })
-  public void testNodeProcessingSchema(AllAfterMatchMap oper)
-  {
-    CollectorTestSink allSink = new CollectorTestSink();
-    oper.allafter.setSink(allSink);
-    oper.setKey("a");
-    oper.setValue(3.0);
-    oper.setTypeEQ();
-
-    oper.beginWindow(0);
-    HashMap<String, Number> input = new HashMap<String, Number>();
-    input.put("a", 2);
-    input.put("b", 20);
-    input.put("c", 1000);
-    oper.data.process(input);
-    input.clear();
-    input.put("a", 3);
-    oper.data.process(input);
-
-    input.clear();
-    input.put("b", 6);
-    oper.data.process(input);
-
-    input.clear();
-    input.put("c", 9);
-    oper.data.process(input);
-
-    oper.endWindow();
-
-    Assert.assertEquals("number emitted tuples", 3,
-        allSink.collectedTuples.size());
-    for (Object o : allSink.collectedTuples) {
-      for (Map.Entry<String, Number> e : ((HashMap<String, Number>)o).entrySet()) {
-        if (e.getKey().equals("a")) {
-          Assert.assertEquals("emitted value for 'a' was ", new Double(3), new Double(e.getValue().doubleValue()));
-        } else if (e.getKey().equals("b")) {
-          Assert.assertEquals("emitted tuple for 'b' was ", new Double(6), new Double(e.getValue().doubleValue()));
-        } else if (e.getKey().equals("c")) {
-          Assert.assertEquals("emitted tuple for 'c' was ", new Double(9), new Double(e.getValue().doubleValue()));
-        }
-      }
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/algo/CompareExceptCountMapTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/algo/CompareExceptCountMapTest.java b/library/src/test/java/com/datatorrent/lib/algo/CompareExceptCountMapTest.java
index bc4f4d8..c7c15ff 100644
--- a/library/src/test/java/com/datatorrent/lib/algo/CompareExceptCountMapTest.java
+++ b/library/src/test/java/com/datatorrent/lib/algo/CompareExceptCountMapTest.java
@@ -21,16 +21,16 @@ package com.datatorrent.lib.algo;
 import java.util.HashMap;
 
 import org.junit.Assert;
-
 import org.junit.Test;
 
 import com.datatorrent.lib.testbench.CountAndLastTupleTestSink;
 
 /**
- *
+ * @deprecated
  * Functional tests for {@link com.datatorrent.lib.algo.CompareExceptCountMap} <p>
- *
+ * (Deprecating inclass) Comment: CompareExceptCountMap is deprecated.
  */
+@Deprecated
 public class CompareExceptCountMapTest
 {
   /**

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/algo/DistinctMapTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/algo/DistinctMapTest.java b/library/src/test/java/com/datatorrent/lib/algo/DistinctMapTest.java
deleted file mode 100644
index 249c39d..0000000
--- a/library/src/test/java/com/datatorrent/lib/algo/DistinctMapTest.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.Assert;
-
-import org.junit.Test;
-
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-/**
- *
- * Functional tests for {@link com.datatorrent.lib.algo.DistinctMap}<p>
- *
- */
-public class DistinctMapTest
-{
-  /**
-   * Test node logic emits correct results
-   */
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  @Test
-  public void testNodeProcessing() throws Exception
-  {
-    DistinctMap<String, Number> oper = new DistinctMap<String, Number>();
-
-    CollectorTestSink sortSink = new CollectorTestSink();
-    oper.distinct.setSink(sortSink);
-
-
-    oper.beginWindow(0);
-    HashMap<String, Number> input = new HashMap<String, Number>();
-
-    input.put("a", 2);
-    oper.data.process(input);
-    input.clear();
-    input.put("a", 2);
-    oper.data.process(input);
-
-    input.clear();
-    input.put("a", 1000);
-    oper.data.process(input);
-
-    input.clear();
-    input.put("a", 5);
-    oper.data.process(input);
-
-    input.clear();
-    input.put("a", 2);
-    input.put("b", 33);
-    oper.data.process(input);
-
-    input.clear();
-    input.put("a", 33);
-    input.put("b", 34);
-    oper.data.process(input);
-
-    input.clear();
-    input.put("b", 34);
-    oper.data.process(input);
-
-    input.clear();
-    input.put("b", 6);
-    input.put("a", 2);
-    oper.data.process(input);
-    input.clear();
-    input.put("c", 9);
-    oper.data.process(input);
-    oper.endWindow();
-
-    Assert.assertEquals("number emitted tuples", 8, sortSink.collectedTuples.size());
-    int aval = 0;
-    int bval = 0;
-    int cval = 0;
-    for (Object o: sortSink.collectedTuples) {
-      for (Map.Entry<String, Integer> e: ((HashMap<String, Integer>)o).entrySet()) {
-        String key = e.getKey();
-        if (key.equals("a")) {
-          aval += e.getValue();
-        } else if (key.equals("b")) {
-          bval += e.getValue();
-        } else if (key.equals("c")) {
-          cval += e.getValue();
-        }
-      }
-    }
-    Assert.assertEquals("Total for key \"a\" ", 1040, aval);
-    Assert.assertEquals("Total for key \"a\" ", 73, bval);
-    Assert.assertEquals("Total for key \"a\" ", 9, cval);
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/algo/FilterKeyValsTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/algo/FilterKeyValsTest.java b/library/src/test/java/com/datatorrent/lib/algo/FilterKeyValsTest.java
deleted file mode 100644
index 7069533..0000000
--- a/library/src/test/java/com/datatorrent/lib/algo/FilterKeyValsTest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-/**
- *
- * Functional tests for {@link com.datatorrent.lib.algo.FilterKeyVals}<p>
- *
- */
-public class FilterKeyValsTest
-{
-  @SuppressWarnings("unchecked")
-  int getTotal(List<Object> list)
-  {
-    int ret = 0;
-    for (Object map: list) {
-      for (Map.Entry<String, Number> e: ((HashMap<String, Number>)map).entrySet()) {
-        ret += e.getValue().intValue();
-      }
-    }
-    return ret;
-  }
-
-  /**
-   * Test node logic emits correct results
-   */
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  @Test
-  public void testNodeProcessing() throws Exception
-  {
-    FilterKeyVals<String,Number> oper = new FilterKeyVals<String,Number>();
-
-    CollectorTestSink sortSink = new CollectorTestSink();
-    oper.filter.setSink(sortSink);
-    HashMap<String,Number> filter = new HashMap<String,Number>();
-    filter.put("b",2);
-    oper.setKeyVals(filter);
-    oper.clearKeys();
-
-    filter.clear();
-    filter.put("e", 200);
-    filter.put("f", 2);
-    filter.put("blah", 2);
-    oper.setKeyVals(filter);
-    filter.clear();
-    filter.put("a", 2);
-    oper.setKeyVals(filter);
-
-    oper.beginWindow(0);
-    HashMap<String, Number> input = new HashMap<String, Number>();
-    input.put("a", 2);
-    input.put("b", 5);
-    input.put("c", 7);
-    input.put("d", 42);
-    input.put("e", 202);
-    input.put("e", 200);
-    input.put("f", 2);
-    oper.data.process(input);
-    Assert.assertEquals("number emitted tuples", 3, sortSink.collectedTuples.size());
-    Assert.assertEquals("Total filtered value is ", 204, getTotal(sortSink.collectedTuples));
-    sortSink.clear();
-
-    input.clear();
-    input.put("a", 5);
-    oper.data.process(input);
-    Assert.assertEquals("number emitted tuples", 0, sortSink.collectedTuples.size());
-    sortSink.clear();
-
-    input.clear();
-    input.put("a", 2);
-    input.put("b", 33);
-    input.put("f", 2);
-    oper.data.process(input);
-    Assert.assertEquals("number emitted tuples", 2, sortSink.collectedTuples.size());
-    Assert.assertEquals("Total filtered value is ", 4, getTotal(sortSink.collectedTuples));
-    sortSink.clear();
-
-    input.clear();
-    input.put("b", 6);
-    input.put("a", 2);
-    input.put("j", 6);
-    input.put("e", 2);
-    input.put("dd", 6);
-    input.put("blah", 2);
-    input.put("another", 6);
-    input.put("notmakingit", 2);
-    oper.data.process(input);
-    Assert.assertEquals("number emitted tuples", 2, sortSink.collectedTuples.size());
-    Assert.assertEquals("Total filtered value is ", 4, getTotal(sortSink.collectedTuples));
-    sortSink.clear();
-
-    input.clear();
-    input.put("c", 9);
-    oper.setInverse(true);
-    oper.data.process(input);
-    Assert.assertEquals("number emitted tuples", 1, sortSink.collectedTuples.size());
-    Assert.assertEquals("Total filtered value is ", 9, getTotal(sortSink.collectedTuples));
-
-    oper.endWindow();
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/algo/FilterKeysHashMapTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/algo/FilterKeysHashMapTest.java b/library/src/test/java/com/datatorrent/lib/algo/FilterKeysHashMapTest.java
deleted file mode 100644
index 3ef30f8..0000000
--- a/library/src/test/java/com/datatorrent/lib/algo/FilterKeysHashMapTest.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.Assert;
-
-import org.junit.Test;
-
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-/**
- *
- * Functional tests for {@link com.datatorrent.lib.algo.FilterKeysHashMap}<p>
- *
- */
-public class FilterKeysHashMapTest
-{
-  @SuppressWarnings("unchecked")
-  int getTotal(Object o)
-  {
-    HashMap<String, HashMap<String, Number>> map = (HashMap<String, HashMap<String, Number>>)o;
-    int ret = 0;
-    for (Map.Entry<String, HashMap<String, Number>> e: map.entrySet()) {
-      for (Map.Entry<String, Number> e2: e.getValue().entrySet()) {
-        ret += e2.getValue().intValue();
-      }
-    }
-    return ret;
-  }
-
-  /**
-   * Test node logic emits correct results
-   */
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  @Test
-  public void testNodeProcessing() throws Exception
-  {
-    FilterKeysHashMap<String, Number> oper = new FilterKeysHashMap<String, Number>();
-
-    CollectorTestSink sortSink = new CollectorTestSink();
-    oper.filter.setSink(sortSink);
-    oper.setKey("b");
-    oper.clearKeys();
-    String[] keys = new String[3];
-    keys[0] = "e";
-    keys[1] = "f";
-    keys[2] = "blah";
-    oper.setKey("a");
-    oper.setKeys(keys);
-
-    oper.beginWindow(0);
-    HashMap<String, HashMap<String, Number>> inputA = new HashMap<String, HashMap<String, Number>>();
-    HashMap<String, Number> input = new HashMap<String, Number>();
-    HashMap<String, Number> input2 = new HashMap<String, Number>();
-
-    input.put("a", 2);
-    input.put("b", 5);
-    input.put("c", 7);
-    input.put("d", 42);
-    input.put("e", 200);
-    input.put("f", 2);
-    inputA.put("A", input);
-    oper.data.process(inputA);
-    Assert.assertEquals("number emitted tuples", 1, sortSink.collectedTuples.size());
-    Assert.assertEquals("Total filtered value is ", 204, getTotal(sortSink.collectedTuples.get(0)));
-    sortSink.clear();
-
-    input.clear();
-    inputA.clear();
-    input.put("a", 5);
-    inputA.put("A", input);
-    oper.data.process(inputA);
-    Assert.assertEquals("number emitted tuples", 1, sortSink.collectedTuples.size());
-    Assert.assertEquals("Total filtered value is ", 5, getTotal(sortSink.collectedTuples.get(0)));
-    sortSink.clear();
-
-    input.clear();
-    inputA.clear();
-    input.put("a", 2);
-    input.put("b", 33);
-    input.put("f", 2);
-    inputA.put("A", input);
-    oper.data.process(inputA);
-    Assert.assertEquals("number emitted tuples", 1, sortSink.collectedTuples.size());
-    Assert.assertEquals("Total filtered value is ", 4, getTotal(sortSink.collectedTuples.get(0)));
-    sortSink.clear();
-
-    input.clear();
-    inputA.clear();
-    input.put("b", 6);
-    input.put("a", 2);
-    input.put("j", 6);
-    input.put("e", 2);
-    input.put("dd", 6);
-    input.put("blah", 2);
-    input.put("another", 6);
-    input.put("notmakingit", 2);
-    inputA.put("A", input);
-    oper.data.process(inputA);
-    Assert.assertEquals("number emitted tuples", 1, sortSink.collectedTuples.size());
-    Assert.assertEquals("Total filtered value is ", 6, getTotal(sortSink.collectedTuples.get(0)));
-    sortSink.clear();
-
-    input.clear();
-    inputA.clear();
-    input.put("c", 9);
-    oper.setInverse(true);
-    inputA.put("A", input);
-    oper.data.process(inputA);
-    Assert.assertEquals("number emitted tuples", 1, sortSink.collectedTuples.size());
-    Assert.assertEquals("Total filtered value is ", 9, getTotal(sortSink.collectedTuples.get(0)));
-    sortSink.clear();
-
-    input.clear();
-    input2.clear();
-    inputA.clear();
-    input.put("e", 2); // pass
-    input.put("c", 9);
-    input2.put("a", 5); // pass
-    input2.put("p", 8);
-    oper.setInverse(false);
-    inputA.put("A", input);
-    inputA.put("B", input2);
-    oper.data.process(inputA);
-    Assert.assertEquals("number emitted tuples", 1, sortSink.collectedTuples.size());
-    Assert.assertEquals("Total filtered value is ", 7, getTotal(sortSink.collectedTuples.get(0)));
-    sortSink.clear();
-
-    oper.endWindow();
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/algo/FilterKeysMapTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/algo/FilterKeysMapTest.java b/library/src/test/java/com/datatorrent/lib/algo/FilterKeysMapTest.java
deleted file mode 100644
index f00652e..0000000
--- a/library/src/test/java/com/datatorrent/lib/algo/FilterKeysMapTest.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-/**
- *
- * Functional tests for {@link com.datatorrent.lib.algo.FilterKeysMap}<p>
- *
- */
-public class FilterKeysMapTest
-{
-  @SuppressWarnings("unchecked")
-  int getTotal(Object o)
-  {
-    HashMap<String, Number> map = (HashMap<String, Number>)o;
-    int ret = 0;
-    for (Map.Entry<String, Number> e: map.entrySet()) {
-      ret += e.getValue().intValue();
-    }
-    return ret;
-  }
-
-  /**
-   * Test node logic emits correct results
-   */
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  @Test
-  public void testNodeProcessing() throws Exception
-  {
-    FilterKeysMap<String,Number> oper = new FilterKeysMap<String,Number>();
-
-    CollectorTestSink sortSink = new CollectorTestSink();
-    oper.filter.setSink(sortSink);
-    oper.setKey("b");
-    oper.clearKeys();
-    String[] keys = new String[3];
-    keys[0] = "e";
-    keys[1] = "f";
-    keys[2] = "blah";
-    oper.setKey("a");
-    oper.setKeys(keys);
-
-    oper.beginWindow(0);
-    HashMap<String, Number> input = new HashMap<String, Number>();
-
-    input.put("a", 2);
-    input.put("b", 5);
-    input.put("c", 7);
-    input.put("d", 42);
-    input.put("e", 200);
-    input.put("f", 2);
-    oper.data.process(input);
-    Assert.assertEquals("number emitted tuples", 1, sortSink.collectedTuples.size());
-    Assert.assertEquals("Total filtered value is ", 204, getTotal(sortSink.collectedTuples.get(0)));
-    sortSink.clear();
-
-    input.clear();
-    input.put("a", 5);
-    oper.data.process(input);
-    Assert.assertEquals("number emitted tuples", 1, sortSink.collectedTuples.size());
-    Assert.assertEquals("Total filtered value is ", 5, getTotal(sortSink.collectedTuples.get(0)));
-    sortSink.clear();
-
-    input.clear();
-    input.put("a", 2);
-    input.put("b", 33);
-    input.put("f", 2);
-    oper.data.process(input);
-    Assert.assertEquals("number emitted tuples", 1, sortSink.collectedTuples.size());
-    Assert.assertEquals("Total filtered value is ", 4, getTotal(sortSink.collectedTuples.get(0)));
-    sortSink.clear();
-
-    input.clear();
-    input.put("b", 6);
-    input.put("a", 2);
-    input.put("j", 6);
-    input.put("e", 2);
-    input.put("dd", 6);
-    input.put("blah", 2);
-    input.put("another", 6);
-    input.put("notmakingit", 2);
-    oper.data.process(input);
-    Assert.assertEquals("number emitted tuples", 1, sortSink.collectedTuples.size());
-    Assert.assertEquals("Total filtered value is ", 6, getTotal(sortSink.collectedTuples.get(0)));
-    sortSink.clear();
-
-    input.clear();
-    input.put("c", 9);
-    oper.setInverse(true);
-    oper.data.process(input);
-    Assert.assertEquals("number emitted tuples", 1, sortSink.collectedTuples.size());
-    Assert.assertEquals("Total filtered value is ", 9, getTotal(sortSink.collectedTuples.get(0)));
-
-    oper.endWindow();
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/algo/FirstMatchMapTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/algo/FirstMatchMapTest.java b/library/src/test/java/com/datatorrent/lib/algo/FirstMatchMapTest.java
deleted file mode 100644
index 2ec53d8..0000000
--- a/library/src/test/java/com/datatorrent/lib/algo/FirstMatchMapTest.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-import java.util.HashMap;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.datatorrent.lib.testbench.CountAndLastTupleTestSink;
-
-/**
- *
- * Functional tests for {@link com.datatorrent.lib.algo.FirstMatchMap}<p>
- *
- */
-public class FirstMatchMapTest
-{
-  /**
-   * Test node logic emits correct results
-   */
-  @Test
-  public void testNodeProcessing() throws Exception
-  {
-    testNodeProcessingSchema(new FirstMatchMap<String, Integer>());
-    testNodeProcessingSchema(new FirstMatchMap<String, Double>());
-    testNodeProcessingSchema(new FirstMatchMap<String, Float>());
-    testNodeProcessingSchema(new FirstMatchMap<String, Short>());
-    testNodeProcessingSchema(new FirstMatchMap<String, Long>());
-  }
-
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  public void testNodeProcessingSchema(FirstMatchMap oper)
-  {
-    CountAndLastTupleTestSink matchSink = new CountAndLastTupleTestSink();
-    oper.first.setSink(matchSink);
-    oper.setKey("a");
-    oper.setValue(3);
-    oper.setTypeEQ();
-
-    oper.beginWindow(0);
-    HashMap<String, Number> input = new HashMap<String, Number>();
-    input.put("a", 4);
-    input.put("b", 20);
-    input.put("c", 1000);
-    oper.data.process(input);
-    input.put("a", 3);
-    input.put("b", 20);
-    input.put("c", 1000);
-    oper.data.process(input);
-    input.clear();
-    input.put("a", 2);
-    oper.data.process(input);
-    input.clear();
-    input.put("a", 4);
-    input.put("b", 21);
-    input.put("c", 1000);
-    oper.data.process(input);
-    input.clear();
-    input.put("a", 4);
-    input.put("b", 20);
-    input.put("c", 5);
-    oper.data.process(input);
-    oper.endWindow();
-
-    Assert.assertEquals("number emitted tuples", 1, matchSink.count);
-    HashMap<String, Number> tuple = (HashMap<String, Number>)matchSink.tuple;
-    Number aval = tuple.get("a");
-    Assert.assertEquals("Value of a was ", 3, aval.intValue());
-    matchSink.clear();
-
-    oper.beginWindow(0);
-    input.clear();
-    input.put("a", 2);
-    input.put("b", 20);
-    input.put("c", 1000);
-    oper.data.process(input);
-    input.clear();
-    input.put("a", 5);
-    oper.data.process(input);
-    oper.endWindow();
-    // There should be no emit as all tuples do not match
-    Assert.assertEquals("number emitted tuples", 0, matchSink.count);
-    matchSink.clear();
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/algo/FirstNTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/algo/FirstNTest.java b/library/src/test/java/com/datatorrent/lib/algo/FirstNTest.java
deleted file mode 100644
index e118459..0000000
--- a/library/src/test/java/com/datatorrent/lib/algo/FirstNTest.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.Assert;
-
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-/**
- *
- * Functional tests for {@link com.datatorrent.lib.algo.FirstN}<p>
- */
-public class FirstNTest
-{
-  private static Logger log = LoggerFactory.getLogger(FirstNTest.class);
-
-  /**
-   * Test node logic emits correct results
-   */
-  @Test
-  public void testNodeProcessing() throws Exception
-  {
-    testNodeProcessingSchema(new FirstN<String, Integer>());
-    testNodeProcessingSchema(new FirstN<String, Double>());
-    testNodeProcessingSchema(new FirstN<String, Float>());
-    testNodeProcessingSchema(new FirstN<String, Short>());
-    testNodeProcessingSchema(new FirstN<String, Long>());
-  }
-
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  public void testNodeProcessingSchema(FirstN oper)
-  {
-    CollectorTestSink sortSink = new CollectorTestSink();
-    oper.first.setSink(sortSink);
-    oper.setN(3);
-
-    oper.beginWindow(0);
-    HashMap<String, Number> input = new HashMap<String, Number>();
-
-    input.put("a", 2);
-    oper.data.process(input);
-
-    input.clear();
-    input.put("a", 20);
-    oper.data.process(input);
-
-    input.clear();
-    input.put("a", 1000);
-    oper.data.process(input);
-
-    input.clear();
-    input.put("a", 5);
-    oper.data.process(input);
-
-    input.clear();
-    input.put("a", 20);
-    input.put("b", 33);
-    oper.data.process(input);
-
-    input.clear();
-    input.put("a", 33);
-    input.put("b", 34);
-    oper.data.process(input);
-
-    input.clear();
-    input.put("b", 34);
-    input.put("a", 1001);
-    oper.data.process(input);
-
-    input.clear();
-    input.put("b", 6);
-    input.put("a", 1);
-    oper.data.process(input);
-    input.clear();
-    input.put("c", 9);
-    oper.data.process(input);
-    oper.endWindow();
-
-    Assert.assertEquals("number emitted tuples", 7, sortSink.collectedTuples.size());
-    int aval = 0;
-    int bval = 0;
-    int cval = 0;
-    for (Object o : sortSink.collectedTuples) {
-      for (Map.Entry<String, Number> e : ((HashMap<String, Number>)o).entrySet()) {
-        if (e.getKey().equals("a")) {
-          aval += e.getValue().intValue();
-        } else if (e.getKey().equals("b")) {
-          bval += e.getValue().intValue();
-        } else if (e.getKey().equals("c")) {
-          cval += e.getValue().intValue();
-        }
-      }
-    }
-    Assert.assertEquals("Value of \"a\" was ", 1022, aval);
-    Assert.assertEquals("Value of \"a\" was ", 101, bval);
-    Assert.assertEquals("Value of \"a\" was ", 9, cval);
-    log.debug("Done testing round\n");
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/algo/FirstTillMatchTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/algo/FirstTillMatchTest.java b/library/src/test/java/com/datatorrent/lib/algo/FirstTillMatchTest.java
deleted file mode 100644
index 8de42d1..0000000
--- a/library/src/test/java/com/datatorrent/lib/algo/FirstTillMatchTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-import java.util.HashMap;
-
-import org.junit.Assert;
-
-import org.junit.Test;
-
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-/**
- *
- * Functional tests for {@link com.datatorrent.lib.algo.FirstTillMatch}<p>
- *
- */
-public class FirstTillMatchTest
-{
-  /**
-   * Test node logic emits correct results
-   */
-  @Test
-  public void testNodeProcessing() throws Exception
-  {
-    testNodeProcessingSchema(new FirstTillMatch<String, Integer>());
-    testNodeProcessingSchema(new FirstTillMatch<String, Double>());
-    testNodeProcessingSchema(new FirstTillMatch<String, Float>());
-    testNodeProcessingSchema(new FirstTillMatch<String, Short>());
-    testNodeProcessingSchema(new FirstTillMatch<String, Long>());
-  }
-
-  @SuppressWarnings( {"unchecked", "rawtypes"})
-  public void testNodeProcessingSchema(FirstTillMatch oper)
-  {
-    CollectorTestSink matchSink = new CollectorTestSink();
-    oper.first.setSink(matchSink);
-    oper.setKey("a");
-    oper.setValue(3);
-    oper.setTypeEQ();
-
-    oper.beginWindow(0);
-    HashMap<String, Number> input = new HashMap<String, Number>();
-    input.put("a", 4);
-    input.put("b", 20);
-    input.put("c", 1000);
-    oper.data.process(input);
-    input.clear();
-    input.put("a", 2);
-    oper.data.process(input);
-    input.put("a", 3);
-    input.put("b", 20);
-    input.put("c", 1000);
-    oper.data.process(input);
-    input.clear();
-    input.put("a", 4);
-    input.put("b", 21);
-    input.put("c", 1000);
-    oper.data.process(input);
-    input.clear();
-    input.put("a", 6);
-    input.put("b", 20);
-    input.put("c", 5);
-    oper.data.process(input);
-    oper.endWindow();
-
-    Assert.assertEquals("number emitted tuples", 2, matchSink.collectedTuples.size());
-    int atotal = 0;
-    for (Object o: matchSink.collectedTuples) {
-      atotal += ((HashMap<String,Number>)o).get("a").intValue();
-    }
-    Assert.assertEquals("Value of a was ", 6, atotal);
-    matchSink.clear();
-
-    oper.beginWindow(0);
-    input.clear();
-    input.put("a", 2);
-    input.put("b", 20);
-    input.put("c", 1000);
-    oper.data.process(input);
-    input.clear();
-    input.put("a", 5);
-    oper.data.process(input);
-    oper.endWindow();
-    // There should be no emit as all tuples do not match
-    Assert.assertEquals("number emitted tuples", 2, matchSink.collectedTuples.size());
-    atotal = 0;
-    for (Object o: matchSink.collectedTuples) {
-      atotal += ((HashMap<String,Number>)o).get("a").intValue();
-    }
-    Assert.assertEquals("Value of a was ", 7, atotal);
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/algo/InsertSortDescTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/algo/InsertSortDescTest.java b/library/src/test/java/com/datatorrent/lib/algo/InsertSortDescTest.java
deleted file mode 100644
index 1dc5a4f..0000000
--- a/library/src/test/java/com/datatorrent/lib/algo/InsertSortDescTest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-/**
- *
- * Functional tests for {@link com.datatorrent.lib.algo.InsertSortDesc}<p>
- */
-public class InsertSortDescTest
-{
-  private static Logger log = LoggerFactory.getLogger(InsertSortDescTest.class);
-
-  /**
-   * Test node logic emits correct results
-   */
-  @Test
-  public void testNodeProcessing() throws Exception
-  {
-    testNodeProcessingSchema(new InsertSortDesc<Integer>(), "Integer");
-    testNodeProcessingSchema(new InsertSortDesc<Double>(), "Double");
-    testNodeProcessingSchema(new InsertSortDesc<Float>(), "Float");
-    testNodeProcessingSchema(new InsertSortDesc<String>(), "String");
-  }
-
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  public void testNodeProcessingSchema(InsertSortDesc oper, String debug)
-  {
-    //FirstN<String,Float> aoper = new FirstN<String,Float>();
-    CollectorTestSink sortSink = new CollectorTestSink();
-    CollectorTestSink hashSink = new CollectorTestSink();
-    oper.sort.setSink(sortSink);
-    oper.sorthash.setSink(hashSink);
-
-    ArrayList input = new ArrayList();
-
-    oper.beginWindow(0);
-
-    input.add(2);
-    oper.datalist.process(input);
-    oper.data.process(20);
-
-    input.clear();
-    input.add(1000);
-    input.add(5);
-    input.add(20);
-    input.add(33);
-    input.add(33);
-    input.add(34);
-    oper.datalist.process(input);
-
-    input.clear();
-    input.add(34);
-    input.add(1001);
-    input.add(6);
-    input.add(1);
-    input.add(33);
-    input.add(9);
-    oper.datalist.process(input);
-    oper.endWindow();
-
-    Assert.assertEquals("number emitted tuples", 1, sortSink.collectedTuples.size());
-    Assert.assertEquals("number emitted tuples", 1, hashSink.collectedTuples.size());
-    HashMap map = (HashMap)hashSink.collectedTuples.get(0);
-    input = (ArrayList)sortSink.collectedTuples.get(0);
-    for (Object o : input) {
-      log.debug(String.format("%s : %s", o.toString(), map.get(o).toString()));
-    }
-    log.debug(String.format("Tested %s type with %d tuples and %d uniques\n", debug, input.size(), map.size()));
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/algo/InvertIndexArrayTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/algo/InvertIndexArrayTest.java b/library/src/test/java/com/datatorrent/lib/algo/InvertIndexArrayTest.java
deleted file mode 100644
index 9a3ce81..0000000
--- a/library/src/test/java/com/datatorrent/lib/algo/InvertIndexArrayTest.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.datatorrent.api.Sink;
-
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-/**
- *
- * Functional tests for {@link com.datatorrent.lib.algo.InvertIndex} <p>
- *
- */
-public class InvertIndexArrayTest
-{
-  private static Logger log = LoggerFactory.getLogger(InvertIndexArrayTest.class);
-
-  /**
-   * Test oper logic emits correct results
-   */
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  @Test
-  public void testNodeProcessing() throws Exception
-  {
-    InvertIndexArray<String,String> oper = new InvertIndexArray<String,String>();
-    CollectorTestSink indexSink = new CollectorTestSink();
-
-    Sink inSink = oper.data.getSink();
-    oper.index.setSink(indexSink);
-
-    oper.beginWindow(0);
-
-    HashMap<String, ArrayList> input = new HashMap<String, ArrayList>();
-    ArrayList<String> alist = new ArrayList<String>();
-    alist.add("str");
-    alist.add("str1");
-    input.put("a", alist);
-    input.put("b", alist);
-    inSink.put(input);
-
-    alist = new ArrayList<String>();
-    input = new HashMap<String, ArrayList>();
-    alist.add("blah");
-    alist.add("str1");
-    input.put("c", alist);
-    inSink.put(input);
-
-    oper.endWindow();
-
-    Assert.assertEquals("number emitted tuples", 3, indexSink.collectedTuples.size());
-    for (Object o: indexSink.collectedTuples) {
-      log.debug(o.toString());
-      HashMap<String, ArrayList<String>> output = (HashMap<String, ArrayList<String>>)o;
-      for (Map.Entry<String, ArrayList<String>> e: output.entrySet()) {
-        String key = e.getKey();
-        alist = e.getValue();
-        if (key.equals("str1")) {
-          Assert.assertEquals("Index for \"str1\" contains \"a\"", true, alist.contains("a"));
-          Assert.assertEquals("Index for \"str1\" contains \"b\"", true, alist.contains("b"));
-          Assert.assertEquals("Index for \"str1\" contains \"c\"", true, alist.contains("c"));
-
-        } else if (key.equals("str")) {
-          Assert.assertEquals("Index for \"str1\" contains \"a\"", true, alist.contains("a"));
-          Assert.assertEquals("Index for \"str1\" contains \"b\"", true, alist.contains("b"));
-          Assert.assertEquals("Index for \"str1\" contains \"c\"", false, alist.contains("c"));
-
-        } else if (key.equals("blah")) {
-          Assert.assertEquals("Index for \"str1\" contains \"a\"", false, alist.contains("a"));
-          Assert.assertEquals("Index for \"str1\" contains \"b\"", false, alist.contains("b"));
-          Assert.assertEquals("Index for \"str1\" contains \"c\"", true, alist.contains("c"));
-        }
-      }
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/algo/InvertIndexTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/algo/InvertIndexTest.java b/library/src/test/java/com/datatorrent/lib/algo/InvertIndexTest.java
deleted file mode 100644
index 7de8e42..0000000
--- a/library/src/test/java/com/datatorrent/lib/algo/InvertIndexTest.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.datatorrent.api.Sink;
-
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-/**
- *
- * Functional tests for {@link com.datatorrent.lib.algo.InvertIndex} <p>
- *
- */
-public class InvertIndexTest
-{
-  private static Logger log = LoggerFactory.getLogger(InvertIndexTest.class);
-
-  /**
-   * Test oper logic emits correct results
-   */
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  @Test
-  public void testNodeProcessing() throws Exception
-  {
-    InvertIndex<String,String> oper = new InvertIndex<String,String>();
-    CollectorTestSink indexSink = new CollectorTestSink();
-
-    Sink inSink = oper.data.getSink();
-    oper.index.setSink(indexSink);
-
-    oper.beginWindow(0);
-
-    HashMap<String, String> input = new HashMap<String, String>();
-
-    input.put("a", "str");
-    input.put("b", "str");
-    inSink.put(input);
-
-    input.clear();
-    input.put("a", "str1");
-    input.put("b", "str1");
-    inSink.put(input);
-
-    input.clear();
-    input.put("c", "blah");
-    inSink.put(input);
-
-    input.clear();
-    input.put("c", "str1");
-    inSink.put(input);
-    oper.endWindow();
-
-    Assert.assertEquals("number emitted tuples", 3, indexSink.collectedTuples.size());
-    for (Object o: indexSink.collectedTuples) {
-      log.debug(o.toString());
-      HashMap<String, ArrayList<String>> output = (HashMap<String, ArrayList<String>>)o;
-      for (Map.Entry<String, ArrayList<String>> e: output.entrySet()) {
-        String key = e.getKey();
-        ArrayList<String> alist = e.getValue();
-        if (key.equals("str1")) {
-          Assert.assertEquals("Index for \"str1\" contains \"a\"", true, alist.contains("a"));
-          Assert.assertEquals("Index for \"str1\" contains \"b\"", true, alist.contains("b"));
-          Assert.assertEquals("Index for \"str1\" contains \"c\"", true, alist.contains("c"));
-
-        } else if (key.equals("str")) {
-          Assert.assertEquals("Index for \"str1\" contains \"a\"", true, alist.contains("a"));
-          Assert.assertEquals("Index for \"str1\" contains \"b\"", true, alist.contains("b"));
-          Assert.assertEquals("Index for \"str1\" contains \"c\"", false, alist.contains("c"));
-
-        } else if (key.equals("blah")) {
-          Assert.assertEquals("Index for \"str1\" contains \"a\"", false, alist.contains("a"));
-          Assert.assertEquals("Index for \"str1\" contains \"b\"", false, alist.contains("b"));
-          Assert.assertEquals("Index for \"str1\" contains \"c\"", true, alist.contains("c"));
-        }
-      }
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/algo/LastMatchMapTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/algo/LastMatchMapTest.java b/library/src/test/java/com/datatorrent/lib/algo/LastMatchMapTest.java
deleted file mode 100644
index 87ec65a..0000000
--- a/library/src/test/java/com/datatorrent/lib/algo/LastMatchMapTest.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-import java.util.HashMap;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.datatorrent.lib.testbench.CountAndLastTupleTestSink;
-
-/**
- *
- * Functional tests for {@link com.datatorrent.lib.algo.LastMatchMap}<p>
- *
- */
-public class LastMatchMapTest
-{
-  /**
-   * Test node logic emits correct results
-   */
-  @Test
-  public void testNodeProcessing() throws Exception
-  {
-    testNodeProcessingSchema(new LastMatchMap<String, Integer>());
-    testNodeProcessingSchema(new LastMatchMap<String, Double>());
-    testNodeProcessingSchema(new LastMatchMap<String, Float>());
-    testNodeProcessingSchema(new LastMatchMap<String, Short>());
-    testNodeProcessingSchema(new LastMatchMap<String, Long>());
-  }
-
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  public void testNodeProcessingSchema(LastMatchMap oper)
-  {
-    CountAndLastTupleTestSink matchSink = new CountAndLastTupleTestSink();
-    oper.last.setSink(matchSink);
-    oper.setKey("a");
-    oper.setValue(3);
-    oper.setTypeEQ();
-
-    oper.beginWindow(0);
-    HashMap<String, Number> input = new HashMap<String, Number>();
-    input.put("a", 4);
-    input.put("b", 20);
-    input.put("c", 1000);
-    oper.data.process(input);
-    input.put("a", 3);
-    input.put("b", 20);
-    input.put("c", 1000);
-    oper.data.process(input);
-    input.clear();
-    input.put("a", 2);
-    oper.data.process(input);
-    input.clear();
-    input.put("a", 4);
-    input.put("b", 21);
-    input.put("c", 1000);
-    oper.data.process(input);
-    input.clear();
-    input.put("a", 3);
-    input.put("b", 52);
-    input.put("c", 5);
-    oper.data.process(input);
-    oper.endWindow();
-
-    Assert.assertEquals("number emitted tuples", 1, matchSink.count);
-    HashMap<String, Number> tuple = (HashMap<String, Number>)matchSink.tuple;
-    Number aval = tuple.get("a");
-    Number bval = tuple.get("b");
-    Assert.assertEquals("Value of a was ", 3, aval.intValue());
-    Assert.assertEquals("Value of a was ", 52, bval.intValue());
-    matchSink.clear();
-
-    oper.beginWindow(0);
-    input.clear();
-    input.put("a", 2);
-    input.put("b", 20);
-    input.put("c", 1000);
-    oper.data.process(input);
-    input.clear();
-    input.put("a", 5);
-    oper.data.process(input);
-    oper.endWindow();
-    // There should be no emit as all tuples do not match
-    Assert.assertEquals("number emitted tuples", 0, matchSink.count);
-    matchSink.clear();
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/algo/LeastFrequentKeyMapTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/algo/LeastFrequentKeyMapTest.java b/library/src/test/java/com/datatorrent/lib/algo/LeastFrequentKeyMapTest.java
deleted file mode 100644
index 8da56ed..0000000
--- a/library/src/test/java/com/datatorrent/lib/algo/LeastFrequentKeyMapTest.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.datatorrent.lib.testbench.CountAndLastTupleTestSink;
-
-/**
- *
- * Functional tests for {@link com.datatorrent.lib.algo.LeastFrequentKeyMap}<p>
- *
- */
-public class LeastFrequentKeyMapTest
-{
-  /**
-   * Test node logic emits correct results
-   */
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  @Test
-  public void testNodeProcessing() throws Exception
-  {
-    LeastFrequentKeyMap<String, Integer> oper = new LeastFrequentKeyMap<String, Integer>();
-    CountAndLastTupleTestSink matchSink = new CountAndLastTupleTestSink();
-    CountAndLastTupleTestSink listSink = new CountAndLastTupleTestSink();
-    oper.least.setSink(matchSink);
-    oper.list.setSink(listSink);
-
-    oper.beginWindow(0);
-    HashMap<String, Integer> amap = new HashMap<String, Integer>(1);
-    HashMap<String, Integer> bmap = new HashMap<String, Integer>(1);
-    HashMap<String, Integer> cmap = new HashMap<String, Integer>(1);
-    int atot = 5;
-    int btot = 3;
-    int ctot = 6;
-    amap.put("a", null);
-    bmap.put("b", null);
-    cmap.put("c", null);
-    for (int i = 0; i < atot; i++) {
-      oper.data.process(amap);
-    }
-    for (int i = 0; i < btot; i++) {
-      oper.data.process(bmap);
-    }
-    for (int i = 0; i < ctot; i++) {
-      oper.data.process(cmap);
-    }
-    oper.endWindow();
-    Assert.assertEquals("number emitted tuples", 1, matchSink.count);
-    HashMap<String, Integer> tuple = (HashMap<String, Integer>)matchSink.tuple;
-    Integer val = tuple.get("b");
-    Assert.assertEquals("Count of b was ", btot, val.intValue());
-    Assert.assertEquals("number emitted tuples", 1, listSink.count);
-    ArrayList<HashMap<String, Integer>> list = (ArrayList<HashMap<String, Integer>>)listSink.tuple;
-    val = list.get(0).get("b");
-    Assert.assertEquals("Count of b was ", btot, val.intValue());
-
-    matchSink.clear();
-    listSink.clear();
-    oper.beginWindow(0);
-    atot = 5;
-    btot = 10;
-    ctot = 5;
-    for (int i = 0; i < atot; i++) {
-      oper.data.process(amap);
-    }
-    for (int i = 0; i < btot; i++) {
-      oper.data.process(bmap);
-    }
-    for (int i = 0; i < ctot; i++) {
-      oper.data.process(cmap);
-    }
-    oper.endWindow();
-    Assert.assertEquals("number emitted tuples", 1, matchSink.count);
-    Assert.assertEquals("number emitted tuples", 1, listSink.count);
-    list = (ArrayList<HashMap<String, Integer>>)listSink.tuple;
-    int acount = 0;
-    int ccount = 0;
-    for (HashMap<String, Integer> h : list) {
-      val = h.get("a");
-      if (val == null) {
-        ccount = h.get("c");
-      } else {
-        acount = val;
-      }
-    }
-    Assert.assertEquals("Count of a was ", atot, acount);
-    Assert.assertEquals("Count of c was ", ctot, ccount);
-    HashMap<String, Integer> mtuple = (HashMap<String, Integer>)matchSink.tuple;
-    val = mtuple.get("a");
-    if (val == null) {
-      val = mtuple.get("c");
-    }
-    Assert.assertEquals("Count of least frequent key was ", ctot, val.intValue());
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/algo/LeastFrequentKeyValueMapTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/algo/LeastFrequentKeyValueMapTest.java b/library/src/test/java/com/datatorrent/lib/algo/LeastFrequentKeyValueMapTest.java
deleted file mode 100644
index 955a901..0000000
--- a/library/src/test/java/com/datatorrent/lib/algo/LeastFrequentKeyValueMapTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.Assert;
-
-import org.junit.Test;
-
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-/**
- *
- * Functional tests for {@link com.datatorrent.lib.algo.LeastFrequentKeyValueMap}<p>
- *
- */
-public class LeastFrequentKeyValueMapTest
-{
-  /**
-   * Test node logic emits correct results
-   */
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  @Test
-  public void testNodeProcessing() throws Exception
-  {
-    LeastFrequentKeyValueMap<String, Integer> oper = new LeastFrequentKeyValueMap<String, Integer>();
-    CollectorTestSink matchSink = new CollectorTestSink();
-    oper.least.setSink(matchSink);
-
-    oper.beginWindow(0);
-    HashMap<String, Integer> amap = new HashMap<String, Integer>(1);
-    HashMap<String, Integer> bmap = new HashMap<String, Integer>(1);
-    HashMap<String, Integer> cmap = new HashMap<String, Integer>(1);
-    int atot1 = 5;
-    int btot1 = 3;
-    int ctot1 = 6;
-    amap.put("a", 1);
-    bmap.put("b", 2);
-    cmap.put("c", 4);
-    for (int i = 0; i < atot1; i++) {
-      oper.data.process(amap);
-    }
-    for (int i = 0; i < btot1; i++) {
-      oper.data.process(bmap);
-    }
-    for (int i = 0; i < ctot1; i++) {
-      oper.data.process(cmap);
-    }
-
-    atot1 = 4;
-    btot1 = 3;
-    ctot1 = 10;
-    amap.put("a", 5);
-    bmap.put("b", 4);
-    cmap.put("c", 3);
-    for (int i = 0; i < atot1; i++) {
-      oper.data.process(amap);
-    }
-    for (int i = 0; i < btot1; i++) {
-      oper.data.process(bmap);
-    }
-    for (int i = 0; i < ctot1; i++) {
-      oper.data.process(cmap);
-    }
-
-    oper.endWindow();
-    Assert.assertEquals("number emitted tuples", 3, matchSink.collectedTuples.size());
-    int vcount;
-    for (Object o: matchSink.collectedTuples) {
-      HashMap<String, HashMap<Integer, Integer>> omap = (HashMap<String, HashMap<Integer, Integer>>)o;
-      for (Map.Entry<String, HashMap<Integer, Integer>> e: omap.entrySet()) {
-        String key = e.getKey();
-        if (key.equals("a")) {
-          vcount = e.getValue().get(5);
-          Assert.assertEquals("Key \"a\" has value ", 4, vcount);
-
-        } else if (key.equals("b")) {
-          vcount = e.getValue().get(2);
-          Assert.assertEquals("Key \"a\" has value ", 3, vcount);
-          vcount = e.getValue().get(4);
-          Assert.assertEquals("Key \"a\" has value ", 3, vcount);
-
-        } else if (key.equals("c")) {
-          vcount = e.getValue().get(4);
-          Assert.assertEquals("Key \"a\" has value ", 6, vcount);
-        }
-      }
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/algo/MatchAllMapTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/algo/MatchAllMapTest.java b/library/src/test/java/com/datatorrent/lib/algo/MatchAllMapTest.java
index 15e7b3a..047acb6 100644
--- a/library/src/test/java/com/datatorrent/lib/algo/MatchAllMapTest.java
+++ b/library/src/test/java/com/datatorrent/lib/algo/MatchAllMapTest.java
@@ -26,10 +26,11 @@ import org.junit.Test;
 import com.datatorrent.lib.testbench.CountAndLastTupleTestSink;
 
 /**
- *
+ * @deprecated
  * Functional tests for {@link com.datatorrent.lib.algo.MatchAllMap}<p>
- *
+ * (Deprecating inclass) Comment: MatchAllMap is deprecated.
  */
+@Deprecated
 public class MatchAllMapTest
 {
   /**

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/algo/MatchAnyMapTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/algo/MatchAnyMapTest.java b/library/src/test/java/com/datatorrent/lib/algo/MatchAnyMapTest.java
index 5dfd9ea..12e3c76 100644
--- a/library/src/test/java/com/datatorrent/lib/algo/MatchAnyMapTest.java
+++ b/library/src/test/java/com/datatorrent/lib/algo/MatchAnyMapTest.java
@@ -21,16 +21,16 @@ package com.datatorrent.lib.algo;
 import java.util.HashMap;
 
 import org.junit.Assert;
-
 import org.junit.Test;
 
 import com.datatorrent.lib.testbench.CountAndLastTupleTestSink;
 
 /**
- *
+ * @deprecated
  * Functional tests for {@link com.datatorrent.lib.algo.MatchAnyMap}<p>
- *
+ * (Deprecating inclass) Comment: MatchAnyMap is deprecated.
  */
+@Deprecated
 public class MatchAnyMapTest
 {
   /**

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/algo/MatchMapTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/algo/MatchMapTest.java b/library/src/test/java/com/datatorrent/lib/algo/MatchMapTest.java
deleted file mode 100644
index ecd5e9b..0000000
--- a/library/src/test/java/com/datatorrent/lib/algo/MatchMapTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.datatorrent.lib.testbench.CountAndLastTupleTestSink;
-
-/**
- *
- * Functional tests for {@link com.datatorrent.lib.algo.MatchMap}<p>
- *
- */
-public class MatchMapTest
-{
-  /**
-   * Test node logic emits correct results
-   */
-  @Test
-  public void testNodeProcessing() throws Exception
-  {
-    testNodeProcessingSchema(new MatchMap<String, Integer>());
-    testNodeProcessingSchema(new MatchMap<String, Double>());
-    testNodeProcessingSchema(new MatchMap<String, Float>());
-    testNodeProcessingSchema(new MatchMap<String, Short>());
-    testNodeProcessingSchema(new MatchMap<String, Long>());
-  }
-
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  public void testNodeProcessingSchema(MatchMap oper)
-  {
-    CountAndLastTupleTestSink matchSink = new CountAndLastTupleTestSink();
-    oper.match.setSink(matchSink);
-    oper.setKey("a");
-    oper.setValue(3.0);
-    oper.setTypeNEQ();
-
-    oper.beginWindow(0);
-    HashMap<String, Number> input = new HashMap<String, Number>();
-    input.put("a", 2);
-    input.put("b", 20);
-    input.put("c", 1000);
-    oper.data.process(input);
-    input.clear();
-    input.put("a", 3);
-    oper.data.process(input);
-    oper.endWindow();
-
-    // One for each key
-    Assert.assertEquals("number emitted tuples", 1, matchSink.count);
-    for (Map.Entry<String, Number> e : ((HashMap<String, Number>)matchSink.tuple).entrySet()) {
-      if (e.getKey().equals("a")) {
-        Assert.assertEquals("emitted value for 'a' was ", new Double(2), new Double(e.getValue().doubleValue()));
-      } else if (e.getKey().equals("b")) {
-        Assert.assertEquals("emitted tuple for 'b' was ", new Double(20), new Double(e.getValue().doubleValue()));
-      } else if (e.getKey().equals("c")) {
-        Assert.assertEquals("emitted tuple for 'c' was ", new Double(1000), new Double(e.getValue().doubleValue()));
-      }
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/algo/MergeSortNumberTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/algo/MergeSortNumberTest.java b/library/src/test/java/com/datatorrent/lib/algo/MergeSortNumberTest.java
index 4701957..b9991bd 100644
--- a/library/src/test/java/com/datatorrent/lib/algo/MergeSortNumberTest.java
+++ b/library/src/test/java/com/datatorrent/lib/algo/MergeSortNumberTest.java
@@ -29,9 +29,11 @@ import com.datatorrent.lib.testbench.CollectorTestSink;
 import static org.junit.Assert.assertTrue;
 
 /**
- *
+ * @deprecated
  * Functional tests for {@link com.datatorrent.lib.algo.MergeSort}<p>
+ *   (Deprecating inclass) Comment: MergeSortNumber is deprecated.
  */
+@Deprecated
 public class MergeSortNumberTest
 {
   /**

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/algo/MostFrequentKeyMapTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/algo/MostFrequentKeyMapTest.java b/library/src/test/java/com/datatorrent/lib/algo/MostFrequentKeyMapTest.java
deleted file mode 100644
index 6851e4a..0000000
--- a/library/src/test/java/com/datatorrent/lib/algo/MostFrequentKeyMapTest.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-
-import org.junit.Assert;
-
-import org.junit.Test;
-
-import com.datatorrent.lib.testbench.CountAndLastTupleTestSink;
-
-/**
- *
- * Functional tests for {@link com.datatorrent.lib.algo.MostFrequentKeyMap}<p>
- *
- */
-public class MostFrequentKeyMapTest
-{
-  /**
-   * Test node logic emits correct results
-   */
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  @Test
-  public void testNodeProcessing() throws Exception
-  {
-    MostFrequentKeyMap<String, Integer> oper = new MostFrequentKeyMap<String, Integer>();
-    CountAndLastTupleTestSink matchSink = new CountAndLastTupleTestSink();
-    CountAndLastTupleTestSink listSink = new CountAndLastTupleTestSink();
-    oper.most.setSink(matchSink);
-    oper.list.setSink(listSink);
-
-    oper.beginWindow(0);
-    HashMap<String, Integer> amap = new HashMap<String, Integer>(1);
-    HashMap<String, Integer> bmap = new HashMap<String, Integer>(1);
-    HashMap<String, Integer> cmap = new HashMap<String, Integer>(1);
-    int atot = 5;
-    int btot = 7;
-    int ctot = 6;
-    amap.put("a", null);
-    bmap.put("b", null);
-    cmap.put("c", null);
-    for (int i = 0; i < atot; i++) {
-      oper.data.process(amap);
-    }
-    for (int i = 0; i < btot; i++) {
-      oper.data.process(bmap);
-    }
-    for (int i = 0; i < ctot; i++) {
-      oper.data.process(cmap);
-    }
-    oper.endWindow();
-    Assert.assertEquals("number emitted tuples", 1, matchSink.count);
-    HashMap<String, Integer> tuple = (HashMap<String, Integer>)matchSink.tuple;
-    Integer val = tuple.get("b");
-    Assert.assertEquals("Count of b was ", btot, val.intValue());
-    Assert.assertEquals("number emitted tuples", 1, listSink.count);
-    ArrayList<HashMap<String, Integer>> list = (ArrayList<HashMap<String, Integer>>)listSink.tuple;
-    val = list.get(0).get("b");
-    Assert.assertEquals("Count of b was ", btot, val.intValue());
-
-    matchSink.clear();
-    listSink.clear();
-    oper.beginWindow(0);
-    atot = 5;
-    btot = 4;
-    ctot = 5;
-    for (int i = 0; i < atot; i++) {
-      oper.data.process(amap);
-    }
-    for (int i = 0; i < btot; i++) {
-      oper.data.process(bmap);
-    }
-    for (int i = 0; i < ctot; i++) {
-      oper.data.process(cmap);
-    }
-    oper.endWindow();
-    Assert.assertEquals("number emitted tuples", 1, matchSink.count);
-    Assert.assertEquals("number emitted tuples", 1, listSink.count);
-    list = (ArrayList<HashMap<String, Integer>>)listSink.tuple;
-    int acount = 0;
-    int ccount = 0;
-    for (HashMap<String, Integer> h : list) {
-      val = h.get("a");
-      if (val == null) {
-        ccount = h.get("c");
-      } else {
-        acount = val;
-      }
-    }
-    Assert.assertEquals("Count of a was ", atot, acount);
-    Assert.assertEquals("Count of c was ", ctot, ccount);
-    HashMap<String, Integer> mtuple = (HashMap<String, Integer>)matchSink.tuple;
-    val = mtuple.get("a");
-    if (val == null) {
-      val = mtuple.get("c");
-    }
-    Assert.assertEquals("Count of least frequent key was ", ctot, val.intValue());
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/algo/MostFrequentKeyValueMapTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/algo/MostFrequentKeyValueMapTest.java b/library/src/test/java/com/datatorrent/lib/algo/MostFrequentKeyValueMapTest.java
deleted file mode 100644
index 5a72a5c..0000000
--- a/library/src/test/java/com/datatorrent/lib/algo/MostFrequentKeyValueMapTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.Assert;
-
-import org.junit.Test;
-
-import com.datatorrent.lib.testbench.CollectorTestSink;
-
-/**
- *
- * Functional tests for {@link com.datatorrent.lib.algo.MostFrequentKeyValueMap}<p>
- *
- */
-public class MostFrequentKeyValueMapTest
-{
-  /**
-   * Test node logic emits correct results
-   */
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  @Test
-  public void testNodeProcessing() throws Exception
-  {
-    MostFrequentKeyValueMap<String, Integer> oper = new MostFrequentKeyValueMap<String, Integer>();
-    CollectorTestSink matchSink = new CollectorTestSink();
-    oper.most.setSink(matchSink);
-
-    oper.beginWindow(0);
-    HashMap<String, Integer> amap = new HashMap<String, Integer>(1);
-    HashMap<String, Integer> bmap = new HashMap<String, Integer>(1);
-    HashMap<String, Integer> cmap = new HashMap<String, Integer>(1);
-    int atot1 = 5;
-    int btot1 = 3;
-    int ctot1 = 6;
-    amap.put("a", 1);
-    bmap.put("b", 2);
-    cmap.put("c", 4);
-    for (int i = 0; i < atot1; i++) {
-      oper.data.process(amap);
-    }
-    for (int i = 0; i < btot1; i++) {
-      oper.data.process(bmap);
-    }
-    for (int i = 0; i < ctot1; i++) {
-      oper.data.process(cmap);
-    }
-
-    atot1 = 4;
-    btot1 = 3;
-    ctot1 = 10;
-    amap.put("a", 5);
-    bmap.put("b", 4);
-    cmap.put("c", 3);
-    for (int i = 0; i < atot1; i++) {
-      oper.data.process(amap);
-    }
-    for (int i = 0; i < btot1; i++) {
-      oper.data.process(bmap);
-    }
-    for (int i = 0; i < ctot1; i++) {
-      oper.data.process(cmap);
-    }
-
-    oper.endWindow();
-    Assert.assertEquals("number emitted tuples", 3, matchSink.collectedTuples.size());
-    int vcount;
-    for (Object o: matchSink.collectedTuples) {
-      HashMap<String, HashMap<Integer, Integer>> omap = (HashMap<String, HashMap<Integer, Integer>>)o;
-      for (Map.Entry<String, HashMap<Integer, Integer>> e: omap.entrySet()) {
-        String key = e.getKey();
-        if (key.equals("a")) {
-          vcount = e.getValue().get(1);
-          Assert.assertEquals("Key \"a\" has value ", 5, vcount);
-
-        } else if (key.equals("b")) {
-          vcount = e.getValue().get(2);
-          Assert.assertEquals("Key \"a\" has value ", 3, vcount);
-          vcount = e.getValue().get(4);
-          Assert.assertEquals("Key \"a\" has value ", 3, vcount);
-
-        } else if (key.equals("c")) {
-          vcount = e.getValue().get(3);
-          Assert.assertEquals("Key \"a\" has value ", 10, vcount);
-        }
-      }
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/algo/SamplerTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/algo/SamplerTest.java b/library/src/test/java/com/datatorrent/lib/algo/SamplerTest.java
deleted file mode 100644
index 10a7f3d..0000000
--- a/library/src/test/java/com/datatorrent/lib/algo/SamplerTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * 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 com.datatorrent.lib.algo;
-
-import org.junit.Assert;
-
-import org.junit.Test;
-
-import com.datatorrent.lib.testbench.CountTestSink;
-
-/**
- *
- * Functional tests for {@link com.datatorrent.lib.algo.Sampler}<p>
- *
- */
-public class SamplerTest
-{
-  /**
-   * Test node logic emits correct results
-   */
-  @SuppressWarnings({ "rawtypes", "unchecked" })
-  @Test
-  public void testNodeProcessing() throws Exception
-  {
-    Sampler<String> oper = new Sampler<String>();
-    CountTestSink sink = new CountTestSink<String>();
-    oper.sample.setSink(sink);
-    oper.setSamplingPercentage(.1);
-
-    String tuple = "a";
-
-
-    int numTuples = 10000;
-    oper.beginWindow(0);
-    for (int i = 0; i < numTuples; i++) {
-      oper.data.process(tuple);
-    }
-
-    oper.endWindow();
-    int lowerlimit = 5;
-    int upperlimit = 15;
-    int actual = (100 * sink.count) / numTuples;
-
-    Assert.assertEquals("number emitted tuples", true, lowerlimit < actual);
-    Assert.assertEquals("number emitted tuples", true, upperlimit > actual);
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/algo/TopNUniqueTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/algo/TopNUniqueTest.java b/library/src/test/java/com/datatorrent/lib/algo/TopNUniqueTest.java
index 601cb3b..8181b2d 100644
--- a/library/src/test/java/com/datatorrent/lib/algo/TopNUniqueTest.java
+++ b/library/src/test/java/com/datatorrent/lib/algo/TopNUniqueTest.java
@@ -30,10 +30,11 @@ import org.slf4j.LoggerFactory;
 import com.datatorrent.lib.testbench.CollectorTestSink;
 
 /**
- *
+ * @deprecated
  * Functional tests for {@link com.datatorrent.lib.algo.TopNUnique}<p>
- *
+ * (Deprecating inclass) Comment: TopNUnique is deprecated.
  */
+@Deprecated
 public class TopNUniqueTest
 {
   private static Logger log = LoggerFactory.getLogger(TopNUniqueTest.class);

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/test/java/com/datatorrent/lib/join/AntiJoinOperatorTest.java
----------------------------------------------------------------------
diff --git a/library/src/test/java/com/datatorrent/lib/join/AntiJoinOperatorTest.java b/library/src/test/java/com/datatorrent/lib/join/AntiJoinOperatorTest.java
index 4241a80..e71074e 100644
--- a/library/src/test/java/com/datatorrent/lib/join/AntiJoinOperatorTest.java
+++ b/library/src/test/java/com/datatorrent/lib/join/AntiJoinOperatorTest.java
@@ -19,6 +19,7 @@
 package com.datatorrent.lib.join;
 
 import java.util.HashMap;
+
 import org.junit.Assert;
 import org.junit.Test;
 


[04/12] apex-malhar git commit: Updated algo & working on math operators

Posted by th...@apache.org.
http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/streamquery/OrderByOperator.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/streamquery/OrderByOperator.java b/library/src/main/java/com/datatorrent/lib/streamquery/OrderByOperator.java
deleted file mode 100644
index 18d9928..0000000
--- a/library/src/main/java/com/datatorrent/lib/streamquery/OrderByOperator.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery;
-
-import java.util.ArrayList;
-import java.util.Map;
-
-import com.datatorrent.api.Context.OperatorContext;
-import com.datatorrent.api.DefaultInputPort;
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.api.Operator;
-import com.datatorrent.api.Operator.Unifier;
-
-/**
- *  An implementation of Operator that provides sql order by operator semantic over live stream data. <br>
- * <p>
- * Input data rows are ordered by order rules, ordered result is emitted on output port. <br>
- * <br>
- *  *  <br>
- *  <b>StateFull : Yes,</b> Operator aggregates input over application window. <br>
- *  <b>Partitions : Yes, </b> This operator is also unifier on output port. <br>
- *  <br>
- * <b>Ports</b>:<br>
- * <b> inport : </b> Input hash map(row) port, expects HashMap&lt;String,Object&gt;<<br>
- * <b> outport : </b> Output hash map(row) port, emits  HashMap&lt;String,Object&gt;<br>
- * <br>
- * <b> Properties : </b> <br>
- * <b> orderByRules : </b>List of order by rules for tuples.
- * @displayName OrderBy
- * @category Stream Manipulators
- * @tags orderby operator
- * @since 0.3.5
- */
-public class OrderByOperator implements Operator, Unifier<Map<String, Object>>
-{
-  /**
-   * Order by rules.
-   */
-  ArrayList<OrderByRule<?>> orderByRules = new ArrayList<OrderByRule<?>>();
-
-  /**
-   * Descending flag.
-   */
-  private boolean isDescending;
-
-  /**
-   * collected rows.
-   */
-  private ArrayList<Map<String, Object>> rows;
-
-  /**
-   * Add order by rule.
-   */
-  public void addOrderByRule(OrderByRule<?> rule)
-  {
-    orderByRules.add(rule);
-  }
-
-  /**
-   * @return isDescending
-   */
-  public boolean isDescending()
-  {
-    return isDescending;
-  }
-
-  /**
-   * @param isDescending isDescending
-   */
-  public void setDescending(boolean isDescending)
-  {
-    this.isDescending = isDescending;
-  }
-
-  @Override
-  public void process(Map<String, Object> tuple)
-  {
-    rows.add(tuple);
-  }
-
-  @Override
-  public void beginWindow(long arg0)
-  {
-    rows = new ArrayList<Map<String, Object>>();
-  }
-
-  @Override
-  public void endWindow()
-  {
-    for (int i = 0; i < orderByRules.size(); i++) {
-      rows = orderByRules.get(i).sort(rows);
-    }
-    if (isDescending) {
-      for (int i = 0; i < rows.size(); i++) {
-        outport.emit(rows.get(i));
-      }
-    } else {
-      for (int i = rows.size() - 1; i >= 0; i--) {
-        outport.emit(rows.get(i));
-      }
-    }
-  }
-
-  @Override
-  public void setup(OperatorContext arg0)
-  {
-    // TODO Auto-generated method stub
-
-  }
-
-  @Override
-  public void teardown()
-  {
-    // TODO Auto-generated method stub
-
-  }
-
-  /**
-   * Input port that takes a map of &lt;string,object&gt;.
-   */
-  public final transient DefaultInputPort<Map<String, Object>> inport = new DefaultInputPort<Map<String, Object>>()
-  {
-    @Override
-    public void process(Map<String, Object> tuple)
-    {
-      rows.add(tuple);
-    }
-  };
-
-  /**
-   * Output port that emits a map of &lt;string,object&gt;.
-   */
-  public final transient DefaultOutputPort<Map<String, Object>> outport = new DefaultOutputPort<Map<String, Object>>()
-  {
-    @Override
-    public Unifier<Map<String, Object>> getUnifier()
-    {
-      OrderByOperator unifier = new OrderByOperator();
-      for (int i = 0; i < getOrderByRules().size(); i++) {
-        unifier.addOrderByRule(getOrderByRules().get(i));
-      }
-      unifier.setDescending(isDescending);
-      return unifier;
-    }
-  };
-
-  /**
-   * @return the orderByRules
-   */
-  public ArrayList<OrderByRule<?>> getOrderByRules()
-  {
-    return orderByRules;
-  }
-
-  /**
-   * The order by rules used to order incoming tuples.
-   * @param oredrByRules the orderByRules to set
-   */
-  public void setOrderByRules(ArrayList<OrderByRule<?>> oredrByRules)
-  {
-    this.orderByRules = oredrByRules;
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/streamquery/OrderByRule.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/streamquery/OrderByRule.java b/library/src/main/java/com/datatorrent/lib/streamquery/OrderByRule.java
deleted file mode 100644
index 8573903..0000000
--- a/library/src/main/java/com/datatorrent/lib/streamquery/OrderByRule.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery;
-
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.TreeMap;
-
-/**
- * Implements order by key name rule. <br>
- * <p>
- * <b>Properties : </b> <br>
- * <b> columnName : </b> Name of column for ordering tuples. <br>
- * @displayName OrderBy Rule
- * @category Stream Manipulators
- * @tags orderby, sort, comparison
- * @since 0.3.3
- */
-@SuppressWarnings("rawtypes")
-public class OrderByRule<T extends Comparable>
-{
-
-  /**
-   * column name for ordering tuples.
-   */
-  private String columnName;
-
-  public OrderByRule(String name)
-  {
-
-    columnName = name;
-  }
-
-  /**
-   * sort rows by each rule and emit result on output port.
-   */
-  @SuppressWarnings("unchecked")
-  public ArrayList<Map<String, Object>> sort(ArrayList<Map<String, Object>> rows)
-  {
-
-    TreeMap<T, ArrayList<Map<String, Object>>> sorted = new TreeMap<T, ArrayList<Map<String, Object>>>();
-    for (int i = 0; i < rows.size(); i++) {
-      Map<String, Object> row = rows.get(i);
-      if (row.containsKey(columnName)) {
-        T value = (T)row.get(columnName);
-        ArrayList<Map<String, Object>> list;
-        if (sorted.containsKey(value)) {
-          list = sorted.get(value);
-        } else {
-          list = new ArrayList<Map<String, Object>>();
-          sorted.put(value, list);
-        }
-        list.add(row);
-      }
-    }
-    ArrayList<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
-    for (Map.Entry<T, ArrayList<Map<String, Object>>> entry : sorted.entrySet()) {
-      result.addAll(entry.getValue());
-    }
-    return result;
-  }
-
-  /**
-   * @return the columnName
-   */
-  public String getColumnName()
-  {
-
-    return columnName;
-  }
-
-  /**
-   * @param columnName
-   *          the columnName to set
-   */
-  public void setColumnName(String columnName)
-  {
-
-    this.columnName = columnName;
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/streamquery/OuterJoinOperator.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/streamquery/OuterJoinOperator.java b/library/src/main/java/com/datatorrent/lib/streamquery/OuterJoinOperator.java
deleted file mode 100644
index 0494bfb..0000000
--- a/library/src/main/java/com/datatorrent/lib/streamquery/OuterJoinOperator.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery;
-
-/**
- * An operator that provides sql left,right and full outer join metric semantics on live stream. <br>
- * <p>
- * Please refer to {@link com.datatorrent.lib.streamquery.InnerJoinOperator} for
- * details.
- *
- * <b> Properties : </b> <br>
- * <b> isLeftJoin : </b> Left join flag. <br>
- * <b> isFullJoin : </b> Full join flag. <br>
- * @displayName Outer Join
- * @category Stream Manipulators
- * @tags sql, outer join operator
- * @since 0.3.4
- */
-public class OuterJoinOperator extends InnerJoinOperator
-{
-
-  private boolean isLeftJoin = true;
-  private boolean isFullJoin = false;
-
-  @Override
-  public void endWindow()
-  {
-    // full outer join
-    if (isFullJoin) {
-      for (int i = 0; i < table1.size(); i++) {
-        boolean merged = false;
-        for (int j = 0; j < table2.size(); j++) {
-          if ((joinCondition == null)
-              || (joinCondition.isValidJoin(table1.get(i), table2.get(j)))) {
-            merged = true;
-          }
-        }
-        if (!merged) {
-          joinRows(table1.get(i), null);
-        }
-      }
-      for (int i = 0; i < table2.size(); i++) {
-        boolean merged = false;
-        for (int j = 0; j < table1.size(); j++) {
-          if ((joinCondition == null)
-              || (joinCondition.isValidJoin(table1.get(j), table2.get(i)))) {
-            merged = true;
-          }
-        }
-        if (!merged) { // only output non merged rows
-          joinRows(null, table2.get(i));
-        }
-      }
-      return;
-    }
-
-    // left or right join
-    if (isLeftJoin) {
-      for (int i = 0; i < table1.size(); i++) {
-        boolean merged = false;
-        for (int j = 0; j < table2.size(); j++) {
-          if ((joinCondition == null)
-              || (joinCondition.isValidJoin(table1.get(i), table2.get(j)))) {
-            merged = true;
-          }
-        }
-        if (!merged) {
-          joinRows(table1.get(i), null);
-        }
-      }
-    } else {
-      for (int i = 0; i < table2.size(); i++) {
-        boolean merged = false;
-        for (int j = 0; j < table1.size(); j++) {
-          if ((joinCondition == null) || (joinCondition.isValidJoin(table1.get(j), table2.get(i)))) {
-            merged = true;
-          }
-        }
-        if (!merged) { // only output non merged rows
-          joinRows(null, table2.get(i));
-        }
-      }
-    }
-  }
-
-  public void setLeftJoin()
-  {
-    isLeftJoin = true;
-  }
-
-  public void setRighttJoin()
-  {
-    isLeftJoin = false;
-  }
-
-  public boolean isFullJoin()
-  {
-    return isFullJoin;
-  }
-
-  public void setFullJoin(boolean isFullJoin)
-  {
-    this.isFullJoin = isFullJoin;
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/streamquery/SelectFunctionOperator.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/streamquery/SelectFunctionOperator.java b/library/src/main/java/com/datatorrent/lib/streamquery/SelectFunctionOperator.java
deleted file mode 100644
index 77616f3..0000000
--- a/library/src/main/java/com/datatorrent/lib/streamquery/SelectFunctionOperator.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
-import com.datatorrent.api.Context.OperatorContext;
-import com.datatorrent.api.DefaultInputPort;
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.api.Operator;
-import com.datatorrent.api.annotation.OperatorAnnotation;
-import com.datatorrent.lib.streamquery.function.FunctionIndex;
-
-/**
- *  An implementation of Operator that applies sql top or limit semantics on incoming tuple(s). <br>
- * <p>
- * <b>StateFull : Yes,</b> Operator aggregates input over application window. <br>
- * <b>Partitions : No, </b> will yield wrong result(s). <br>
- * <br>
- * <b>Ports : </b> <br>
- * <b>inport : </b> expect tuple for type T. <br>
- * <b>outport : </b> emits tuple for type T. <br>
- * <br>
- * <b> Properties : </b> <br>
- * <b> functions : </b> Sql function for rows. <br>
- * @displayName Select Function
- * @category Stream Manipulators
- * @tags sql top, sql limit, sql select operator
- * @since 0.3.4
- */
-@OperatorAnnotation(partitionable = false)
-public class SelectFunctionOperator implements Operator
-{
-  /**
-   * array of rows.
-   */
-  private ArrayList<Map<String, Object>> rows;
-
-  /**
-   * Aggregate function for rows.
-   */
-  private ArrayList<FunctionIndex> functions = new ArrayList<FunctionIndex>();
-
-  /**
-   * Input port that takes a map of &lt;string,object&gt;.
-   */
-  public final transient DefaultInputPort<Map<String, Object>> inport = new DefaultInputPort<Map<String, Object>>()
-  {
-
-    @Override
-    public void process(Map<String, Object> row)
-    {
-      rows.add(row);
-    }
-  };
-
-  @Override
-  public void setup(OperatorContext context)
-  {
-    // TODO Auto-generated method stub
-
-  }
-
-  @Override
-  public void teardown()
-  {
-    // TODO Auto-generated method stub
-
-  }
-
-  @Override
-  public void beginWindow(long windowId)
-  {
-    rows = new ArrayList<Map<String, Object>>();
-  }
-
-  @Override
-  public void endWindow()
-  {
-    if (functions.size() == 0) {
-      return;
-    }
-    Map<String, Object>  collect = new HashMap<String, Object>();
-    for (FunctionIndex function : functions) {
-      try {
-        function.filter(rows, collect);
-      } catch (Exception e) {
-        e.printStackTrace();
-        return;
-      }
-    }
-    outport.emit(collect);
-  }
-
-  /**
-   * Output port that emits a map of &lt;string,object&gt;.
-   */
-  public final transient DefaultOutputPort<Map<String, Object>> outport = new DefaultOutputPort<Map<String, Object>>();
-
-  /**
-   * Add sql function.
-   * @param function  Sql function for rows.
-   */
-  public void addSqlFunction(FunctionIndex function)
-  {
-    functions.add(function);
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/streamquery/SelectOperator.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/streamquery/SelectOperator.java b/library/src/main/java/com/datatorrent/lib/streamquery/SelectOperator.java
deleted file mode 100644
index 4dbc1f0..0000000
--- a/library/src/main/java/com/datatorrent/lib/streamquery/SelectOperator.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
-import com.datatorrent.api.DefaultInputPort;
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.common.util.BaseOperator;
-import com.datatorrent.lib.streamquery.condition.Condition;
-import com.datatorrent.lib.streamquery.index.Index;
-
-/**
- * An implementation of that provides sql select query semantics on live data stream. <br>
- * <p>
- * Stream rows passing condition are emitted on output port stream. <br>
- * <br>
- * <b>StateFull : NO,</b> all row data is processed in current time window. <br>
- * <b>Partitions : Yes, </b> No Input dependency among input rows. <br>
- * <br>
- * <b>Ports</b>:<br>
- * <b> inport : </b> Input hash map(row) port, expects
- * HashMap&lt;String,Object&gt;<<br>
- * <b> outport : </b> Output hash map(row) port, emits
- * HashMap&lt;String,Object&gt;<br>
- * <br>
- * <b> Properties : <b> <br>
- * <b> condition : </b> Select condition for selecting rows. <br>
- * <b> columns : </b> Column names/aggregate functions for select. <br>
- * <br>
- * @displayName Select
- * @category Stream Manipulators
- * @tags sql select operator, index, sql condition
- * @since 0.3.3
- */
-public class SelectOperator extends BaseOperator
-{
-
-  /**
-   * select columns/expression;
-   */
-  private ArrayList<Index> indexes = new ArrayList<Index>();
-
-  /**
-   * condition.
-   */
-  private Condition condition = null;
-
-  /**
-   * add index.
-   */
-  public void addIndex(Index index)
-  {
-    indexes.add(index);
-  }
-
-  /**
-   * set condition.
-   */
-  public void setCondition(Condition condition)
-  {
-    this.condition = condition;
-  }
-
-  /**
-   * Input port that takes a map of &lt;string,object&gt;.
-   */
-  public final transient DefaultInputPort<Map<String, Object>> inport = new DefaultInputPort<Map<String, Object>>()
-  {
-
-    @Override
-    public void process(Map<String, Object> tuple)
-    {
-      if ((condition != null) && (!condition.isValidRow(tuple))) {
-        return;
-      }
-      if (indexes.size() == 0) {
-        outport.emit(tuple);
-        return;
-      }
-      Map<String, Object> result = new HashMap<String, Object>();
-      for (int i = 0; i < indexes.size(); i++) {
-        indexes.get(i).filter(tuple, result);
-      }
-      outport.emit(result);
-    }
-  };
-
-  /**
-   * Output port that emits a map of &lt;string,object&gt;.
-   */
-  public final transient DefaultOutputPort<Map<String, Object>> outport = new DefaultOutputPort<Map<String, Object>>();
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/streamquery/SelectTopOperator.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/streamquery/SelectTopOperator.java b/library/src/main/java/com/datatorrent/lib/streamquery/SelectTopOperator.java
deleted file mode 100644
index c3ae083..0000000
--- a/library/src/main/java/com/datatorrent/lib/streamquery/SelectTopOperator.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery;
-
-import java.util.ArrayList;
-import java.util.Map;
-
-import com.datatorrent.api.Context.OperatorContext;
-import com.datatorrent.api.DefaultInputPort;
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.api.Operator;
-
-/**
- * An implementation of Operator that provides sql top select query semantic on live data stream. <br>
- * <p>
- * Stream rows passing condition are emitted on output port stream. <br>
- * <br>
- * <b>StateFull : NO,</b> all row data is processed in current time window. <br>
- * <b>Partitions : Yes, </b> No Input dependency among input rows. <br>
- * <br>
- * <b>Ports</b>:<br>
- * <b> inport : </b> Input hash map(row) port, expects
- * HashMap&lt;String,Object&gt;<<br>
- * <b> outport : </b> Output hash map(row) port, emits
- * HashMap&lt;String,Object&gt;<br>
- * <br>
- * <b> Properties : <b> <br>
- * <b> topValue : </b> top values count. <br>
- * <b> isPercentage : </b> top values count is percentage flag.
- * <br>
- * @displayName Select Top
- * @category Stream Manipulators
- * @tags sql select, sql top operator
- *  @since 0.3.4
- */
-public class SelectTopOperator implements Operator
-{
-  private ArrayList<Map<String, Object>> list;
-  private int topValue = 1;
-  private boolean isPercentage = false;
-
-  /**
-   * Input port that takes a map of &lt;string,object&gt;.
-   */
-  public final transient DefaultInputPort<Map<String, Object>> inport = new DefaultInputPort<Map<String, Object>>()
-  {
-    @Override
-    public void process(Map<String, Object> tuple)
-    {
-      list.add(tuple);
-    }
-  };
-
-  @Override
-  public void setup(OperatorContext context)
-  {
-    // TODO Auto-generated method stub
-
-  }
-
-  @Override
-  public void teardown()
-  {
-    // TODO Auto-generated method stub
-
-  }
-
-  @Override
-  public void beginWindow(long windowId)
-  {
-    list = new ArrayList<Map<String, Object>>();
-  }
-
-  @Override
-  public void endWindow()
-  {
-    int numEmits = topValue;
-    if (isPercentage) {
-      numEmits = list.size() * (topValue / 100);
-    }
-    for (int i = 0; (i < numEmits) && (i < list.size()); i++) {
-      outport.emit(list.get(i));
-    }
-  }
-
-  public int getTopValue()
-  {
-    return topValue;
-  }
-
-  public void setTopValue(int topValue) throws Exception
-  {
-    if (topValue <= 0) {
-      throw new Exception("Top value must be positive number.");
-    }
-    this.topValue = topValue;
-  }
-
-  public boolean isPercentage()
-  {
-    return isPercentage;
-  }
-
-  public void setPercentage(boolean isPercentage)
-  {
-    this.isPercentage = isPercentage;
-  }
-
-  /**
-   * Output port that emits a map of &lt;string,object&gt;.
-   */
-  public final transient DefaultOutputPort<Map<String, Object>> outport =  new DefaultOutputPort<Map<String, Object>>();
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/streamquery/UpdateOperator.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/streamquery/UpdateOperator.java b/library/src/main/java/com/datatorrent/lib/streamquery/UpdateOperator.java
deleted file mode 100644
index 6724a7e..0000000
--- a/library/src/main/java/com/datatorrent/lib/streamquery/UpdateOperator.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import com.datatorrent.api.DefaultInputPort;
-import com.datatorrent.api.DefaultOutputPort;
-import com.datatorrent.common.util.BaseOperator;
-import com.datatorrent.lib.streamquery.condition.Condition;
-
-/**
- *  An implementation of BaseOperator that provides sql update query semantic on live data stream. <br>
- *  <p>
- *  Stream rows passing condition are emitted on output port stream. <br>
- *  <br>
- *  <b>StateFull : NO,</b> all row data is processed in current time window. <br>
- *  <b>Partitions : Yes, </b> No Input dependency among input rows. <br>
- *  <br>
- * <b>Ports</b>:<br>
- * <b> inport : </b> Input hash map(row) port, expects HashMap&lt;String,Object&gt;<<br>
- * <b> outport : </b> Output hash map(row) port, emits  HashMap&lt;String,Object&gt;<br>
- * <br>
- * <b> Properties : <b> <br>
- * <b> condition : </b> Select condition for selecting rows. <br>
- * <b> columns : </b> Column names/aggregate functions for select. <br>
- * <br>
- * @displayName Update
- * @category Stream Manipulators
- * @tags sql update operator, sql condition
- * @since 0.3.3
- */
-public class UpdateOperator extends BaseOperator
-{
-  /**
-   * Update value map.
-   */
-  Map<String, Object> updates = new HashMap<String, Object>();
-
-  /**
-   *  condition.
-   */
-  private Condition condition = null;
-
-  /**
-   * set condition.
-   */
-  public void setCondition(Condition condition)
-  {
-    this.condition = condition;
-  }
-
-  /**
-   * Input port that takes a map of &lt;string,object&gt;.
-   */
-  public final transient DefaultInputPort<Map<String, Object>> inport = new DefaultInputPort<Map<String, Object>>()
-  {
-    @Override
-    public void process(Map<String, Object> tuple)
-    {
-      if ((condition != null) && (!condition.isValidRow(tuple))) {
-        return;
-      }
-      if (updates.size() == 0) {
-        outport.emit(tuple);
-        return;
-      }
-      Map<String, Object> result = new HashMap<String, Object>();
-      for (Map.Entry<String, Object> entry : tuple.entrySet()) {
-        if (updates.containsKey(entry.getKey())) {
-          result.put(entry.getKey(), updates.get(entry.getKey()));
-        } else {
-          result.put(entry.getKey(), entry.getValue());
-        }
-      }
-      outport.emit(result);
-    }
-  };
-
-  /**
-   * Output port that emits a map of &lt;string,object&gt;.
-   */
-  public final transient DefaultOutputPort<Map<String, Object>> outport =  new DefaultOutputPort<Map<String, Object>>();
-
-  /**
-   * Add update value.
-   */
-  public void addUpdate(String name, Object value)
-  {
-    updates.put(name, value);
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/streamquery/condition/BetweenCondition.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/streamquery/condition/BetweenCondition.java b/library/src/main/java/com/datatorrent/lib/streamquery/condition/BetweenCondition.java
deleted file mode 100644
index 43cdc72..0000000
--- a/library/src/main/java/com/datatorrent/lib/streamquery/condition/BetweenCondition.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery.condition;
-
-import java.util.Map;
-
-import javax.validation.constraints.NotNull;
-
-/**
- *  A derivation of Condition that validates row by checking if the given column name value lies between given left,right range. <br>
- * <p>
- * <b>Properties : </b> <br>
- * <b> column : </b> Name of column. <br>
- * <b> leftValue : </b> left range of column value. <br>
- * <b> rightValue : </b> right range od column value. <br>
- * <br>
- * @displayName Between Condition
- * @category Stream Manipulators
- * @tags sql condition
- * @since 0.3.4
- */
-public class BetweenCondition  extends Condition
-{
-  /**
-   * Column name to be checked.
-   */
-  @NotNull
-  private String column;
-
-  /**
-   * Left range value.
-   */
-  @NotNull
-  private Object leftValue;
-
-  /**
-   * Right range value.
-   */
-  @NotNull
-  private Object rightValue;
-
-  /**
-   * @param  column  Name of column, must be non null. <br>
-   * @param  leftValue  Left range for value, mut be non null. <br>
-   * @param  rightValue  right range for value, mut be non null. <br>
-   */
-  public BetweenCondition(@NotNull String column, @NotNull  Object leftValue, @NotNull Object rightValue)
-  {
-    this.column = column;
-    this.leftValue = leftValue;
-    this.rightValue = rightValue;
-  }
-
-  /**
-   * Validate given row.
-   */
-  @SuppressWarnings({"rawtypes", "unchecked"})
-  @Override
-  public boolean isValidRow(@NotNull Map<String, Object> row)
-  {
-    if (!row.containsKey(column)) {
-      return false;
-    }
-    Object value = row.get(column);
-    if (value == null) {
-      return false;
-    }
-    if (((Comparable)value).compareTo((Comparable)leftValue) < 0) {
-      return false;
-    }
-    if (((Comparable)value).compareTo((Comparable)rightValue) > 0) {
-      return false;
-    }
-    return true;
-  }
-
-  /**
-   * Must not be called.
-   */
-  @Override
-  public boolean isValidJoin(@NotNull Map<String, Object> row1, Map<String, Object> row2)
-  {
-    assert (false);
-    return false;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/streamquery/condition/CompoundCondition.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/streamquery/condition/CompoundCondition.java b/library/src/main/java/com/datatorrent/lib/streamquery/condition/CompoundCondition.java
deleted file mode 100644
index b4bd3ed..0000000
--- a/library/src/main/java/com/datatorrent/lib/streamquery/condition/CompoundCondition.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery.condition;
-
-import java.util.Map;
-
-import javax.validation.constraints.NotNull;
-
-/**
- * A derivation of Condition index that implements logical AND/OR select expression. <br>
- * <p>
- * Class provides logical OR or AND function specified in parameters. User can implement
- * complex and/or expression by chaining operator itself.
- * <br>
- * <b> Properties : </b> <br>
- * <b> leftCondition : </b> Left validate row condition . <br>
- * <b> rightCondition : </b> Right validate row condition. <br>
- * <b> logicalOr : </b> OR/AND logical metric flag. <br>
- * <br>
- * @displayName Compound Condition
- * @category Stream Manipulators
- * @tags sql condition, logical
- * @since 0.3.4
- */
-public class CompoundCondition extends Condition
-{
-  /**
-   * Left validate row condition .
-   */
-  @NotNull
-  private Condition leftCondition;
-
-  /**
-   * Right validate row condition .
-   */
-  @NotNull
-  private Condition rightCondition;
-
-  /**
-   * AND/OR metric flag.
-   */
-  private boolean logicalOr = true;
-
-  /**
-   * Constructor for logical or metric.
-   *
-   * @param leftCondition  Left validate row condition, must be non null. <br>
-   * @param rightCondition Right validate row condition, must be non null. <br>
-   */
-  public CompoundCondition(Condition leftCondition, Condition rightCondition)
-  {
-    this.leftCondition = leftCondition;
-    this.rightCondition = rightCondition;
-  }
-
-  /**
-   * Constructor for logical and metric if logical and parameter is true.
-   * <br>
-   *
-   * @param leftCondition  Left validate row condition, must be non null. <br>
-   * @param rightCondition Right validate row condition, must be non null. <br>
-   * @param isLogicalAnd   Logical AND if true.
-   */
-  public CompoundCondition(Condition leftCondition, Condition rightCondition, boolean isLogicalAnd)
-  {
-    this.leftCondition = leftCondition;
-    this.rightCondition = rightCondition;
-    logicalOr = !isLogicalAnd;
-  }
-
-  @Override
-  public boolean isValidRow(Map<String, Object> row)
-  {
-    if (logicalOr) {
-      return leftCondition.isValidRow(row) || rightCondition.isValidRow(row);
-    } else {
-      return leftCondition.isValidRow(row) && rightCondition.isValidRow(row);
-    }
-  }
-
-  @Override
-  public boolean isValidJoin(Map<String, Object> row1, Map<String, Object> row2)
-  {
-    // TODO Auto-generated method stub
-    return false;
-  }
-
-  public Condition getLeftCondition()
-  {
-    return leftCondition;
-  }
-
-  public void setLeftCondition(Condition leftCondition)
-  {
-    this.leftCondition = leftCondition;
-  }
-
-  public Condition getRightCondition()
-  {
-    return rightCondition;
-  }
-
-  public void setRightCondition(Condition rightCondition)
-  {
-    this.rightCondition = rightCondition;
-  }
-
-  public void setLogicalAnd()
-  {
-    this.logicalOr = false;
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/streamquery/condition/EqualValueCondition.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/streamquery/condition/EqualValueCondition.java b/library/src/main/java/com/datatorrent/lib/streamquery/condition/EqualValueCondition.java
deleted file mode 100644
index bb478cf..0000000
--- a/library/src/main/java/com/datatorrent/lib/streamquery/condition/EqualValueCondition.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery.condition;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-/**
- * An implementation of condition on column equality.
- * <p>
- * A valid row must have all key/value map in column name/value map.
- *
- * <b> Properties : </b> <br>
- *  <b> equalMap : </b> Column equal value map store.
- * @displayName Equal Value Condition
- * @category Stream Manipulators
- * @tags sql condition
- * @since 0.3.4
- */
-public class EqualValueCondition extends Condition
-{
-
-  /**
-   * Equal column map.
-   */
-  private HashMap<String, Object> equalMap = new HashMap<String, Object>();
-
-  /**
-   * Add column equal condition.
-   */
-  public void addEqualValue(String column, Object value)
-  {
-    equalMap.put(column, value);
-  }
-
-  /**
-   * Check valid row.
-   */
-  @Override
-  public boolean isValidRow(Map<String, Object> row)
-  {
-    // no conditions
-    if (equalMap.size() == 0) {
-      return true;
-    }
-
-    // compare each condition value
-    for (Map.Entry<String, Object> entry : equalMap.entrySet()) {
-      if (!row.containsKey(entry.getKey())) {
-        return false;
-      }
-      Object value = row.get(entry.getKey());
-      if (entry.getValue() == null) {
-        if (value == null) {
-          return true;
-        }
-        return false;
-      }
-      if (value == null) {
-        return false;
-      }
-      if (!entry.getValue().equals(value)) {
-        return false;
-      }
-    }
-    return true;
-  }
-
-  /**
-   * check valid join, not implemented
-   *
-   * @return false
-   */
-  @Override
-  public boolean isValidJoin(Map<String, Object> row1, Map<String, Object> row2)
-  {
-    return false;
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/streamquery/condition/HavingCompareValue.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/streamquery/condition/HavingCompareValue.java b/library/src/main/java/com/datatorrent/lib/streamquery/condition/HavingCompareValue.java
deleted file mode 100644
index 7877053..0000000
--- a/library/src/main/java/com/datatorrent/lib/streamquery/condition/HavingCompareValue.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery.condition;
-
-import java.util.ArrayList;
-import java.util.Map;
-
-import javax.validation.constraints.NotNull;
-
-import com.datatorrent.lib.streamquery.function.FunctionIndex;
-
-/**
- *  A derivation of HavingCondition that implements comparison of aggregate index value to input compare value. <br>
- * <p>
- * Compare value must implement interface Comparable. <br>
- * <br>
- * <b> Properties : </b>
- *  <b> compareValue : </b>  Value to be compared. <br>
- *  <b>  compareType : </b> Type of comparison -1 == lt, 0 == eq, 1 == gt. <br>
- * @displayName Having Compare Value
- * @category Stream Manipulators
- * @tags compare, sql condition
- * @since 0.3.4
- */
-@SuppressWarnings("rawtypes")
-public class HavingCompareValue<T extends Comparable>   extends HavingCondition
-{
-  /**
-   * Value to be compared.
-   */
-  private T compareValue;
-
-  /**
-   * Type of comparison -1 == lt, 0 == eq, 1 == gt.
-   */
-  private int compareType;
-
-  /**
-   * @param aggregateIndex   aggregate index for comparison. <br>
-   * @param compareValue     Value to be compared. <br>
-   * @param compareType    Type of comparison -1 == lt, 0 == eq, 1 == gt. <br>
-   */
-  public HavingCompareValue(FunctionIndex aggregateIndex, T compareValue, int compareType)
-  {
-    super(aggregateIndex);
-    this.compareValue = compareValue;
-    this.compareType  = compareType;
-  }
-
-  /**
-   * Validate aggregate override. <br>
-   */
-  @SuppressWarnings("unchecked")
-  @Override
-  public boolean isValidAggregate(@NotNull ArrayList<Map<String, Object>> rows) throws Exception
-  {
-    Object computed = aggregateIndex.compute(rows);
-    return (compareType == compareValue.compareTo(computed));
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/streamquery/condition/HavingCondition.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/streamquery/condition/HavingCondition.java b/library/src/main/java/com/datatorrent/lib/streamquery/condition/HavingCondition.java
deleted file mode 100644
index 6dac690..0000000
--- a/library/src/main/java/com/datatorrent/lib/streamquery/condition/HavingCondition.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery.condition;
-
-import java.util.ArrayList;
-import java.util.Map;
-
-import javax.validation.constraints.NotNull;
-
-import com.datatorrent.lib.streamquery.function.FunctionIndex;
-
-/**
- *  A base class for Group,Having operator with aggregate index constraint.&nsbsp; Subclasses should provide the
-    implementation to check if aggregate is valid.
- * <p>
- * @displayName Having Condition
- * @category Stream Manipulators
- * @tags sql condition, index, group
- * @since 0.3.4
- */
-public abstract class HavingCondition
-{
-  /**
-   * Aggregate index to be validated.
-   */
-  protected FunctionIndex  aggregateIndex = null;
-
-  /**
-   * @param aggregateIndex Aggregate index to be validated.
-   */
-  public HavingCondition(FunctionIndex aggregateIndex)
-  {
-    this.aggregateIndex = aggregateIndex;
-  }
-
-  /**
-   *  Check if aggregate is valid.
-   */
-  public abstract boolean isValidAggregate(@NotNull ArrayList<Map<String, Object>> rows) throws Exception;
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/streamquery/condition/InCondition.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/streamquery/condition/InCondition.java b/library/src/main/java/com/datatorrent/lib/streamquery/condition/InCondition.java
deleted file mode 100644
index 236f3b1..0000000
--- a/library/src/main/java/com/datatorrent/lib/streamquery/condition/InCondition.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery.condition;
-
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.validation.constraints.NotNull;
-
-/**
- * An implementation of condition class to check if a column value is in a given set of values.
- * <p>
- * <br>
- * <b>Properties : </b> <br>
- * <b> column : </b> Column name for which value is checked in values set. <br>
- * <b> inValues : </b> Set of values in which column value is checked. <br>
- * @displayName In Condition
- * @category Stream Manipulators
- * @tags sql condition
- * @since 0.3.4
- */
-public class InCondition extends Condition
-{
-  /**
-   * Column name for which value is checked in values set.
-   */
-  @NotNull
-  private String column;
-
-  /**
-   * Set of values in which column value is checked.
-   */
-  private Set<Object> inValues = new HashSet<Object>();
-
-  /**
-   * @param column Column name for which value is checked in values set.
-   */
-  public InCondition(@NotNull String column)
-  {
-    this.column = column;
-  }
-
-  @Override
-  public boolean isValidRow(@NotNull Map<String, Object> row)
-  {
-    if (!row.containsKey(column)) {
-      return false;
-    }
-    return inValues.contains(row.get(column));
-  }
-
-  @Override
-  public boolean isValidJoin(@NotNull Map<String, Object> row1, @NotNull Map<String, Object> row2)
-  {
-    return false;
-  }
-
-  public String getColumn()
-  {
-    return column;
-  }
-
-  public void setColumn(String column)
-  {
-    this.column = column;
-  }
-
-  public void addInValue(Object value)
-  {
-    this.inValues.add(value);
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/streamquery/condition/JoinColumnEqualCondition.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/streamquery/condition/JoinColumnEqualCondition.java b/library/src/main/java/com/datatorrent/lib/streamquery/condition/JoinColumnEqualCondition.java
index d350edc..4d8199e 100644
--- a/library/src/main/java/com/datatorrent/lib/streamquery/condition/JoinColumnEqualCondition.java
+++ b/library/src/main/java/com/datatorrent/lib/streamquery/condition/JoinColumnEqualCondition.java
@@ -23,7 +23,6 @@ import java.util.Map;
 
 import javax.validation.constraints.NotNull;
 
-
 /**
  * An implementation of equal join condition class.
  * <p>

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/streamquery/condition/LikeCondition.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/streamquery/condition/LikeCondition.java b/library/src/main/java/com/datatorrent/lib/streamquery/condition/LikeCondition.java
deleted file mode 100644
index b3d7174..0000000
--- a/library/src/main/java/com/datatorrent/lib/streamquery/condition/LikeCondition.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery.condition;
-
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.validation.constraints.NotNull;
-
-
-/**
- * An implementation of condition class to filter rows for which given column name value matches given regular expression. <br>
- *<p>
- *<b> Properties : </b> <br>
- *<b> column : < /b> Column to be matched with regular expression. <br>
- *<b> pattern : </b> Regular expression pattern.<br>
- * @displayName Like Condition
- * @category Stream Manipulators
- * @tags sql, like condition, regular expression
- * @since 0.3.4
- */
-public class LikeCondition extends Condition
-{
-  /**
-   * Column to be matched with regular expression.
-   */
-  @NotNull
-  private String column;
-
-  /**
-   * Regular expression pattern.
-   */
-  @NotNull
-  private Pattern pattern;
-
-  /**
-   * @param column Column to be matched with regular expression, must be non-null.
-   * @param pattern Regular expression pattern, must be non-null.
-   */
-  public LikeCondition(@NotNull String column,@NotNull String pattern)
-  {
-    setColumn(column);
-    setPattern(pattern);
-  }
-
-  /**
-   * For valid row column value string must match regular expression.
-   * @return row valid status.
-   */
-  @Override
-  public boolean isValidRow(Map<String, Object> row)
-  {
-    if (!row.containsKey(column)) {
-      return false;
-    }
-    Matcher match = pattern.matcher((CharSequence)row.get(column));
-    return match.find();
-  }
-
-  /**
-   * Must not be called.
-   */
-  @Override
-  public boolean isValidJoin(Map<String, Object> row1, Map<String, Object> row2)
-  {
-    assert (false);
-    return false;
-  }
-
-  public String getColumn()
-  {
-    return column;
-  }
-
-  public void setColumn(String column)
-  {
-    this.column = column;
-  }
-
-  public void setPattern(String pattern)
-  {
-    this.pattern = Pattern.compile(pattern);
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/streamquery/function/AverageFunction.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/streamquery/function/AverageFunction.java b/library/src/main/java/com/datatorrent/lib/streamquery/function/AverageFunction.java
deleted file mode 100644
index e212ff8..0000000
--- a/library/src/main/java/com/datatorrent/lib/streamquery/function/AverageFunction.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery.function;
-
-import java.util.ArrayList;
-import java.util.Map;
-
-import javax.validation.constraints.NotNull;
-
-import org.apache.commons.lang.StringUtils;
-
-/**
- * An implementation of function index that implements average function semantics. <br>
- * <p>
- *   e.g : sql => SELECT AVG(column_name) FROM table_name. <br>
- *   <br>
- *   <b> Properties : </b> <br>
- *   <b> column : </b> Aggregate over given column values.   <br>
- *   <b> alias  : </b> Alias name for aggregate output. <br>
- * @displayName Average Function
- * @category Stream Manipulators
- * @tags sql average
- * @since 0.3.4
- */
-public class AverageFunction  extends FunctionIndex
-{
-  /**
-   * @param column Aggregate over given column values, must be non null.
-   * @param alias  Alias name for aggregate output.
-   */
-  public AverageFunction(@NotNull String column, String alias)
-  {
-    super(column, alias);
-  }
-
-  /**
-   * Compute average for given column values.
-   */
-  @Override
-  public Object compute(@NotNull ArrayList<Map<String, Object>> rows) throws Exception
-  {
-    if (rows.size() == 0) {
-      return 0.0;
-    }
-    double sum = 0.0;
-    for (Map<String, Object> row : rows) {
-      sum += ((Number)row.get(column)).doubleValue();
-    }
-    return sum / rows.size();
-  }
-
-  /**
-   * Get aggregate name.
-   * @return name.
-   */
-  @Override
-  protected String aggregateName()
-  {
-    if (!StringUtils.isEmpty(alias)) {
-      return alias;
-    }
-    return "AVG(" + column + ")";
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/streamquery/function/CountFunction.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/streamquery/function/CountFunction.java b/library/src/main/java/com/datatorrent/lib/streamquery/function/CountFunction.java
deleted file mode 100644
index dafe54e..0000000
--- a/library/src/main/java/com/datatorrent/lib/streamquery/function/CountFunction.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery.function;
-
-import java.util.ArrayList;
-import java.util.Map;
-
-import javax.validation.constraints.NotNull;
-
-import org.apache.commons.lang.StringUtils;
-
-/**
- * An implementation of function index that implements sql count function semantic. <br>
- * <p>
- * Counts number of values of given column and returns count of non null values in column.
- *   e.g : sql => SELECT COUNT(column_name) FROM table_name. <br>
- *   <br>
- *   <b> Properties : </b> <br>
- *   <b> column : </b> column name for values count.   <br>
- *   <b> alias  : </b> Alias name for aggregate output. <br>
- * @displayName Count Function
- * @category Stream Manipulators
- * @tags sql count
- * @since 0.3.4
- */
-public class CountFunction extends FunctionIndex
-{
-  /**
-   * @param column column for values count, must be non null.
-   * @param alias  Alias name for aggregate output.
-   */
-  public CountFunction(@NotNull String column, String alias)
-  {
-    super(column, alias);
-  }
-
-  /**
-   * Count number of values of given column.
-   * @return Count of non null values in column.
-   */
-  @Override
-  public Object compute(ArrayList<Map<String, Object>> rows) throws Exception
-  {
-    if (column.equals("*")) {
-      return rows.size();
-    }
-    long count = 0;
-    for (Map<String, Object> row : rows) {
-      if (row.containsKey(column) && (row.get(column) != null)) {
-        count++;
-      }
-    }
-    return count;
-  }
-
-  /**
-   * Aggregate output name.
-   * @return name string.
-   */
-  @Override
-  protected String aggregateName()
-  {
-    if (!StringUtils.isEmpty(alias)) {
-      return alias;
-    }
-    return "COUNT(" + column + ")";
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/streamquery/function/FirstLastFunction.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/streamquery/function/FirstLastFunction.java b/library/src/main/java/com/datatorrent/lib/streamquery/function/FirstLastFunction.java
deleted file mode 100644
index db2c2b7..0000000
--- a/library/src/main/java/com/datatorrent/lib/streamquery/function/FirstLastFunction.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery.function;
-
-import java.util.ArrayList;
-import java.util.Map;
-
-import javax.validation.constraints.NotNull;
-
-import org.apache.commons.lang.StringUtils;
-
-/**
- * An implementation of function index that implements sql first,last function semantic. <br>
- * <p>
- *   e.g : sql => SELECT FIRST/LAST(column_name) FROM table_name. <br>
- *   <br>
- *   <b> Properties : </b> <br>
- *   <b> column : </b> column name for first/last value.   <br>
- *   <b> alias  : </b> Alias name for output. <br>
- *   <b> isFirst : </b> return first value if true.
- * @displayName First Last Function
- * @category Stream Manipulators
- * @tags sql first, sql last
- * @since 0.3.4
- */
-public class FirstLastFunction extends FunctionIndex
-{
-  /**
-   * return first value if true.
-   */
-  private boolean isFirst;
-
-  /**
-   * @param column  column name for first/last value.
-   * @param  alias   Alias name for output.
-   * @param  isFirst return first value if true.
-   */
-  public FirstLastFunction(@NotNull String column, String alias, boolean isLast)
-  {
-    super(column, alias);
-    isFirst = !isLast;
-  }
-
-  /**
-   * Get first/last non null value for column.
-   */
-  @Override
-  public Object compute(@NotNull ArrayList<Map<String, Object>> rows) throws Exception
-  {
-    if (rows.size() == 0) {
-      return null;
-    }
-    if (isFirst) {
-      for (int i = 0; i < rows.size(); i++) {
-        if (rows.get(i).get(column) != null) {
-          return rows.get(i).get(column);
-        }
-      }
-    } else {
-      for (int i = (rows.size() - 1); i >= 0; i--) {
-        if (rows.get(i).get(column) != null) {
-          return rows.get(i).get(column);
-        }
-      }
-    }
-    return null;
-  }
-
-  /**
-   * Aggregate output name.
-   * @return name string.
-   */
-  @Override
-  protected String aggregateName()
-  {
-    if (!StringUtils.isEmpty(alias)) {
-      return alias;
-    }
-    if (isFirst) {
-      return "FIRST(" + column + ")";
-    }
-    return "LAST(" + column + ")";
-  }
-
-  public boolean isFirst()
-  {
-    return isFirst;
-  }
-
-  public void setFirst(boolean isFirst)
-  {
-    this.isFirst = isFirst;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/streamquery/function/FunctionIndex.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/streamquery/function/FunctionIndex.java b/library/src/main/java/com/datatorrent/lib/streamquery/function/FunctionIndex.java
deleted file mode 100644
index 918ca89..0000000
--- a/library/src/main/java/com/datatorrent/lib/streamquery/function/FunctionIndex.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery.function;
-
-import java.util.ArrayList;
-import java.util.Map;
-
-import javax.validation.constraints.NotNull;
-
-/**
- * A base class for select aggregate function implementation.&nbsp; Subclasses should provide the
-   implementation for aggregate compute functions.
- * <p>
- * <br>
- * <b>Properties : </b> <br>
- * <b>column : </b> Column name for aggregation.
- * <b>alias : </b> Output value alias name.
- * @displayName Function Index
- * @category Stream Manipulators
- * @tags sql aggregate
- * @since 0.3.4
- */
-public abstract class FunctionIndex
-{
-  /**
-   * Column name.
-   */
-  @NotNull
-  protected String column;
-
-  /**
-   * Alias name.
-   */
-  protected String alias;
-
-  /**
-   * @param column Column name for aggregation.
-   * @param alias Output value alias name.
-   */
-  public FunctionIndex(@NotNull String column, String alias)
-  {
-    this.column = column;
-    this.alias = alias;
-  }
-
-  /**
-   * Aggregate compute function, implementation in sub class.
-   * @param rows Tuple list over application window.
-   * @return aggregate result object.
-   */
-  public abstract Object compute(@NotNull ArrayList<Map<String, Object>> rows) throws Exception;
-
-  /**
-   * Get aggregate output value name.
-   * @return name string.
-   */
-  protected abstract String aggregateName();
-
-  /**
-   * Apply compute function to given rows and store result in collect by output value name.
-   * @param  rows Tuple list over application window.
-   */
-  public void filter(ArrayList<Map<String, Object>> rows, Map<String, Object> collect) throws Exception
-  {
-    if (rows == null) {
-      return;
-    }
-    String name = column;
-    if (alias != null) {
-      name = alias;
-    }
-    if (name == null) {
-      name = aggregateName();
-    }
-    collect.put(name, compute(rows));
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/streamquery/function/MaxMinFunction.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/streamquery/function/MaxMinFunction.java b/library/src/main/java/com/datatorrent/lib/streamquery/function/MaxMinFunction.java
deleted file mode 100644
index f02e82c..0000000
--- a/library/src/main/java/com/datatorrent/lib/streamquery/function/MaxMinFunction.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery.function;
-
-import java.util.ArrayList;
-import java.util.Map;
-
-import javax.validation.constraints.NotNull;
-
-import org.apache.commons.lang.StringUtils;
-
-/**
- * An implementation of function index that implements sql max and sql min function semantic. <br>
- * <p>
- *   e.g : sql => SELECT MAX/MIN(column_name) FROM table_name. <br>
- *   <br>
- *   <b> Properties : </b> <br>
- *   <b> column : </b> column name for values max/min computation.   <br>
- *   <b> alias  : </b> Alias name for  output value. <br>
- *   <b> isMax : </b> Flag to indicate max/min compute value. <br>
- * @displayName Max Min Function
- * @category Stream Manipulators
- * @tags sql max, sql min
- * @since 0.3.4
- */
-public class MaxMinFunction extends FunctionIndex
-{
-  /**
-   * Flag to indicate max/min compute value, compute max if true.
-   */
-  private boolean isMax = true;
-
-  /**
-   * @param column column name for values max/min computation.   <br>
-   * @param alias  Alias name for output. <br>
-   * @param isMax  Flag to indicate max/min compute value. <br>
-   */
-  public MaxMinFunction(@NotNull String column, String alias, boolean isMin)
-  {
-    super(column, alias);
-    isMax = !isMin;
-  }
-
-  /**
-   * Compute max/min for given column.
-   * @return max/min value.
-   */
-  @Override
-  public Object compute(ArrayList<Map<String, Object>> rows) throws Exception
-  {
-    double minMax = 0.0;
-    for (Map<String, Object> row : rows) {
-      double value = ((Number)row.get(column)).doubleValue();
-      if ((isMax && (minMax < value)) || (!isMax && (minMax > value))) {
-        minMax = value;
-      }
-    }
-    return minMax;
-  }
-
-  /**
-   * Aggregate output name.
-   * @return name string.
-   */
-  @Override
-  protected String aggregateName()
-  {
-    if (!StringUtils.isEmpty(alias)) {
-      return alias;
-    }
-    if (isMax) {
-      return "MAX(" + column + ")";
-    }
-    return "MIN(" + column + ")";
-  }
-
-  public boolean isMax()
-  {
-    return isMax;
-  }
-
-  public void setMax(boolean isMax)
-  {
-    this.isMax = isMax;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/streamquery/function/SumFunction.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/streamquery/function/SumFunction.java b/library/src/main/java/com/datatorrent/lib/streamquery/function/SumFunction.java
deleted file mode 100644
index 02186cd..0000000
--- a/library/src/main/java/com/datatorrent/lib/streamquery/function/SumFunction.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery.function;
-
-import java.util.ArrayList;
-import java.util.Map;
-
-import javax.validation.constraints.NotNull;
-
-
-
-/**
- * <p> An implementation of sql sum function. </p>
- * <p>
- * @displayName Sum Function
- * @category Stream Manipulators
- * @tags sql sum, aggregate
- * @since 0.3.4
- */
-public class SumFunction extends FunctionIndex
-{
-  public SumFunction(String column, String alias) throws Exception
-  {
-    super(column, alias);
-  }
-
-  @Override
-  public Object compute(@NotNull ArrayList<Map<String, Object>> rows) throws Exception
-  {
-    Double result = 0.0;
-    for (Map<String, Object> row : rows) {
-      if (!row.containsKey(column)) {
-        continue;
-      }
-      result += ((Number)row.get(column)).doubleValue();
-    }
-    return result;
-  }
-
-  @Override
-  protected String aggregateName()
-  {
-    return "Sum(" + column;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/streamquery/index/BinaryExpression.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/streamquery/index/BinaryExpression.java b/library/src/main/java/com/datatorrent/lib/streamquery/index/BinaryExpression.java
deleted file mode 100644
index 21c1d11..0000000
--- a/library/src/main/java/com/datatorrent/lib/streamquery/index/BinaryExpression.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery.index;
-
-import javax.validation.constraints.NotNull;
-
-
-/**
- * Abstract class to filter row by binary expression index.
- * <p>
- * Sub class will implement filter/getExpressionName functions.
- * @displayName Binary Expression
- * @category Stream Manipulators
- * @tags alias
- * @since 0.3.4
- */
-public abstract class BinaryExpression  implements Index
-{
-  /**
-   * Left column name argument for expression.
-   */
-  @NotNull
-  protected String left;
-
-  /**
-   * Right column name argument for expression.
-   */
-  @NotNull
-  protected String right;
-
-  /**
-   *  Alias name for output field.
-   */
-  protected String alias;
-
-  /**
-   * @param left column name argument for expression.
-   * @param right column name argument for expression.
-   * @param alias name for output field.
-   */
-  public BinaryExpression(@NotNull String left, @NotNull String right, String alias)
-  {
-    this.left = left;
-    this.right = right;
-  }
-
-  public String getAlias()
-  {
-    return alias;
-  }
-
-  public void setAlias(String alias)
-  {
-    this.alias = alias;
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/streamquery/index/MidIndex.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/streamquery/index/MidIndex.java b/library/src/main/java/com/datatorrent/lib/streamquery/index/MidIndex.java
deleted file mode 100644
index 931ddaa..0000000
--- a/library/src/main/java/com/datatorrent/lib/streamquery/index/MidIndex.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery.index;
-
-import java.util.Map;
-
-import javax.validation.constraints.NotNull;
-
-/**
- * <p>An implementation of Column Index that implements filter method based on mid index. </p>
- * <p>
- * @displayName Mid Index
- * @category Stream Manipulators
- * @tags index
- * @since 0.3.4
- */
-public class MidIndex extends ColumnIndex
-{
-  private int start;
-  private int length = 0;
-
-  public MidIndex(@NotNull String column, String alias, int start)
-  {
-    super(column, alias);
-    assert (start >= 0);
-    this.start = start;
-  }
-
-  @Override
-  public void filter(@NotNull  Map<String, Object> row, @NotNull  Map<String, Object> collect)
-  {
-    if (!row.containsKey(column)) {
-      return;
-    }
-    if (!(row.get(column) instanceof String)) {
-      assert (false);
-    }
-    String name = getColumn();
-    if (alias != null) {
-      name = alias;
-    }
-
-    int endIndex = start + length;
-    if ((length == 0) || (endIndex > ((String)row.get(column)).length())) {
-      collect.put(name, row.get(column));
-    } else {
-      collect.put(name, ((String)row.get(column)).substring(start, endIndex));
-    }
-  }
-
-  public int getLength()
-  {
-    return length;
-  }
-
-  public void setLength(int length)
-  {
-    assert (length > 0);
-    this.length = length;
-  }
-}
-

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/streamquery/index/NegateExpression.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/streamquery/index/NegateExpression.java b/library/src/main/java/com/datatorrent/lib/streamquery/index/NegateExpression.java
deleted file mode 100644
index 969e3af..0000000
--- a/library/src/main/java/com/datatorrent/lib/streamquery/index/NegateExpression.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery.index;
-
-import java.util.Map;
-
-import javax.validation.constraints.Null;
-
-
-/**
- * An implementation of Unary Expression that implements filter method using negate metric sql semantic on column value.
- * <p>
- * @displayName Negate Expression
- * @category Stream Manipulators
- * @tags expression, alias
- * @since 0.3.4
- */
-public class NegateExpression extends UnaryExpression
-{
-
-  /**
-   * @param column   Name of column value to be negated.
-   */
-  public NegateExpression(@Null String column, String alias)
-  {
-    super(column, alias);
-    if (this.alias == null) {
-      this.alias = "NEGATE(" + column + ")";
-    }
-  }
-
-  /* (non-Javadoc)
-   * @see com.datatorrent.lib.streamquery.index.Index#filter(java.util.Map, java.util.Map)
-   */
-  @Override
-  public void filter(Map<String, Object> row, Map<String, Object> collect)
-  {
-    if (!row.containsKey(column)) {
-      return;
-    }
-    collect.put(alias, -((Number)row.get(column)).doubleValue());
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/streamquery/index/RoundDoubleIndex.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/streamquery/index/RoundDoubleIndex.java b/library/src/main/java/com/datatorrent/lib/streamquery/index/RoundDoubleIndex.java
deleted file mode 100644
index 90e16a1..0000000
--- a/library/src/main/java/com/datatorrent/lib/streamquery/index/RoundDoubleIndex.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery.index;
-
-import java.util.Map;
-
-import javax.validation.constraints.NotNull;
-
-/**
- * <p>An implementation of column index that implements filter method using Round Double Index. </p>
- *
- * @displayName Round Double Index
- * @category Stream Manipulators
- * @tags alias, maths
- * @since 0.3.4
- */
-public class RoundDoubleIndex  extends ColumnIndex
-{
-  private int rounder;
-  public RoundDoubleIndex(@NotNull String column, String alias, int numDecimals)
-  {
-    super(column, alias);
-    rounder = 1;
-    if (numDecimals > 0) {
-      rounder = (int)Math.pow(10, numDecimals);
-    }
-  }
-
-  @Override
-  public void filter(@NotNull  Map<String, Object> row, @NotNull  Map<String, Object> collect)
-  {
-    if (!row.containsKey(column)) {
-      return;
-    }
-    double value = (Double)row.get(column);
-    value = Math.round(value * rounder) / rounder;
-    String name = getColumn();
-    if (alias != null) {
-      name = alias;
-    }
-    collect.put(name, value);
-  }
-}
-

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/streamquery/index/StringCaseIndex.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/streamquery/index/StringCaseIndex.java b/library/src/main/java/com/datatorrent/lib/streamquery/index/StringCaseIndex.java
deleted file mode 100644
index 2c49a79..0000000
--- a/library/src/main/java/com/datatorrent/lib/streamquery/index/StringCaseIndex.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery.index;
-
-import java.util.Map;
-
-import javax.validation.constraints.NotNull;
-
-/**
- * <p>An implementation of Column Index that implements filter method using case of a string index. </p>
- *
- * @displayName String Case Index
- * @category Stream Manipulators
- * @tags alias
- * @since 0.3.4
- */
-public class StringCaseIndex extends  ColumnIndex
-{
-  private boolean toUpperCase = true;
-  public StringCaseIndex(@NotNull String column, String alias, boolean toLowerCase)
-  {
-    super(column, alias);
-    toUpperCase = !toLowerCase;
-  }
-
-  @Override
-  public void filter(@NotNull  Map<String, Object> row, @NotNull  Map<String, Object> collect)
-  {
-    if (!row.containsKey(column)) {
-      return;
-    }
-    if (!(row.get(column) instanceof String)) {
-      assert (false);
-    }
-
-    String name = getColumn();
-    if (alias != null) {
-      name = alias;
-    }
-    if (toUpperCase) {
-      collect.put(name, ((String)row.get(column)).toUpperCase());
-    } else {
-      collect.put(name, ((String)row.get(column)).toLowerCase());
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/streamquery/index/StringLenIndex.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/streamquery/index/StringLenIndex.java b/library/src/main/java/com/datatorrent/lib/streamquery/index/StringLenIndex.java
deleted file mode 100644
index 4dbfee1..0000000
--- a/library/src/main/java/com/datatorrent/lib/streamquery/index/StringLenIndex.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery.index;
-
-import java.util.Map;
-
-import javax.validation.constraints.NotNull;
-
-/**
- * <p>An implementation of Column Index that implements filter method using length of a string Index. </p>
- * <p>
- * @displayName String Length Index
- * @category Stream Manipulators
- * @tags alias
- * @since 0.3.4
- */
-public class StringLenIndex  extends ColumnIndex
-{
-  public StringLenIndex(@NotNull String column, String alias)
-  {
-    super(column, alias);
-  }
-
-  @Override
-  public void filter(@NotNull  Map<String, Object> row, @NotNull  Map<String, Object> collect)
-  {
-    if (!row.containsKey(column)) {
-      return;
-    }
-    if (!(row.get(column) instanceof String)) {
-      assert (false);
-    }
-
-    String name = getColumn();
-    if (alias != null) {
-      name = alias;
-    }
-    collect.put(name, ((String)row.get(column)).length());
-  }
-}

http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/8f00cefa/library/src/main/java/com/datatorrent/lib/streamquery/index/SumExpression.java
----------------------------------------------------------------------
diff --git a/library/src/main/java/com/datatorrent/lib/streamquery/index/SumExpression.java b/library/src/main/java/com/datatorrent/lib/streamquery/index/SumExpression.java
deleted file mode 100644
index a0144da..0000000
--- a/library/src/main/java/com/datatorrent/lib/streamquery/index/SumExpression.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * 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 com.datatorrent.lib.streamquery.index;
-
-import java.util.Map;
-
-import javax.validation.constraints.NotNull;
-
-
-/**
- * Implements sum on column index.
- * <p>
- * Select index class for implementing sum column index.
- * @displayName Sum Expression
- * @category Stream Manipulators
- * @tags sum
- * @since 0.3.4
- */
-public class SumExpression extends BinaryExpression
-{
-
-  /**
-   * @param left column name argument for expression.
-   * @param right column name argument for expression.
-   * @param alias name for output field.
-   */
-  public SumExpression(@NotNull String left, @NotNull String right, String alias)
-  {
-    super(left, right, alias);
-    if (this.alias == null) {
-      this.alias = "SUM(" + left + "," + right + ")";
-    }
-  }
-
-  /* sum column values.
-   * @see com.datatorrent.lib.streamquery.index.Index#filter(java.util.Map, java.util.Map)
-   */
-  @Override
-  public void filter(Map<String, Object> row, Map<String, Object> collect)
-  {
-    if (!row.containsKey(left) || !row.containsKey(right)) {
-      return;
-    }
-    collect.put(alias, ((Number)row.get(left)).doubleValue() + ((Number)row.get(right)).doubleValue());
-  }
-
-}