simpledb.query
Class SelectScan

java.lang.Object
  extended by simpledb.query.SelectScan
All Implemented Interfaces:
Scan, UpdateScan

public class SelectScan
extends Object
implements UpdateScan

The scan class corresponding to the select relational algebra operator. All methods except next delegate their work to the underlying scan.

Author:
Edward Sciore

Constructor Summary
SelectScan(Scan s, Predicate pred)
          Creates a select scan having the specified underlying scan and predicate.
 
Method Summary
 void beforeFirst()
          Positions the scan before its first record.
 void close()
          Closes the scan and its subscans, if any.
 void delete()
          Deletes the current record from the scan.
 int getInt(String fldname)
          Returns the value of the specified integer field in the current record.
 RID getRid()
          Returns the RID of the current record.
 String getString(String fldname)
          Returns the value of the specified string field in the current record.
 Constant getVal(String fldname)
          Returns the value of the specified field in the current record.
 boolean hasField(String fldname)
          Returns true if the scan has the specified field.
 void insert()
          Inserts a new record somewhere in the scan.
 void moveToRid(RID rid)
          Positions the scan so that the current record has the specified RID.
 boolean next()
          Move to the next record satisfying the predicate.
 void setInt(String fldname, int val)
          Modifies the field value of the current record.
 void setString(String fldname, String val)
          Modifies the field value of the current record.
 void setVal(String fldname, Constant val)
          Modifies the field value of the current record.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SelectScan

public SelectScan(Scan s,
                  Predicate pred)
Creates a select scan having the specified underlying scan and predicate.

Parameters:
s - the scan of the underlying query
pred - the selection predicate
Method Detail

beforeFirst

public void beforeFirst()
Description copied from interface: Scan
Positions the scan before its first record.

Specified by:
beforeFirst in interface Scan

next

public boolean next()
Move to the next record satisfying the predicate. The method repeatedly calls next on the underlying scan until a suitable record is found, or the underlying scan contains no more records.

Specified by:
next in interface Scan
Returns:
false if there is no next record
See Also:
Scan.next()

close

public void close()
Description copied from interface: Scan
Closes the scan and its subscans, if any.

Specified by:
close in interface Scan

getVal

public Constant getVal(String fldname)
Description copied from interface: Scan
Returns the value of the specified field in the current record. The value is expressed as a Constant.

Specified by:
getVal in interface Scan
Parameters:
fldname - the name of the field
Returns:
the value of that field, expressed as a Constant.

getInt

public int getInt(String fldname)
Description copied from interface: Scan
Returns the value of the specified integer field in the current record.

Specified by:
getInt in interface Scan
Parameters:
fldname - the name of the field
Returns:
the field's integer value in the current record

getString

public String getString(String fldname)
Description copied from interface: Scan
Returns the value of the specified string field in the current record.

Specified by:
getString in interface Scan
Parameters:
fldname - the name of the field
Returns:
the field's string value in the current record

hasField

public boolean hasField(String fldname)
Description copied from interface: Scan
Returns true if the scan has the specified field.

Specified by:
hasField in interface Scan
Parameters:
fldname - the name of the field
Returns:
true if the scan has that field

setVal

public void setVal(String fldname,
                   Constant val)
Description copied from interface: UpdateScan
Modifies the field value of the current record.

Specified by:
setVal in interface UpdateScan
Parameters:
fldname - the name of the field
val - the new value, expressed as a Constant

setInt

public void setInt(String fldname,
                   int val)
Description copied from interface: UpdateScan
Modifies the field value of the current record.

Specified by:
setInt in interface UpdateScan
Parameters:
fldname - the name of the field
val - the new integer value

setString

public void setString(String fldname,
                      String val)
Description copied from interface: UpdateScan
Modifies the field value of the current record.

Specified by:
setString in interface UpdateScan
Parameters:
fldname - the name of the field
val - the new string value

delete

public void delete()
Description copied from interface: UpdateScan
Deletes the current record from the scan.

Specified by:
delete in interface UpdateScan

insert

public void insert()
Description copied from interface: UpdateScan
Inserts a new record somewhere in the scan.

Specified by:
insert in interface UpdateScan

getRid

public RID getRid()
Description copied from interface: UpdateScan
Returns the RID of the current record.

Specified by:
getRid in interface UpdateScan
Returns:
the RID of the current record

moveToRid

public void moveToRid(RID rid)
Description copied from interface: UpdateScan
Positions the scan so that the current record has the specified RID.

Specified by:
moveToRid in interface UpdateScan
Parameters:
rid - the RID of the desired record


Copyright © 2011. All Rights Reserved.