adoptions, fixes for last commit

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1919 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 19 years ago
parent 488a0ed580
commit 526407f32e

@ -213,7 +213,10 @@ public class dbtest {
}
if (command.equals("list")) {
Iterator i = table.rows(true, false, null);
Iterator i = null;
if (table instanceof kelondroSplittedTree) i = ((kelondroSplittedTree) table).rows(true, false);
if (table instanceof kelondroTree) i = ((kelondroTree) table).rows(true, false, null);
if (table instanceof dbTable) i = ((dbTable) table).rows(true, false, null);
byte[][] row;
while (i.hasNext()) {
row = (byte[][]) i.next();
@ -382,6 +385,11 @@ final class dbTable implements kelondroIndex {
return null;
}
public Iterator keys(boolean up, boolean rotating, byte[] startKey) throws IOException {
// Objects are of type String
return null;
}
public int columns() {
// TODO Auto-generated method stub
return 0;

@ -57,7 +57,6 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Iterator;
import de.anomic.server.serverByteBuffer;
public class kelondroDyn extends kelondroTree {
@ -166,24 +165,28 @@ public class kelondroDyn extends kelondroTree {
public void remove() {
throw new UnsupportedOperationException("no remove in RawKeyIterator");
}
private String n() {
byte[] g;
String k;
String v;
int c;
byte[][] nt;
while (ri.hasNext()) {
nt = (byte[][]) ri.next();
if (nt == null) throw new kelondroException(filename, "no more elements available");
g = nt[0];
if (g == null) return null;
k = new String(g, 0, keylen);
v = new String(g, keylen, counterlen);
try {c = Integer.parseInt(v, 16);} catch (NumberFormatException e) {c = -1;}
if (c == 0) return k;
}
return null;
}
private String n() {
byte[] g;
String k;
String v;
int c;
byte[][] nt;
while (ri.hasNext()) {
nt = (byte[][]) ri.next();
if (nt == null) throw new kelondroException(filename, "no more elements available");
g = nt[0];
if (g == null) return null;
k = new String(g, 0, keylen);
v = new String(g, keylen, counterlen);
try {
c = Integer.parseInt(v, 16);
} catch (NumberFormatException e) {
c = -1;
}
if (c == 0) return k;
}
return null;
}
}
public synchronized dynKeyIterator dynKeys(boolean up, boolean rotating) throws IOException {

@ -51,7 +51,6 @@
package de.anomic.kelondro;
import java.io.IOException;
import java.util.Iterator;
public interface kelondroIndex {
@ -61,5 +60,9 @@ public interface kelondroIndex {
public byte[][] get(byte[] key) throws IOException;
public byte[][] put(byte[][] row) throws IOException;
public byte[][] remove(byte[] key) throws IOException;
public Iterator rows(boolean up, boolean rotating, byte[] startKey) throws IOException; // Objects are of type byte[][]
//public Iterator rows(boolean up, boolean rotating, byte[] startKey) throws IOException; // Objects are of type byte[][]
//public Iterator keys(boolean up, boolean rotating, byte[] startKey) throws IOException; // Objects are of type String
//public TreeMap rowMap(boolean up, boolean rotating, byte[] firstKey, boolean including, int count) throws IOException;
//public TreeSet keySet(boolean up, boolean rotating, byte[] firstKey, boolean including, int count) throws IOException;
}

@ -153,8 +153,8 @@ public class kelondroSplittedTree implements kelondroIndex {
return ktfs[partition(key)].remove(key);
}
public Iterator rows(boolean up, boolean rotating, byte[] startKey) throws IOException {
return new ktfsIterator(up, rotating, startKey);
public Iterator rows(boolean up, boolean rotating) throws IOException {
return new ktfsIterator(up, rotating);
}
public class ktfsIterator implements Iterator {
@ -162,12 +162,10 @@ public class kelondroSplittedTree implements kelondroIndex {
int c = 0;
Iterator ktfsI;
boolean up, rot;
byte[] start;
public ktfsIterator(boolean up, boolean rotating, byte[] startKey) throws IOException {
public ktfsIterator(boolean up, boolean rotating) throws IOException {
this.up = up;
this.rot = rotating;
this.start = startKey;
c = (up) ? 0 : (ff - 1);
ktfsI = ktfs[c].rows(up, false, null);
}
@ -185,7 +183,7 @@ public class kelondroSplittedTree implements kelondroIndex {
if (c < (ff - 1)) {
c++;
try {
ktfsI = ktfs[c].rows(true, false, start);
ktfsI = ktfs[c].rows(true, false, null);
} catch (IOException e) {
return null;
}
@ -194,7 +192,7 @@ public class kelondroSplittedTree implements kelondroIndex {
if (rot) {
c = 0;
try {
ktfsI = ktfs[c].rows(true, false, start);
ktfsI = ktfs[c].rows(true, false, null);
} catch (IOException e) {
return null;
}
@ -206,7 +204,7 @@ public class kelondroSplittedTree implements kelondroIndex {
if (c > 0) {
c--;
try {
ktfsI = ktfs[c].rows(false, false, start);
ktfsI = ktfs[c].rows(false, false, null);
} catch (IOException e) {
return null;
}
@ -215,7 +213,7 @@ public class kelondroSplittedTree implements kelondroIndex {
if (rot) {
c = ff - 1;
try {
ktfsI = ktfs[c].rows(false, false, start);
ktfsI = ktfs[c].rows(false, false, null);
} catch (IOException e) {
return null;
}

@ -81,7 +81,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
private static int root = 0; // pointer for FHandles-array: pointer to root node
private Search writeSearchObj = new Search();
private kelondroOrder objectOrder = new kelondroNaturalOrder(true);
protected kelondroOrder objectOrder = new kelondroNaturalOrder(true);
private final kelondroOrder loopDetectionOrder = new kelondroNaturalOrder(true);
public kelondroTree(File file, long buffersize, int key, int value, boolean exitOnFail) {
@ -987,11 +987,11 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
}
public void remove() {
throw new java.lang.UnsupportedOperationException("kelondroTree: remove in kelondro Tables not yet supported");
throw new java.lang.UnsupportedOperationException("kelondroTree: remove in kelondro node iterator not yet supported");
}
}
public TreeMap rows(boolean up, boolean rotating, byte[] firstKey, boolean including, int count) throws IOException {
public TreeMap rowMap(boolean up, boolean rotating, byte[] firstKey, boolean including, int count) throws IOException {
// returns an ordered map of keys/row relations; key objects are of type String, value objects are of type byte[][]
kelondroOrder setOrder = (kelondroOrder) objectOrder.clone();
setOrder.direction(up);
@ -1008,7 +1008,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
return rows;
}
public TreeSet keys(boolean up, boolean rotating, byte[] firstKey, boolean including, int count) throws IOException {
public TreeSet keySet(boolean up, boolean rotating, byte[] firstKey, boolean including, int count) throws IOException {
// returns an ordered set of keys; objects are of type String
kelondroOrder setOrder = (kelondroOrder) objectOrder.clone();
setOrder.direction(up);
@ -1058,7 +1058,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
count = 0;
lastKey = null;
chunkSize = (int) Math.min(100, guessedCountLimit);
rowBuffer = rows(inc, rot, start, true, chunkSize);
rowBuffer = rowMap(inc, rot, start, true, chunkSize);
bufferIterator = rowBuffer.entrySet().iterator();
}
@ -1075,7 +1075,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
if (!(bufferIterator.hasNext())) {
// assign next buffer chunk
try {
rowBuffer = rows(inc, rot, lastKey, false, chunkSize);
rowBuffer = rowMap(inc, rot, lastKey, false, chunkSize);
bufferIterator = rowBuffer.entrySet().iterator();
} catch (IOException e) {
rowBuffer = null;
@ -1115,7 +1115,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
count = 0;
lastKey = null;
chunkSize = (int) Math.min(100, guessedCountLimit);
keyBuffer = keys(inc, rot, start, true, chunkSize);
keyBuffer = keySet(inc, rot, start, true, chunkSize);
bufferIterator = keyBuffer.iterator();
}
@ -1131,7 +1131,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
if (!(bufferIterator.hasNext())) {
// assign next buffer chunk
try {
keyBuffer = keys(inc, rot, lastKey.getBytes(), false, chunkSize);
keyBuffer = keySet(inc, rot, lastKey.getBytes(), false, chunkSize);
bufferIterator = keyBuffer.iterator();
} catch (IOException e) {
keyBuffer = null;

Loading…
Cancel
Save