Return the next decodable record from the current partition. If the current partition has no more
decodable record, move on to the next partition. If all partitions have been processed, return null.
494432
@SuppressWarnings("unchecked")
  @Override
  public D readRecordImpl(D reuse) throws DataRecordException, IOException {
    if (this.shutdownRequested.get()) {
      return null;
    }

    long readStartTime = System.nanoTime();

    while (!allPartitionsFinished()) {
      if (currentPartitionFinished()) {
        moveToNextPartition();
        continue;
      }
      if (this.messageIterator == null || !this.messageIterator.hasNext()) {
        try {
          long fetchStartTime = System.nanoTime();
          this.messageIterator = fetchNextMessageBuffer();
          this.currentPartitionFetchMessageBufferTime += System.nanoTime() - fetchStartTime;
        } catch (Exception e) {
          LOG.error(String.format("Failed to fetch next message buffer for partition %s. Will skip this partition.",
              getCurrentPartition()), e);
          moveToNextPartition();
          continue;
        }
        if (this.messageIterator == null || !this.messageIterator.hasNext()) {
          moveToNextPartition();
          continue;
        }
      }
      while (!currentPartitionFinished()) {
        if (!this.messageIterator.hasNext()) {
          break;
        }

        KafkaConsumerRecord nextValidMessage = this.messageIterator.next();

        // Even though we ask Kafka to give us a message buffer starting from offset x, it may
        // return a buffer that starts from offset smaller than x, so we need to skip messages
        // until we get to x.
        if (nextValidMessage.getOffset() < this.nextWatermark.get(this.currentPartitionIdx)) {
          continue;
        }

        this.nextWatermark.set(this.currentPartitionIdx, nextValidMessage.getNextOffset());
        try {
          // track time for decode/convert depending on the record type
          long decodeStartTime = System.nanoTime();

          D record = decodeKafkaMessage(nextValidMessage);

          this.currentPartitionDecodeRecordTime += System.nanoTime() - decodeStartTime;
          this.currentPartitionRecordCount++;
          this.currentPartitionTotalSize += nextValidMessage.getValueSizeInBytes();
          this.currentPartitionReadRecordTime += System.nanoTime() - readStartTime;
          this.currentPartitionLastSuccessfulRecord = record;
          return record;
        } catch (Throwable t) {
          this.errorPartitions.add(this.currentPartitionIdx);
          this.undecodableMessageCount++;
          if (shouldLogError()) {
            LOG.error(String.format("A record from partition %s cannot be decoded.", getCurrentPartition()), t);
          }
          incrementErrorCount();
        }
      }
    }
    LOG.info("Finished pulling topic " + this.topicName);

    this.currentPartitionReadRecordTime += System.nanoTime() - readStartTime;
    return null;
  }
613745
def next(self):
        
        try:
            return self.dict_to_xn(self.csvreader.next())
        except MetadataException:
            # row was metadata; proceed to next row
            return next(self)
456408
public String getNextString()
    {
        Object data = this.getNextData();
        if (data instanceof String)
            return (String)data;
        return null;    // EOF
    }
328558
@Override
    public Record nextRecord() {
        if(!hasNext()){ //Also triggers prefetch
            throw new NoSuchElementException("No next element");
        }
        Record toRet = next;
        next = null;
        return toRet;
    }
599734
def next(self):
        
        # do not acquire lock if NuMap is not finished.
        if self.finished:
            raise StopIteration
        # get per-tee lock
        self.piper.tee_locks[self.i].acquire()
        # get result or exception
        exception = True
        try:
            result = self.piper.tees[self.i].next()
            exception = False
        except StopIteration, result:
            self.finished = True
        except Exception, result:
            pass
        # release per-tee lock either self or next
        if self.s == self.stride or self.finished:
            self.s = 1
            self.piper.tee_locks[(self.i + 1) % len(self.piper.tees)].release()

        else:
            self.s += 1
            self.piper.tee_locks[self.i].release()
        if exception:
            raise result
        else:
            return result
1034087
@Override
  public PurgeableHivePartitionDataset readRecord(PurgeableHivePartitionDataset record)
      throws IOException {
    if (this.read) {
      return null;
    }
    this.read = true;
    if (this.record == null) {
      this.record = createPurgeableHivePartitionDataset(this.state);
    }
    return this.record;
  }
386664
def peek(self):
        
        records = self._records
        if records:
            return records[0]
        if not self.attached():
            return None
        if self.attached():
            self._session.send()
        while self.attached() and not records:
            self._session.fetch()
            if records:
                return records[0]
        return None
749264
def next(self):
        
        try:
            res, excp = self._stride_buffer.next()
        except (StopIteration, AttributeError):
            try:
                self._stride_buffer = izip(*self._repeat_buffer.next())
            except (StopIteration, AttributeError):
                self._rebuffer()
                self._stride_buffer = izip(*self._repeat_buffer.next())
            res, excp = self._stride_buffer.next()
        if excp:
            raise res
        else:
            return res
910018
def _next_record(self, next_line):
        
        record = self.loader.parse_record_stream(self.reader,
                                                 next_line,
                                                 self.known_format,
                                                 self.no_record_parse,
                                                 self.ensure_http_headers)

        self.member_info = None

        # Track known format for faster parsing of other records
        if not self.mixed_arc_warc:
            self.known_format = record.format

        return record
514198
@SuppressWarnings("unchecked")
  private void readNext() {
    // Compute the index of the next entry in the segment.
    final long index = getNextIndex();

    try {
      // Read more bytes from the segment if necessary.
      if (memory.remaining() < maxEntrySize) {
        long position = channel.position() + memory.position();
        channel.position(position);
        memory.clear();
        channel.read(memory);
        channel.position(position);
        memory.flip();
      }

      // Mark the buffer so it can be reset if necessary.
      memory.mark();

      try {
        // Read the length of the entry.
        final int length = memory.getInt();

        // If the buffer length is zero then return.
        if (length <= 0 || length > maxEntrySize) {
          memory.reset().limit(memory.position());
          nextEntry = null;
          return;
        }

        // Read the checksum of the entry.
        long checksum = memory.getInt() & 0xFFFFFFFFL;

        // Compute the checksum for the entry bytes.
        final Checksum crc32 = new CRC32();
        crc32.update(memory.array(), memory.position(), length);

        // If the stored checksum equals the computed checksum, return the entry.
        if (checksum == crc32.getValue()) {
          int limit = memory.limit();
          memory.limit(memory.position() + length);
          E entry = namespace.deserialize(memory);
          memory.limit(limit);
          nextEntry = new Indexed<>(index, entry, length);
        } else {
          memory.reset().limit(memory.position());
          nextEntry = null;
        }
      } catch (BufferUnderflowException e) {
        memory.reset().limit(memory.position());
        nextEntry = null;
      }
    } catch (IOException e) {
      throw new StorageException(e);
    }
  }
760748
function Next()
	{
		// check the file description
		if (!$this->fd)
		{
			trigger_error("XDB::Next(), null db handler.", E_USER_WARNING);
			return false;
		}

		// Traversal the all tree
		if (!($ptr = array_pop($this->trave_stack)))
		{
			do
			{
				$this->trave_index++;
				if ($this->trave_index >= $this->hash_prime)
					break;

				$poff = $this->trave_index * 8 + 32;
				fseek($this->fd, $poff, SEEK_SET);
				$buf = fread($this->fd, 8);
				if (strlen($buf) != 8) 
				{
					$ptr = false;
					break;
				}

				$ptr = unpack('Ioff/Ilen', $buf);
			}
			while ($ptr['len'] == 0);
		}

		// end the all records?
		if (!$ptr || $ptr['len'] == 0)
			return false;

		// read the record
		$rec = $this->_tree_get_record($ptr['off'], $ptr['len']);

		// push the left & right
		if ($rec['llen'] != 0)
		{
			$left = array('off' => $rec['loff'], 'len' => $rec['llen']);
			array_push($this->trave_stack, $left);
		}
		if ($rec['rlen'] != 0)
		{
			$right = array('off' => $rec['roff'], 'len' => $rec['rlen']);
			array_push($this->trave_stack, $right);
		}

		// return value
		return $rec;
	}
878886
@SuppressWarnings("unchecked")
  @Override
  public REC previous() {
    checkDirection(false);

    if (currentRecord != null)
      try {
        // RETURN LAST LOADED RECORD
        return (REC) currentRecord;
      } finally {
        currentRecord = null;
      }

    ORecordInternal<?> record = getRecord();

    // MOVE BACKWARD IN THE CURRENT CLUSTER
    while (hasPrevious()) {
      if (currentRecord != null)
        try {
          // RETURN LAST LOADED RECORD
          return (REC) currentRecord;
        } finally {
          currentRecord = null;
        }

      if (record == null)
        record = readCurrentRecord(null, -1);

      if (record != null)
        // FOUND
        if (include(record))
          return (REC) record;
    }

    record = getTransactionEntry();
    if (record != null)
      return (REC) record;

    throw new NoSuchElementException("Direction: backward, last position was: " + current + ", range: " + beginRange + "-"
        + endRange);
  }
1106400
def next(self):
        
        self.open_read()
        data = self.resp.read(self.BufferSize)
        if not data:
            self.close()
            raise StopIteration
        return data
272336
@Override
	public T next(T target) throws IOException {
		// check for the left over element
		if (this.readPhase) {
			return getNextRecord(target);
		} else {
			// writing phase. check for leftover first
			if (this.leftOverReturned) {
				// get next record
				if ((target = this.input.next(target)) != null) {
					if (writeNextRecord(target)) {
						return target;
					} else {
						// did not fit into memory, keep as leftover
						this.leftOverRecord = this.serializer.copy(target, this.leftOverRecord);
						this.leftOverReturned = false;
						this.fullWriteBuffer = true;
						return null;
					}
				} else {
					this.noMoreBlocks = true;
					return null;
				}
			} else if (this.fullWriteBuffer) {
				return null;
			} else {
				this.leftOverReturned = true;
				target = this.serializer.copy(this.leftOverRecord, target);
				return target;
			}
		}
	}
569301
def next(self):
        """"""
        if self.curr_idx == len(self.idx):
            raise StopIteration
        #i = batches index, j = starting record
        i, j = self.idx[self.curr_idx] 
        self.curr_idx += 1

        indices = self.ndindex[i][j:j + self.batch_size]
        sentences = self.ndsent[i][j:j + self.batch_size]
        characters = self.ndchar[i][j:j + self.batch_size]
        label = self.ndlabel[i][j:j + self.batch_size]

        return DataBatch([sentences, characters], [label], pad=0, index = indices, bucket_key=self.buckets[i],
                         provide_data=[DataDesc(name=self.data_names[0], shape=sentences.shape, layout=self.layout),
                                       DataDesc(name=self.data_names[1], shape=characters.shape, layout=self.layout)],
                         provide_label=[DataDesc(name=self.label_name, shape=label.shape, layout=self.layout)])
82706
public Revision next()
		throws Exception
	{

		// Checks whether the next revision has already been reconstructed.
		Revision revision;
		if (chronoStorage.isTop(revisionIndex)) {

			// If this is the case the revision will removed from the storage
			return chronoStorage.remove();
		}

		// Otherwise the chronological order counter will be mapped to the
		// revsision counter
		int revCount = revisionIndex;
		if (mappingStorage.containsKey(revisionIndex)) {
			revCount = mappingStorage.get(revisionIndex);
		}

		// Retrieve the related full revision block
		ChronoFullRevision cfr = fullRevStorage.get(revCount);

		int queryPK, limit, previousRevisionCounter;
		String previousRevision;

		// Determine the nearest revision that could be used to construct
		// the specified revision
		revision = cfr.getNearest(revCount);
		if (revision == null) {

			// Create query bounds (all revisions from the full revision till
			// now)
			queryPK = articlePK + cfr.getStartRC() - 1;
			limit = revCount - cfr.getStartRC() + 1;

			previousRevision = null;
			previousRevisionCounter = -1;

		}
		else {

			// Create query bounds (only new revisions, last known + 1 till now)
			queryPK = revision.getPrimaryKey() + 1;
			limit = revCount - revision.getRevisionCounter();

			previousRevision = revision.getRevisionText();
			previousRevisionCounter = revision.getRevisionCounter();

		}

		Statement statement = null;
		ResultSet result = null;
		revision = null;

		try {
			statement = this.connection.createStatement();

			// Retrieve encoded revisions
			result = statement
					.executeQuery("SELECT Revision, PrimaryKey, RevisionCounter, RevisionID, ArticleID, Timestamp "
							+ "FROM revisions "
							+ "WHERE PrimaryKey >= "
							+ queryPK + " LIMIT " + limit);

			String currentRevision = null;

			Diff diff;
			RevisionDecoder decoder;

			boolean binaryData = result.getMetaData().getColumnType(1) == Types.LONGVARBINARY;

			while (result.next()) {

				decoder = new RevisionDecoder(config.getCharacterSet());

				// binary or base64 encoded
				if (binaryData) {
					decoder.setInput(result.getBinaryStream(1), true);
				}
				else {
					decoder.setInput(result.getString(1));
				}

				// Decode and rebuild
				diff = decoder.decode();
				if (previousRevisionCounter != -1) {

					if (previousRevisionCounter + 1 != result.getInt(3)) {

						System.err.println("Reconstruction data invalid - "
								+ "\r\n\t" + "Expected "
								+ (previousRevisionCounter + 1)
								+ " instead of " + result.getInt(3));

						return null;
					}

				}
				else {

					if (cfr.getStartRC() != result.getInt(3)) {

						System.err.println("Reconstruction data invalid - "
								+ "\r\n\t" + "Expected " + (cfr.getStartRC())
								+ " instead of " + result.getInt(3));

						return null;
					}

				}

				try {
					currentRevision = diff.buildRevision(previousRevision);

					revision = new Revision(result.getInt(3));
					revision.setRevisionText(currentRevision);
					revision.setPrimaryKey(result.getInt(2));
					revision.setRevisionID(result.getInt(4));
					revision.setArticleID(result.getInt(5));
					revision.setTimeStamp(new Timestamp(result.getLong(6)));

					previousRevision = currentRevision;
					previousRevisionCounter = revision.getRevisionCounter();

				}
				catch (Exception e) {

					System.err.println("Reconstruction failed while retrieving"
							+ " data to reconstruct <" + revisionIndex + ">"
							+ "\r\n\t" + "[ArticleId " + result.getInt(5)
							+ ", RevisionId " + result.getInt(4)
							+ ", RevisionCounter " + result.getInt(3) + "]");

					previousRevision = null;
					revision = null;

					return null;
				}

				// Add the reconstructed revision to the storage
				if (revision != null) {
					chronoStorage.add(revision);
				}
			}

			// Ensure that the correct revision is on top of the storage
			if (chronoStorage.isTop(revisionIndex)) {

				chronoStorage.remove();
				return revision;

			}
			else {
				return null;
			}

		}
		finally {
			if (statement != null) {
				statement.close();
			}
			if (result != null) {
				result.close();
			}
		}
	}
655077
def next(self):
        
        self._check("ra")
        if self.firstmember is not None:
            m = self.firstmember
            self.firstmember = None
            return m

        # Read the next block.
        self.fileobj.seek(self.offset)
        tarinfo = None
        while True:
            try:
                tarinfo = self.tarinfo.fromtarfile(self)
            except EOFHeaderError as e:
                if self.ignore_zeros:
                    self._dbg(2, "0x%X: %s" % (self.offset, e))
                    self.offset += BLOCKSIZE
                    continue
            except InvalidHeaderError as e:
                if self.ignore_zeros:
                    self._dbg(2, "0x%X: %s" % (self.offset, e))
                    self.offset += BLOCKSIZE
                    continue
                elif self.offset == 0:
                    raise ReadError(str(e))
            except EmptyHeaderError:
                if self.offset == 0:
                    raise ReadError("empty file")
            except TruncatedHeaderError as e:
                if self.offset == 0:
                    raise ReadError(str(e))
            except SubsequentHeaderError as e:
                raise ReadError(str(e))
            break

        if tarinfo is not None:
            self.members.append(tarinfo)
        else:
            self._loaded = True

        return tarinfo