helper for rowget/rowset
341654
def index_tuple(self,tables_dict,index,is_set):
    ""
    if not self.aonly_resolved: raise RuntimeError('resolve_aonly() before querying nix')
    with tables_dict.tempkeys():
      tables_dict.update(self.aonly) # todo: find spec support for aliases overwriting existing tables. (more likely, it's an error)
      index = index.name if isinstance(index,sqparse2.NameX) else index
      if isinstance(index,basestring):
        candidates = [t for t in self.table_order if any(f.name==index for f in tables_dict[t].fields)]
        if len(candidates)!=1: raise ColumnNameError(("ambiguous_column" if candidates else "no_such_column"),index)
        tname, = candidates
        return self.table_order.index(tname), tables_dict[tname].lookup(index).index
      elif isinstance(index,sqparse2.AttrX):
        if index.parent.name not in self.aliases: raise TableNameError('table_notin_x',index.parent,self.aliases)
        tname = self.aliases[index.parent.name]
        tindex = self.table_order.index(tname)
        if isinstance(index.attr,sqparse2.AsterX):
          if is_set: raise ValueError('cant_set_asterisk') # todo: better error class
          else: return (tindex,)
        else: return (tindex,tables_dict[tname].lookup(index.attr).index)
        # todo: stronger typing here. make sure both fields of the AttrX are always strings.
      else: raise TypeError(type(index)) # pragma: no cover
655404
protected function _formatRelatedRowset($rowset) {
        $out = array();
        foreach ($rowset as $row) {
            if (is_array($row)) {
                $values = array_values($row);
                $values = implode(' : ', $values);
                $out[] = $values;
                continue;
            }
            $out[] = $row;
        }
        $out = implode(' | ', $out);
        return $out;
    }
1267046
@SuppressWarnings("deprecation")
    public static <T> DataSet newDataSet(Collection<String> columnNames, Collection<T> rowList) {
        if (N.isNullOrEmpty(columnNames) && N.isNullOrEmpty(rowList)) {
            // throw new IllegalArgumentException("Column name list and row list can not be both null or empty");
            return new RowDataSet(new ArrayList<String>(0), new ArrayList<List<Object>>(0));
        } else if (N.isNullOrEmpty(rowList)) {
            return new RowDataSet(new ArrayList<String>(columnNames), new ArrayList<List<Object>>(0));
        }

        final int rowSize = rowList.size();

        if (N.isNullOrEmpty(columnNames)) {
            final Set<String> columnNameSet = new LinkedHashSet<>();
            Set<Class<?>> clsSet = null;
            Map<Class<?>, Set<String>> clsSignedPropNameSetMap = new HashMap<>();

            Class<?> cls = null;
            Type<?> type = null;

            for (Object e : rowList) {
                if (e == null) {
                    continue;
                }

                cls = e.getClass();
                type = N.typeOf(cls);

                if (type.isMap()) {
                    columnNameSet.addAll(((Map<String, Object>) e).keySet());
                } else if (type.isEntity()) {
                    if (e instanceof DirtyMarker) {
                        Set<String> clsSignedPropNameSet = clsSignedPropNameSetMap.get(cls);

                        if (clsSignedPropNameSet == null) {
                            clsSignedPropNameSet = new HashSet<>();
                            clsSignedPropNameSetMap.put(cls, clsSignedPropNameSet);
                        }

                        Method method = null;

                        for (String signedPropName : ((DirtyMarker) e).signedPropNames()) {
                            if (clsSignedPropNameSet.add(signedPropName) == false) {
                                continue;
                            }

                            method = ClassUtil.getPropGetMethod(cls, signedPropName);

                            if (method != null) {
                                columnNameSet.add(ClassUtil.getPropNameByMethod(method));
                            }
                        }
                    } else {
                        if (clsSet == null) {
                            clsSet = new HashSet<>();
                        }

                        if (clsSet.contains(cls)) {
                            continue;
                        }

                        columnNameSet.addAll(ClassUtil.checkPropGetMethodList(cls).keySet());
                        clsSet.add(cls);
                    }
                } else {
                    throw new IllegalArgumentException("'columnNameList' is required if the sepcified row type is not Entity or Map");
                }
            }

            // re-order column.
            for (Map.Entry<Class<?>, Set<String>> entry : clsSignedPropNameSetMap.entrySet()) {
                final List<String> intersecion = N.intersection(ClassUtil.getPropGetMethodList(entry.getKey()).keySet(), columnNameSet);
                columnNameSet.removeAll(intersecion);
                columnNameSet.addAll(intersecion);
            }

            columnNames = new ArrayList<>(columnNameSet);

            if (N.isNullOrEmpty(columnNames)) {
                throw new IllegalArgumentException("Column name list can not be obtained from row list because it's empty or null");
            }
        }

        final int columnCount = columnNames.size();
        final List<String> columnNameList = new ArrayList<>(columnNames);
        final List<List<Object>> columnList = new ArrayList<>(columnCount);
        for (int i = 0; i < columnCount; i++) {
            columnList.add(new ArrayList<>(rowSize));
        }

        Type<?> type = null;
        for (Object e : rowList) {
            if (e == null) {
                for (int i = 0; i < columnCount; i++) {
                    columnList.get(i).add(null);
                }

                continue;
            }

            type = N.typeOf(e.getClass());

            if (type.isMap()) {
                Map<String, Object> props = (Map<String, Object>) e;

                for (int i = 0; i < columnCount; i++) {
                    columnList.get(i).add(props.get(columnNameList.get(i)));
                }
            } else if (type.isEntity()) {
                Class<?> cls = e.getClass();

                Method method = null;
                for (int i = 0; i < columnCount; i++) {
                    method = ClassUtil.getPropGetMethod(cls, columnNameList.get(i));

                    if (method == null) {
                        columnList.get(i).add(null);
                    } else {
                        columnList.get(i).add(ClassUtil.getPropValue(e, method));
                    }
                }
            } else if (type.isArray()) {
                if (type.isPrimitiveArray()) {
                    for (int i = 0; i < columnCount; i++) {
                        columnList.get(i).add(Array.get(e, i));
                    }
                } else {
                    Object[] array = (Object[]) e;

                    for (int i = 0; i < columnCount; i++) {
                        columnList.get(i).add(array[i]);
                    }
                }
            } else if (type.isCollection()) {
                final Iterator<Object> it = ((Collection<Object>) e).iterator();

                for (int i = 0; i < columnCount; i++) {
                    columnList.get(i).add(it.next());
                }
            } else {
                throw new IllegalArgumentException(
                        "Unsupported row type: " + ClassUtil.getCanonicalClassName(e.getClass()) + ". Only array, collection, map and entity are supported");
            }
        }

        return new RowDataSet(columnNameList, columnList);
    }
354698
def _get_num_similar_rows(self, row, until=None):
        """"""
        return len(list(filter(lambda r: row == r, self.dataset[:until])))
54609
@Override
  public RowSet getNextRowSet(FetchOrientation orientation, long maxRows) throws HiveSQLException {
    validateDefaultFetchOrientation(orientation);
    if (orientation.equals(FetchOrientation.FETCH_FIRST)) {
      resetResultReader();
    }
    List<String> rows = readResults((int) maxRows);
    RowSet rowSet = RowSetFactory.create(resultSchema, getProtocolVersion());

    for (String row : rows) {
      rowSet.addRow(new String[] {row});
    }
    return rowSet;
  }
1252258
function ResultSet(metadata, rows) {
  this.rows = [];
  this.metadata = metadata;
  for (var i = 0; i < rows.length; i++) {
    this.rows.push(new Row(metadata.columnSpecs, rows[i]));
  }
}
187671
def row(self, fields):
        """"""

        d = self.dict

        row = [None] * len(fields)

        for i, f in enumerate(fields):
            if f in d:
                row[i] = d[f]

        return row
553784
def row_iter(self):
        """"""
        for k in utils.range_(self.side):
            yield self.row(k)
1021728
def prepare_rows(self,
                     rows,
                     indent,
                     has_header):

        ''''''

        out = []

        def row_wrapper(row):
            new_rows = [
                self.wrapfunc(item).split('\n')
                for item in row
            ]
            rows = []
            for item in map(lambda *args: args, *new_rows):
                if isinstance(item, (tuple, list)):
                    rows.append([substr or '' for substr in item])
                else:
                    rows.append([item])
            return rows

        logical_rows = [
            row_wrapper(row)
            for row in rows
        ]

        columns = map(lambda *args: args, *reduce(operator.add, logical_rows))

        max_widths = [
            max([len(six.text_type(item)) for item in column])
            for column in columns
        ]
        row_separator = self.row_delimiter * (len(self.prefix) + len(self.suffix) + sum(max_widths) +
                                              len(self.delim) * (len(max_widths) - 1))

        justify = self._JUSTIFY_MAP[self.justify.lower()]

        if self.separate_rows:
            out.append(
                self.ustring(
                    indent,
                    self.LIGHT_GRAY,  # pylint: disable=no-member
                    row_separator
                )
            )
        for physical_rows in logical_rows:
            for row in physical_rows:
                line = self.prefix \
                        + self.delim.join([
                                justify(six.text_type(item), width)
                                for (item, width) in zip(row, max_widths)
                        ]) + self.suffix
                out.append(
                    self.ustring(
                        indent,
                        self.WHITE,  # pylint: disable=no-member
                        line
                    )
                )
            if self.separate_rows or has_header:
                out.append(
                    self.ustring(
                        indent,
                        self.LIGHT_GRAY,  # pylint: disable=no-member
                        row_separator
                    )
                )
                has_header = False
        return out
1241062
def _parse_row(row, sep=','):
    '''

    '''
    parsed = row.split(sep)
    parsed = [x for x in parsed if x.strip()]
    return parsed
1070599
private List iterateAndReturn(ResultSet rSet) {
        Iterator<Row> rowIter = rSet.iterator();
        List results = new ArrayList();

        while (rowIter.hasNext()) {
            Row row = rowIter.next();
            ColumnDefinitions columnDefs = row.getColumnDefinitions();
            Iterator<Definition> columnDefIter = columnDefs.iterator();
            Map rowData = new HashMap();
            while (columnDefIter.hasNext()) {
                Definition columnDef = columnDefIter.next();
                rowData.put(columnDef.getName(), DSClientUtilities.assign(row, null, null,
                    columnDef.getType().getName(), null, columnDef.getName(), null, null));
            }
            results.add(rowData);
        }
        return results;
    }
425407
def row(row, val = nil)
      if val.nil?
        get_row(row)
      else
        set_row(row, val)
      end
    end
1260562
def handle_set_row(self):
        """"""
        row = self.reader.int()
        logger.info(" -> row: %s", row)
        self.controller.row = row
602265
public String getRowText(int rowIndex) {
        String rowText = null;
        String xPath = getXPathBase() + "tr[" + rowIndex + "]";

        rowText = HtmlElementUtils.locateElement(xPath).getText();

        return rowText;
    }
926955
def attrput(self, groupname, attrname, rownr, value, unit=[], meas=[]):
        """"""
        return self._attrput(groupname, attrname, rownr, value, unit, meas)
198460
public void containsRow(@NullableDecl Object rowKey) {
    check("rowKeySet()").that(actual().rowKeySet()).contains(rowKey);
  }
211469
function convertRowsetToRows(
    statement,
    startIndex,
    rowset,
    columns,
    mapColumnNameToIndices)
{
  // assert that rowset and columns are arrays
  Errors.assertInternal(Util.isArray(rowset));
  Errors.assertInternal(Util.isArray(columns));


  ///////////////////////////////////////////////////////////////////////////
  ////     Create functions that will be used as row methods             ////
  ///////////////////////////////////////////////////////////////////////////

  /**
   * Returns the index of this row in the result.
   *
   * @returns {Number}
   */
  var getRowIndex = function()
  {
    return this.rowIndex;
  };

  /**
   * Returns the statement that produced this row.
   *
   * @returns {*}
   */
  var getStatement = function getStatement()
  {
    return statement;
  };

  /**
   * Returns the value of a column.
   *
   * @param {String | Number} columnIdentifier this can be either the column
   *   name or the column index.
   *
   * @returns {*}
   */
  var getColumnValue = function getColumnValue(columnIdentifier)
  {
    // resolve the column identifier to the correct column if possible
    var column = resolveColumnIdentifierToColumn(
        columns, columnIdentifier, mapColumnNameToIndices);

    return column ? column.getRowValue(this) : undefined;
  };

  /**
   * Returns the value of a column as a String.
   *
   * @param {String | Number} columnIdentifier this can be either the column
   *   name or the column index.
   *
   * @returns {*}
   */
  var getColumnValueAsString = function getColumnValueAsString(columnIdentifier)
  {
    // resolve the column identifier to the correct column if possible
    var column = resolveColumnIdentifierToColumn(
        columns, columnIdentifier, mapColumnNameToIndices);

    return column ? column.getRowValueAsString(this) : undefined;
  };


  ///////////////////////////////////////////////////////////////////////////
  ////     Convert the rowset to an array of row objects                 ////
  ///////////////////////////////////////////////////////////////////////////

  // create a new array to store the processed rows
  var length = rowset.length;
  var rows = new Array(length);
  for (var index = 0; index < length; index++)
  {
    // add a new item to the rows array
    rows[index] =
    {
      _arrayProcessedColumns : [],

      values                 : rowset[index],
      rowIndex               : startIndex + index,
      getRowIndex            : getRowIndex,
      getStatement           : getStatement,
      getColumnValue         : getColumnValue,
      getColumnValueAsString : getColumnValueAsString
    };
  }

  return rows;
}