made kelondroTree.nodeIterator private

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1910 6c8d7289-2bf4-0310-a012-ef5d649a1542
This commit is contained in:
orbiter 2006-03-17 18:10:48 +00:00
parent 5f6fdf1786
commit f02b426073
3 changed files with 48 additions and 20 deletions

View File

@ -807,7 +807,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
return node;
}
public synchronized Iterator nodeIterator(boolean up, boolean rotating) {
private synchronized Iterator nodeIterator(boolean up, boolean rotating) {
// iterates the elements in a sorted way. returns Node - type Objects
try {
return new nodeIterator(up, rotating);
@ -816,7 +816,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
}
}
public synchronized Iterator nodeIterator(boolean up, boolean rotating, byte[] firstKey) {
private synchronized Iterator nodeIterator(boolean up, boolean rotating, byte[] firstKey) {
// iterates the elements in a sorted way. returns Node - type Objects
try {
return new nodeIterator(up, rotating, firstKey, true);
@ -1203,7 +1203,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
System.out.println();
}
private static void cmd(String[] args) {
public static void cmd(String[] args) {
System.out.print("kelondroTree ");
for (int i = 0; i < args.length; i++) System.out.print(args[i] + " ");
System.out.println("");
@ -1228,7 +1228,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
fm.put("def2".getBytes(), dummy); fm.put("bab2".getBytes(), dummy);
fm.put("abc3".getBytes(), dummy); fm.put("bcd3".getBytes(), dummy);
fm.put("def3".getBytes(), dummy); fm.put("bab3".getBytes(), dummy);
fm.print();
fm.print();
fm.remove("def1".getBytes()); fm.remove("bab1".getBytes());
fm.remove("abc2".getBytes()); fm.remove("bcd2".getBytes());
fm.remove("def2".getBytes()); fm.remove("bab2".getBytes());
@ -1318,7 +1318,8 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
}
public static void main(String[] args) {
cmd(args);
//cmd(args);
iterationtest();
//bigtest(Integer.parseInt(args[0]));
//randomtest(Integer.parseInt(args[0]));
//smalltest();
@ -1457,6 +1458,37 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
}
}
public static void iterationtest() {
File f = new File("test.db");
if (f.exists()) f.delete();
try {
kelondroTree tt = new kelondroTree(f, 0, 4, 4, true);
byte[] b;
for (int i = 0; i < 100; i++) {
b = ("T" + i).getBytes(); tt.put(b, b);
}
Iterator i = tt.keys(true, false);
while (i.hasNext()) System.out.print((String) i.next() + ", ");
System.out.println();
i = tt.keys(true, false, "T80".getBytes());
while (i.hasNext()) System.out.print((String) i.next() + ", ");
System.out.println();
i = tt.keys(true, true, "T80".getBytes());
for (int j = 0; j < 40; j++) System.out.print((String) i.next() + ", ");
System.out.println();
i = tt.keys(false, true, "T20".getBytes());
for (int j = 0; j < 40; j++) System.out.print((String) i.next() + ", ");
System.out.println();
tt.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public static kelondroTree testTree(File f, String testentities) throws IOException {
if (f.exists()) f.delete();
kelondroTree tt = new kelondroTree(f, 0, 4, 4, true);

View File

@ -62,7 +62,6 @@ import de.anomic.http.httpc;
import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroException;
import de.anomic.kelondro.kelondroTree;
import de.anomic.kelondro.kelondroRecords.Node;
import de.anomic.server.serverSemaphore;
import de.anomic.server.logging.serverLog;
import de.anomic.tools.bitfield;
@ -543,15 +542,14 @@ public final class plasmaCrawlStacker {
}
try {
// loop through the list and fill the messageList with url hashs
Iterator iter = this.urlEntryCache.nodeIterator(true,false);
Node n;
Iterator iter = this.urlEntryCache.keys(true, false);
String urlHash;
while (iter.hasNext()) {
n = (Node) iter.next();
if (n == null) {
urlHash = (String) iter.next();
if (urlHash == null) {
System.out.println("ERROR! null element found");
continue;
}
String urlHash = new String(n.getKey());
this.urlEntryHashCache.add(urlHash);
this.readSync.V();
}

View File

@ -47,7 +47,6 @@ package de.anomic.plasma;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import de.anomic.kelondro.kelondroRecords;
import de.anomic.kelondro.kelondroTree;
import de.anomic.kelondro.kelondroException;
import de.anomic.server.logging.serverLog;
@ -215,11 +214,15 @@ public final class plasmaWordIndexEntity {
if (theIndex == null) {
i = null;
} else try {
i = theIndex.nodeIterator(up, false);
i = theIndex.rows(up, false);
} catch (kelondroException e) {
e.printStackTrace();
theIndex.file().delete();
i = null;
} catch (IOException e) {
e.printStackTrace();
theIndex.file().delete();
i = null;
}
}
public boolean hasNext() {
@ -227,13 +230,8 @@ public final class plasmaWordIndexEntity {
}
public Object next() {
if (i == null) return null;
try {
byte[][] n = ((kelondroRecords.Node) i.next()).getValues();
return new plasmaWordIndexEntry(new String(n[0]), new String(n[1]));
} catch (IOException e) {
i = null;
throw new RuntimeException("dbenum: " + e.getMessage());
}
byte[][] n = (byte[][]) i.next();
return new plasmaWordIndexEntry(new String(n[0]), new String(n[1]));
}
public void remove() {
throw new UnsupportedOperationException();