From 95160d7f2ccd825888c40c5476b9254823af1d16 Mon Sep 17 00:00:00 2001 From: orbiter Date: Fri, 11 Aug 2006 16:01:18 +0000 Subject: [PATCH] fixed size computation of index elements from the collection index git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2380 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/de/anomic/index/indexCollectionRI.java | 8 ++++++++ source/de/anomic/kelondro/kelondroCollectionIndex.java | 8 ++++++++ source/de/anomic/plasma/plasmaDHTChunk.java | 3 ++- source/de/anomic/plasma/plasmaWordIndex.java | 2 +- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/source/de/anomic/index/indexCollectionRI.java b/source/de/anomic/index/indexCollectionRI.java index e28b6ff9f..96951f073 100644 --- a/source/de/anomic/index/indexCollectionRI.java +++ b/source/de/anomic/index/indexCollectionRI.java @@ -70,6 +70,14 @@ public class indexCollectionRI extends indexAbstractRI implements indexRI { } } + public int indexSize(String wordHash) { + try { + return collectionIndex.indexSize(wordHash.getBytes()); + } catch (IOException e) { + return 0; + } + } + public Iterator wordContainers(String startWordHash, boolean rot) { return new wordContainersIterator(startWordHash, rot); } diff --git a/source/de/anomic/kelondro/kelondroCollectionIndex.java b/source/de/anomic/kelondro/kelondroCollectionIndex.java index 71d1a7595..7aa6185bf 100644 --- a/source/de/anomic/kelondro/kelondroCollectionIndex.java +++ b/source/de/anomic/kelondro/kelondroCollectionIndex.java @@ -305,6 +305,14 @@ public class kelondroCollectionIndex { index.put(indexEntry); } + public int indexSize(byte[] key) throws IOException { + synchronized (index) { + kelondroRow.Entry indexrow = index.get(key); + if (indexrow == null) return 0; + return (int) indexrow.getColLong(idx_col_chunkcount); + } + } + public kelondroRowSet get(byte[] key, boolean deleteIfEmpty) throws IOException { // find an entry, if one exists synchronized (index) { diff --git a/source/de/anomic/plasma/plasmaDHTChunk.java b/source/de/anomic/plasma/plasmaDHTChunk.java index d32357d5f..50c900b79 100644 --- a/source/de/anomic/plasma/plasmaDHTChunk.java +++ b/source/de/anomic/plasma/plasmaDHTChunk.java @@ -288,8 +288,9 @@ public class plasmaDHTChunk { iEntry = (indexEntry) urlIter.next(); urlHashes.add(iEntry.urlHash()); } + String wordHash = indexContainers[i].getWordHash(); count += wordIndex.removeEntries(this.indexContainers[i].getWordHash(), urlHashes, true); - log.logFine("Deleted partial index (" + c + " URLs) for word " + this.indexContainers[i].getWordHash() + "; " + this.wordIndex.indexSize(indexContainers[i].getWordHash()) + " entries left"); + log.logFine("Deleted partial index (" + c + " URLs) for word " + wordHash + "; " + this.wordIndex.indexSize(wordHash) + " entries left"); this.indexContainers[i] = null; } return count; diff --git a/source/de/anomic/plasma/plasmaWordIndex.java b/source/de/anomic/plasma/plasmaWordIndex.java index 197ac0670..e7dddc7ad 100644 --- a/source/de/anomic/plasma/plasmaWordIndex.java +++ b/source/de/anomic/plasma/plasmaWordIndex.java @@ -398,7 +398,7 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI { entity.close(); } } catch (IOException e) {} - if (useCollectionIndex) size += collections.size(); + if (useCollectionIndex) size += collections.indexSize(wordHash); size += assortmentCluster.indexSize(wordHash); size += ramCache.indexSize(wordHash); return size;