All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hazelcast.jet.aggregate.AggregateOperation2 Maven / Gradle / Ivy

There is a newer version: 4.5.4
Show newest version
/*
 * Copyright (c) 2008-2018, Hazelcast, Inc. All Rights Reserved.
 *
 * Licensed 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.hazelcast.jet.aggregate;

import com.hazelcast.jet.function.DistributedBiConsumer;
import com.hazelcast.jet.function.DistributedFunction;

import javax.annotation.Nonnull;

/**
 * Specialization of {@link AggregateOperation} to the "arity-2" case with
 * two data streams being aggregated over. This example constructs an operation
 * that sums up {@code long} values from two streams:
 *
 * 
{@code
 * AggregateOperation2 aggrOp = AggregateOperation
 *     .withCreate(LongAccumulator::new)
 *     .andAccumulate0(LongAccumulator::add)
 *     .andAccumulate1(LongAccumulator::add)
 *     .andFinish(LongAccumulator::get);
 * }
* * @param the type of item in stream-0 * @param the type of item in stream-1 * @param the type of the accumulator * @param the type of the aggregation result */ public interface AggregateOperation2 extends AggregateOperation { /** * A primitive that updates the accumulator state to account for a new * item coming from stream-0. */ @Nonnull DistributedBiConsumer accumulateFn0(); /** * A primitive that updates the accumulator state to account for a new * item coming from stream-1. */ @Nonnull DistributedBiConsumer accumulateFn1(); /** * Returns a copy of this aggregate operation, but with the {@code * accumulate} primitive at index 0 replaced with the one supplied here. */ @Nonnull AggregateOperation2 withAccumulateFn0( @Nonnull DistributedBiConsumer newAccFn0 ); /** * Returns a copy of this aggregate operation, but with the {@code * accumulate} primitive at index 1 replaced with the one supplied here. */ @Nonnull AggregateOperation2 withAccumulateFn1( @Nonnull DistributedBiConsumer newAccFn1 ); // Override with a narrowed return type @Nonnull @Override AggregateOperation2 withFinishFn( @Nonnull DistributedFunction finishFn ); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy