📄 indexjoinplan.java
字号:
package simpledb.index.query;import simpledb.tx.Transaction;import simpledb.record.Schema;import simpledb.query.*;import simpledb.index.Index;import simpledb.index.metadata.IndexInfo;/** The Plan class corresponding to the <i>indexjoin</i> * relational algebra operator. * @author Edward Sciore */public class IndexJoinPlan implements Plan { private Plan p; private IndexInfo ii; private String joinfield; /** * Creates a new indexjoin node in the query tree, * using the specified LHS subquery and RHS index. * @param p the left-hand subquery * @param ii information about the right-hand index * @param joinfield the left-hand field used for joining * @param tx the calling transaction */ public IndexJoinPlan(Plan p, IndexInfo ii, String joinfield, Transaction tx) { this.p = p; this.ii = ii; this.joinfield = joinfield; } /** * Opens an indexjoin scan for this query * @see simpledb.query.Plan#open() */ public Scan open() { Scan s = p.open(); Index idx = ii.open(); return new IndexJoinScan(s, idx, joinfield); } /** * Estimates the number of block accesses to compute the join. * The formula is: * <pre> B(indexjoin(p,idx)) = B(p) + R(p)*B(idx) </pre> * @see simpledb.query.Plan#blocksAccessed() */ public int blocksAccessed() { return p.blocksAccessed() + (p.recordsOutput() * ii.blocksAccessed()); } /** * Estimates the number of output records in the join. * The formula is: * <pre> R(indexjoin(p,idx)) = R(p)*R(idx) </pre> * @see simpledb.query.Plan#recordsOutput() */ public int recordsOutput() { return p.recordsOutput() * ii.recordsOutput(); } /** * Estimates the number of distinct values for the * specified field. This value is the same as * in the LHS plan. * @see simpledb.query.Plan#distinctValues(java.lang.String) */ public int distinctValues(String fldname) { return p.distinctValues(fldname); } /** * Returns the schema of the index join. * Since the index has no interesting fields, * the schema is the same as in the LHS plan. * @see simpledb.query.Plan#schema() */ public Schema schema() { return p.schema(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -