Returns the next record in the master file.  This will process any
directives before the next record.
@return The next record.
@throws IOException The master file could not be read, or was syntactically
invalid.
777701
public Record
_nextRecord() throws IOException {
	Tokenizer.Token token;
	String s;

	if (included != null) {
		Record rec = included.nextRecord();
		if (rec != null)
			return rec;
		included = null;
	}
	if (generator != null) {
		Record rec = nextGenerated();
		if (rec != null)
			return rec;
		endGenerate();
	}
	while (true) {
		Name name;

		token = st.get(true, false);
		if (token.type == Tokenizer.WHITESPACE) {
			Tokenizer.Token next = st.get();
			if (next.type == Tokenizer.EOL)
				continue;
			else if (next.type == Tokenizer.EOF)
				return null;
			else
				st.unget();
			if (last == null)
				throw st.exception("no owner");
			name = last.getName();
		}
		else if (token.type == Tokenizer.EOL)
			continue;
		else if (token.type == Tokenizer.EOF)
			return null;
		else if (((String) token.value).charAt(0) == '$') {
			s = token.value;

			if (s.equalsIgnoreCase("$ORIGIN")) {
				origin = st.getName(Name.root);
				st.getEOL();
				continue;
			} else if (s.equalsIgnoreCase("$TTL")) {
				defaultTTL = st.getTTL();
				st.getEOL();
				continue;
			} else  if (s.equalsIgnoreCase("$INCLUDE")) {
				String filename = st.getString();
				File newfile;
				if (file != null) {
					String parent = file.getParent();
					newfile = new File(parent, filename);
				} else {
					newfile = new File(filename);
				}
				Name incorigin = origin;
				token = st.get();
				if (token.isString()) {
					incorigin = parseName(token.value,
							      Name.root);
					st.getEOL();
				}
				included = new Master(newfile, incorigin,
						      defaultTTL);
				/*
				 * If we continued, we wouldn't be looking in
				 * the new file.  Recursing works better.
				 */
				return nextRecord();
			} else  if (s.equalsIgnoreCase("$GENERATE")) {
				if (generator != null)
					throw new IllegalStateException
						("cannot nest $GENERATE");
				startGenerate();
				if (noExpandGenerate) {
					endGenerate();
					continue;
				}
				return nextGenerated();
			} else {
				throw st.exception("Invalid directive: " + s);
			}
		} else {
			s = token.value;
			name = parseName(s, origin);
			if (last != null && name.equals(last.getName())) {
				name = last.getName();
			}
		}

		parseTTLClassAndType();
		last = Record.fromString(name, currentType, currentDClass,
					 currentTTL, st, origin);
		if (needSOATTL) {
			long ttl = ((SOARecord)last).getMinimum();
			last.setTTL(ttl);
			defaultTTL = ttl;
			needSOATTL = false;
		}
		return last;
	}
}
554735
public byte[] getRecord(final long iPosition) throws IOException {
    if (iPosition == -1)
      return null;

    acquireSharedLock();
    try {

      final long[] pos = getRelativePosition(iPosition);
      final OFile file = files[(int) pos[0]];

      final int recordSize = file.readInt(pos[1]);
      if (recordSize <= 0)
        // RECORD DELETED
        return null;

      if (pos[1] + RECORD_FIX_SIZE + recordSize > file.getFilledUpTo())
        throw new OStorageException(
            "Error on reading record from file '"
                + file.getName()
                + "', position "
                + iPosition
                + ", size "
                + OFileUtils.getSizeAsString(recordSize)
                + ": the record size is bigger then the file itself ("
                + OFileUtils.getSizeAsString(getFilledUpTo())
                + "). Probably the record is dirty due to a previous crash. It is strongly suggested to restore the database or export and reimport this one.");

      final byte[] content = new byte[recordSize];
      file.read(pos[1] + RECORD_FIX_SIZE, content, recordSize);
      return content;

    } finally {
      releaseSharedLock();
    }
  }
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
272455
@Override
    public List<Writable> next() {
        List<String> next = dataIter.next();
        invokeListeners(next);
        List<Writable> ret = new ArrayList<>();
        for (String s : next)
            ret.add(new Text(s));
        return ret;
    }

    /**
     * Check whether there are anymore records
     *
     * @return Whether there are more records
     */
    @Override
    public boolean hasNext() {
        return dataIter.hasNext();
    }

    /**
     * List of label strings
     *
     * @return
     */
    @Override
    public List<String> getLabels() {
        return null;
    }

    /**
     * Reset record reader iterator
     *
     */
    @Override
    public void reset() {
        dataIter = delimitedData.iterator();
    }

    @Override
    public boolean resetSupported() {
        return true;
    }

    /**
     * Load the record from the given DataInputStream
     * Unlike {@link #next()} the internal state of the RecordReader is not modified
     * Implementations of this method should not close the DataInputStream
     *
     * @param uri
     * @param dataInputStream
     * @throws IOException if error occurs during reading from the input stream
     */
    @Override
    public List<Writable> record(URI uri, DataInputStream dataInputStream) throws IOException {
        return null;
    }

    @Override
    public Record nextRecord() {
        return new org.datavec.api.records.impl.Record(next(), null);
    }

    @Override
    public Record loadFromMetaData(RecordMetaData recordMetaData) throws IOException {
        throw new UnsupportedOperationException("Loading from metadata not yet implemented");
    }

    @Override
    public List<Record> loadFromMetaData(List<RecordMetaData> recordMetaDatas) throws IOException {
        throw new UnsupportedOperationException("Loading from metadata not yet implemented");
    }

    /**
     * Closes this stream and releases any system resources associated
     * with it. If the stream is already closed then invoking this
     * method has no effect.
     * <p>
     * <p> As noted in {@link AutoCloseable#close()}, cases where the
     * close may fail require careful attention. It is strongly advised
     * to relinquish the underlying resources and to internally
     * <em>mark</em> the {@code Closeable} as closed, prior to throwing
     * the {@code IOException}.
     *
     * @throws IOException if an I/O error occurs
     */
    @Override
    public void close() throws IOException {

    }

    /**
     * Set the configuration to be used by this object.
     *
     * @param conf
     */
    @Override
    public void setConf(Configuration conf) {
        this.conf = conf;
    }

    /**
     * Return the configuration used by this object.
     */
    @Override
    public Configuration getConf() {
        return conf;
    }
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;
    }
1082968
public TemporalDocument next() {
	//String fileName = filesToProcess.poll();
	NameAndTime n = filesToProcess.poll();
	if (n == null) 
	    return null;
	try {
	    return (n.hasTimeStamp()) 
		? new TemporalFileDocument(n.fileName, n.timeStamp)
		: new TemporalFileDocument(n.fileName); // no timestamp
	} catch (IOException ioe) {
	    return null;
	}
    }
830956
@SuppressWarnings("unchecked")
	@Override
	public REC previous() {
		checkDirection(false);

		ORecordInternal<?> record = getRecord();

		// ITERATE UNTIL THE PREVIOUS GOOD RECORD
		while (hasPrevious()) {
			if ((record = readCurrentRecord(record, -1)) != null)
				// FOUND
				return (REC) record;
		}

		throw new NoSuchElementException();
	}
893129
@Override
    public boolean next() {
        if (pointer < rows.size() && pointer + 1 != rows.size()) {
            pointer++;
            currentRecord = new RowRecord(rows.get(pointer), metaData, parser.isColumnNamesCaseSensitive(), pzConvertProps, strictNumericParse,
                    upperCase, lowerCase, parser.isNullEmptyStrings());
            return true;
        }
        currentRecord = null;
        return false;
    }
593531
public SF next() throws IOException {

		int remaining = afpData.remaining();
		if(remaining == 0) return null;
		if(remaining < 9) throw new IOException("trailing garbage at the end of file.");
		
		byte buf;
		long thisOffset = afpData.position();

		try {
			if(leadingLengthBytes == -1) {
				// we haven't tested for mvs download leading length bytes
				// we don't need them and don't want to see them
				int leadingLength = 0;
				do {
					buf = afpData.get();
					leadingLength++;
				} while((buf & 0xff) != 0x5a && afpData.remaining() > 0 && leadingLength < 5);
				
				leadingLengthBytes = leadingLength-1;
								
			} else {
				if(leadingLengthBytes > 0) afpData.position(afpData.position() + leadingLengthBytes); // just throw away those
				buf = afpData.get();
			}
			
			if((buf & 0xff) != 0x5a)
				throw new IOException("cannot find 5a magic byte");
			data[0] = buf;
			
			buf = afpData.get();
			data[1] = buf;
			length = (byte) buf << 8;

			buf = afpData.get();
			data[2] = (byte) (buf & 0xff);
			length |= (byte) buf & 0xff;
			
			length -= 2;
			
			if(length + 3 > data.length)
				throw new IOException("length of structured field is too large: "+length);
					
			afpData.get(data, 3, length);
		} catch (BufferUnderflowException e) {
			return null; // FIXME could also be an error
		}
		
		SF sf = factory.sf(data, 0, getLength() + 2);
		sf.setLength(length + 3);
		sf.setOffset(thisOffset);
		sf.setNumber(number++);
		
		return sf;
	}
697898
public File getNextFile() throws IOException {
		synchronized(this) {
			// Loop trying to get the file because files may be removed during the loop
			while(true) {
				if(filesDone) return null;

				// Initialize the stacks, if needed
				if(currentDirectories==null) {
					if(startPath.length()==0) {
						// Starting at root will include the starting directory itself
						(currentDirectories=new Stack<>()).push("");
						(currentLists=new Stack<>()).push(getFilesystemRoots());
					} else {
						if(isFilesystemRoot(startPath)) {
							// Starting from a root, has no parent
							(currentDirectories=new Stack<>()).push("");
							(currentLists=new Stack<>()).push(new String[] {startPath});
						} else {
							// Starting at non root will include the starting directory itself
							File startPathFile = new File(startPath);
							String parent = startPathFile.getParent();
							String name = startPathFile.getName();
							(currentDirectories=new Stack<>()).push(parent);
							(currentLists=new Stack<>()).push(new String[] {name});
						}
					}
					(currentIndexes=new Stack<>()).push(0);
				}
				String currentDirectory;
				String[] currentList=null;
				int currentIndex=-1;
				try {
					currentDirectory=currentDirectories.peek();
					currentList=currentLists.peek();
					currentIndex=currentIndexes.peek();

					// Undo the stack as far as needed
					while(currentDirectory!=null && currentIndex>=currentList.length) {
						currentDirectories.pop();
						currentLists.pop();
						currentIndexes.pop();
						String oldCurrentDirectory = currentDirectory;
						currentDirectory=currentDirectories.peek();
						currentList=currentLists.peek();
						currentIndex=currentIndexes.peek();
						if(!isPreorder) return new File(oldCurrentDirectory); // This is performed last because the EmptyStackException caused by peek indicates end of traversal
					}
				} catch(EmptyStackException err) {
					currentDirectory=null;
				}
				if(currentDirectory==null) {
					filesDone=true;
					return null;
				} else {
					// Get the current filename
					final String filename;
					if(currentDirectory.length()==0) filename=currentList[currentIndex];
					else if(currentDirectory.endsWith(File.separator)) filename=currentDirectory+currentList[currentIndex];
					else filename=currentDirectory+File.separatorChar+currentList[currentIndex];

					// Increment index to point to the next file
					currentIndexes.pop();
					currentIndexes.push(currentIndex+1);

					try {
						final File file=new File(filename);
						if(file.isDirectory()) {
							// Directories
							final String filenamePlusSlash;
							if(filename.endsWith(File.separator)) filenamePlusSlash = filename;
							else filenamePlusSlash = filename+File.separatorChar;

							final boolean includeDirectory;
							final boolean recurse;
							// If the settings for the directory indicate include
							if(isIncluded(filename)) {
								// Directory is included, optimized recurse follows
								includeDirectory = true;
								FilesystemIteratorRule rule = rules.get(filenamePlusSlash);
								if(rule==null) {
									recurse = true;
								} else {
									if(rule.isIncluded(filenamePlusSlash)) {
										recurse = true;
									} else {
										// This is the shortcut to not list directory when flagged as "/proc/"-style skip and
										// there are no overriding children
										recurse = hasIncludedChild(filenamePlusSlash);
									}
								}
							} else {
								// Force include if there are any backup-enabled settings that are a child of this
								if(hasIncludedChild(filenamePlusSlash)) {
									includeDirectory = true;
									recurse = true;
								} else {
									includeDirectory = false;
									recurse = false;
								}
							}
							// Push on stacks for next level
							if(includeDirectory) {
								String[] list;
								if(recurse) {
									// Skip anything that is not canonical, this avoids symbolic link targets
									if(file.getCanonicalPath().equals(filename)) {
										list = file.list();
										if(list==null) {
											list = AoArrays.EMPTY_STRING_ARRAY;
										} else if(isSorted && list.length>0) {
											Arrays.sort(list);
										}
									} else {
										//System.err.println("Skipping non-canonical directory listing: "+filename);
										list = AoArrays.EMPTY_STRING_ARRAY;
									}
								} else {
									list = AoArrays.EMPTY_STRING_ARRAY;
								}
								// No need to push onto the stack if the children are empty?
								if(list.length>0) {
									currentDirectories.push(filename);
									currentLists.push(list);
									currentIndexes.push(0);
									if(isPreorder) return file;
								} else {
									// If empty directory both preorder and postorder return directory immediately
									// and bypass using the stack.
									return file;
								}
							} else {
								if(recurse) throw new AssertionError("recurse=true and includeDirectory=false");
							}
						} else {
							// Non-directories
							if(isIncluded(filename)) return file;
						}
					} catch(FileNotFoundException err) {
						// Normal if the file was deleted while accessing
					}
				}
			}
		}
	}
495041
@Override
	public BasicLogRecord next() {
		if (!isForward) {
			currentRec = currentRec - pointerSize;
			isForward = true;
		}
		if (currentRec == 0)
			moveToNextBlock();
		currentRec = (Integer) pg.getVal(currentRec, INTEGER).asJavaVal();
		return new BasicLogRecord(pg, new LogSeqNum(blk.number(), currentRec + pointerSize * 2));
	}
583321
public boolean next() throws IOException {
		boolean hasNext = true;
		try {
			oldId = stream.readInt();
			oldText = stream.readUTFAsArray();
		} catch (EOFException e) {
			hasNext = false;
		}
		return hasNext;
	}
86821
@Override
    public FileEntry next () {
        FileEntry n = this.next;
        try {
            FileEntry ne = advance();
            if ( ne == null ) {
                doClose();
                return n;
            }
            this.next = ne;
        }
        catch ( CIFSException e ) {
            log.warn("Enumeration failed", e);
            this.next = null;
        }
        return n;
    }
86401
public Object next()
    {
        int iOldKeyOrder = m_recFieldData.getDefaultOrder();
        try {
            if (m_bFirstTime)
                this.scanSharedFields();

            if (m_iCurrentIndex >= m_vFieldList.size())
                return null;    // EOF
            FieldSummary fieldSummary = (FieldSummary)m_vFieldList.elementAt(m_iCurrentIndex);
            m_iCurrentIndex++;

            m_recFieldData.setKeyArea(FieldData.ID_KEY);
            m_recFieldData.addNew();
            m_recFieldData.getField(FieldData.kID).setData(fieldSummary.m_objID);
            if (!m_recFieldData.seek(null))
                return null;    // Never
            
            if (fieldSummary.m_strNewBaseField != null)
                m_recFieldData.getField(FieldData.BASE_FIELD_NAME).setString(fieldSummary.m_strNewBaseField);
            if (fieldSummary.m_strNewFieldClass == UNUSED)
            {
                m_recFieldData.getField(FieldData.FIELD_CLASS).setString(fieldSummary.m_strNewFieldClass);
                m_recFieldData.getField(FieldData.DEFAULT_VALUE).setString(DBConstants.BLANK);
                m_recFieldData.getField(FieldData.INITIAL_VALUE).setString(DBConstants.BLANK);
            }
            else if (this.inBaseField(fieldSummary.m_strFieldFileName, m_rgstrClasses))
            {   // This field is in a base record class, so fake the record to think it just overrides the field
                m_recFieldData.addNew();
                m_recFieldData.getField(FieldData.BASE_FIELD_NAME).setString(fieldSummary.m_strFieldName);
                m_recFieldData.getField(FieldData.FIELD_NAME).setString(fieldSummary.m_strFieldName);
                m_recFieldData.getField(FieldData.FIELD_FILE_NAME).setString(m_rgstrClasses[m_rgstrClasses.length-1]);
            }
            m_recFieldData.getField(FieldData.INCLUDE_SCOPE).setValue(fieldSummary.m_iIncludeScope);

            return m_recFieldData;  // This is the next field data record
            
        } catch (DBException ex)    {
            ex.printStackTrace();
            return null;
        } finally {
            m_recFieldData.setKeyArea(iOldKeyOrder);
        }
    }
941446
public String next() {
        if (fifo.isEmpty()) {
            throw new RuntimeException("Fifo is empty");
        }
        String cmd = (String) fifo.get(0);
        fifo.remove(0);
        return cmd;
    }
717174
def next(self):
        
        if self._current < len(self._record_list):
            rec = self._record_list[self._current]
            key = rec['name']
            self._current += 1
            return key
        else:
            raise StopIteration
149899
@Override
    public Record nextRecord() {
        List<Writable> next = next();
        URI uri = (locations == null || locations.length < 1 ? null : locations[splitIndex]);
        RecordMetaData meta = new RecordMetaDataLine(this.lineIndex - 1, uri, SVMLightRecordReader.class); //-1 as line number has been incremented already...
        return new org.datavec.api.records.impl.Record(next, meta);
    }