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

View File

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

View File

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