simpledb.query
Class TableScan

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

public class TableScan
extends Object
implements UpdateScan

The Scan class corresponding to a table. A table scan is just a wrapper for a RecordFile object; most methods just delegate to the corresponding RecordFile methods.

Author:
Edward Sciore

Constructor Summary
TableScan(TableInfo ti, Transaction tx)
          Creates a new table scan, and opens its corresponding record file.
 
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, as a Constant.
 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()
          Moves the scan to the next record.
 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)
          Sets the value of the specified field, as a Constant.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TableScan

public TableScan(TableInfo ti,
                 Transaction tx)
Creates a new table scan, and opens its corresponding record file.

Parameters:
ti - the table's metadata
tx - the calling transaction
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()
Description copied from interface: Scan
Moves the scan to the next record.

Specified by:
next in interface Scan
Returns:
false if there is no next record

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)
Returns the value of the specified field, as a Constant. The schema is examined to determine the field's type. If INTEGER, then the record file's getInt method is called; otherwise, the getString method is called.

Specified by:
getVal in interface Scan
Parameters:
fldname - the name of the field
Returns:
the value of that field, expressed as a Constant.
See Also:
Scan.getVal(java.lang.String)

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)
Sets the value of the specified field, as a Constant. The schema is examined to determine the field's type. If INTEGER, then the record file's setInt method is called; otherwise, the setString method is called.

Specified by:
setVal in interface UpdateScan
Parameters:
fldname - the name of the field
val - the new value, expressed as a Constant
See Also:
UpdateScan.setVal(java.lang.String, simpledb.query.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.