simpledb.materialize
Class MergeJoinScan

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

public class MergeJoinScan
extends Object
implements Scan

The Scan class for the mergejoin operator.

Author:
Edward Sciore

Constructor Summary
MergeJoinScan(Scan s1, SortScan s2, String fldname1, String fldname2)
          Creates a mergejoin scan for the two underlying sorted scans.
 
Method Summary
 void beforeFirst()
          Positions the scan before the first record, by positioning each underlying scan before their first records.
 void close()
          Closes the scan by closing the two underlying scans.
 int getInt(String fldname)
          Returns the integer value of the specified field.
 String getString(String fldname)
          Returns the string value of the specified field.
 Constant getVal(String fldname)
          Returns the value of the specified field.
 boolean hasField(String fldname)
          Returns true if the specified field is in either of the underlying scans.
 boolean next()
          Moves to the next record.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MergeJoinScan

public MergeJoinScan(Scan s1,
                     SortScan s2,
                     String fldname1,
                     String fldname2)
Creates a mergejoin scan for the two underlying sorted scans.

Parameters:
s1 - the LHS sorted scan
s2 - the RHS sorted scan
fldname1 - the LHS join field
fldname2 - the RHS join field
Method Detail

beforeFirst

public void beforeFirst()
Positions the scan before the first record, by positioning each underlying scan before their first records.

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

close

public void close()
Closes the scan by closing the two underlying scans.

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

next

public boolean next()
Moves to the next record. This is where the action is.

If the next RHS record has the same join value, then move to it. Otherwise, if the next LHS record has the same join value, then reposition the RHS scan back to the first record having that join value. Otherwise, repeatedly move the scan having the smallest value until a common join value is found. When one of the scans runs out of records, return false.

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

getVal

public Constant getVal(String fldname)
Returns the value of the specified field. The value is obtained from whichever scan contains the field.

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)
Returns the integer value of the specified field. The value is obtained from whichever scan contains the field.

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)
Returns the string value of the specified field. The value is obtained from whichever scan contains the field.

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 either of the underlying scans.

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)


Copyright © 2011. All Rights Reserved.