1
0
mirror of https://github.com/yacy/yacy_search_server.git synced 2025-07-19 08:44:42 -04:00

kelondroFlex bugfix

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2254 6c8d7289-2bf4-0310-a012-ef5d649a1542
This commit is contained in:
orbiter
2006-06-28 16:14:47 +00:00
parent 0e9192a622
commit 84dfd76a6a
8 changed files with 81 additions and 13 deletions

@ -335,6 +335,8 @@ public class dbtest {
}
long aftercommand = System.currentTimeMillis();
// final report
System.out.println("Database size = " + table.size() + " unique entries.");
// finally close the database/table
if (table instanceof kelondroTree) ((kelondroTree) table).close();
@ -414,6 +416,10 @@ final class dbTable implements kelondroIndex {
}
}
public int size() {
return 0; // *** SQL IMPLEMENTATION NEEDED ***
}
public kelondroRow row() {
return this.rowdef;
}

@ -106,12 +106,13 @@ public class kelondroFixedWidthArray extends kelondroRecords implements kelondro
return getHandle(index).hashCode();
}
public synchronized int add(kelondroRow.Entry rowinstance) throws IOException {
public synchronized int add(kelondroRow.Entry rowentry) throws IOException {
Node n = newNode();
n.commit(CP_LOW);
int index = n.handle().hashCode();
set(index, rowinstance);
return index;
n.setValueRow(rowentry.bytes());
n.commit(CP_NONE);
return n.handle().hashCode();
}
public synchronized void remove(int index) throws IOException {
@ -203,7 +204,24 @@ public class kelondroFixedWidthArray extends kelondroRecords implements kelondro
}
public static void main(String[] args) {
cmd(args);
//cmd(args);
File f = new File("d:\\\\mc\\privat\\fixtest.db");
f.delete();
kelondroFixedWidthArray k = new kelondroFixedWidthArray(f, new kelondroRow(new int[]{12, 4}), 6, true);
try {
k.set(3, k.row().newEntry(new byte[][]{
"test123".getBytes(), "abcd".getBytes()}));
k.add(k.row().newEntry(new byte[][]{
"test456".getBytes(), "efgh".getBytes()}));
k.close();
k = new kelondroFixedWidthArray(f);
System.out.println(k.get(2).toString());
System.out.println(k.get(3).toString());
System.out.println(k.get(4).toString());
} catch (IOException e) {
e.printStackTrace();
}
}
}

@ -43,7 +43,7 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr
for (int i = 0; i < indexArray.size(); i++) index.put(indexArray.get(i).getColBytes(0), new Integer(i));
indexArray.close();
*/
System.out.print("Loading " + path);
System.out.print("*** Loading " + path);
Iterator content = super.col[0].contentNodes();
kelondroRecords.Node node;
int i;
@ -51,11 +51,17 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr
node = (kelondroRecords.Node) content.next();
i = node.handle().hashCode();
index.addi(node.getValueRow(), i);
if ((i % 10000) == 0) System.out.print('.');
if ((i % 10000) == 0) {
System.out.print('.');
System.out.flush();
}
}
System.out.print(" -ordering- ");
System.out.flush();
this.index.setOrdering(kelondroNaturalOrder.naturalOrder, 0);
index.shape();
System.out.println(index.size() + " index entries initialized and sorted");
System.out.println(" -done-");
System.out.println(index.size() + " index entries initialized and sorted from " + super.col[0].size() + " keys.");
}
/*

@ -192,4 +192,25 @@ public class kelondroFlexWidthArray implements kelondroArray {
System.out.println("EndOfTable");
}
public static void main(String[] args) {
File f = new File("d:\\\\mc\\privat\\");
try {
kelondroFlexWidthArray k = new kelondroFlexWidthArray(f, "flextest", new kelondroRow(new int[]{12, 4}), true);
k.set(3, k.row().newEntry(new byte[][]{
"test123".getBytes(), "abcd".getBytes()}));
k.add(k.row().newEntry(new byte[][]{
"test456".getBytes(), "efgh".getBytes()}));
k.close();
k = new kelondroFlexWidthArray(f, "flextest", new kelondroRow(new int[]{12, 4}), true);
System.out.println(k.get(2).toString());
System.out.println(k.get(3).toString());
System.out.println(k.get(4).toString());
} catch (IOException e) {
e.printStackTrace();
}
}
}

@ -54,6 +54,8 @@ import java.io.IOException;
public interface kelondroIndex {
public int size();
public kelondroRow row();
public kelondroRow.Entry get(byte[] key) throws IOException;

@ -536,8 +536,8 @@ public class kelondroRecords {
private Handle handle = null; // index of the entry, by default NUL means undefined
private byte[] headChunk = null; // contains ohBytes, ohHandles and the key value
private byte[] tailChunk = null; // contains all values except the key value
private boolean headChanged = false;
private boolean tailChanged = false;
private boolean headChanged = true;
private boolean tailChanged = true;
private Node() throws IOException {
// create a new empty node and reserve empty space in file for it
@ -548,8 +548,8 @@ public class kelondroRecords {
// create empty chunks
this.headChunk = new byte[headchunksize];
this.tailChunk = new byte[tailchunksize];
for (int i = 0; i < headchunksize; i++) this.headChunk[i] = 0;
for (int i = 0; i < tailchunksize; i++) this.tailChunk[i] = 0;
for (int i = headchunksize - 1; i >= 0; i--) this.headChunk[i] = 0;
for (int i = tailchunksize - 1; i >= 0; i--) this.tailChunk[i] = 0;
}
private Node(Handle handle) throws IOException {

@ -285,6 +285,17 @@ public class kelondroRow {
}
return b;
}
public String toString() {
StringBuffer b = new StringBuffer();
b.append('{');
for (int i = 0; i < columns(); i++) {
b.append(getColString(i, null));
if (i < columns() - 1) b.append(", ");
}
b.append('}');
return new String(b);
}
}
public final static void long2bytes(long x, byte[] b, int offset, int length) {

@ -132,6 +132,10 @@ public class kelondroSplittedTree implements kelondroIndex {
for (int i = 0; i < ktfs.length; i++) ktfs[i].close();
}
public int size() {
return ktfs[0].size();
}
public kelondroRow row() {
return ktfs[0].row();
}