- some bugfixing and code cleanup

- now assortments can completely left out if they do not exist
  before startup and collection index is selected.

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2757 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 19 years ago
parent bdf4c7c51e
commit 50f2578c55

@ -281,18 +281,22 @@ public class PerformanceQueues_p {
prop.put("onlineCautionDelayCurrent", System.currentTimeMillis() - switchboard.proxyLastAccess);
int[] asizes = switchboard.wordIndex.assortmentsSizes();
for (int i = 0; i < asizes.length; i += 8) {
prop.put("assortmentCluster_" + (i/8) + "_assortmentSlots", (i + 1) + "-" + (i + 8));
prop.put("assortmentCluster_" + (i/8) + "_assortmentSizeA", asizes[i]);
prop.put("assortmentCluster_" + (i/8) + "_assortmentSizeB", asizes[i + 1]);
prop.put("assortmentCluster_" + (i/8) + "_assortmentSizeC", asizes[i + 2]);
prop.put("assortmentCluster_" + (i/8) + "_assortmentSizeD", asizes[i + 3]);
prop.put("assortmentCluster_" + (i/8) + "_assortmentSizeE", asizes[i + 4]);
prop.put("assortmentCluster_" + (i/8) + "_assortmentSizeF", asizes[i + 5]);
prop.put("assortmentCluster_" + (i/8) + "_assortmentSizeG", asizes[i + 6]);
prop.put("assortmentCluster_" + (i/8) + "_assortmentSizeH", asizes[i + 7]);
if (asizes != null) {
for (int i = 0; i < asizes.length; i += 8) {
prop.put("assortmentCluster_" + (i/8) + "_assortmentSlots", (i + 1) + "-" + (i + 8));
prop.put("assortmentCluster_" + (i/8) + "_assortmentSizeA", asizes[i]);
prop.put("assortmentCluster_" + (i/8) + "_assortmentSizeB", asizes[i + 1]);
prop.put("assortmentCluster_" + (i/8) + "_assortmentSizeC", asizes[i + 2]);
prop.put("assortmentCluster_" + (i/8) + "_assortmentSizeD", asizes[i + 3]);
prop.put("assortmentCluster_" + (i/8) + "_assortmentSizeE", asizes[i + 4]);
prop.put("assortmentCluster_" + (i/8) + "_assortmentSizeF", asizes[i + 5]);
prop.put("assortmentCluster_" + (i/8) + "_assortmentSizeG", asizes[i + 6]);
prop.put("assortmentCluster_" + (i/8) + "_assortmentSizeH", asizes[i + 7]);
}
prop.put("assortmentCluster", asizes.length / 8);
} else {
prop.put("assortmentCluster", 0);
}
prop.put("assortmentCluster", asizes.length / 8);
// table thread pool settings
GenericKeyedObjectPool.Config crawlerPoolConfig = switchboard.cacheLoader.getPoolConfig();

@ -270,7 +270,7 @@ public class kelondroCollectionIndex {
if (oldindexrow == null) {
if ((collection != null) && (collection.size() > 0)) {
// the collection is new
overwrite(key, collection);
overwrite(key, collection, arrayIndex(collection.size()));
}
return 0;
}
@ -286,8 +286,8 @@ public class kelondroCollectionIndex {
if (merge) {
// load the old collection and join it
kelondroRowSet oldcollection = getdelete(oldindexrow, false, false);
kelondroRowSet oldcollection = getwithparams(oldindexrow, oldchunksize, oldchunkcount, oldPartitionNumber, oldrownumber, oldSerialNumber, false, false);
// join with new collection
oldcollection.addAll(collection);
collection = oldcollection;
@ -296,7 +296,7 @@ public class kelondroCollectionIndex {
int removed = 0;
if (removekeys != null) {
// load the old collection and remove keys
kelondroRowSet oldcollection = getdelete(oldindexrow, false, false);
kelondroRowSet oldcollection = getwithparams(oldindexrow, oldchunksize, oldchunkcount, oldPartitionNumber, oldrownumber, oldSerialNumber, false, false);
// remove the keys from the set
Iterator i = removekeys.iterator();
@ -338,7 +338,7 @@ public class kelondroCollectionIndex {
// update the index entry
oldindexrow.setCol(idx_col_chunkcount, collection.size());
oldindexrow.setCol(idx_col_clusteridx, (byte) newPartitionNumber);
oldindexrow.setCol(idx_col_clusteridx, (byte) oldPartitionNumber);
oldindexrow.setCol(idx_col_flags, (byte) 0);
oldindexrow.setCol(idx_col_lastwrote, kelondroRowCollection.daysSince2000(System.currentTimeMillis()));
index.put(oldindexrow);
@ -351,19 +351,18 @@ public class kelondroCollectionIndex {
array.remove(oldrownumber);
// write a new entry in the other array
overwrite(key, collection);
overwrite(key, collection, newPartitionNumber);
}
return removed;
}
}
private void overwrite(byte[] key, kelondroRowCollection collection) throws IOException {
private void overwrite(byte[] key, kelondroRowCollection collection, int targetpartition) throws IOException {
// helper method, should not be called directly and only within a synchronized(index) environment
// simply store a collection without check if the collection existed before
// find array file
int clusteridx = arrayIndex(collection.size());
kelondroFixedWidthArray array = getArray(clusteridx, 0, this.playloadrow.objectsize());
kelondroFixedWidthArray array = getArray(targetpartition, 0, this.playloadrow.objectsize());
// define row
kelondroRow.Entry arrayEntry = array.row().newEntry();
@ -378,7 +377,7 @@ public class kelondroCollectionIndex {
indexEntry.setCol(idx_col_key, key);
indexEntry.setCol(idx_col_chunksize, this.playloadrow.objectsize());
indexEntry.setCol(idx_col_chunkcount, collection.size());
indexEntry.setCol(idx_col_clusteridx, (byte) clusteridx);
indexEntry.setCol(idx_col_clusteridx, (byte) targetpartition);
indexEntry.setCol(idx_col_flags, (byte) 0);
indexEntry.setCol(idx_col_indexpos, (long) newRowNumber);
indexEntry.setCol(idx_col_lastread, kelondroRowCollection.daysSince2000(System.currentTimeMillis()));
@ -413,7 +412,7 @@ public class kelondroCollectionIndex {
return removedCollection;
}
}
protected kelondroRowSet getdelete(kelondroRow.Entry indexrow, boolean remove, boolean deleteIfEmpty) throws IOException {
// call this only within a synchronized(index) environment
@ -425,10 +424,14 @@ public class kelondroCollectionIndex {
assert(partitionnumber >= arrayIndex(chunkcount));
int serialnumber = 0;
return getwithparams(indexrow, chunksize, chunkcount, partitionnumber, rownumber, serialnumber, remove, deleteIfEmpty);
}
private kelondroRowSet getwithparams(kelondroRow.Entry indexrow, int chunksize, int chunkcount, int clusteridx, int rownumber, int serialnumber, boolean remove, boolean deleteIfEmpty) throws IOException {
// open array entry
kelondroFixedWidthArray array = getArray(partitionnumber, serialnumber, chunksize);
kelondroFixedWidthArray array = getArray(clusteridx, serialnumber, chunksize);
kelondroRow.Entry arrayrow = array.get(rownumber);
if (arrayrow == null) throw new kelondroException(arrayFile(this.path, this.filenameStub, this.loadfactor, chunksize, partitionnumber, serialnumber).toString(), "array does not contain expected row");
if (arrayrow == null) throw new kelondroException(arrayFile(this.path, this.filenameStub, this.loadfactor, chunksize, clusteridx, serialnumber).toString(), "array does not contain expected row");
// read the row and define a collection
kelondroRowSet collection = new kelondroRowSet(this.playloadrow, arrayrow.getColBytes(1)); // FIXME: this does not yet work with different rowdef in case of several rowdef.objectsize()
@ -440,7 +443,7 @@ public class kelondroCollectionIndex {
indexEntry.setCol(idx_col_key, arrayrow.getColBytes(0));
indexEntry.setCol(idx_col_chunksize, this.playloadrow.objectsize());
indexEntry.setCol(idx_col_chunkcount, collection.size());
indexEntry.setCol(idx_col_clusteridx, (byte) partitionnumber);
indexEntry.setCol(idx_col_clusteridx, (byte) clusteridx);
indexEntry.setCol(idx_col_flags, (byte) 0);
indexEntry.setCol(idx_col_indexpos, (long) rownumber);
indexEntry.setCol(idx_col_lastread, kelondroRowCollection.daysSince2000(System.currentTimeMillis()));
@ -453,14 +456,12 @@ public class kelondroCollectionIndex {
// fix the entry in index
indexrow.setCol(idx_col_chunkcount, chunkcountInArray);
index.put(indexrow);
array.logFailure("INCONSISTENCY in " + arrayFile(this.path, this.filenameStub, this.loadfactor, chunksize, partitionnumber, serialnumber).toString() + ": array has different chunkcount than index: index = " + chunkcount + ", array = " + chunkcountInArray + "; the index has been auto-fixed");
array.logFailure("INCONSISTENCY in " + arrayFile(this.path, this.filenameStub, this.loadfactor, chunksize, clusteridx, serialnumber).toString() + ": array has different chunkcount than index: index = " + chunkcount + ", array = " + chunkcountInArray + "; the index has been auto-fixed");
}
if ((remove) || ((chunkcountInArray == 0) && (deleteIfEmpty))) array.remove(rownumber);
if ((remove) || ((collection.size() == 0) && (deleteIfEmpty))) array.remove(rownumber);
return collection;
}
public Iterator keycollections(byte[] startKey, boolean rot) {
// returns an iteration of {byte[], kelondroRowSet} Objects
try {

@ -78,14 +78,14 @@ public class kelondroMergeIterator implements Iterator {
private void nexta() {
try {
if (a.hasNext()) na = a.next(); else na = null;
if ((a != null) && (a.hasNext())) na = a.next(); else na = null;
} catch (ConcurrentModificationException e) {
na = null;
}
}
private void nextb() {
try {
if (b.hasNext()) nb = b.next(); else nb = null;
if ((b != null) && (b.hasNext())) nb = b.next(); else nb = null;
} catch (ConcurrentModificationException e) {
nb = null;
}

@ -1,3 +1,29 @@
// plasmaCrawlLURLEntry.java
// (C) 2006 by Michael Peter Christen; mc@anomic.de, Frankfurt a. M., Germany
// first published 13.10.2006 on http://www.anomic.de
//
// This is a part of YaCy, a peer-to-peer based web search engine
//
// $LastChangedDate: 2006-04-02 22:40:07 +0200 (So, 02 Apr 2006) $
// $LastChangedRevision: 1986 $
// $LastChangedBy: orbiter $
//
// LICENSE
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package de.anomic.plasma;
import java.io.IOException;

@ -1,3 +1,29 @@
// plasmaCrawlLURLOldEntry.java
// (C) 2006 by Michael Peter Christen; mc@anomic.de, Frankfurt a. M., Germany
// first published 13.10.2006 on http://www.anomic.de
//
// This is a part of YaCy, a peer-to-peer based web search engine
//
// $LastChangedDate: 2006-04-02 22:40:07 +0200 (So, 02 Apr 2006) $
// $LastChangedRevision: 1986 $
// $LastChangedBy: orbiter $
//
// LICENSE
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package de.anomic.plasma;
import java.io.IOException;

@ -1,14 +1,15 @@
// plasmaWordIndex.java
// -----------------------
// part of YACY
// (C) by Michael Peter Christen; mc@anomic.de
// first published on http://www.anomic.de
// Frankfurt, Germany, 2005
// (C) 2005, 2006 by Michael Peter Christen; mc@anomic.de, Frankfurt a. M., Germany
// first published 2005 on http://www.anomic.de
//
// This is a part of YaCy, a peer-to-peer based web search engine
//
// $LastChangedDate$
// $LastChangedRevision$
// $LastChangedBy$
//
// LICENSE
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
@ -22,28 +23,6 @@
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Using this software in any meaning (reading, learning, copying, compiling,
// running) means that you agree that the Author(s) is (are) not responsible
// for cost, loss of data or any harm that may be caused directly or indirectly
// by usage of this softare or this documentation. The usage of this software
// is on your own risk. The installation and usage (starting/running) of this
// software may allow other people or application to access your computer and
// any attached devices and is highly dependent on the configuration of the
// software which must be done by the user of the software; the author(s) is
// (are) also not responsible for proper configuration and usage of the
// software, even if provoked by documentation provided together with
// the software.
//
// Any changes to this file according to the GPL as documented in the file
// gpl.txt aside this file in the shipment you received can be done to the
// lines that follows this copyright notice here, but changes must not be
// done inside the copyright notive above. A re-distribution must contain
// the intact and unchanged copyright notice.
// Contributions and changes to the program code must be marked as such.
// compile with
// javac -classpath classes -sourcepath source -d classes -g source/de/anomic/plasma/*.java
package de.anomic.plasma;
@ -101,16 +80,21 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI {
// create assortment cluster path
File assortmentClusterPath = new File(oldDatabaseRoot, indexAssortmentClusterPath);
if (!(assortmentClusterPath.exists())) assortmentClusterPath.mkdirs();
this.assortmentBufferSize = bufferkb;
this.assortmentCluster = new plasmaWordIndexAssortmentCluster(assortmentClusterPath, assortmentCount, assortmentBufferSize, preloadTime, log);
// create collections storage path
if (!(newIndexRoot.exists())) newIndexRoot.mkdirs();
if (useCollectionIndex)
collections = new indexCollectionRI(newIndexRoot, "test_generation1", bufferkb * 1024, preloadTime);
else
collections = null;
if (useCollectionIndex) {
this.collections = new indexCollectionRI(newIndexRoot, "test_generation1", bufferkb * 1024, preloadTime);
if (assortmentClusterPath.exists())
this.assortmentCluster = new plasmaWordIndexAssortmentCluster(assortmentClusterPath, assortmentCount, assortmentBufferSize, preloadTime, log);
else
this.assortmentCluster = null;
} else {
this.collections = null;
if (!(assortmentClusterPath.exists())) assortmentClusterPath.mkdirs();
this.assortmentCluster = new plasmaWordIndexAssortmentCluster(assortmentClusterPath, assortmentCount, assortmentBufferSize, preloadTime, log);
}
busyCacheFlush = false;
this.useCollectionIndex = useCollectionIndex;
@ -155,23 +139,23 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI {
}
public int[] assortmentsSizes() {
return assortmentCluster.sizes();
return (assortmentCluster == null) ? null : assortmentCluster.sizes();
}
public int assortmentsCacheChunkSizeAvg() {
return assortmentCluster.cacheChunkSizeAvg();
return (assortmentCluster == null) ? 0 : assortmentCluster.cacheChunkSizeAvg();
}
public int assortmentsCacheObjectSizeAvg() {
return assortmentCluster.cacheObjectSizeAvg();
return (assortmentCluster == null) ? 0 : assortmentCluster.cacheObjectSizeAvg();
}
public int[] assortmentsCacheNodeStatus() {
return assortmentCluster.cacheNodeStatus();
return (assortmentCluster == null) ? null : assortmentCluster.cacheNodeStatus();
}
public long[] assortmentsCacheObjectStatus() {
return assortmentCluster.cacheObjectStatus();
return (assortmentCluster == null) ? null : assortmentCluster.cacheObjectStatus();
}
public void setMaxWordCount(int maxWords) {
@ -376,13 +360,15 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI {
}
// get from assortments
if (container == null) {
container = assortmentCluster.getContainer(wordHash, urlselection, true, (maxTime < 0) ? -1 : maxTime);
} else {
// add containers from assortment cluster
container.add(assortmentCluster.getContainer(wordHash, urlselection, true, (maxTime < 0) ? -1 : maxTime), -1);
if (assortmentCluster != null) {
if (container == null) {
container = assortmentCluster.getContainer(wordHash, urlselection, true, (maxTime < 0) ? -1 : maxTime);
} else {
// add containers from assortment cluster
container.add(assortmentCluster.getContainer(wordHash, urlselection, true, (maxTime < 0) ? -1 : maxTime), -1);
}
}
// get from backend
if (maxTime > 0) {
maxTime = maxTime - (System.currentTimeMillis() - start);
@ -425,11 +411,11 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI {
public int size() {
if (useCollectionIndex)
return java.lang.Math.max(collections.size(),
java.lang.Math.max(assortmentCluster.size(),
java.lang.Math.max((assortmentCluster == null) ? 0 : assortmentCluster.size(),
java.lang.Math.max(backend.size(),
java.lang.Math.max(dhtInCache.size(), dhtOutCache.size()))));
else
return java.lang.Math.max(assortmentCluster.size(),
return java.lang.Math.max((assortmentCluster == null) ? 0 : assortmentCluster.size(),
java.lang.Math.max(backend.size(),
java.lang.Math.max(dhtInCache.size(), dhtOutCache.size())));
}
@ -444,7 +430,7 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI {
}
} catch (IOException e) {}
if (useCollectionIndex) size += collections.indexSize(wordHash);
size += assortmentCluster.indexSize(wordHash);
size += (assortmentCluster == null) ? 0 : assortmentCluster.indexSize(wordHash);
size += dhtInCache.indexSize(wordHash);
size += dhtOutCache.indexSize(wordHash);
return size;
@ -455,7 +441,7 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI {
dhtInCache.close(waitingBoundSeconds);
dhtOutCache.close(waitingBoundSeconds);
if (useCollectionIndex) collections.close(-1);
assortmentCluster.close(-1);
if (assortmentCluster != null) assortmentCluster.close(-1);
backend.close(10);
}
}
@ -465,7 +451,7 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI {
c.add(dhtInCache.deleteContainer(wordHash), -1);
c.add(dhtOutCache.deleteContainer(wordHash), -1);
if (useCollectionIndex) c.add(collections.deleteContainer(wordHash), -1);
c.add(assortmentCluster.deleteContainer(wordHash), -1);
if (assortmentCluster != null) c.add(assortmentCluster.deleteContainer(wordHash), -1);
c.add(backend.deleteContainer(wordHash), -1);
return c;
}
@ -475,7 +461,7 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI {
removed = removed | (dhtInCache.removeEntry(wordHash, urlHash, deleteComplete));
removed = removed | (dhtOutCache.removeEntry(wordHash, urlHash, deleteComplete));
if (useCollectionIndex) {removed = removed | (collections.removeEntry(wordHash, urlHash, deleteComplete));}
removed = removed | (assortmentCluster.removeEntry(wordHash, urlHash, deleteComplete));
if (assortmentCluster != null) removed = removed | (assortmentCluster.removeEntry(wordHash, urlHash, deleteComplete));
removed = removed | backend.removeEntry(wordHash, urlHash, deleteComplete);
return removed;
}
@ -489,7 +475,7 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI {
removed += collections.removeEntries(wordHash, urlHashes, deleteComplete);
//if (removed == urlHashes.size()) return removed;
}
removed += assortmentCluster.removeEntries(wordHash, urlHashes, deleteComplete);
if (assortmentCluster != null) removed += assortmentCluster.removeEntries(wordHash, urlHashes, deleteComplete);
//if (removed == urlHashes.size()) return removed;
removed += backend.removeEntries(wordHash, urlHashes, deleteComplete);
return removed;
@ -502,7 +488,7 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI {
if (useCollectionIndex) {
removed += collections.removeEntries(wordHash, urlHashes, deleteComplete) + ", ";
} else removed += "0, ";
removed += assortmentCluster.removeEntries(wordHash, urlHashes, deleteComplete) + ", ";
if (assortmentCluster != null) removed += assortmentCluster.removeEntries(wordHash, urlHashes, deleteComplete) + ", ";
removed += backend.removeEntries(wordHash, urlHashes, deleteComplete);
return removed;
}
@ -574,14 +560,14 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI {
new indexContainerOrder(kelondroNaturalOrder.naturalOrder),
indexContainer.containerMergeMethod,
true),
assortmentCluster.wordContainers(startWordHash, true, false),
(assortmentCluster == null) ? null : assortmentCluster.wordContainers(startWordHash, true, false),
new indexContainerOrder(kelondroNaturalOrder.naturalOrder),
indexContainer.containerMergeMethod,
true);
} else {
return new kelondroMergeIterator(
dhtOutCache.wordContainers(startWordHash, false),
assortmentCluster.wordContainers(startWordHash, true, false),
(assortmentCluster == null) ? null : assortmentCluster.wordContainers(startWordHash, true, false),
new indexContainerOrder(kelondroNaturalOrder.naturalOrder),
indexContainer.containerMergeMethod,
true);
@ -597,7 +583,7 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI {
new indexContainerOrder(kelondroNaturalOrder.naturalOrder),
indexContainer.containerMergeMethod,
true),
assortmentCluster.wordContainers(startWordHash, true, false),
(assortmentCluster == null) ? null : assortmentCluster.wordContainers(startWordHash, true, false),
new indexContainerOrder(kelondroNaturalOrder.naturalOrder),
indexContainer.containerMergeMethod,
true),
@ -609,7 +595,7 @@ public final class plasmaWordIndex extends indexAbstractRI implements indexRI {
return new kelondroMergeIterator(
new kelondroMergeIterator(
dhtOutCache.wordContainers(startWordHash, false),
assortmentCluster.wordContainers(startWordHash, true, false),
(assortmentCluster == null) ? null : assortmentCluster.wordContainers(startWordHash, true, false),
new indexContainerOrder(kelondroNaturalOrder.naturalOrder),
indexContainer.containerMergeMethod,
true),

Loading…
Cancel
Save