com.yahoo.bullet.storm.grouping.IDGrouping Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bullet-storm Show documentation
Show all versions of bullet-storm Show documentation
This is the implementation of Bullet - a real-time query engine - in Apache Storm.
The newest version!
/*
* Copyright 2021, Yahoo Inc.
* Licensed under the terms of the Apache License, Version 2.0.
* See the LICENSE file associated with the project for terms.
*/
package com.yahoo.bullet.storm.grouping;
import org.apache.storm.generated.GlobalStreamId;
import org.apache.storm.grouping.CustomStreamGrouping;
import org.apache.storm.task.WorkerTopologyContext;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import static com.yahoo.bullet.storm.StormUtils.getHashIndex;
import static com.yahoo.bullet.storm.TopologyConstants.ID_POSITION;
/**
* Custom grouping used to group by the id (first) field.
*/
public class IDGrouping implements CustomStreamGrouping {
private List> tasks;
@Override
public void prepare(WorkerTopologyContext context, GlobalStreamId stream, List targetTasks) {
tasks = targetTasks.stream().map(Collections::singletonList).collect(Collectors.toList());
}
@Override
public List chooseTasks(int taskID, List