📄 indexselectscan.java
字号:
package simpledb.index.query;import simpledb.record.RID;import simpledb.query.*;import simpledb.index.Index;/** * The scan class corresponding to the select relational * algebra operator. * @author Edward Sciore */public class IndexSelectScan implements RidScan { private Index idx; private Constant val; /** * Creates an index select scan for the specified * index and selection constant. * @param idx the index * @param val the selection constant */ public IndexSelectScan(Index idx, Constant val) { this.idx = idx; this.val = val; beforeFirst(); } /** * Positions the scan before the first record, * which in this case means positioning the index * before the first instance of the selection constant. * @see simpledb.query.Scan#beforeFirst() */ public void beforeFirst() { idx.beforeFirst(val); } /** * Moves to the next record, which in this case means * moving the index to the next record satisfying the * selection constant, and returning false if there are * no more such index records. * @see simpledb.query.Scan#next() */ public boolean next() { return idx.next(); } /** * Closes the scan by closing the index. * @see simpledb.query.Scan#close() */ public void close() { idx.close(); } /** * Throws an exception, because the schema contains * no fields. * @see simpledb.query.Scan#getVal(java.lang.String) */ public Constant getVal(String fldname) { throw new RuntimeException("field " + fldname + " not found."); } /** * Throws an exception, because the schema contains * no fields. * @see simpledb.query.Scan#getInt(java.lang.String) */ public int getInt(String fldname) { throw new RuntimeException("field " + fldname + " not found."); } /** * Throws an exception, because the schema contains * no fields. * @see simpledb.query.Scan#getString(java.lang.String) */ public String getString(String fldname) { throw new RuntimeException("field " + fldname + " not found."); } /** * Always return false, because the schema has no fields. * @see simpledb.query.Scan#hasField(java.lang.String) */ public boolean hasField(String fldname) { return false; } /** * Returns the dataRid value of the current record, * which is obtained from the current index record. * @see simpledb.index.query.RidScan#getDataRid() */ public RID getDataRid() { return idx.getDataRid(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -