blob: fc657316bc1f7d6cca9437b26af71500c26defeb [file] [log] [blame]
/*
* 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.flink.table.runtime.functions;
import org.apache.flink.table.dataformat.BaseRow;
/**
* Basic interface for handling aggregate function.
*/
public interface AggHandleFunctionBase {
/**
* Initialization method for the function. It is called before the actual working methods.
*/
void open(ExecutionContext ctx) throws Exception;
/**
* Merges the other accumulators into current accumulators.
*
* @param accumulators The other row of accumulators
*/
void merge(BaseRow accumulators) throws Exception;
/**
* Set the current accumulators (saved in a row) which contains the current.
* aggregated results
* @param accumulators current accumulators
*/
void setAccumulators(BaseRow accumulators) throws Exception;
/**
* Resets all the accumulators.
*/
void resetAccumulators() throws Exception;
/**
* Gets the current accumulators (saved in a row) which contains the current
* aggregated results.
* @return the current accumulators
*/
BaseRow getAccumulators() throws Exception;
/**
* Initializes the accumulators and save them to a accumulators row.
*
* @return a row of accumulators which contains the aggregated results
*/
BaseRow createAccumulators() throws Exception;
/**
* Cleanup for the retired accumulators state.
*/
void cleanup() throws Exception;
/**
* Tear-down method for this function. It can be used for clean up work.
* By default, this method does nothing.
*/
void close() throws Exception;
}