simpledb.materialize
Class SortScan

java.lang.Object
  extended by simpledb.materialize.SortScan
All Implemented Interfaces:
Scan

public class SortScan
extends Object
implements Scan

Author:
sciore

Constructor Summary
SortScan(List<TempTable> runs, RecordComparator comp)
          Creates a sort scan, given a list of 1 or 2 runs.
 
Method Summary
 void beforeFirst()
          Positions the scan before the first record in sorted order.
 void close()
          Closes the two underlying scans.
 int getInt(String fldname)
          Gets the integer value of the specified field of the current scan.
 String getString(String fldname)
          Gets the string value of the specified field of the current scan.
 Constant getVal(String fldname)
          Gets the Constant value of the specified field of the current scan.
 boolean hasField(String fldname)
          Returns true if the specified field is in the current scan.
 boolean next()
          Moves to the next record in sorted order.
 void restorePosition()
          Moves the scan to its previously-saved position.
 void savePosition()
          Saves the position of the current record, so that it can be restored at a later time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SortScan

public SortScan(List<TempTable> runs,
                RecordComparator comp)
Creates a sort scan, given a list of 1 or 2 runs. If there is only 1 run, then s2 will be null and hasmore2 will be false.

Parameters:
runs - the list of runs
comp - the record comparator
Method Detail

beforeFirst

public void beforeFirst()
Positions the scan before the first record in sorted order. Internally, it moves to the first record of each underlying scan. The variable currentscan is set to null, indicating that there is no current scan.

Specified by:
beforeFirst in interface Scan
See Also:
Scan.beforeFirst()

next

public boolean next()
Moves to the next record in sorted order. First, the current scan is moved to the next record. Then the lowest record of the two scans is found, and that scan is chosen to be the new current scan.

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

close

public void close()
Closes the two underlying scans.

Specified by:
close in interface Scan
See Also:
Scan.close()

getVal

public Constant getVal(String fldname)
Gets the Constant value of the specified field of the current scan.

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)
Gets the integer value of the specified field of the current scan.

Specified by:
getInt in interface Scan
Parameters:
fldname - the name of the field
Returns:
the field's integer value in the current record
See Also:
Scan.getInt(java.lang.String)

getString

public String getString(String fldname)
Gets the string value of the specified field of the current scan.

Specified by:
getString in interface Scan
Parameters:
fldname - the name of the field
Returns:
the field's string value in the current record
See Also:
Scan.getString(java.lang.String)

hasField

public boolean hasField(String fldname)
Returns true if the specified field is in the current scan.

Specified by:
hasField in interface Scan
Parameters:
fldname - the name of the field
Returns:
true if the scan has that field
See Also:
Scan.hasField(java.lang.String)

savePosition

public void savePosition()
Saves the position of the current record, so that it can be restored at a later time.


restorePosition

public void restorePosition()
Moves the scan to its previously-saved position.



Copyright © 2011. All Rights Reserved.