Github user ddebrunner commented on a diff in the pull request:
https://github.com/apache/incubator-quarks/pull/11#discussion_r56183501
--- Diff:
spi/topology/src/main/java/quarks/topology/spi/graph/ConnectorStream.java ---
@@ -96,6 +89,35 @@ protected Graph graph() {
}
@Override
+ public <E extends Enum<E>> EnumMap<E,TStream<T>> split(Class<E>
enumClass, Function<T, E> splitter) {
+
+ E[] es = enumClass.getEnumConstants();
+
+/*
+ List<TStream<T>> outputs = split(es.length, e ->
IntStream.range(0, es.length).filter(i-> es[i].equals(splitter.apply(e)))
+ .mapToObj(i -> es[i].ordinal()).findAny().orElse(-1));
+*/
+
+ List<TStream<T>> outputs = split(es.length, new ToIntFunction<T>()
{
--- End diff --
The function is incorrect as it can call the splitter function multiple
times, I think it can be simplified to something like:
```
t -> {E split = spitter.apply(t); return split != null ? split.ordinal() :
-1;}
```
which also implies that when the splitter returns null that the tuple is
discard which should be documented in the api method's javadoc.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---