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")) { 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; byte[][] row;
while (i.hasNext()) { while (i.hasNext()) {
row = (byte[][]) i.next(); row = (byte[][]) i.next();
@ -382,6 +385,11 @@ final class dbTable implements kelondroIndex {
return null; return null;
} }
public Iterator keys(boolean up, boolean rotating, byte[] startKey) throws IOException {
// Objects are of type String
return null;
}
public int columns() { public int columns() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return 0; return 0;

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

@ -51,7 +51,6 @@
package de.anomic.kelondro; package de.anomic.kelondro;
import java.io.IOException; import java.io.IOException;
import java.util.Iterator;
public interface kelondroIndex { public interface kelondroIndex {
@ -61,5 +60,9 @@ public interface kelondroIndex {
public byte[][] get(byte[] key) throws IOException; public byte[][] get(byte[] key) throws IOException;
public byte[][] put(byte[][] row) throws IOException; public byte[][] put(byte[][] row) throws IOException;
public byte[][] remove(byte[] key) 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); return ktfs[partition(key)].remove(key);
} }
public Iterator rows(boolean up, boolean rotating, byte[] startKey) throws IOException { public Iterator rows(boolean up, boolean rotating) throws IOException {
return new ktfsIterator(up, rotating, startKey); return new ktfsIterator(up, rotating);
} }
public class ktfsIterator implements Iterator { public class ktfsIterator implements Iterator {
@ -162,12 +162,10 @@ public class kelondroSplittedTree implements kelondroIndex {
int c = 0; int c = 0;
Iterator ktfsI; Iterator ktfsI;
boolean up, rot; 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.up = up;
this.rot = rotating; this.rot = rotating;
this.start = startKey;
c = (up) ? 0 : (ff - 1); c = (up) ? 0 : (ff - 1);
ktfsI = ktfs[c].rows(up, false, null); ktfsI = ktfs[c].rows(up, false, null);
} }
@ -185,7 +183,7 @@ public class kelondroSplittedTree implements kelondroIndex {
if (c < (ff - 1)) { if (c < (ff - 1)) {
c++; c++;
try { try {
ktfsI = ktfs[c].rows(true, false, start); ktfsI = ktfs[c].rows(true, false, null);
} catch (IOException e) { } catch (IOException e) {
return null; return null;
} }
@ -194,7 +192,7 @@ public class kelondroSplittedTree implements kelondroIndex {
if (rot) { if (rot) {
c = 0; c = 0;
try { try {
ktfsI = ktfs[c].rows(true, false, start); ktfsI = ktfs[c].rows(true, false, null);
} catch (IOException e) { } catch (IOException e) {
return null; return null;
} }
@ -206,7 +204,7 @@ public class kelondroSplittedTree implements kelondroIndex {
if (c > 0) { if (c > 0) {
c--; c--;
try { try {
ktfsI = ktfs[c].rows(false, false, start); ktfsI = ktfs[c].rows(false, false, null);
} catch (IOException e) { } catch (IOException e) {
return null; return null;
} }
@ -215,7 +213,7 @@ public class kelondroSplittedTree implements kelondroIndex {
if (rot) { if (rot) {
c = ff - 1; c = ff - 1;
try { try {
ktfsI = ktfs[c].rows(false, false, start); ktfsI = ktfs[c].rows(false, false, null);
} catch (IOException e) { } catch (IOException e) {
return null; 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 static int root = 0; // pointer for FHandles-array: pointer to root node
private Search writeSearchObj = new Search(); private Search writeSearchObj = new Search();
private kelondroOrder objectOrder = new kelondroNaturalOrder(true); protected kelondroOrder objectOrder = new kelondroNaturalOrder(true);
private final kelondroOrder loopDetectionOrder = new kelondroNaturalOrder(true); private final kelondroOrder loopDetectionOrder = new kelondroNaturalOrder(true);
public kelondroTree(File file, long buffersize, int key, int value, boolean exitOnFail) { 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() { 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[][] // 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(); kelondroOrder setOrder = (kelondroOrder) objectOrder.clone();
setOrder.direction(up); setOrder.direction(up);
@ -1008,7 +1008,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
return rows; 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 // returns an ordered set of keys; objects are of type String
kelondroOrder setOrder = (kelondroOrder) objectOrder.clone(); kelondroOrder setOrder = (kelondroOrder) objectOrder.clone();
setOrder.direction(up); setOrder.direction(up);
@ -1058,7 +1058,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
count = 0; count = 0;
lastKey = null; lastKey = null;
chunkSize = (int) Math.min(100, guessedCountLimit); chunkSize = (int) Math.min(100, guessedCountLimit);
rowBuffer = rows(inc, rot, start, true, chunkSize); rowBuffer = rowMap(inc, rot, start, true, chunkSize);
bufferIterator = rowBuffer.entrySet().iterator(); bufferIterator = rowBuffer.entrySet().iterator();
} }
@ -1075,7 +1075,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
if (!(bufferIterator.hasNext())) { if (!(bufferIterator.hasNext())) {
// assign next buffer chunk // assign next buffer chunk
try { try {
rowBuffer = rows(inc, rot, lastKey, false, chunkSize); rowBuffer = rowMap(inc, rot, lastKey, false, chunkSize);
bufferIterator = rowBuffer.entrySet().iterator(); bufferIterator = rowBuffer.entrySet().iterator();
} catch (IOException e) { } catch (IOException e) {
rowBuffer = null; rowBuffer = null;
@ -1115,7 +1115,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
count = 0; count = 0;
lastKey = null; lastKey = null;
chunkSize = (int) Math.min(100, guessedCountLimit); chunkSize = (int) Math.min(100, guessedCountLimit);
keyBuffer = keys(inc, rot, start, true, chunkSize); keyBuffer = keySet(inc, rot, start, true, chunkSize);
bufferIterator = keyBuffer.iterator(); bufferIterator = keyBuffer.iterator();
} }
@ -1131,7 +1131,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
if (!(bufferIterator.hasNext())) { if (!(bufferIterator.hasNext())) {
// assign next buffer chunk // assign next buffer chunk
try { try {
keyBuffer = keys(inc, rot, lastKey.getBytes(), false, chunkSize); keyBuffer = keySet(inc, rot, lastKey.getBytes(), false, chunkSize);
bufferIterator = keyBuffer.iterator(); bufferIterator = keyBuffer.iterator();
} catch (IOException e) { } catch (IOException e) {
keyBuffer = null; keyBuffer = null;

Loading…
Cancel
Save