Cleanup prints

This commit is contained in:
Max O'Cull 2019-03-29 19:32:33 -04:00
parent a8351b98f4
commit b3c3961130
4 changed files with 102 additions and 102 deletions

View File

@ -36,7 +36,7 @@ public class HashJoin extends Iterator {
// private Tuple nextTuple = null; // private Tuple nextTuple = null;
public HashJoin(Iterator aIter1, Iterator aIter2, int aJoinCol1, int aJoinCol2) { public HashJoin(Iterator aIter1, Iterator aIter2, int aJoinCol1, int aJoinCol2) {
System.out.println("> new HashJoin"); // System.out.println("> new HashJoin");
this.smaller = aIter1; this.smaller = aIter1;
this.larger = aIter2; this.larger = aIter2;
this.smallerJoinCol = aJoinCol1; this.smallerJoinCol = aJoinCol1;
@ -70,7 +70,7 @@ public class HashJoin extends Iterator {
* Restarts the iterator, i.e. as if it were just constructed. * Restarts the iterator, i.e. as if it were just constructed.
*/ */
public void restart() { public void restart() {
System.out.println("> HashJoin.restart"); // System.out.println("> HashJoin.restart");
this.smaller.restart(); this.smaller.restart();
this.larger.restart(); this.larger.restart();
} }
@ -79,7 +79,7 @@ public class HashJoin extends Iterator {
* Returns true if the iterator is open; false otherwise. * Returns true if the iterator is open; false otherwise.
*/ */
public boolean isOpen() { public boolean isOpen() {
System.out.println("> HashJoin.isOpen"); // System.out.println("> HashJoin.isOpen");
if (this.larger.isOpen()) { if (this.larger.isOpen()) {
return true; return true;
} }
@ -91,7 +91,7 @@ public class HashJoin extends Iterator {
* Closes the iterator, releasing any resources (i.e. pinned pages). * Closes the iterator, releasing any resources (i.e. pinned pages).
*/ */
public void close() { public void close() {
System.out.println("> HashJoin.close"); // System.out.println("> HashJoin.close");
if (this.isOpen()) { if (this.isOpen()) {
this.smaller.close(); this.smaller.close();
this.larger.close(); this.larger.close();
@ -109,7 +109,7 @@ public class HashJoin extends Iterator {
// } // }
if (this.nextTupleBatch.size() > 0) { if (this.nextTupleBatch.size() > 0) {
System.out.print("> HashJoin.hasNext : Queue has entries"); // System.out.print("> HashJoin.hasNext : Queue has entries");
return true; return true;
} }

View File

@ -19,7 +19,7 @@ public class KeyScan extends Iterator {
* Constructs an index scan, given the hash index and schema. * Constructs an index scan, given the hash index and schema.
*/ */
public KeyScan(Schema aSchema, HashIndex aIndex, SearchKey aKey, HeapFile aFile) { public KeyScan(Schema aSchema, HashIndex aIndex, SearchKey aKey, HeapFile aFile) {
System.out.println("> new KeyScan"); // System.out.println("> new KeyScan");
this.schema = aSchema; this.schema = aSchema;
this.index = aIndex; this.index = aIndex;
this.key = aKey; this.key = aKey;
@ -39,7 +39,7 @@ public class KeyScan extends Iterator {
* Restarts the iterator, i.e. as if it were just constructed. * Restarts the iterator, i.e. as if it were just constructed.
*/ */
public void restart() { public void restart() {
System.out.println("> KeyScan.restart"); // System.out.println("> KeyScan.restart");
this.close(); this.close();
this.scan = this.index.openScan(this.key); this.scan = this.index.openScan(this.key);
} }
@ -48,7 +48,7 @@ public class KeyScan extends Iterator {
* Returns true if the iterator is open; false otherwise. * Returns true if the iterator is open; false otherwise.
*/ */
public boolean isOpen() { public boolean isOpen() {
System.out.println("> KeyScan.isOpen"); // System.out.println("> KeyScan.isOpen");
if (this.scan != null) { if (this.scan != null) {
return true; return true;
} }
@ -60,7 +60,7 @@ public class KeyScan extends Iterator {
* Closes the iterator, releasing any resources (i.e. pinned pages). * Closes the iterator, releasing any resources (i.e. pinned pages).
*/ */
public void close() { public void close() {
System.out.println("> KeyScan.close"); // System.out.println("> KeyScan.close");
if (this.isOpen()) { if (this.isOpen()) {
this.scan.close(); this.scan.close();
this.scan = null; this.scan = null;
@ -71,7 +71,7 @@ public class KeyScan extends Iterator {
* Returns true if there are more tuples, false otherwise. * Returns true if there are more tuples, false otherwise.
*/ */
public boolean hasNext() { public boolean hasNext() {
System.out.println("> KeyScan.hasNext"); // System.out.println("> KeyScan.hasNext");
if (this.isOpen()) { if (this.isOpen()) {
return this.scan.hasNext(); return this.scan.hasNext();
} }
@ -85,7 +85,7 @@ public class KeyScan extends Iterator {
* @throws IllegalStateException if no more tuples * @throws IllegalStateException if no more tuples
*/ */
public Tuple getNext() { public Tuple getNext() {
System.out.println("> KeyScan.getNext"); // System.out.println("> KeyScan.getNext");
if (this.isOpen()) { if (this.isOpen()) {
RID rid = scan.getNext(); RID rid = scan.getNext();
Tuple tuple = new Tuple(this.schema, this.file.selectRecord(rid)); Tuple tuple = new Tuple(this.schema, this.file.selectRecord(rid));

View File

@ -14,7 +14,7 @@ public class Projection extends Iterator {
* Constructs a projection, given the underlying iterator and field numbers. * Constructs a projection, given the underlying iterator and field numbers.
*/ */
public Projection(Iterator aIter, Integer... aFields) { public Projection(Iterator aIter, Integer... aFields) {
System.out.println("> new Projection"); // System.out.println("> new Projection");
this.iterator = aIter; this.iterator = aIter;
this.fields = aFields; this.fields = aFields;
@ -39,7 +39,7 @@ public class Projection extends Iterator {
* Restarts the iterator, i.e. as if it were just constructed. * Restarts the iterator, i.e. as if it were just constructed.
*/ */
public void restart() { public void restart() {
System.out.println("> Projection.restart"); // System.out.println("> Projection.restart");
this.iterator.restart(); this.iterator.restart();
} }
@ -47,7 +47,7 @@ public class Projection extends Iterator {
* Returns true if the iterator is open; false otherwise. * Returns true if the iterator is open; false otherwise.
*/ */
public boolean isOpen() { public boolean isOpen() {
System.out.println("> Projection.isOpen: " + this.iterator.isOpen()); // System.out.println("> Projection.isOpen: " + this.iterator.isOpen());
return this.iterator.isOpen(); return this.iterator.isOpen();
} }
@ -55,7 +55,7 @@ public class Projection extends Iterator {
* Closes the iterator, releasing any resources (i.e. pinned pages). * Closes the iterator, releasing any resources (i.e. pinned pages).
*/ */
public void close() { public void close() {
System.out.println("> Projection.close"); // System.out.println("> Projection.close");
if (this.isOpen()) { if (this.isOpen()) {
this.iterator.close(); this.iterator.close();
} }
@ -65,7 +65,7 @@ public class Projection extends Iterator {
* Returns true if there are more tuples, false otherwise. * Returns true if there are more tuples, false otherwise.
*/ */
public boolean hasNext() { public boolean hasNext() {
System.out.println("> Projection.hasNext"); // System.out.println("> Projection.hasNext");
return this.iterator.hasNext(); return this.iterator.hasNext();
} }
@ -75,7 +75,7 @@ public class Projection extends Iterator {
* @throws IllegalStateException if no more tuples * @throws IllegalStateException if no more tuples
*/ */
public Tuple getNext() { public Tuple getNext() {
System.out.println("> Projection.getNext"); // System.out.println("> Projection.getNext");
// if (this.iterator.hasNext()) { // if (this.iterator.hasNext()) {
Tuple original = this.iterator.getNext(); Tuple original = this.iterator.getNext();
Tuple projecting = new Tuple(this.schema); Tuple projecting = new Tuple(this.schema);

View File

@ -218,50 +218,50 @@ public class ROTest extends TestDriver {
rot.delete_minibase(); rot.delete_minibase();
} }
// @Test @Test
// public void testFileScan() { public void testFileScan() {
// // Scan drivers table // Scan drivers table
// Iterator fscan = new FileScan(s_drivers, f_drivers); Iterator fscan = new FileScan(s_drivers, f_drivers);
// execute_and_compare("Filescan", "filescan", fscan); execute_and_compare("Filescan", "filescan", fscan);
// } }
//
// @Test @Test
// public void testIndexScan() { public void testIndexScan() {
// // Scan drivers index // Scan drivers index
// Iterator idxscan = new IndexScan(s_drivers, idx_drivers, f_drivers); Iterator idxscan = new IndexScan(s_drivers, idx_drivers, f_drivers);
// execute_and_compare("IndexScan", "idxscan", idxscan); execute_and_compare("IndexScan", "idxscan", idxscan);
// } }
//
// @Test @Test
// public void testKeyScan() { public void testKeyScan() {
// // Scan drivers index for key 20f // Scan drivers index for key 20f
// Iterator keyscan = new KeyScan(s_drivers, idx_drivers, new SearchKey(20f), f_drivers); Iterator keyscan = new KeyScan(s_drivers, idx_drivers, new SearchKey(20f), f_drivers);
// execute_and_compare("KeyScan", "keyscan", keyscan); execute_and_compare("KeyScan", "keyscan", keyscan);
// } }
//
// @Test @Test
// public void testSelection() { public void testSelection() {
// // Selection drivers with age > 20 // Selection drivers with age > 20
// Iterator selection = new Selection(new FileScan(s_drivers, f_drivers), Iterator selection = new Selection(new FileScan(s_drivers, f_drivers),
// new Predicate(AttrOperator.GT, AttrType.COLNAME, "age", AttrType.FLOAT, 20F)); new Predicate(AttrOperator.GT, AttrType.COLNAME, "age", AttrType.FLOAT, 20F));
// execute_and_compare("Selection", "selection", selection); execute_and_compare("Selection", "selection", selection);
// } }
//
// @Test @Test
// public void testSelectionMultiplePredicates() { public void testSelectionMultiplePredicates() {
// Iterator selection_preds = new Selection(new FileScan(s_drivers, f_drivers), Iterator selection_preds = new Selection(new FileScan(s_drivers, f_drivers),
// new Predicate(AttrOperator.GT, AttrType.COLNAME, "age", AttrType.FLOAT, 23F), new Predicate(AttrOperator.GT, AttrType.COLNAME, "age", AttrType.FLOAT, 23F),
// new Predicate(AttrOperator.LT, AttrType.COLNAME, "age", AttrType.FLOAT, 19F)); new Predicate(AttrOperator.LT, AttrType.COLNAME, "age", AttrType.FLOAT, 19F));
// execute_and_compare("Selection Multipled Predicates", "selection_preds", selection_preds); execute_and_compare("Selection Multipled Predicates", "selection_preds", selection_preds);
// } }
//
// @Test @Test
// public void testProjection() { public void testProjection() {
// // Projection on Drivers: {FirstName, NumSeats} // Projection on Drivers: {FirstName, NumSeats}
// Iterator projection = new Projection(new FileScan(s_drivers, f_drivers), s_drivers.fieldNumber("FirstName"), Iterator projection = new Projection(new FileScan(s_drivers, f_drivers), s_drivers.fieldNumber("FirstName"),
// s_drivers.fieldNumber("NumSeats")); s_drivers.fieldNumber("NumSeats"));
// execute_and_compare("Projection", "projection", projection); execute_and_compare("Projection", "projection", projection);
// } }
@Test @Test
public void testHashJoin() { public void testHashJoin() {
@ -273,27 +273,27 @@ public class ROTest extends TestDriver {
@Test @Test
public void testSelectionPipelining() { public void testSelectionPipelining() {
// Test all possible Iterator inputs to Selection // Test all possible Iterator inputs to Selection
// Iterator sel_idx = new Selection(new IndexScan(s_drivers, idx_drivers, f_drivers), Iterator sel_idx = new Selection(new IndexScan(s_drivers, idx_drivers, f_drivers),
// new Predicate(AttrOperator.EQ, AttrType.COLNAME, "FirstName", AttrType.STRING, "Walid")); new Predicate(AttrOperator.EQ, AttrType.COLNAME, "FirstName", AttrType.STRING, "Walid"));
// execute_and_compare("Selection - Pipelining IndexScan", "sel_idx", sel_idx); execute_and_compare("Selection - Pipelining IndexScan", "sel_idx", sel_idx);
// Iterator sel_key = new Selection(new KeyScan(s_drivers, idx_drivers, new SearchKey(20F), f_drivers), Iterator sel_key = new Selection(new KeyScan(s_drivers, idx_drivers, new SearchKey(20F), f_drivers),
// new Predicate(AttrOperator.EQ, AttrType.COLNAME, "FirstName", AttrType.STRING, "Walid")); new Predicate(AttrOperator.EQ, AttrType.COLNAME, "FirstName", AttrType.STRING, "Walid"));
// execute_and_compare("Selection - Pipelining Keyscan", "sel_key", sel_key); execute_and_compare("Selection - Pipelining Keyscan", "sel_key", sel_key);
// Iterator sel_sel = new Selection( Iterator sel_sel = new Selection(
// new Selection(new FileScan(s_drivers, f_drivers), new Selection(new FileScan(s_drivers, f_drivers),
// new Predicate(AttrOperator.EQ, AttrType.COLNAME, "Age", AttrType.FLOAT, 20F)), new Predicate(AttrOperator.EQ, AttrType.COLNAME, "Age", AttrType.FLOAT, 20F)),
// new Predicate(AttrOperator.EQ, AttrType.COLNAME, "FirstName", AttrType.STRING, "Walid")); new Predicate(AttrOperator.EQ, AttrType.COLNAME, "FirstName", AttrType.STRING, "Walid"));
// execute_and_compare("Selection - Pipelining Selection", "sel_sel", sel_sel); execute_and_compare("Selection - Pipelining Selection", "sel_sel", sel_sel);
// Iterator sel_proj = new Selection( Iterator sel_proj = new Selection(
// new Projection(new FileScan(s_drivers, f_drivers), s_drivers.fieldNumber("DriverId"), new Projection(new FileScan(s_drivers, f_drivers), s_drivers.fieldNumber("DriverId"),
// s_drivers.fieldNumber("FirstName")), s_drivers.fieldNumber("FirstName")),
// new Predicate(AttrOperator.EQ, AttrType.COLNAME, "FirstName", AttrType.STRING, "Walid")); new Predicate(AttrOperator.EQ, AttrType.COLNAME, "FirstName", AttrType.STRING, "Walid"));
// execute_and_compare("Selection - Pipelining Projection", "sel_proj", sel_proj); execute_and_compare("Selection - Pipelining Projection", "sel_proj", sel_proj);
// Iterator sel_sj = new Selection( Iterator sel_sj = new Selection(
// new SimpleJoin(new FileScan(s_drivers, f_drivers), new FileScan(s_rides, f_rides), new SimpleJoin(new FileScan(s_drivers, f_drivers), new FileScan(s_rides, f_rides),
// new Predicate(AttrOperator.EQ, AttrType.FIELDNO, 0, AttrType.FIELDNO, 5)), new Predicate(AttrOperator.EQ, AttrType.FIELDNO, 0, AttrType.FIELDNO, 5)),
// new Predicate(AttrOperator.EQ, AttrType.COLNAME, "FirstName", AttrType.STRING, "Walid")); new Predicate(AttrOperator.EQ, AttrType.COLNAME, "FirstName", AttrType.STRING, "Walid"));
// execute_and_compare("Selection - Pipelining Simple Join", "sel_sj", sel_sj); execute_and_compare("Selection - Pipelining Simple Join", "sel_sj", sel_sj);
Iterator sel_hj = new Selection( Iterator sel_hj = new Selection(
new HashJoin(new FileScan(s_drivers, f_drivers), new FileScan(s_rides, f_rides), 0, 0), new HashJoin(new FileScan(s_drivers, f_drivers), new FileScan(s_rides, f_rides), 0, 0),
new Predicate(AttrOperator.EQ, AttrType.COLNAME, "FirstName", AttrType.STRING, "Walid")); new Predicate(AttrOperator.EQ, AttrType.COLNAME, "FirstName", AttrType.STRING, "Walid"));
@ -303,26 +303,26 @@ public class ROTest extends TestDriver {
@Test @Test
public void testProjectionPipelining() { public void testProjectionPipelining() {
// Test all possible Iterator inputs to HashJoin // Test all possible Iterator inputs to HashJoin
// Iterator proj_idx = new Projection(new IndexScan(s_drivers, idx_drivers, f_drivers), Iterator proj_idx = new Projection(new IndexScan(s_drivers, idx_drivers, f_drivers),
// s_drivers.fieldNumber("DriverId"), s_drivers.fieldNumber("Age")); s_drivers.fieldNumber("DriverId"), s_drivers.fieldNumber("Age"));
// execute_and_compare("Projection - Pipelining IndexScan", "proj_idx", proj_idx); execute_and_compare("Projection - Pipelining IndexScan", "proj_idx", proj_idx);
// Iterator proj_key = new Projection(new KeyScan(s_drivers, idx_drivers, new SearchKey(20F), f_drivers), Iterator proj_key = new Projection(new KeyScan(s_drivers, idx_drivers, new SearchKey(20F), f_drivers),
// s_drivers.fieldNumber("DriverId"), s_drivers.fieldNumber("Age")); s_drivers.fieldNumber("DriverId"), s_drivers.fieldNumber("Age"));
// execute_and_compare("Projection - Pipelining KeyScan", "proj_key", proj_key); execute_and_compare("Projection - Pipelining KeyScan", "proj_key", proj_key);
// Iterator proj_sel = new Projection( Iterator proj_sel = new Projection(
// new Selection(new FileScan(s_drivers, f_drivers), new Selection(new FileScan(s_drivers, f_drivers),
// new Predicate(AttrOperator.EQ, AttrType.COLNAME, "Age", AttrType.FLOAT, 20F)), new Predicate(AttrOperator.EQ, AttrType.COLNAME, "Age", AttrType.FLOAT, 20F)),
// s_drivers.fieldNumber("DriverId"), s_drivers.fieldNumber("Age")); s_drivers.fieldNumber("DriverId"), s_drivers.fieldNumber("Age"));
// execute_and_compare("Projection - Pipelining Selection", "proj_sel", proj_sel); execute_and_compare("Projection - Pipelining Selection", "proj_sel", proj_sel);
// Iterator proj_proj = new Projection(new Projection(new FileScan(s_drivers, f_drivers), Iterator proj_proj = new Projection(new Projection(new FileScan(s_drivers, f_drivers),
// s_drivers.fieldNumber("DriverId"), s_drivers.fieldNumber("FirstName"), s_drivers.fieldNumber("Age")), 0, s_drivers.fieldNumber("DriverId"), s_drivers.fieldNumber("FirstName"), s_drivers.fieldNumber("Age")), 0,
// 2); 2);
// execute_and_compare("Projection - Pipelining Projection", "proj_proj", proj_proj); execute_and_compare("Projection - Pipelining Projection", "proj_proj", proj_proj);
// Iterator proj_sj = new Projection( Iterator proj_sj = new Projection(
// new SimpleJoin(new FileScan(s_drivers, f_drivers), new FileScan(s_rides, f_rides), new SimpleJoin(new FileScan(s_drivers, f_drivers), new FileScan(s_rides, f_rides),
// new Predicate(AttrOperator.EQ, AttrType.FIELDNO, 0, AttrType.FIELDNO, 5)), new Predicate(AttrOperator.EQ, AttrType.FIELDNO, 0, AttrType.FIELDNO, 5)),
// 0, 3); 0, 3);
// execute_and_compare("Projection - Pipelining Simple Join", "proj_sj", proj_sj); execute_and_compare("Projection - Pipelining Simple Join", "proj_sj", proj_sj);
Iterator proj_hj = new Projection( Iterator proj_hj = new Projection(
new HashJoin(new FileScan(s_drivers, f_drivers), new FileScan(s_rides, f_rides), 0, 0), 0, 3); new HashJoin(new FileScan(s_drivers, f_drivers), new FileScan(s_rides, f_rides), 0, 0), 0, 3);
execute_and_compare("Projection - Pipelining Hash Join", "proj_hj", proj_hj); execute_and_compare("Projection - Pipelining Hash Join", "proj_hj", proj_hj);