Skip to content

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

multiple bugfixes for new stack/row features

orbiter89424ff122de
diff --git a/source/de/anomic/kelondro/kelondroRecords.java b/source/de/anomic/kelondro/kelondroRecords.java
index 161eae343..2d3de8299 100644
--- a/source/de/anomic/kelondro/kelondroRecords.java
+++ b/source/de/anomic/kelondro/kelondroRecords.java
@@ -681,11 +681,11 @@ public class kelondroRecords {
}
}
- private void setValue(byte[] value, int valuewidth, byte[] targetarray, int targetoffset) {
+ private void setValue(byte[] value, int valueoffset, int valuewidth, byte[] targetarray, int targetoffset) {
if (value == null) {
while (valuewidth-- > 0) targetarray[targetoffset + valuewidth] = 0;
} else {
- System.arraycopy(value, 0, targetarray, targetoffset, Math.min(value.length, valuewidth)); // error?
+ System.arraycopy(value, valueoffset, targetarray, targetoffset, Math.min(value.length, valuewidth)); // error?
if (value.length < valuewidth) {
while (valuewidth-- > value.length) targetarray[targetoffset + valuewidth] = 0;
}
@@ -736,10 +736,10 @@ public class kelondroRecords {
// set values
if (this.handle.index != NUL) {
- setValue(row[0], ROW.width(0), headChunk, overhead);
+ setValue(row[0], 0, ROW.width(0), headChunk, overhead);
int offset = 0;
for (int i = 1; i < row.length; i++) {
- setValue(row[i], ROW.width(i), tailChunk, offset);
+ setValue(row[i], 0, ROW.width(i), tailChunk, offset);
offset +=ROW.width(i);
}
}
@@ -755,8 +755,8 @@ public class kelondroRecords {
// set values
if (this.handle.index != NUL) {
- setValue(row, ROW.width(0), headChunk, overhead);
- setValue(row, ROW.width(1), tailChunk, 0);
+ setValue(row, 0, ROW.width(0), headChunk, overhead);
+ if (ROW.columns() > 0) setValue(row, ROW.width(0), ROW.size() - ROW.width(0), tailChunk, 0);
}
this.headChanged = true;
this.tailChanged = true;
diff --git a/source/de/anomic/kelondro/kelondroRow.java b/source/de/anomic/kelondro/kelondroRow.java
index 1deba76aa..b64d78153 100644
--- a/source/de/anomic/kelondro/kelondroRow.java
+++ b/source/de/anomic/kelondro/kelondroRow.java
@@ -143,7 +143,7 @@ public class kelondroRow {
rowinstance = new byte[objectsize];
for (int i = 0; i < objectsize; i++) this.rowinstance[i] = 0;
for (int i = 0; i < cols.length; i++) {
- System.arraycopy(cols[i], 0, rowinstance, colstart[i], row[i].cellwidth());
+ if (cols[i] != null) System.arraycopy(cols[i], 0, rowinstance, colstart[i], Math.min(cols[i].length, row[i].cellwidth()));
}
}
diff --git a/source/de/anomic/kelondro/kelondroStack.java b/source/de/anomic/kelondro/kelondroStack.java
index 4e58e979b..9506148d2 100644
--- a/source/de/anomic/kelondro/kelondroStack.java
+++ b/source/de/anomic/kelondro/kelondroStack.java
@@ -443,7 +443,17 @@ public final class kelondroStack extends kelondroRecords {
// -g test.stack
// -v test.stack
// -g 1 test.stack
- cmd(args);
+ cmd(args);
+ /*
+ kelondroStack s = new kelondroStack(new File("/Users/admin/dev/yacy/trunk/test.stack"), 1024, new int[]{10,10}, false);
+ try {
+ s.push(s.row().newEntry(new byte[][]{"test123".getBytes(), "abcdefg".getBytes()}));
+ s.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ */
}
}