mirror of
https://github.com/yacy/yacy_search_server.git
synced 2024-09-19 00:01:41 +02:00
correct R/W head positioning in kelondroFlex
and some enhancements git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3409 6c8d7289-2bf4-0310-a012-ef5d649a1542
This commit is contained in:
parent
116fc016d0
commit
1fda50fd3c
|
@ -40,6 +40,8 @@ import de.anomic.kelondro.kelondroRow;
|
|||
import de.anomic.server.logging.serverLog;
|
||||
|
||||
public class indexCachedRI implements indexRI {
|
||||
|
||||
private static final int flushsize = 1000;
|
||||
|
||||
private kelondroRow payloadrow;
|
||||
private kelondroOrder indexOrder;
|
||||
|
@ -76,10 +78,10 @@ public class indexCachedRI implements indexRI {
|
|||
// check for forced flush
|
||||
synchronized (this) {
|
||||
if (riExtern.size() > riExtern.getMaxWordCount()) {
|
||||
flushCache(riExtern, riExtern.size() + 500 - riExtern.getMaxWordCount());
|
||||
flushCache(riExtern, riExtern.size() + flushsize - riExtern.getMaxWordCount());
|
||||
}
|
||||
if (riIntern.size() > riIntern.getMaxWordCount()) {
|
||||
flushCache(riIntern, riIntern.size() + 500 - riIntern.getMaxWordCount());
|
||||
flushCache(riIntern, riIntern.size() + flushsize - riIntern.getMaxWordCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ import java.io.IOException;
|
|||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import de.anomic.server.logging.serverLog;
|
||||
|
@ -201,13 +200,7 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr
|
|||
ordered.put(new Integer(pos), row);
|
||||
}
|
||||
}
|
||||
i = ordered.entrySet().iterator();
|
||||
Map.Entry entry;
|
||||
while (i.hasNext()) {
|
||||
entry = (Map.Entry) i.next();
|
||||
pos = ((Integer) entry.getKey()).intValue();
|
||||
super.set(pos, (kelondroRow.Entry) entry.getValue());
|
||||
}
|
||||
super.setMultiple(ordered);
|
||||
}
|
||||
|
||||
public synchronized kelondroRow.Entry put(kelondroRow.Entry row, Date entryDate) throws IOException {
|
||||
|
|
|
@ -28,7 +28,9 @@ package de.anomic.kelondro;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import de.anomic.server.serverFileUtils;
|
||||
|
||||
|
@ -182,6 +184,34 @@ public class kelondroFlexWidthArray implements kelondroArray {
|
|||
return col[0].size();
|
||||
}
|
||||
|
||||
public void setMultiple(TreeMap /*of {Integer, kelondroRow.Entry}*/ entries) throws IOException {
|
||||
// a R/W head path-optimized option to write a set of entries
|
||||
Iterator i;
|
||||
Map.Entry entry;
|
||||
kelondroRow.Entry rowentry, e0;
|
||||
int c = 0, index, lastcol;
|
||||
synchronized (col) {
|
||||
// go across each file
|
||||
while (c < rowdef.columns()) {
|
||||
i = entries.entrySet().iterator();
|
||||
lastcol = c + col[c].row().columns() - 1;
|
||||
while (i.hasNext()) {
|
||||
entry = (Map.Entry) i.next();
|
||||
index = ((Integer) entry.getKey()).intValue();
|
||||
rowentry = (kelondroRow.Entry) entry.getValue();
|
||||
assert rowentry.bytes().length == this.rowdef.objectsize;
|
||||
|
||||
e0 = col[c].row().newEntry(
|
||||
rowentry.bytes(),
|
||||
rowdef.colstart[c],
|
||||
rowdef.colstart[lastcol] - rowdef.colstart[c] + rowdef.width(lastcol));
|
||||
col[c].set(index, e0);
|
||||
}
|
||||
c = c + col[c].row().columns();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void set(int index, kelondroRow.Entry rowentry) throws IOException {
|
||||
assert rowentry.bytes().length == this.rowdef.objectsize;
|
||||
int c = 0;
|
||||
|
|
|
@ -55,6 +55,8 @@ import de.anomic.yacy.yacyDHTAction;
|
|||
|
||||
public final class plasmaWordIndex implements indexRI {
|
||||
|
||||
private static final int flushsize = 2000;
|
||||
|
||||
private final kelondroOrder indexOrder = kelondroBase64Order.enhancedCoder;
|
||||
private final indexRAMRI dhtOutCache, dhtInCache;
|
||||
private final indexCollectionRI collections; // new database structure to replace AssortmentCluster and FileCluster
|
||||
|
@ -135,10 +137,10 @@ public final class plasmaWordIndex implements indexRI {
|
|||
// check for forced flush
|
||||
synchronized (this) {
|
||||
if (dhtOutCache.size() > dhtOutCache.getMaxWordCount()) {
|
||||
flushCache(dhtOutCache, dhtOutCache.size() + 500 - dhtOutCache.getMaxWordCount());
|
||||
flushCache(dhtOutCache, dhtOutCache.size() + flushsize - dhtOutCache.getMaxWordCount());
|
||||
}
|
||||
if (dhtInCache.size() > dhtInCache.getMaxWordCount()) {
|
||||
flushCache(dhtInCache, dhtInCache.size() + 500 - dhtInCache.getMaxWordCount());
|
||||
flushCache(dhtInCache, dhtInCache.size() + flushsize - dhtInCache.getMaxWordCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -190,7 +192,7 @@ public final class plasmaWordIndex implements indexRI {
|
|||
|
||||
private void flushCacheSome(indexRAMRI ram, boolean busy) {
|
||||
int flushCount = (busy) ? ram.size() / busyDivisor : ram.size() / idleDivisor;
|
||||
if (flushCount > 100) flushCount = 100;
|
||||
if (flushCount > 1000) flushCount = 1000;
|
||||
if (flushCount >= 1) {
|
||||
flushCache(ram, flushCount);
|
||||
}
|
||||
|
@ -199,7 +201,7 @@ public final class plasmaWordIndex implements indexRI {
|
|||
|
||||
private void flushCache(indexRAMRI ram, int count) {
|
||||
if (count <= 0) return;
|
||||
if (count > 1000) count = 1000;
|
||||
if (count >= 5000) count = 5000;
|
||||
busyCacheFlush = true;
|
||||
String wordHash;
|
||||
ArrayList containerList = new ArrayList();
|
||||
|
|
Loading…
Reference in New Issue
Block a user