* disabled new kelondroFlex table for NURLs

* added new RAM index Class
* fixed possible synchronization problem in kelondroRecords


git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2388 6c8d7289-2bf4-0310-a012-ef5d649a1542
This commit is contained in:
orbiter 2006-08-12 00:58:43 +00:00
parent 689bbcf9cd
commit 9ae9062bd3
5 changed files with 88 additions and 9 deletions

View File

@ -81,9 +81,6 @@ public class kelondroCollectionIndex {
return new File(path, filenameStub + "." + lf + "." + cs + ".properties"); // kelondro collection array
}
/*
*/
public kelondroCollectionIndex(File path, String filenameStub, int keyLength, kelondroOrder indexOrder,
long buffersize, long preloadTime,
int loadfactor, kelondroRow rowdef) throws IOException {

View File

@ -130,8 +130,10 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr
public synchronized kelondroRow.Entry get(byte[] key) throws IOException {
synchronized (index) {
int i = index.geti(key);
if (i >= this.size()) System.out.println("error");
if (i < 0) return null;
// i may be greater than this.size(), because this table may have deleted entries
// the deleted entries are subtracted from the 'real' tablesize, so the size may be
// smaller than an index to a row entry
return super.get(i);
}
}

View File

@ -0,0 +1,78 @@
// kelondroRAMIndex.java
// (C) 2006 by Michael Peter Christen; mc@anomic.de, Frankfurt a. M., Germany
// first published 12.08.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.kelondro;
import java.util.Iterator;
import java.util.TreeMap;
import de.anomic.kelondro.kelondroRow.Entry;
public class kelondroRAMIndex implements kelondroIndex {
private TreeMap index;
private kelondroOrder order;
private kelondroRow rowdef;
public kelondroRAMIndex(kelondroOrder defaultOrder, kelondroRow rowdef) {
this.index = new TreeMap(defaultOrder);
this.order = defaultOrder;
this.rowdef = rowdef;
}
public kelondroOrder order() {
return this.order;
}
public int size() {
return this.index.size();
}
public kelondroRow row() {
return this.rowdef;
}
public Entry get(byte[] key) {
return (kelondroRow.Entry) index.get(key);
}
public Entry put(Entry row) {
return (kelondroRow.Entry) index.put(row.getColBytes(0), row);
}
public Entry remove(byte[] key) {
return (kelondroRow.Entry) index.remove(key);
}
public Iterator rows(boolean up, boolean rotating, byte[] firstKey) {
return index.values().iterator();
}
public void close() {
index = null;
}
}

View File

@ -536,9 +536,11 @@ public class kelondroRecords {
synchronized (cacheHeaders) {
cacheHeaders.removeb(handle.index);
cacheDelete++;
dispose(handle);
}
} else {
dispose(handle);
}
dispose(handle);
}
public final class Node {
@ -740,7 +742,7 @@ public class kelondroRecords {
public byte[] setValueRow(byte[] row) throws IOException {
// if the index is defined, then write values directly to the file, else only to the object
assert row.length == ROW.objectsize();
if (row.length != ROW.objectsize()) throw new IOException("setValueRow with wrong (" + row.length + ") row length instead correct: " + ROW.objectsize());
byte[] result = getValueRow(); // previous value (this loads the values if not already happened)
// set values

View File

@ -167,14 +167,14 @@ public class plasmaCrawlNURL extends indexURL {
private void openHashCache() {
File oldCacheFile = new File(cacheStacksPath, "urlNotice1.db");
File newCacheFile = new File(cacheStacksPath, "urlNotice2.table");
if (newCacheFile.exists()) try {
//File newCacheFile = new File(cacheStacksPath, "urlNotice2.table");
/*if (newCacheFile.exists()) try {
urlHashCache = new kelondroFlexTable(cacheStacksPath, "urlNotice2.table", kelondroBase64Order.enhancedCoder, bufferkb * 0x400, preloadTime, rowdef, true);
} catch (IOException e) {
e.printStackTrace();
oldCacheFile.delete();
urlHashCache = new kelondroTree(oldCacheFile, bufferkb * 0x400, preloadTime, kelondroTree.defaultObjectCachePercent, rowdef, true);
} else if (oldCacheFile.exists()) try {
} else*/ if (oldCacheFile.exists()) try {
// open existing cache
kelondroTree tree = new kelondroTree(oldCacheFile, bufferkb * 0x400, preloadTime, kelondroTree.defaultObjectCachePercent);
tree.assignRowdef(rowdef);