Skip to content

Commit

Permalink
multiple bugfixes for new stack/row features
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2159 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
orbiter committed May 30, 2006
1 parent fcefefb commit 89424ff
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
12 changes: 6 additions & 6 deletions source/de/anomic/kelondro/kelondroRecords.java
Expand Up @@ -681,11 +681,11 @@ private void initContent() throws IOException {
}
}

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;
}
Expand Down Expand Up @@ -736,10 +736,10 @@ public byte[][] setValueCells(byte[][] row) throws IOException {

// 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);
}
}
Expand All @@ -755,8 +755,8 @@ public byte[] setValueRow(byte[] row) throws IOException {

// 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;
Expand Down
2 changes: 1 addition & 1 deletion source/de/anomic/kelondro/kelondroRow.java
Expand Up @@ -143,7 +143,7 @@ public Entry(byte[][] cols) {
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()));
}
}

Expand Down
12 changes: 11 additions & 1 deletion source/de/anomic/kelondro/kelondroStack.java
Expand Up @@ -443,7 +443,17 @@ public static void main(String[] args) {
// -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();
}
*/
}

}

0 comments on commit 89424ff

Please sign in to comment.