tech.ytsaurus.client.operations.ReducerWithKey Maven / Gradle / Ivy
The newest version!
package tech.ytsaurus.client.operations;
import java.util.Iterator;
import javax.annotation.Nullable;
import tech.ytsaurus.core.operations.OperationContext;
import tech.ytsaurus.core.operations.Yield;
import tech.ytsaurus.lang.NonNullApi;
import tech.ytsaurus.lang.NonNullFields;
@NonNullApi
@NonNullFields
public interface ReducerWithKey extends Reducer {
TKey key(TInput entry);
default void reduce(TKey key, Iterator entries, Yield yield, Statistics statistics) {
}
default void reduce(TKey key, Iterator entries, Yield yield, Statistics statistics,
OperationContext context) {
reduce(key, entries, yield, statistics);
}
default void reduce(Iterator entries, Yield yield, Statistics statistics,
@Nullable OperationContext context) {
ReducerWithKeyIterator it = new ReducerWithKeyIterator<>(this::key, entries);
TKey key = it.nextKey();
while (key != null) {
if (context != null) {
context.setReturnPrevIndexes(true);
}
reduce(key, it, yield, statistics, context);
it.forEachRemaining(tmp -> {
});
key = it.nextKey();
}
}
}