public void send(Row row) { // TODO: fix the size of this row. RowBuilder builder = Row.newBuilder(grouping.cardinality()); int j = 0; for (Integer i : grouping) { builder.set(j++, row.getObject(i)); } Row key = builder.build(); if (!accumulators.containsKey(key)) { AccumulatorList list = new AccumulatorList(); for (AccumulatorFactory factory : accumulatorFactories) { list.add(factory.get()); } accumulators.put(key, list); } accumulators.get(key).send(row); }
public void end(Sink sink) throws InterruptedException { for (Map.Entry<Row, AccumulatorList> e : accumulators.entrySet()) { final Row key = e.getKey(); final AccumulatorList list = e.getValue(); RowBuilder rb = Row.newBuilder(outputRowLength); int index = 0; for (Integer groupPos : unionGroups) { if (grouping.get(groupPos)) { rb.set(index, key.getObject(index)); if (rel.indicator) { rb.set(unionGroups.cardinality() + index, true); } } // need to set false when not part of grouping set. index++; } list.end(rb); sink.send(rb.build()); } } }
public void end(Sink sink) throws InterruptedException { for (Map.Entry<Row, AccumulatorList> e : accumulators.entrySet()) { final Row key = e.getKey(); final AccumulatorList list = e.getValue(); RowBuilder rb = Row.newBuilder(outputRowLength); int index = 0; for (Integer groupPos : unionGroups) { if (grouping.get(groupPos)) { rb.set(index, key.getObject(index)); if (rel.indicator) { rb.set(unionGroups.cardinality() + index, true); } } // need to set false when not part of grouping set. index++; } list.end(rb); sink.send(rb.build()); } } }
public void send(Row row) { // TODO: fix the size of this row. RowBuilder builder = Row.newBuilder(grouping.cardinality()); int j = 0; for (Integer i : grouping) { builder.set(j++, row.getObject(i)); } Row key = builder.build(); if (!accumulators.containsKey(key)) { AccumulatorList list = new AccumulatorList(); for (AccumulatorFactory factory : accumulatorFactories) { list.add(factory.get()); } accumulators.put(key, list); } accumulators.get(key).send(row); }