iterator
Class SortMerge

java.lang.Object
  extended byiterator.Iterator
      extended byiterator.SortMerge
All Implemented Interfaces:
Flags, GlobalConst

public class SortMerge
extends Iterator
implements GlobalConst

This file contains the interface for the sort_merg joins. We name the two relations being joined as R and S. This file contains an implementation of the sort merge join algorithm as described in the Shapiro paper. It makes use of the external sorting utility to generate runs, and then uses the iterator interface to get successive tuples for the final merge.


Field Summary
 
Fields inherited from class iterator.Iterator
closeFlag
 
Fields inherited from interface global.GlobalConst
INVALID_PAGE, MAX_NAME, MAX_SPACE, MAXATTRNAME, MAXFILENAME, MAXINDEXNAME, MINIBASE_BUFFER_POOL_SIZE, MINIBASE_DB_SIZE, MINIBASE_DEFAULT_SHAREDMEM_SIZE, MINIBASE_MAX_TRANSACTIONS, MINIBASE_MAXARRSIZE, MINIBASE_PAGESIZE, NUMBUF
 
Fields inherited from interface global.Flags
DEBUG, TEST
 
Constructor Summary
SortMerge(AttrType[] in1, int len_in1, short[] s1_sizes, AttrType[] in2, int len_in2, short[] s2_sizes, int join_col_in1, int sortFld1Len, int join_col_in2, int sortFld2Len, int amt_of_mem, Iterator am1, Iterator am2, boolean in1_sorted, boolean in2_sorted, TupleOrder order, CondExpr[] outFilter, FldSpec[] proj_list, int n_out_flds)
          constructor,initialization
 
Method Summary
 void close()
          implement the abstract method close() from super class Iterator to finish cleaning up
 Tuple get_next()
          The tuple is returned All this function has to do is to get 1 tuple from one of the Iterators (from both initially), use the sorting order to determine which one gets sent up.
 
Methods inherited from class iterator.Iterator
free_buffer_pages, get_buffer_pages
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SortMerge

public SortMerge(AttrType[] in1,
                 int len_in1,
                 short[] s1_sizes,
                 AttrType[] in2,
                 int len_in2,
                 short[] s2_sizes,
                 int join_col_in1,
                 int sortFld1Len,
                 int join_col_in2,
                 int sortFld2Len,
                 int amt_of_mem,
                 Iterator am1,
                 Iterator am2,
                 boolean in1_sorted,
                 boolean in2_sorted,
                 TupleOrder order,
                 CondExpr[] outFilter,
                 FldSpec[] proj_list,
                 int n_out_flds)
          throws JoinNewFailed,
                 JoinLowMemory,
                 SortException,
                 TupleUtilsException,
                 java.io.IOException
constructor,initialization

Parameters:
len_in1 - # of columns in R
s1_sizes - shows the length of the string fields in R.
len_in2 - # of columns in S
s2_sizes - shows the length of the string fields in S
sortFld1Len - the length of sorted field in R
sortFld2Len - the length of sorted field in S
join_col_in1 - The col of R to be joined with S
join_col_in2 - the col of S to be joined with R
amt_of_mem - IN PAGES
am1 - access method for left input to join
am2 - access method for right input to join
in1_sorted - is am1 sorted?
in2_sorted - is am2 sorted?
order - the order of the tuple: assending or desecnding?
proj_list - shows what input fields go where in the output tuple
n_out_flds - number of outer relation fileds
Throws:
JoinNewFailed - allocate failed
JoinLowMemory - memory not enough
SortException - exception from sorting
TupleUtilsException - exception from using tuple utils
java.io.IOException - some I/O fault
Method Detail

get_next

public Tuple get_next()
               throws java.io.IOException,
                      JoinsException,
                      index.IndexException,
                      InvalidTupleSizeException,
                      InvalidTypeException,
                      PageNotReadException,
                      TupleUtilsException,
                      PredEvalException,
                      SortException,
                      LowMemException,
                      UnknowAttrType,
                      UnknownKeyTypeException,
                      java.lang.Exception
This provides the next joined tuple.
If there are no remaining joined tuples, null is returned.

Specified by:
get_next in class Iterator
Returns:
the joined tuple is returned
Throws:
java.io.IOException - I/O errors
JoinsException - some join exception
index.IndexException - exception from super class
InvalidTupleSizeException - invalid tuple size
InvalidTypeException - tuple type not valid
PageNotReadException - exception from lower layer
TupleUtilsException - exception from using tuple utilities
PredEvalException - exception from PredEval class
SortException - sort exception
LowMemException - memory error
UnknowAttrType - attribute type unknown
UnknownKeyTypeException - key type unknown
java.lang.Exception - other exceptions

close

public void close()
           throws JoinsException,
                  java.io.IOException,
                  index.IndexException
implement the abstract method close() from super class Iterator to finish cleaning up

Specified by:
close in class Iterator
Throws:
java.io.IOException - I/O error from lower layers
JoinsException - join error from lower layers
index.IndexException - index access error