Applies the function in {@code rowConsumer} to each group of contiguous rows of size n in the table
This can be used, for example, to calculate a running average of in rows
555839
public void rollWithRows(Consumer<Row[]> rowConsumer, int n) {
        if (isEmpty()) {
            return;
        }
        Row[] rows = new Row[n];
        for (int i = 0; i < n; i++) {
            rows[i] = new Row(this);
        }

        int max = rowCount() - (n - 2);
        for (int i = 1; i < max; i++) {
            for (int r = 0; r < n; r++) {
                rows[r].at(i + r - 1);
            }
            rowConsumer.accept(rows);
        }
    }
106279
private Iterator<Record> rowQuery(final List<Map.Entry<ByteBuffer, Key>> rowKeys, final ReadConsistency consistency,
                                      final DeltaPlacement placement) {
        List<ByteBuffer> keys = Lists.newArrayListWithCapacity(rowKeys.size());
        final Map<ByteBuffer, Key> rawKeyMap = Maps.newHashMap();
        for (Map.Entry<ByteBuffer, Key> entry : rowKeys) {
            keys.add(entry.getKey());
            rawKeyMap.put(entry.getKey(), entry.getValue());
        }

        BlockedDeltaTableDDL tableDDL = placement.getBlockedDeltaTableDDL();

        Statement statement = selectDeltaFrom(tableDDL)
                .where(in(tableDDL.getRowKeyColumnName(), keys))
                .setConsistencyLevel(SorConsistencies.toCql(consistency));

        Iterator<Iterable<Row>> rowGroups = deltaQueryAsync(placement, statement, false, "Failed to read records %s", rawKeyMap.values());

        return Iterators.concat(
                // First iterator reads the row groups found and transforms them to Records
                Iterators.transform(rowGroups, rows -> {
                    ByteBuffer keyBytes = getRawKeyFromRowGroup(rows);
                    Key key = rawKeyMap.remove(keyBytes);
                    assert key != null : "Query returned row with a key out of bound";
                    return newRecordFromCql(key, rows, placement, ByteBufferUtil.bytesToHex(keyBytes));
                }),
                // Second iterator returns an empty Record for each key queried but not found.
                new AbstractIterator<Record>() {
                    private Iterator<Key> _nonExistentKeyIterator;

                    @Override
                    protected Record computeNext() {
                        // Lazily return an empty record for each key not found in the previous iterator.
                        // rawKeyMap.iterator() must not be called until the first iterator is completely spent.
                        if (_nonExistentKeyIterator == null) {
                            _nonExistentKeyIterator = rawKeyMap.values().iterator();
                        }
                        return _nonExistentKeyIterator.hasNext() ?
                                emptyRecord(_nonExistentKeyIterator.next()) :
                                endOfData();
                    }
                });
    }
105976
ImmutableCell<V> validateCounts(int rowCount, int columnCount) {
        if (row >= rowCount || column >= columnCount) {
            throw new IndexOutOfBoundsException("Invalid row-column: " + row + "," + column + " for grid " + rowCount + "x" + columnCount);
        }
        return this;
    }
1138575
protected void addPrevExpandedRow(final Object rowKey) {
		WTableComponentModel model = getOrCreateComponentModel();
		if (model.prevExpandedRows == null) {
			model.prevExpandedRows = new HashSet<>();
		}
		model.prevExpandedRows.add(rowKey);
	}
1230504
@Override
    public final boolean satisfiedForConsume(final FilterOutcomes outcomes, final InputRow row) {
        final boolean satisfiedOutcomesForConsume =
                satisfiedOutcomesForConsume(_hasComponentRequirement, row, outcomes);
        if (!satisfiedOutcomesForConsume) {
            return false;
        }
        return satisfiedInputsForConsume(row, outcomes);
    }
1279570
@SuppressWarnings({ "unchecked", "rawtypes" })
    public Table aggregate(ListMultimap<String, AggregateFunction<?,?>> functions) {
        Preconditions.checkArgument(!getSlices().isEmpty());
        Table groupTable = summaryTableName(sourceTable);
        StringColumn groupColumn = StringColumn.create("Group");
        groupTable.addColumns(groupColumn);
        for (Map.Entry<String, Collection<AggregateFunction<?,?>>> entry : functions.asMap().entrySet()) {
            String columnName = entry.getKey();
            int functionCount = 0;
            for (AggregateFunction function : entry.getValue()) {
                String colName = aggregateColumnName(columnName, function.functionName());
                ColumnType type = function.returnType();
                Column resultColumn = type.create(colName);
                for (TableSlice subTable : getSlices()) {
                    Object result = function.summarize(subTable.column(columnName));
                    if (functionCount == 0) {
                        groupColumn.append(subTable.name());
                    }
                    if (result instanceof Number) {
                        Number number = (Number) result;
                        resultColumn.append(number.doubleValue());
                    } else {
                        resultColumn.append(result);
                    }
                }
                groupTable.addColumns(resultColumn);
                functionCount++;
            }
        }
        return splitGroupingColumn(groupTable);
    }
848458
function Grid(cellSize, cellCount, parentHierarchy) {
    this.cellSize = cellSize;
    this.inverseCellSize = 1 / cellSize;
    this.rowColumnCount = ~~Math.sqrt(cellCount);
    this.xyHashMask = this.rowColumnCount - 1;
    this.occupiedCells = [];
    this.allCells = Array(this.rowColumnCount * this.rowColumnCount);
    this.allObjects = [];
    this.sharedInnerOffsets = [];

    this._parentHierarchy = parentHierarchy || null;
}
1170117
public static void multRows(double[] diag, int offset, DMatrixSparseCSC A) {
        if( diag.length < A.numRows )
            throw new IllegalArgumentException("Array is too small. "+diag.length+" < "+A.numCols);

        for (int i = 0; i < A.nz_length; i++) {
            A.nz_values[i] *= diag[A.nz_rows[i+offset]];
        }
    }
324767
public static List<RowProcessingConsumer> sortConsumers(List<RowProcessingConsumer> consumers) {
        final RowProcessingConsumerSorter sorter = new RowProcessingConsumerSorter(consumers);
        final List<RowProcessingConsumer> sortedConsumers = sorter.createProcessOrderedConsumerList();
        if (logger.isDebugEnabled()) {
            logger.debug("Row processing order ({} consumers):", sortedConsumers.size());
            int i = 1;
            for (RowProcessingConsumer rowProcessingConsumer : sortedConsumers) {
                logger.debug(" {}) {}", i, rowProcessingConsumer);
                i++;
            }
        }
        return sortedConsumers;
    }
360760
private void doPaintRows(final WTable table, final WebXmlRenderContext renderContext) {
		TableRepeater repeater = table.getRepeater();

		WComponent row = repeater.getRepeatedComponent();

		List<RowIdWrapper> wrappers = repeater.getBeanList();

		Set<?> otherSelectedRows = new HashSet<>(table.getSelectedRows());

		int index = -1;
		for (RowIdWrapper wrapper : wrappers) {
			index++;

			Object rowKey = wrapper.getRowKey();

			if (table.getSelectedRows().contains(rowKey)) {
				otherSelectedRows.remove(rowKey);
			}

			// Only rendering top level rows
			// Child rows handled by the layout, so dont paint the row
			if (wrapper.getParent() != null) {
				continue;
			}

			// Each row has its own context. This is why we can reuse the same
			// WComponent instance for each row.
			UIContext rowContext = repeater.getRowContext(wrapper, index);

			UIContextHolder.pushContext(rowContext);

			try {
				row.paint(renderContext);
			} finally {
				UIContextHolder.popContext();
			}
		}
		this.selectedOnOther = otherSelectedRows.size();
	}
871066
public void accumulate(Object workingMemoryContext,
                           Object context,
                           Tuple leftTuple,
                           InternalFactHandle handle,
                           Declaration[] declarations,
                           Declaration[] innerDeclarations,
                           WorkingMemory workingMemory) throws Exception {
        final Object value = this.expression.evaluate( handle,
                                                       leftTuple,
                                                       declarations,
                                                       innerDeclarations,
                                                       workingMemory,
                                                       workingMemoryContext ).getValue();
        if ( this.function.supportsReverse() ) {
            ((JavaAccumulatorFunctionContext) context).reverseSupport.put( handle.getId(),
                                                                           value );
        }
        this.function.accumulate( ((JavaAccumulatorFunctionContext) context).context,
                                  value );
    }
71664
public void setRowsSpanned(final Table table, final TableAppender appender, final int rowIndex,
                               final int colIndex, final int n) throws IOException {
        if (n <= 1) return;

        final TableCell firstCell = this.getRowSecure(table, appender, rowIndex, false)
                .getOrCreateCell(colIndex);
        if (firstCell.isCovered()) return;

        firstCell.markRowsSpanned(n);
        this.coverCellsBelow(table, appender, rowIndex, colIndex, n);
    }
664502
public static <K, V, R extends MutableMultimap<K, V>> MutableMultimap<K, V> groupBy(
            Iterable<V> iterable,
            Function<? super V, ? extends K> function,
            R concurrentMultimap,
            int batchSize)
    {
        return ParallelIterate.groupBy(iterable, function, concurrentMultimap, batchSize, ParallelIterate.EXECUTOR_SERVICE);
    }
897491
@Override
    public final void closeConsumers() {
        final TaskRunner taskRunner = getTaskRunner();
        final List<RowProcessingConsumer> configurableConsumers = getConsumers();
        for (final RowProcessingConsumer consumer : configurableConsumers) {
            final TaskRunnable task = createCloseTask(consumer, null);
            taskRunner.run(task);
        }
    }
587760
public static <T, R> Consumer<T> consumer(Function<T, R> function) {
        dbc.precondition(function != null, "cannot adapt a null function");
        return function::apply;
    }
730130
public static <I, O> void crossProduct(List<I> left, List<I> right, Function<I, List<O>> transformer, BiConsumer<Pair<Integer, Integer>, List<O>> rowConsumer) {
        final int SIZE = left.size() * right.size();

        for (int i = 0; i < SIZE; i++) {
            List<O> newRowValues = new ArrayList<>();
            int j = 1;
            List<Integer> currentIndexes = new ArrayList<>();
            for (List<I> rowsList : new ArrayList<List<I>>() {
                {
                    add(left);
                    add(right);
                }
            }) {
                final int index = ( i / j ) % rowsList.size();
                currentIndexes.add(index);
                I row = rowsList.get(index);
                List<O> rowPart = transformer.apply(row);
                newRowValues.addAll(rowPart);
                j *= rowsList.size();
            }
            if (currentIndexes.size() == 2) {
                rowConsumer.accept(new Pair<>(currentIndexes.get(0), currentIndexes.get(1)), newRowValues);
            }
        }
    }
21777
public ApiFuture<Void> add(final RowMutation rowMutation) {
    Preconditions.checkState(!closed, "BulkMutations has been closed");
    numOutstanding.incrementAndGet();

    ApiFuture<Void> future = callable.futureCall(rowMutation);

    ApiFutures.addCallback(
        future,
        new ApiFutureCallback<Void>() {
          @Override
          public void onFailure(Throwable throwable) {
            onMutationComplete(false);
          }

          @Override
          public void onSuccess(Void aVoid) {
            onMutationComplete(true);
          }
        },
        MoreExecutors.directExecutor());

    return future;
  }