Commit partial work

This commit is contained in:
Max O'Cull 2019-03-28 02:06:17 -04:00
parent c076533a19
commit 732977b4fa
3 changed files with 28 additions and 12 deletions

BIN
p3/max.minibase Normal file

Binary file not shown.

View File

@ -9,7 +9,6 @@ import heap.HeapScan;
* version takes schema into consideration and generates real tuples. * version takes schema into consideration and generates real tuples.
*/ */
public class FileScan extends Iterator { public class FileScan extends Iterator {
private HeapFile file = null; // needed for restart(), getFile(); private HeapFile file = null; // needed for restart(), getFile();
private HeapScan scan = null; private HeapScan scan = null;
private RID rid = null; private RID rid = null;
@ -70,7 +69,7 @@ public class FileScan extends Iterator {
/** /**
* Gets the next tuple in the iteration. * Gets the next tuple in the iteration.
* *
* @throws IllegalStateException if no more tuples * @throws IllegalStateException if no more tuples
*/ */
public Tuple getNext() { public Tuple getNext() {
@ -83,7 +82,7 @@ public class FileScan extends Iterator {
public RID getLastRID() { public RID getLastRID() {
return rid; return rid;
} }
// getter; added so HashJoin doesn't have to copy the file; // getter; added so HashJoin doesn't have to copy the file;
public HeapFile getFile(){ public HeapFile getFile(){
return file; return file;

View File

@ -9,12 +9,22 @@ import index.HashScan;
* Wrapper for hash scan, an index access method. * Wrapper for hash scan, an index access method.
*/ */
public class KeyScan extends Iterator { public class KeyScan extends Iterator {
private HeapFile file = null; // needed for restart(), getFile();
private HashScan scan = null;
private HashIndex index = null;
private SearchKey key = null;
private boolean isOpen;
/** /**
* 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) {
throw new UnsupportedOperationException("Not implemented"); this.schema = aSchema;
this.index = aIndex;
this.key = aKey;
this.file = aFile;
this.scan = this.index.openScan(this.key);
this.isOpen = true;
} }
/** /**
@ -22,44 +32,51 @@ public class KeyScan extends Iterator {
* child iterators, and increases the indent depth along the way. * child iterators, and increases the indent depth along the way.
*/ */
public void explain(int depth) { public void explain(int depth) {
throw new UnsupportedOperationException("Not implemented"); throw new UnsupportedOperationException("Not implemented");
} }
/** /**
* 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() {
throw new UnsupportedOperationException("Not implemented"); this.isOpen = false; // In case of errors maybe?
this.close();
this.scan = this.index.openScan(this.key);
this.isOpen = true;
} }
/** /**
* Returns true if the iterator is open; false otherwise. * Returns true if the iterator is open; false otherwise.
*/ */
public boolean isOpen() { public boolean isOpen() {
throw new UnsupportedOperationException("Not implemented"); return this.isOpen;
} }
/** /**
* 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() {
throw new UnsupportedOperationException("Not implemented"); if (this.isOpen()) {
this.scan.close();
this.scan = null;
this.isOpen = false;
}
} }
/** /**
* Returns true if there are more tuples, false otherwise. * Returns true if there are more tuples, false otherwise.
*/ */
public boolean hasNext() { public boolean hasNext() {
throw new UnsupportedOperationException("Not implemented"); throw new UnsupportedOperationException("Not implemented");
} }
/** /**
* Gets the next tuple in the iteration. * Gets the next tuple in the iteration.
* *
* @throws IllegalStateException if no more tuples * @throws IllegalStateException if no more tuples
*/ */
public Tuple getNext() { public Tuple getNext() {
throw new UnsupportedOperationException("Not implemented"); throw new UnsupportedOperationException("Not implemented");
} }
} // public class KeyScan extends Iterator } // public class KeyScan extends Iterator