⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 logrecorditerator.java

📁 用java语言简单实现数据库的初步功能
💻 JAVA
字号:
package simpledb.tx.recovery;import static simpledb.tx.recovery.LogRecord.*;import java.util.Iterator;import simpledb.log.BasicLogRecord;import simpledb.server.SimpleDB;/** * A class that provides the ability to read records * from the log in reverse order. * Unlike the similar class simpledb.buffer.LogIterator, this class  * understands the meaning of the log records. * @author Edward Sciore */class LogRecordIterator implements Iterator<LogRecord> {	private Iterator<BasicLogRecord> iter = SimpleDB.logMgr().iterator();	public boolean hasNext() {		return iter.hasNext();	}	/**	 * Constructs a log record from the values in the current log record.	 * The method first reads an integer, which denotes	 * the type of the log record.  Based on that type,	 * the method calls the appropriate LogRecord constructor	 * to read the remaining values.	 * @return the next log record, or null if no more records	 */	public LogRecord next() {		BasicLogRecord rec = iter.next();		int op = rec.nextInt();		switch (op) {			case CHECKPOINT:				return new CheckpointRecord(rec);			case START:				return new StartRecord(rec);			case COMMIT:				return new CommitRecord(rec);			case ROLLBACK:				return new RollbackRecord(rec);			case SETINT:				return new SetIntRecord(rec);			case SETSTRING:				return new SetStringRecord(rec);			default:				return null;		}	}			public void remove() {		throw new UnsupportedOperationException();	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -