Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

correct R/W head positioning in kelondroFlex and some enhancements

orbiter1fda50fd3c1f
diff --git a/source/de/anomic/index/indexCachedRI.java b/source/de/anomic/index/indexCachedRI.java
index 44307846b..3e366d32d 100644
--- a/source/de/anomic/index/indexCachedRI.java
+++ b/source/de/anomic/index/indexCachedRI.java
@@ -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());
}
}
}
diff --git a/source/de/anomic/kelondro/kelondroFlexTable.java b/source/de/anomic/kelondro/kelondroFlexTable.java
index d8c2a709a..6ce428919 100644
--- a/source/de/anomic/kelondro/kelondroFlexTable.java
+++ b/source/de/anomic/kelondro/kelondroFlexTable.java
@@ -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 {
diff --git a/source/de/anomic/kelondro/kelondroFlexWidthArray.java b/source/de/anomic/kelondro/kelondroFlexWidthArray.java
index 1cf8a7143..96fe56004 100644
--- a/source/de/anomic/kelondro/kelondroFlexWidthArray.java
+++ b/source/de/anomic/kelondro/kelondroFlexWidthArray.java
@@ -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;
diff --git a/source/de/anomic/plasma/plasmaWordIndex.java b/source/de/anomic/plasma/plasmaWordIndex.java
index 9ca749569..1d59f4cb6 100644
--- a/source/de/anomic/plasma/plasmaWordIndex.java
+++ b/source/de/anomic/plasma/plasmaWordIndex.java
@@ -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();