Oops. IteratorPool was occasionally creating too many RODIterators in cases where some reference-ordered data was missing. Fixed by better tracking position of RODIterator.

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@857 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
hanna 2009-05-29 21:00:31 +00:00
parent d601548d53
commit 8761ab3aff
1 changed files with 9 additions and 8 deletions

View File

@ -299,7 +299,7 @@ public class ReferenceOrderedData<ROD extends ReferenceOrderedDatum> implements
public class RODIterator implements Iterator<ROD> { public class RODIterator implements Iterator<ROD> {
private PushbackIterator<ROD> it; private PushbackIterator<ROD> it;
private ROD prev = null; private GenomeLoc position = null;
public RODIterator(Iterator<ROD> it) { public RODIterator(Iterator<ROD> it) {
this.it = new PushbackIterator<ROD>(it); this.it = new PushbackIterator<ROD>(it);
@ -307,8 +307,9 @@ public class ReferenceOrderedData<ROD extends ReferenceOrderedDatum> implements
public boolean hasNext() { return it.hasNext(); } public boolean hasNext() { return it.hasNext(); }
public ROD next() { public ROD next() {
prev = it.next(); ROD next = it.next();
return prev; position = next.getLocation().clone();
return next;
} }
/** /**
@ -316,9 +317,7 @@ public class ReferenceOrderedData<ROD extends ReferenceOrderedDatum> implements
* @return Current position of the iterator, or null if no position exists. * @return Current position of the iterator, or null if no position exists.
*/ */
public GenomeLoc position() { public GenomeLoc position() {
if( prev != null ) return position;
return prev.getLocation();
return null;
} }
/** /**
@ -334,7 +333,7 @@ public class ReferenceOrderedData<ROD extends ReferenceOrderedDatum> implements
ROD result = null; ROD result = null;
if ( DEBUG ) System.out.printf(" *** starting seek to %s %d %s%n", loc.getContig(), loc.getStart(), prev); if ( DEBUG ) System.out.printf(" *** starting seek to %s %d%n", loc.getContig(), loc.getStart());
while ( hasNext() ) { while ( hasNext() ) {
ROD current = next(); ROD current = next();
//System.out.printf(" -> Seeking to %s %d AT %s %d%n", contigName, pos, current.getContig(), current.getStart()); //System.out.printf(" -> Seeking to %s %d AT %s %d%n", contigName, pos, current.getContig(), current.getStart());
@ -358,6 +357,8 @@ public class ReferenceOrderedData<ROD extends ReferenceOrderedDatum> implements
System.out.printf(" ### Found %s%n", result.getLocation()); System.out.printf(" ### Found %s%n", result.getLocation());
} }
// make a note that the iterator last seeked to the specified position
position = loc.clone();
// we ran out of elements or found something // we ran out of elements or found something
return result; return result;