com.datatorrent.lib.math.ChangeAlertMap Maven / Gradle / Ivy
/**
* 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 <key,value> pair in hash map across the windows for comparison and emits hash map of <key,percent change in value for each key> if percent change
* exceeds preset threshold.
*
*
* StateFull : Yes, key/value pair in current window are stored for comparison in next window.
* Partition : No, will yield wrong result, base value won't be consistent across instances.
*
* Ports:
* data: expects Map<K,V extends Number>
* alert: emits HashMap<K,HashMap<V,Double>>(1)
*
* Properties:
* threshold: The threshold of change between consecutive tuples of the same key that triggers an alert tuple
* inverse: if set to true the key in the filter will block tuple
* filterBy: List of keys to filter on
* @displayName Change Alert Map
* @category Rules and Alerts
* @tags change, key value, numeric, percentage, map
* @since 0.3.2
*/
public class ChangeAlertMap extends BaseNumberKeyValueOperator
{
/**
* Input data port that takes a map of <key,value>.
*/
public final transient DefaultInputPort