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

redis.clients.jedis.search.aggr.Group Maven / Gradle / Ivy

The newest version!
package redis.clients.jedis.search.aggr;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Created by mnunberg on 2/22/18.
 */
public class Group {

  private final List fields = new ArrayList<>();
  private final List reducers = new ArrayList<>();

  public Group(String... fields) {
    this.fields.addAll(Arrays.asList(fields));
  }

  public Group reduce(Reducer r) {
    reducers.add(r);
    return this;
  }

  public void addArgs(List args) {

    args.add(fields.size());
    args.addAll(fields);

    reducers.forEach((r) -> r.addArgs(args));
  }
}