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

📄 lookupplan.java

📁 用java语言简单实现数据库的初步功能
💻 JAVA
字号:
package simpledb.index.query;import simpledb.record.Schema;import simpledb.query.*;/** * The Plan class for the <i>lookup</i> relational algebra operator. * @author Edward Sciore * */public class LookupPlan implements Plan {	private Plan rp, tp;	private Schema sch = new Schema();	/**	 * Creates a new lookup node having the specified	 * LHS rid-table and RHS data table.	 * @param rp the LHS rid-table	 * @param tp the RHS table	 */	public LookupPlan(Plan rp, Plan tp) {		this.rp = rp;		this.tp = tp;		sch.addAll(rp.schema());		sch.addAll(tp.schema());	}	/**	 * Creates a new lookup scan for this query.	 * @see simpledb.query.Plan#open()	 */	public Scan open() {		RidScan rs = (RidScan) rp.open();		TableScan ts = (TableScan) tp.open();		return new LookupScan(rs, ts);	}	/**	 * Estimates the number of block accesses to compute the 	 * lookup, which is the sum of the costs of its	 * LHS and RHS.	 * @see simpledb.query.Plan#blocksAccessed()	 */	public int blocksAccessed() {		return rp.blocksAccessed() + rp.recordsOutput();	}	/**	 * Estimates the number of output records in the lookup,	 * which is the same as in the LHS rid-table.	 * @see simpledb.query.Plan#recordsOutput()	 */	public int recordsOutput() {		return rp.recordsOutput();	}	/**	 * Estimate the number of distinct values for the	 * specified field. 	 * This value is the same as in the LHS or RHS,	 * depending on where the field came from.	 * @see simpledb.query.Plan#distinctValues(java.lang.String)	 */	public int distinctValues(String fldname) {		if (rp.schema().hasField(fldname))			return rp.distinctValues(fldname);		else			return tp.distinctValues(fldname);	}	/**	 * Returns the union of the LHS and RHS schemas.	 * @see simpledb.query.Plan#schema()	 */	public Schema schema() {		return sch;	}}

⌨️ 快捷键说明

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