Author: orbiter Date: 2008-01-25 12:44:27 +0100 (Fri, 25 Jan 2008) New Revision: 4399
Modified: trunk/htroot/IndexControlURLs_p.java trunk/source/de/anomic/kelondro/kelondroCollectionIndex.java trunk/source/de/anomic/kelondro/kelondroDyn.java trunk/source/de/anomic/kelondro/kelondroEcoFS.java trunk/source/de/anomic/kelondro/kelondroEcoTable.java trunk/source/de/anomic/kelondro/kelondroMapTable.java trunk/source/de/anomic/kelondro/kelondroObjects.java trunk/source/de/anomic/kelondro/kelondroRotateIterator.java trunk/source/de/anomic/plasma/plasmaWordIndex.java trunk/source/de/anomic/yacy/yacyDHTAction.java Log: added termination control for RotateIterator Modified: trunk/htroot/IndexControlURLs_p.java =================================================================== --- trunk/htroot/IndexControlURLs_p.java 2008-01-24 23:58:18 UTC (rev 4398) +++ trunk/htroot/IndexControlURLs_p.java 2008-01-25 11:44:27 UTC (rev 4399) @@ -164,7 +164,7 @@ // generate list if (post.containsKey("urlhashsimilar")) { try { - final Iterator entryIt = new kelondroRotateIterator(sb.wordIndex.loadedURL.entries(true, urlhash), new String(kelondroBase64Order.zero(urlhash.length()))); + final Iterator<indexURLEntry> entryIt = new kelondroRotateIterator<indexURLEntry>(sb.wordIndex.loadedURL.entries(true, urlhash), new String(kelondroBase64Order.zero(urlhash.length())), sb.wordIndex.size()); StringBuffer result = new StringBuffer("Sequential List of URL-Hashes:<br>"); indexURLEntry entry; int i = 0; Modified: trunk/source/de/anomic/kelondro/kelondroCollectionIndex.java =================================================================== --- trunk/source/de/anomic/kelondro/kelondroCollectionIndex.java 2008-01-24 23:58:18 UTC (rev 4398) +++ trunk/source/de/anomic/kelondro/kelondroCollectionIndex.java 2008-01-25 11:44:27 UTC (rev 4399) @@ -1049,7 +1049,7 @@ public keycollectionIterator(byte[] startKey, byte[] secondKey, boolean rot) throws IOException { // iterator of {byte[], kelondroRowSet} Objects kelondroCloneableIterator<kelondroRow.Entry> i = index.rows(true, startKey); - indexRowIterator = (rot) ? new kelondroRotateIterator<kelondroRow.Entry>(i, secondKey) : i; + indexRowIterator = (rot) ? new kelondroRotateIterator<kelondroRow.Entry>(i, secondKey, index.size()) : i; } public boolean hasNext() { Modified: trunk/source/de/anomic/kelondro/kelondroDyn.java =================================================================== --- trunk/source/de/anomic/kelondro/kelondroDyn.java 2008-01-24 23:58:18 UTC (rev 4398) +++ trunk/source/de/anomic/kelondro/kelondroDyn.java 2008-01-25 11:44:27 UTC (rev 4399) @@ -219,7 +219,7 @@ // iterates only the keys of the Nodes // enumerated objects are of type String dynKeyIterator i = new dynKeyIterator(index.rows(up, null)); - if (rotating) return new kelondroRotateIterator<String>(i, null); else return i; + if (rotating) return new kelondroRotateIterator<String>(i, null, index.size()); else return i; } public synchronized dynKeyIterator dynKeys(boolean up, byte[] firstKey) throws IOException { Modified: trunk/source/de/anomic/kelondro/kelondroEcoFS.java =================================================================== --- trunk/source/de/anomic/kelondro/kelondroEcoFS.java 2008-01-24 23:58:18 UTC (rev 4398) +++ trunk/source/de/anomic/kelondro/kelondroEcoFS.java 2008-01-25 11:44:27 UTC (rev 4399) @@ -39,14 +39,14 @@ * The access rules are in such a way that a minimum of IO operations are necessary * Two caches provide a mirror to content in the file: a read cache and a write buffer * The read cache contains a number of entries from the file; a mirror that moves - * whenever information outsite the mirror is requested. + * whenever information outside the mirror is requested. * The write buffer always exists only at the end of the file. It contains only records * that have never been written to the file before. When the write buffer is flushed, * the file grows * The record file may also shrink when the last entry of the file is removed. * Removal of Entries inside the file is not possible, but such entries can be erased * by overwriting the data with zero bytes - * All access to the file is made with byte[] that are generated outsite of this class + * All access to the file is made with byte[] that are generated outside of this class * This class only references byte[] that are handed over to methods of this class. */ Modified: trunk/source/de/anomic/kelondro/kelondroEcoTable.java =================================================================== --- trunk/source/de/anomic/kelondro/kelondroEcoTable.java 2008-01-24 23:58:18 UTC (rev 4398) +++ trunk/source/de/anomic/kelondro/kelondroEcoTable.java 2008-01-25 11:44:27 UTC (rev 4399) @@ -119,7 +119,7 @@ byte[] record = new byte[rowdef.objectsize]; byte[] key = new byte[rowdef.primaryKeyLength]; int fs = (int) file.size(); - System.out.print("*** initializing RAM index for EcoTable " + tablefile + ":"); + System.out.print("*** initializing RAM index for EcoTable " + tablefile.getName() + ":"); for (int i = 0; i < fs; i++) { // read entry file.get(i, record, 0); @@ -325,6 +325,9 @@ public synchronized Entry put(Entry row) throws IOException { assert file.size() == index.size() : "file.size() = " + file.size() + ", index.size() = " + index.size(); assert ((table == null) || (table.size() == index.size())); + assert row != null; + assert row.bytes() != null; + if ((row == null) || (row.bytes() == null)) return null; int i = index.geti(row.getPrimaryKeyBytes()); if (i == -1) { addUnique(row); Modified: trunk/source/de/anomic/kelondro/kelondroMapTable.java =================================================================== --- trunk/source/de/anomic/kelondro/kelondroMapTable.java 2008-01-24 23:58:18 UTC (rev 4398) +++ trunk/source/de/anomic/kelondro/kelondroMapTable.java 2008-01-25 11:44:27 UTC (rev 4399) @@ -147,7 +147,7 @@ kelondroIndex tree = (kelondroIndex) tTables.get(tablename); if (tree == null) throw new RuntimeException("kelondroTables.bytes: tree table '" + tablename + "' does not exist."); kelondroCloneableIterator<kelondroRow.Entry> i = tree.rows(up, firstKey); - if (rotating) return new kelondroRotateIterator<kelondroRow.Entry>(i, secondKey); else return i; + if (rotating) return new kelondroRotateIterator<kelondroRow.Entry>(i, secondKey, tree.size()); else return i; } // if you need the long-values from a row-iteration, please use kelondroRecords.bytes2long to convert from byte[] to long Modified: trunk/source/de/anomic/kelondro/kelondroObjects.java =================================================================== --- trunk/source/de/anomic/kelondro/kelondroObjects.java 2008-01-24 23:58:18 UTC (rev 4398) +++ trunk/source/de/anomic/kelondro/kelondroObjects.java 2008-01-25 11:44:27 UTC (rev 4399) @@ -140,7 +140,7 @@ public synchronized kelondroCloneableIterator<String> keys(final boolean up, final boolean rotating, final byte[] firstKey, final byte[] secondKey) throws IOException { // simple enumeration of key names without special ordering kelondroCloneableIterator<String> i = dyn.dynKeys(up, firstKey); - if (rotating) return new kelondroRotateIterator<String>(i, secondKey); else return i; + if (rotating) return new kelondroRotateIterator<String>(i, secondKey, dyn.sizeDyn()); else return i; } Modified: trunk/source/de/anomic/kelondro/kelondroRotateIterator.java =================================================================== --- trunk/source/de/anomic/kelondro/kelondroRotateIterator.java 2008-01-24 23:58:18 UTC (rev 4398) +++ trunk/source/de/anomic/kelondro/kelondroRotateIterator.java 2008-01-25 11:44:27 UTC (rev 4399) @@ -31,21 +31,23 @@ kelondroCloneableIterator<E> a, clone; Object modifier; boolean nempty; + int terminationCount; - public kelondroRotateIterator(kelondroCloneableIterator<E> a, Object modifier) { + public kelondroRotateIterator(kelondroCloneableIterator<E> a, Object modifier, int terminationCount) { // this works currently only for String-type key iterations this.a = a; this.modifier = modifier; + this.terminationCount = terminationCount; this.clone = (kelondroCloneableIterator<E>) a.clone(modifier); this.nempty = this.clone.hasNext(); } public kelondroRotateIterator<E> clone(Object modifier) { - return new kelondroRotateIterator<E>(a, modifier); + return new kelondroRotateIterator<E>(a, modifier, terminationCount - 1); } public boolean hasNext() { - return this.nempty; + return (terminationCount > 0) && (this.nempty); } public E next() { @@ -56,6 +58,7 @@ a = (kelondroCloneableIterator<E>) clone.clone(modifier); assert a.hasNext(); } + terminationCount--; return a.next(); } Modified: trunk/source/de/anomic/plasma/plasmaWordIndex.java =================================================================== --- trunk/source/de/anomic/plasma/plasmaWordIndex.java 2008-01-24 23:58:18 UTC (rev 4398) +++ trunk/source/de/anomic/plasma/plasmaWordIndex.java 2008-01-25 11:44:27 UTC (rev 4399) @@ -552,7 +552,7 @@ public synchronized kelondroCloneableIterator<indexContainer> wordContainers(String startHash, boolean ram, boolean rot) { kelondroCloneableIterator<indexContainer> i = wordContainers(startHash, ram); if (rot) { - return new kelondroRotateIterator<indexContainer>(i, new String(kelondroBase64Order.zero(startHash.length()))); + return new kelondroRotateIterator<indexContainer>(i, new String(kelondroBase64Order.zero(startHash.length())), dhtOutCache.size() + ((ram) ? 0 : collections.size())); } else { return i; } Modified: trunk/source/de/anomic/yacy/yacyDHTAction.java =================================================================== --- trunk/source/de/anomic/yacy/yacyDHTAction.java 2008-01-24 23:58:18 UTC (rev 4398) +++ trunk/source/de/anomic/yacy/yacyDHTAction.java 2008-01-25 11:44:27 UTC (rev 4399) @@ -278,7 +278,7 @@ public synchronized yacySeed getPublicClusterCrawlSeed(String urlHash, TreeMap<String, String> clusterhashes) { // clusterhashes is a String(hash)/String(IP) - mapping - kelondroCloneableIterator<String> i = new kelondroRotateIterator<String>(new kelondroCloneableMapIterator<String>(clusterhashes, urlHash), null); + kelondroCloneableIterator<String> i = new kelondroRotateIterator<String>(new kelondroCloneableMapIterator<String>(clusterhashes, urlHash), null, clusterhashes.size()); String hash; int count = clusterhashes.size(); // counter to ensure termination while ((i.hasNext()) && (count-- > 0)) { _______________________________________________ YaCy-svn mailing list YaCy-svn@lists.berlios.de https://lists.berlios.de/mailman/listinfo/yacy-svn