Reads in the next record on the file and return a row

@param ds
@return Row
767322
@Override
    public Row buildRow(final DefaultDataSet ds) {
        String line = null;
        try {
            while ((line = br.readLine()) != null) {
                lineCount++;
                // empty line skip past it
                if (line.trim().length() == 0) {
                    continue;
                }

                final String mdkey = FixedWidthParserUtils.getCMDKey(getPzMetaData(), line);

                final Row row = new Row();
                row.setRowNumber(lineCount);
                row.setMdkey(mdkey.equals(FPConstants.DETAIL_ID) ? null : mdkey);

                final List<ColumnMetaData> cmds = ParserUtils.getColumnMetaData(mdkey, getPzMetaData());

                final int recordLength = ((Integer) recordLengths.get(mdkey)).intValue();

                if (line.length() > recordLength) {
                    // Incorrect record length on line log the error. Line will not
                    // be included in the
                    // dataset
                    if (isIgnoreExtraColumns()) {
                        addError(ds, "TRUNCATED LINE TO CORRECT LENGTH", lineCount, 1);
                        // user has chosen to ignore the fact that we have too many bytes in the fixed
                        // width file. Truncate the line to the correct length
                        row.addColumn(FixedWidthParserUtils.splitFixedText(cmds, line.substring(0, recordLength), isPreserveLeadingWhitespace(),
                                isPreserveTrailingWhitespace()));
                    } else {
                        addError(ds, "LINE TOO LONG. LINE IS " + line.length() + " LONG. SHOULD BE " + recordLength, lineCount, 2,
                                isStoreRawDataToDataError() ? line : null);
                        continue;
                    }
                } else if (line.length() < recordLength) {
                    if (isHandlingShortLines()) {
                        // log a warning
                        addError(ds, "PADDED LINE TO CORRECT RECORD LENGTH", lineCount, 1);
                        // We can pad this line out
                        row.addColumn(FixedWidthParserUtils.splitFixedText(cmds, line + ParserUtils.padding(recordLength - line.length(), ' '),
                                isPreserveLeadingWhitespace(), isPreserveTrailingWhitespace()));

                    } else {
                        addError(ds, "LINE TOO SHORT. LINE IS " + line.length() + " LONG. SHOULD BE " + recordLength, lineCount, 2,
                                isStoreRawDataToDataError() ? line : null);
                        continue;
                    }
                } else {
                    row.addColumn(FixedWidthParserUtils.splitFixedText(cmds, line, isPreserveLeadingWhitespace(), isPreserveTrailingWhitespace()));
                }

                if (isFlagEmptyRows()) {
                    // user has elected to have the parser flag rows that are empty
                    row.setEmpty(ParserUtils.isListElementsEmpty(row.getCols()));
                }
                if (isStoreRawDataToDataSet()) {
                    // user told the parser to keep a copy of the raw data in the row
                    // WARNING potential for high memory usage here
                    row.setRawData(line);
                }

                return row;
            }

        } catch (final IOException e) {
            throw new FPException("Error Fetching Record From File...", e);
        }

        return null;
    }
570566
public OnDiskAtom readNext() throws IOException
    {
        Composite name = nameDeserializer.readNext();
        assert !name.isEmpty(); // This would imply hasNext() hasn't been called

        nextFlags = nextFlags == Integer.MIN_VALUE ? in.readUnsignedByte() : nextFlags;
        OnDiskAtom atom = (nextFlags & ColumnSerializer.RANGE_TOMBSTONE_MASK) != 0
                        ? type.rangeTombstoneSerializer().deserializeBody(in, name, version)
                        : type.columnSerializer().deserializeColumnBody(in, (CellName)name, nextFlags, flag, expireBefore);
        nextFlags = Integer.MIN_VALUE;
        return atom;
    }
328558
@Override
    public Record nextRecord() {
        if(!hasNext()){ //Also triggers prefetch
            throw new NoSuchElementException("No next element");
        }
        Record toRet = next;
        next = null;
        return toRet;
    }
1041531
public Object get( int row, int col ) {
        return (dstore == null) ? null : dstore.get(row, col);
    }
808805
@Override
    public Row nextRow() {
        if (nextRow == null) {
            // Didn't call 'hasNext()' ...
            if (!hasNext()) {
                throw new NoSuchElementException();
            }
        }
        assert nextRow != null;
        Row result = nextRow;
        nextRow = null;
        position++;
        return result;
    }
156114
public EntryRecord getRecord(Object key, byte[] serializedKey) throws IOException {
      int segment = (key.hashCode() & Integer.MAX_VALUE) % segments.length;
      lock.readLock().lock();
      try {
         return IndexNode.applyOnLeaf(segments[segment], serializedKey, segments[segment].rootReadLock(), IndexNode.ReadOperation.GET_RECORD);
      } finally {
         lock.readLock().unlock();
      }
   }
1097711
def read_records(file):
    """"""
    records = []
    for record_data in read_recordio(file):
        record = Record()
        record.ParseFromString(record_data)
        records.append(record)
    return records
1202277
private java.nio.ByteBuffer getReadingRow() {
        final int row = this.readerIndex / this.localCapacity;
        return this.storage.get(row);
    }
177424
def file_rows(self, fo):
        """"""

        rows = []
        for i in range(NUMROWS):
            line = fo.readline()
            if not line:
                break
            rows += [line]

        return rows
439194
public DBaseFileRecord readNextDBFRecord() throws IOException {
		if (this.recordCount == -1) {
			throw new MustCallReadHeaderFunctionException();
		}
		if (this.readingPosition >= this.recordCount) {
			return null;
		}

		try {
			// Update the readingPosition attribute AFTER the call to the
			// reading function to avoid invalid usage of its value
			// by this function.
			final DBaseFileRecord record = readDBFRecord(this.readingPosition);
			++this.readingPosition;
			return record;
		} catch (EOFException e) {
			this.finished = true;
			return null;
		}
	}
160547
def next_row(self):
        """"""
        row = self.currentIndex().row()
        rows = self.source_model.rowCount()
        if row + 1 == rows:
            row = -1
        self.selectRow(row + 1)
18482
protected function getNextRow()
    {
        if ($this->position >= $this->totalRows) {
            return;
        }

        if ($this->indexMap) {
            $rowIndex = $this->indexMap[$this->position];
        } else {
            $rowIndex = $this->position;
        }

        $data = Json::decodeFromFile($this->dir . "/" . $rowIndex . ".row");

        $this->position++;

        return $data;
    }
754444
public V getRecord(long index) throws IOException {
        //First: determine which reader to read from...
        int readerIdx = -1;
        for (int i = 0; i < recordIndexesEachReader.size(); i++) {
            Pair<Long, Long> p = recordIndexesEachReader.get(i);
            if (index >= p.getFirst() && index <= p.getSecond()) {
                readerIdx = i;
                break;
            }
        }
        if (readerIdx == -1) {
            throw new IllegalStateException("Index not found in any reader: " + index);
        }

        WritableComparable key = indexToKey.getKeyForIndex(index);
        Writable value = ReflectionUtils.newInstance(recordClass, null);

        V v = (V) readers[readerIdx].get(key, value);
        return v;
    }
124825
private boolean readNextRow() {
        while (!stop) {
            String row = getLineWrapped();
            // end of stream - null indicates end of stream before we see last_seq which shouldn't
            // be possible but we should handle it
            if (row == null || row.startsWith("{\"last_seq\":")) {
                terminate();
                return false;
            } else if (row.isEmpty()) {
                // heartbeat
                continue;
            }
            setNextRow(gson.fromJson(row, ChangesResult.Row.class));
            return true;
        }
        // we were stopped, end of changes feed
        terminate();
        return false;
    }
524199
private String[] getExpectedRow( TableIterator<String[]> tableRowIterator, DateTime expectedDT ) throws IOException {
        while( tableRowIterator.hasNext() ) {
            String[] row = tableRowIterator.next();
            DateTime currentTimestamp = formatter.parseDateTime(row[1]);
            if (currentTimestamp.equals(expectedDT)) {
                if (pNum == 1) {
                    return row;
                } else {
                    String[][] allRows = new String[pNum][];
                    allRows[0] = row;
                    int rowNum = 1;
                    for( int i = 1; i < pNum; i++ ) {
                        if (tableRowIterator.hasNext()) {
                            String[] nextRow = tableRowIterator.next();
                            allRows[i] = nextRow;
                            rowNum++;
                        }
                    }
                    // now aggregate
                    String[] aggregatedRow = new String[row.length];
                    // date is the one of the first instant
                    aggregatedRow[0] = allRows[0][0];
                    aggregatedRow[1] = allRows[0][1];
                    for( int col = 2; col < allRows[0].length; col++ ) {

                        boolean hasOne = false;
                        switch( pAggregation ) {
                        case 0:
                            double sum = 0;
                            for( int j = 0; j < rowNum; j++ ) {
                                String valueStr = allRows[j][col];
                                if (!valueStr.equals(fileNovalue)) {
                                    double value = Double.parseDouble(valueStr);
                                    sum = sum + value;
                                    hasOne = true;
                                }
                            }
                            if (!hasOne) {
                                sum = doubleNovalue;
                            }
                            aggregatedRow[col] = String.valueOf(sum);
                            break;
                        case 1:
                            double avg = 0;
                            for( int j = 0; j < rowNum; j++ ) {
                                String valueStr = allRows[j][col];
                                if (!valueStr.equals(fileNovalue)) {
                                    double value = Double.parseDouble(valueStr);
                                    avg = avg + value;
                                    hasOne = true;
                                }
                            }
                            if (!hasOne) {
                                avg = doubleNovalue;
                            } else {
                                avg = avg / pNum;
                            }
                            aggregatedRow[col] = String.valueOf(avg);
                            break;

                        default:
                            break;
                        }

                    }
                    return aggregatedRow;
                }
            } else if (currentTimestamp.isBefore(expectedDT)) {
                // browse until the instant is found
                continue;
            } else if (currentTimestamp.isAfter(expectedDT)) {
                /*
                 * lost the moment, for now throw exception.
                 * Could be enhanced in future.
                 */
                String message = "The data are not aligned with the simulation interval (" + currentTimestamp + "/" + expectedDT
                        + "). Check your data file: " + file;
                throw new IOException(message);
            }

        }
        return null;
    }
959083
private boolean getRow() {
    try {
      rowCache.clear();
      while(rowCache.size() < rowCacheSize && parser.hasNext()) {
        handleEvent(parser.nextEvent());
      }
      rowCacheIterator = rowCache.iterator();
      return rowCacheIterator.hasNext();
    } catch(XMLStreamException e) {
      throw new ParseException("Error reading XML stream", e);
    }
  }
1055873
@Override
    public Row buildRow(final DefaultDataSet ds) {
        /** loop through each line in the file */
        while (true) {
            String line;
            try {
                line = fetchNextRecord(br, getQualifier(), getDelimiter());
            } catch (final IOException e) {
                throw new FPException("Error Fetching Record From File...", e);
            }

            if (line == null) {
                return null;
            }

            // check to see if the user has elected to skip the first record
            if (shouldSkipFirstRecord(line, ds)) {
                continue;
            }

            // TODO
            // seems like we may want to try doing something like this. I have my reservations because
            // it is possible that we don't get a "detail" id and this might generate NPE
            // is it going to create too much overhead to do a null check here as well???
            List<String> columns = ParserUtils.splitLine(line, getDelimiter(), getQualifier(), FPConstants.SPLITLINE_SIZE_INIT,
                    isPreserveLeadingWhitespace(), isPreserveTrailingWhitespace());
            final String mdkey = ParserUtils.getCMDKeyForDelimitedFile(getPzMetaData(), columns);
            final List<ColumnMetaData> cmds = ParserUtils.getColumnMetaData(mdkey, getPzMetaData());
            // DEBUG

            // Incorrect record length on line log the error. Line
            // will not be included in the dataset
            if (!validateColumns(ds, columns, cmds, line)) {
                continue;
            }

            return createRow(line, columns, mdkey);
        }
    }