simpledb.index.query
Class IndexJoinScan

java.lang.Object
  extended by simpledb.index.query.IndexJoinScan
All Implemented Interfaces:
Scan

public class IndexJoinScan
extends Object
implements Scan

The scan class corresponding to the indexjoin relational algebra operator. The code is very similar to that of ProductScan, which makes sense because an index join is essentially the product of each LHS record with the matching RHS index records.

Author:
Edward Sciore

Constructor Summary
IndexJoinScan(Scan s, Index idx, String joinfield, TableScan ts)
          Creates an index join scan for the specified LHS scan and RHS index.
 
Method Summary
 void beforeFirst()
          Positions the scan before the first record.
 void close()
          Closes the scan by closing its LHS scan and its RHS index.
 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 Constant value of the specified field.
 boolean hasField(String fldname)
          Returns true if the field is in the schema.
 boolean next()
          Moves the scan to the next record.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IndexJoinScan

public IndexJoinScan(Scan s,
                     Index idx,
                     String joinfield,
                     TableScan ts)
Creates an index join scan for the specified LHS scan and RHS index.

Parameters:
s - the LHS scan
idx - the RHS index
joinfield - the LHS field used for joining
Method Detail

beforeFirst

public void beforeFirst()
Positions the scan before the first record. That is, the LHS scan will be positioned at its first record, and the index will be positioned before the first record for the join value.

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

next

public boolean next()
Moves the scan to the next record. The method moves to the next index record, if possible. Otherwise, it moves to the next LHS record and the first index record. If there are no more LHS records, the method returns false.

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

close

public void close()
Closes the scan by closing its LHS scan and its RHS index.

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

getVal

public Constant getVal(String fldname)
Returns the Constant value of the specified 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.

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.getVal(java.lang.String)

getString

public String getString(String fldname)
Returns the string value of the specified 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.getVal(java.lang.String)

hasField

public boolean hasField(String fldname)
Returns true if the field is in the schema.

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.