Skip to content

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

one more patch again OOM during secondary remote search see also: http://forum.yacy-websuche.de/viewtopic.php?f=6&t=3202

orbiter799c53493518
diff --git a/source/de/anomic/yacy/yacyClient.java b/source/de/anomic/yacy/yacyClient.java
index d49ceedd8..353636cde 100644
--- a/source/de/anomic/yacy/yacyClient.java
+++ b/source/de/anomic/yacy/yacyClient.java
@@ -537,16 +537,17 @@ public final class yacyClient {
ByteBuffer ci;
int ac = 0;
for (Map.Entry<byte[], String> abstractEntry: result.indexabstract.entrySet()) {
- wordhash = new String(abstractEntry.getKey());
- whacc += wordhash;
try {
- ci = new ByteBuffer(abstractEntry.getValue().getBytes("UTF-8"));
- } catch (UnsupportedEncodingException e) {
+ ci = new ByteBuffer(abstractEntry.getValue());
+ wordhash = new String(abstractEntry.getKey());
+ } catch (OutOfMemoryError e) {
Log.logException(e);
- return -1;
+ continue;
}
+ whacc += wordhash;
secondarySearchSuperviser.addAbstract(wordhash, ReferenceContainer.decompressIndex(ci, target.hash));
ac++;
+
}
if (ac > 0) {
secondarySearchSuperviser.commitAbstract();
diff --git a/source/net/yacy/kelondro/util/ByteBuffer.java b/source/net/yacy/kelondro/util/ByteBuffer.java
index 585157785..164fd6f0e 100644
--- a/source/net/yacy/kelondro/util/ByteBuffer.java
+++ b/source/net/yacy/kelondro/util/ByteBuffer.java
@@ -32,6 +32,8 @@ import java.util.Collection;
import java.util.List;
import java.util.Properties;
+import net.yacy.cora.document.UTF8;
+
public final class ByteBuffer extends OutputStream {
public static final byte singlequote = (byte) 39;
@@ -53,13 +55,19 @@ public final class ByteBuffer extends OutputStream {
this.buffer = new byte[initLength];
this.length = 0;
this.offset = 0;
- }
+ }
public ByteBuffer(final byte[] bb) {
buffer = bb;
length = bb.length;
offset = 0;
}
+
+ public ByteBuffer(final String s) {
+ buffer = s.getBytes(UTF8.charset);
+ length = buffer.length;
+ offset = 0;
+ }
public ByteBuffer(final byte[] bb, final int initLength) {
this.buffer = new byte[initLength];