From: <bra...@us...> - 2007-11-28 00:57:46
|
Revision: 2080 http://archive-access.svn.sourceforge.net/archive-access/?rev=2080&view=rev Author: bradtofel Date: 2007-11-27 16:57:47 -0800 (Tue, 27 Nov 2007) Log Message: ----------- UNDO: backed out useless changes for DurableArchiveRecordIterator.. Changes need to be made down in ARCReader -- it does not indicate the end of the record begun when a problem is encountered. Modified Paths: -------------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourcestore/ArcIndexer.java Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourcestore/ArcIndexer.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourcestore/ArcIndexer.java 2007-11-28 00:43:02 UTC (rev 2079) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourcestore/ArcIndexer.java 2007-11-28 00:57:47 UTC (rev 2080) @@ -28,7 +28,6 @@ import java.io.PrintWriter; import java.io.IOException; import java.util.Iterator; -import java.util.NoSuchElementException; import org.archive.io.ArchiveRecord; import org.archive.io.arc.ARCReader; @@ -61,8 +60,8 @@ */ public CloseableIterator<SearchResult> iterator(File arc) throws IOException { -// ARCReader arcReader = ARCReaderFactory.get(arc); -// arcReader.setParseHttpHeaders(true); + ARCReader arcReader = ARCReaderFactory.get(arc); + arcReader.setParseHttpHeaders(true); Adapter<ArchiveRecord,ARCRecord> adapter1 = new ArchiveRecordToARCRecordAdapter(); @@ -70,7 +69,7 @@ Adapter<ARCRecord,SearchResult> adapter2 = new ARCRecordToSearchResultAdapter(); - Iterator<ArchiveRecord> itr1 = new DurableArchiveRecordIterator(arc); + Iterator<ArchiveRecord> itr1 = arcReader.iterator(); CloseableIterator<ARCRecord> itr2 = new AdaptedIterator<ArchiveRecord,ARCRecord>(itr1,adapter1); @@ -94,86 +93,86 @@ } } - private class DurableArchiveRecordIterator - implements Iterator<ArchiveRecord> { +// private class DurableArchiveRecordIterator +// implements Iterator<ArchiveRecord> { +// +// private long lastRestart = 0; +// private File arc = null; +// Iterator<ArchiveRecord> innerItr = null; +// ArchiveRecord cachedNext = null; +// +// public DurableArchiveRecordIterator(File arc) throws IOException { +// this.arc = arc; +// restart(0); +// } +// +// private void restart(long offset) throws IOException { +// ARCReader arcReader = ARCReaderFactory.get(arc,offset); +// arcReader.setParseHttpHeaders(true); +// innerItr = arcReader.iterator(); +// } +// +// private long parseErrorOffset(String message) { +// long found = -1; +// int idx = message.indexOf("Offset "); +// if(idx >= 0) { +// int idx2 = message.indexOf(")"); +// if(idx2 > 0) { +// String part = message.substring(idx + 7,idx2); +// System.err.println("Found(" + part +") from (" + message + ")"); +// found = Long.parseLong(part) + 100; +// } +// } +// return found; +// } +// +// public boolean hasNext() { +// if(cachedNext != null) { +// return true; +// } +// while(true) { +// try { +// if(!innerItr.hasNext()) { +// return false; +// } +// cachedNext = innerItr.next(); +// } catch (RuntimeException e) { +// long offset = parseErrorOffset(e.getMessage()); +// if(offset > 0) { +// if(lastRestart == offset) { +// return false; +// } +// lastRestart = offset; +// try { +// restart(offset); +// } catch (IOException e1) { +// throw new RuntimeException(e1); +// } +// } else { +// throw e; +// } +// } +// if(cachedNext != null) { +// break; +// } +// } +// return true; +// } +// +// public ArchiveRecord next() { +// if(cachedNext == null) { +// throw new NoSuchElementException("next() without hasNext()"); +// } +// ArchiveRecord tmp = cachedNext; +// cachedNext = null; +// return tmp; +// } +// +// public void remove() { +// throw new UnsupportedOperationException("remove unimplemented"); +// } +// } - private long lastRestart = 0; - private File arc = null; - Iterator<ArchiveRecord> innerItr = null; - ArchiveRecord cachedNext = null; - - public DurableArchiveRecordIterator(File arc) throws IOException { - this.arc = arc; - restart(0); - } - - private void restart(long offset) throws IOException { - ARCReader arcReader = ARCReaderFactory.get(arc,offset); - arcReader.setParseHttpHeaders(true); - innerItr = arcReader.iterator(); - } - - private long parseErrorOffset(String message) { - long found = -1; - int idx = message.indexOf("Offset "); - if(idx >= 0) { - int idx2 = message.indexOf(")"); - if(idx2 > 0) { - String part = message.substring(idx + 7,idx2); - System.err.println("Found(" + part +") from (" + message + ")"); - found = Long.parseLong(part) + 100; - } - } - return found; - } - - public boolean hasNext() { - if(cachedNext != null) { - return true; - } - while(true) { - try { - if(!innerItr.hasNext()) { - return false; - } - cachedNext = innerItr.next(); - } catch (RuntimeException e) { - long offset = parseErrorOffset(e.getMessage()); - if(offset > 0) { - if(lastRestart == offset) { - return false; - } - lastRestart = offset; - try { - restart(offset); - } catch (IOException e1) { - throw new RuntimeException(e1); - } - } else { - throw e; - } - } - if(cachedNext != null) { - break; - } - } - return true; - } - - public ArchiveRecord next() { - if(cachedNext == null) { - throw new NoSuchElementException("next() without hasNext()"); - } - ArchiveRecord tmp = cachedNext; - cachedNext = null; - return tmp; - } - - public void remove() { - throw new UnsupportedOperationException("remove unimplemented"); - } - } - private static void USAGE() { System.err.println("USAGE:"); System.err.println(""); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |