simpledb.multibuffer
Class MultiBufferProductPlan

java.lang.Object
  extended by simpledb.multibuffer.MultiBufferProductPlan
All Implemented Interfaces:
Plan

public class MultiBufferProductPlan
extends Object
implements Plan

The Plan class for the muti-buffer version of the product operator.

Author:
Edward Sciore

Constructor Summary
MultiBufferProductPlan(Plan lhs, Plan rhs, Transaction tx)
          Creates a product plan for the specified queries.
 
Method Summary
 int blocksAccessed()
          Returns an estimate of the number of block accesses required to execute the query.
 int distinctValues(String fldname)
          Estimates the distinct number of field values in the product.
 Scan open()
          A scan for this query is created and returned, as follows.
 int recordsOutput()
          Estimates the number of output records in the product.
 Schema schema()
          Returns the schema of the product, which is the union of the schemas of the underlying queries.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiBufferProductPlan

public MultiBufferProductPlan(Plan lhs,
                              Plan rhs,
                              Transaction tx)
Creates a product plan for the specified queries.

Parameters:
lhs - the plan for the LHS query
rhs - the plan for the RHS query
tx - the calling transaction
Method Detail

open

public Scan open()
A scan for this query is created and returned, as follows. First, the method materializes its RHS query. It then determines the optimal chunk size, based on the size of the materialized file and the number of available buffers. It creates a chunk plan for each chunk, saving them in a list. Finally, it creates a multiscan for this list of plans, and returns that scan.

Specified by:
open in interface Plan
Returns:
a scan
See Also:
Plan.open()

blocksAccessed

public int blocksAccessed()
Returns an estimate of the number of block accesses required to execute the query. The formula is:
 B(product(p1,p2)) = B(p2) + B(p1)*C(p2) 
where C(p2) is the number of chunks of p2. The method uses the current number of available buffers to calculate C(p2), and so this value may differ when the query scan is opened.

Specified by:
blocksAccessed in interface Plan
Returns:
the estimated number of block accesses
See Also:
Plan.blocksAccessed()

recordsOutput

public int recordsOutput()
Estimates the number of output records in the product. The formula is:
 R(product(p1,p2)) = R(p1)*R(p2) 

Specified by:
recordsOutput in interface Plan
Returns:
the estimated number of output records
See Also:
Plan.recordsOutput()

distinctValues

public int distinctValues(String fldname)
Estimates the distinct number of field values in the product. Since the product does not increase or decrease field values, the estimate is the same as in the appropriate underlying query.

Specified by:
distinctValues in interface Plan
Parameters:
fldname - the name of a field
Returns:
the estimated number of distinct field values in the output
See Also:
Plan.distinctValues(java.lang.String)

schema

public Schema schema()
Returns the schema of the product, which is the union of the schemas of the underlying queries.

Specified by:
schema in interface Plan
Returns:
the query's schema
See Also:
Plan.schema()


Copyright © 2011. All Rights Reserved.