Class JoinMethods

java.lang.Object
  extended by JoinMethods

public class JoinMethods
extends java.lang.Object

Library of methods to handle joins between two heap files.

Author:
Dave Musicant, with considerable material reused from the UW-Madison Minibase project

Nested Class Summary
static class JoinMethods.JoinLengthsDifferentException
           
 
Constructor Summary
JoinMethods()
           
 
Method Summary
static void blockNestedLoop(java.lang.String filename1, int numCols1, int[] colSizes1, int joinCol1, java.lang.String filename2, int numCols2, int[] colSizes2, int joinCol2, java.lang.String filenameOut, int numPagesOut, BufferManager bufMgr)
          Joins two heap files using block nested loop algorithm, and places results in a new heapfile.
static void tupleNestedLoop(java.lang.String filename1, int numCols1, int[] colSizes1, int joinCol1, java.lang.String filename2, int numCols2, int[] colSizes2, int joinCol2, java.lang.String filenameOut, int numPagesOut, BufferManager bufMgr)
          Joins two heap files using tuple nested loop algorithm, and places results in a new heapfile.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JoinMethods

public JoinMethods()
Method Detail

tupleNestedLoop

public static void tupleNestedLoop(java.lang.String filename1,
                                   int numCols1,
                                   int[] colSizes1,
                                   int joinCol1,
                                   java.lang.String filename2,
                                   int numCols2,
                                   int[] colSizes2,
                                   int joinCol2,
                                   java.lang.String filenameOut,
                                   int numPagesOut,
                                   BufferManager bufMgr)
                            throws java.io.IOException
Joins two heap files using tuple nested loop algorithm, and places results in a new heapfile. Each new record produced for the new heapfile is a concatenation of the two source records.

Parameters:
filename1 - name of heap file containing relation 1.
numCols1 - number of columns in relation 1.
colSizes1 - array containing sizes of columns in relation 1.
joinCol1 - join column of relation 1. Legitimate values of joinCol1 are in the range from 0 to (numCols1-1), inclusive.
filename2 - name of heap file containing relation 2.
numCols2 - number of columns in relation 2.
colSizes2 - array containing sizes of columns in relation 2.
joinCol2 - join column of relation 2. Legitimate values of joinCol2 are in the range from 0 to (numCols2-1), inclusive.
filenameOut - name of output heap file to be created.
numPagesOut - number of pages to be contained in new output heap file.
bufMgr - reference to a buffer manager to contain pages in memory while working.
Throws:
java.io.IOException - passed through from underlying file system.
JoinMethods.JoinLengthsDifferentException - if the lengths of the two join fields are not the same.

blockNestedLoop

public static void blockNestedLoop(java.lang.String filename1,
                                   int numCols1,
                                   int[] colSizes1,
                                   int joinCol1,
                                   java.lang.String filename2,
                                   int numCols2,
                                   int[] colSizes2,
                                   int joinCol2,
                                   java.lang.String filenameOut,
                                   int numPagesOut,
                                   BufferManager bufMgr)
                            throws java.io.IOException
Joins two heap files using block nested loop algorithm, and places results in a new heapfile. Each new record produced for the new heapfile is a concatenation of the two source records.

Parameters:
filename1 - name of heap file containing relation 1.
numCols1 - number of columns in relation 1.
colSizes1 - array containing sizes of columns in relation 1.
joinCol1 - join column of relation 1. Legitimate values of joinCol1 are in the range from 0 to (numCols1-1), inclusive.
filename2 - name of heap file containing relation 2.
numCols2 - number of columns in relation 2.
colSizes2 - array containing sizes of columns in relation 2.
joinCol2 - join column of relation 2. Legitimate values of joinCol2 are in the range from 0 to (numCols2-1), inclusive.
filenameOut - name of output heap file to be created.
numPagesOut - number of pages to be contained in new output heap file.
bufMgr - reference to a buffer manager to contain pages in memory while working.
Throws:
java.io.IOException - passed through from underlying file system.
JoinMethods.JoinLengthsDifferentException - if the lengths of the two join fields are not the same.