/*
The actual method that splits the DataList into an ArrayList of rows that
contain an ArrayList of Columns
492426
public function createGridLayout($itemsInGrid, $numberOfCols)
    {
        $position = 1;
        $columns = new ArrayList();
        $result = new ArrayList();
        foreach ($itemsInGrid as $key => $item) {
            $columns->push($item);
            if (($position) >= $numberOfCols) {
                $position = 1;
                $row = new ArrayList();
                $row->Columns = $columns;
                $result->push($row);
                $columns = new ArrayList();
            } else {
                $position = $position + 1;
            }
        }
        if ($columns->Count() > 0) {
            $row = new ArrayList();
            $row->Columns = $columns;
            $result->push($row);
        }
        return $result;
    }
1015759
public final List<Element> mapRowToList(final ResultSet rs, final String columnNameArray) throws SQLException {
        if (rs == null) {
            return Collections.emptyList();
        }

        final Array sqlArray = rs.getArray(columnNameArray);

        if (sqlArray == null) {
            return Collections.emptyList();
        } else {
            final ResultSet resultSet = sqlArray.getResultSet();
            final List<String> l = new ArrayList<String>();
            while (resultSet.next()) {
                String test = resultSet.getString(2);
                l.add(test);
            }

            List<Element> elements = new ArrayList<Element>(l.size());
            for (String s : l) {
                try {
                    List<String> resultList = ParseUtils.postgresROW2StringList(s);
                    Element element = new Element();
                    element.setRowList(resultList);
                    elements.add(element);
                } catch (Exception e) {
                    LOG.error("Problem parsing received ROW value [{}]: {}", new Object[] {s, e.getMessage(), e});
                }
            }

            return elements;
        }

    }
510266
private ObjectNode convertRow(ObjectNode reuse, RowTypeInfo info, Row row) {
		if (reuse == null) {
			reuse = mapper.createObjectNode();
		}
		final String[] fieldNames = info.getFieldNames();
		final TypeInformation<?>[] fieldTypes = info.getFieldTypes();

		// validate the row
		if (row.getArity() != fieldNames.length) {
			throw new IllegalStateException(String.format(
				"Number of elements in the row '%s' is different from number of field names: %d", row, fieldNames.length));
		}

		for (int i = 0; i < fieldNames.length; i++) {
			final String name = fieldNames[i];

			final JsonNode fieldConverted = convert(reuse, reuse.get(name), fieldTypes[i], row.getField(i));
			reuse.set(name, fieldConverted);
		}

		return reuse;
	}
970831
@NonNull
    Collection<TObj> getRowItems(int row) {
        Collection<TObj> result = new LinkedList<>();
        SparseArrayCompat<TObj> array = mData.get(row);
        for (int count = array.size(), i = 0; i < count; i++) {
            int key = array.keyAt(i);
            TObj columnObj = array.get(key);
            if (columnObj != null) {
                result.add(columnObj);
            }

        }
        return result;
    }
89265
private static double[][] rowsum(double[][] rr, ArrayList<String> sets) throws Exception {
		LinkedHashMap<String, Double> sumMap = new LinkedHashMap<String, Double>();
		if (rr.length != sets.size()) {
			throw new Exception("Cluster value for each sample are not of equal length n=" + rr.length + " cluster length=" + sets.size());
		}
		double[][] sum = null;
		for (int j = 0; j < rr[0].length; j++) {
			for (int i = 0; i < sets.size(); i++) {
				String s = sets.get(i);
				Double v = sumMap.get(s); //get in order
				if (v == null) {
					v = 0.0;
				}
				v = v + rr[i][j];
				sumMap.put(s, v);

			}
			if (sum == null) {
				sum = new double[sumMap.size()][rr[0].length];
			}

			ArrayList<String> index = new ArrayList<String>(sumMap.keySet());
			//sorting does seem to make a difference in test cases at the .0000000001
	   //     ArrayList<Integer> in = new ArrayList<Integer>();
	   //     for (String s : index) {
	   //         in.add(Integer.parseInt(s));
	   //     }
	   //     Collections.sort(index);

			for (int m = 0; m < index.size(); m++) {
				String key = index.get(m);
				sum[m][j] = sumMap.get(key);
			}

			sumMap.clear();
		}

		return sum;

	}
836451
public final DataSet rows(Object[][] rows) {
    checkIfNotReadOnly();
    for (Object[] columnValues : rows) {
      addRow(new Row(columnValues));
    }
    return this;
  }
550777
function _getRows(matrix) {
  var rows = [];
  for (var i=0; i<matrix.size.rows; i++) {
    rows.push([]);
    for (var j=0; j<matrix.size.columns; j++)
      rows[i].push(matrix.values[matrix.size.columns * i + j]);
  }
  return rows;
}
873856
@Override protected void init() throws IllegalArgumentException {
    super.init();
    /* Check input parameters */
    float sum = 0;
    long nrows = source.numRows();
    if (nrows <= ratios.length) throw new IllegalArgumentException("Dataset does not have enough row to be split!");
    for (int i=0; i<ratios.length; i++) {
      if (!(ratios[i] > 0 && ratios[i] < 1)) throw new IllegalArgumentException("Split ration has to be in (0,1) interval!");
      if (ratios[i] * nrows <= 1) throw new IllegalArgumentException("Ratio " + ratios[i] + " produces empty frame since the source frame has only " + nrows + "!");
      sum += ratios[i];
    }
    if (!(sum<1f)) throw new IllegalArgumentException("Sum of split ratios has to be less than 1!");
  }
1287121
function() {
      var array = [],
          i, j, ilen, jlen;
      for(i = 0, ilen = this.elements.length; i < ilen; i++) {
        var row = [];
        for(j = 0, jlen = this.column_names.length; j < jlen ; j++) {
          row.push( this.elements[i][ this.column_names[j] ] );
        }
        array.push(row);
      }
      return array;
    }
821864
protected List getAsList(Map<String, Object> row, String columnName) {
		return (List)row.get(columnName);
	}
412239
function _Matrix(numRows, numColumns, data) {
  if(!Number.isInteger(numRows))
    throw new TypeError("/numRows/ must be an integer.");
  if(!Number.isInteger(numColumns))
      throw new TypeError("/numColumns/ must be an integer.");

  var _values;
  var _numValues = numRows * numColumns;
  if (!data || data === undefined)
    _values = [];
  else if (!util.isNumberArray(data))
    throw new TypeError('Invalid values for vector.');
  else
    _values = data;

  // Make sure the matrix has numRows * numColumns values
  if (_values.length < _numValues) {
    var zeros = Array(_numValues - _values.length).fill(0);
    _values = _values.concat(zeros);
  } else if (_values.length > _numValues) {
    _values = _values.slice(0, _numValues);
  }

  var size = {"rows": numRows, "columns": numColumns};
  readonly(this, "size", size);
  readonly(this, "values", _values);
  readonly(this, "rows", _getRows(this));
  readonly(this, "columns", _getColumns(this));
}
429735
public double[] map( Map<String, Double> row, double data[] ) {
    String[] colNames = getNames();
    for( int i=0; i<colNames.length-1; i++ ) {
      Double d = row.get(colNames[i]);
      data[i] = d==null ? Double.NaN : d;
    }
    return data;
  }
551564
public static Collection<Row> getRowsFromsCells(Collection<Cells> cellsCol) {
        Collection<Row> result = new ArrayList<>();
        for (Cells cells : cellsCol) {
            result.add(getRowFromCells(cells));
        }
        return result;
    }
1087512
public static DMatrixRMaj[] splitIntoVectors(DMatrix1Row A , boolean column )
    {
        int w = column ? A.numCols : A.numRows;

        int M = column ? A.numRows : 1;
        int N = column ? 1 : A.numCols;

        int o = Math.max(M,N);

        DMatrixRMaj[] ret  = new DMatrixRMaj[w];

        for( int i = 0; i < w; i++ ) {
            DMatrixRMaj a = new DMatrixRMaj(M,N);

            if( column )
                subvector(A,0,i,o,false,0,a);
            else
                subvector(A,i,0,o,true,0,a);

            ret[i] = a;
        }

        return ret;
    }
587589
function getResultsList(dataList) {
  if (isObject(dataList)) {
    if (isArray(dataList)) {
      return dataList.map(function(v) {
        return v[0]; //v[0] contains full string
      });
    }
    else {
      /*
       * Example dataList:
       *
       * data: [{a: 10, b: ['dude', 'd', '', 'ude'], c:['dumb', 'd', '', 'umb']}, {a: 10, b: ['dude man', 'd', '', 'ude man'], c: null}]
       * searchInProps: ['b', 'c']
       */
      var tempDataList = clone(dataList);

      tempDataList.data = tempDataList.data.map(function(data) {
        tempDataList.searchInProps.forEach(function(key) {
          if (data[key]) data[key] = data[key][0];
        });
        return data;
      });
      return tempDataList;
    }
  }
  else throw new SyntaxError(messages.DataMustBeArrayOrObject);
}
893156
private void parseQueryRowsRaw(boolean lastChunk) {
        while (responseContent.isReadable()) {
            int splitPos = findSplitPosition(responseContent, ',');
            int arrayEndPos = findSplitPosition(responseContent, ']');

            boolean doSectionDone = false;

            if (splitPos == -1 && arrayEndPos == -1) {
                //need more data
                break;
            } else if (arrayEndPos > 0 && (arrayEndPos < splitPos || splitPos == -1)) {
                splitPos = arrayEndPos;
                doSectionDone = true;
            }

            int length = splitPos - responseContent.readerIndex();
            ByteBuf resultSlice = responseContent.readSlice(length);
            queryRowObservable.onNext(resultSlice.copy());
            responseContent.skipBytes(1);
            responseContent.discardReadBytes();

            if (doSectionDone) {
                sectionDone();
                queryParsingState = transitionToNextToken(lastChunk);
                break;
            }
        }
    }
102072
public static List<Integer> rowIndexStringToList(final String row) {
		if (row == null) {
			return null;
		}

		List<Integer> rowIndex = new ArrayList<>();

		try {

			// Convert StringId to array
			String[] rowIdString = row.split(INDEX_DELIMITER);
			for (int i = 0; i < rowIdString.length; i++) {
				rowIndex.add(Integer.parseInt(rowIdString[i]));
			}
		} catch (NumberFormatException e) {
			LOG.warn("Invalid row id: " + row);
		}

		return rowIndex;
	}