Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
moved to Java 1.5: - changed build script to use java 1.5 compiler - first stept to resolve missing generics definition (about 400 from over 4100 'missing'-warnings) - added key-iterator to kelondro databases (for rapid from-memory enumerations, will be used for domain name collection, not used yet)
orbiter4dc438f7e722
diff --git a/build.properties b/build.propertiesindex f488a1b1e..851ad22db 100644--- a/build.properties+++ b/build.properties@@ -1,6 +1,6 @@# defining some compiler arguments-javacSource=1.4-javacTarget=1.4+javacSource=1.5+javacTarget=1.5# Release ConfigurationreleaseVersion=0.561diff --git a/source/de/anomic/index/indexCollectionRI.java b/source/de/anomic/index/indexCollectionRI.javaindex 120fb5b1b..fa4107f20 100644--- a/source/de/anomic/index/indexCollectionRI.java+++ b/source/de/anomic/index/indexCollectionRI.java@@ -99,7 +99,7 @@ public class indexCollectionRI implements indexRI {this.wci = collectionIndex.keycollections(startWordHash.getBytes(), kelondroBase64Order.zero(startWordHash.length()), rot);}- public Object clone(Object secondWordHash) {+ public wordContainersIterator clone(Object secondWordHash) {return new wordContainersIterator((String) secondWordHash, rot);}diff --git a/source/de/anomic/index/indexContainer.java b/source/de/anomic/index/indexContainer.javaindex 43e906124..0a941bca4 100644--- a/source/de/anomic/index/indexContainer.java+++ b/source/de/anomic/index/indexContainer.java@@ -156,21 +156,21 @@ public class indexContainer extends kelondroRowSet {return new indexRWIRowEntry(entry);}- public int removeEntries(Set urlHashes) {+ public int removeEntries(Set<String> urlHashes) {int count = 0;- Iterator i = urlHashes.iterator();- while (i.hasNext()) count += (remove((String) i.next()) == null) ? 0 : 1;+ Iterator<String> i = urlHashes.iterator();+ while (i.hasNext()) count += (remove(i.next()) == null) ? 0 : 1;return count;}- public Iterator entries() {+ public Iterator<indexRWIRowEntry> entries() {// returns an iterator of indexRWIEntry objectsreturn new entryIterator();}- public class entryIterator implements Iterator {+ public class entryIterator implements Iterator<indexRWIRowEntry> {- Iterator rowEntryIterator;+ Iterator<kelondroRow.Entry> rowEntryIterator;public entryIterator() {rowEntryIterator = rows();@@ -180,7 +180,7 @@ public class indexContainer extends kelondroRowSet {return rowEntryIterator.hasNext();}- public Object next() {+ public indexRWIRowEntry next() {kelondroRow.Entry rentry = (kelondroRow.Entry) rowEntryIterator.next();if (rentry == null) return null;return new indexRWIRowEntry(rentry);@@ -340,8 +340,8 @@ public class indexContainer extends kelondroRowSet {indexContainer conj = new indexContainer(null, i1.rowdef, 0); // start with empty search resultif (!((i1.rowdef.getOrdering().signature().equals(i2.rowdef.getOrdering().signature())) &&(i1.rowdef.primaryKeyIndex == i2.rowdef.primaryKeyIndex))) return conj; // ordering must be equal- Iterator e1 = i1.entries();- Iterator e2 = i2.entries();+ Iterator<indexRWIRowEntry> e1 = i1.entries();+ Iterator<indexRWIRowEntry> e2 = i2.entries();int c;if ((e1.hasNext()) && (e2.hasNext())) {indexRWIEntry ie1;@@ -352,7 +352,7 @@ public class indexContainer extends kelondroRowSet {while (true) {assert (ie1.urlHash().length() == keylength) : "ie1.urlHash() = " + ie1.urlHash();assert (ie2.urlHash().length() == keylength) : "ie2.urlHash() = " + ie2.urlHash();- c = i1.rowdef.getOrdering().compare(ie1.urlHash(), ie2.urlHash());+ c = i1.rowdef.getOrdering().compare(ie1.urlHash().getBytes(), ie2.urlHash().getBytes());//System.out.println("** '" + ie1.getUrlHash() + "'.compareTo('" + ie2.getUrlHash() + "')="+c);if (c < 0) {if (e1.hasNext()) ie1 = (indexRWIEntry) e1.next(); else break;@@ -415,8 +415,8 @@ public class indexContainer extends kelondroRowSet {assert (keylength == excl.rowdef.width(0));if (!((pivot.rowdef.getOrdering().signature().equals(excl.rowdef.getOrdering().signature())) &&(pivot.rowdef.primaryKeyIndex == excl.rowdef.primaryKeyIndex))) return pivot; // ordering must be equal- Iterator e1 = pivot.entries();- Iterator e2 = excl.entries();+ Iterator<indexRWIRowEntry> e1 = pivot.entries();+ Iterator<indexRWIRowEntry> e2 = excl.entries();int c;if ((e1.hasNext()) && (e2.hasNext())) {indexRWIEntry ie1;@@ -427,7 +427,7 @@ public class indexContainer extends kelondroRowSet {while (true) {assert (ie1.urlHash().length() == keylength) : "ie1.urlHash() = " + ie1.urlHash();assert (ie2.urlHash().length() == keylength) : "ie2.urlHash() = " + ie2.urlHash();- c = pivot.rowdef.getOrdering().compare(ie1.urlHash(), ie2.urlHash());+ c = pivot.rowdef.getOrdering().compare(ie1.urlHash().getBytes(), ie2.urlHash().getBytes());//System.out.println("** '" + ie1.getUrlHash() + "'.compareTo('" + ie2.getUrlHash() + "')="+c);if (c < 0) {if (e1.hasNext()) ie1 = (indexRWIEntry) e1.next(); else break;diff --git a/source/de/anomic/index/indexContainerOrder.java b/source/de/anomic/index/indexContainerOrder.javaindex 7c82ca76b..12222f3b9 100644--- a/source/de/anomic/index/indexContainerOrder.java+++ b/source/de/anomic/index/indexContainerOrder.java@@ -26,7 +26,10 @@package de.anomic.index;+import de.anomic.kelondro.kelondroNode;import de.anomic.kelondro.kelondroOrder;+import de.anomic.kelondro.kelondroRow;+import de.anomic.kelondro.kelondroRow.Entry;public class indexContainerOrder implements kelondroOrder {@@ -52,11 +55,8 @@ public class indexContainerOrder implements kelondroOrder {return this.embeddedOrder.partition(key, forks);}- public int compare(Object a, Object b) {- if ((a instanceof indexContainer) && (b instanceof indexContainer)) {- return this.embeddedOrder.compare(((indexContainer) a).getWordHash(), ((indexContainer) b).getWordHash());- }- return this.embeddedOrder.compare(a, b);+ public int compare(indexContainer a, indexContainer b) {+ return this.embeddedOrder.compare(a.getWordHash().getBytes(), b.getWordHash().getBytes());}public byte[] zero() {@@ -79,6 +79,46 @@ public class indexContainerOrder implements kelondroOrder {return this.embeddedOrder.cardinal(key);}+ public int compare(Object a, Object b) {+ if ((a instanceof byte[]) && (b instanceof byte[])) {+ return this.embeddedOrder.compare((byte[]) a, (byte[]) b);+ }+ if ((a instanceof Integer) && (b instanceof Integer)) {+ return ((Integer) a).compareTo((Integer) b);+ }+ if ((a instanceof String) && (b instanceof String)) {+ return this.embeddedOrder.compare(((String) a).getBytes(), ((String) b).getBytes());+ }+ if ((a instanceof kelondroNode) && (b instanceof kelondroNode)) {+ return this.embeddedOrder.compare((kelondroNode) a, (kelondroNode) b);+ }+ if ((a instanceof kelondroRow.Entry) && (b instanceof kelondroRow.Entry)) {+ return this.embeddedOrder.compare((kelondroRow.Entry) a, (kelondroRow.Entry) b);+ }+ if ((a instanceof indexContainer) && (b instanceof indexContainer)) {+ return this.embeddedOrder.compare((indexContainer) a, (indexContainer) b);+ }+ Class<? extends Object> ac = a.getClass();+ Class<? extends Object> bc = b.getClass();+ if (ac.equals(bc)) {+ throw new UnsupportedOperationException("compare not implemented for this object type: " + ac);+ } else {+ throw new UnsupportedOperationException("compare must be applied to same object classes; here a = " + ac + ", b = " + bc);+ }+ }++ public int compare(String a, String b) {+ return this.embeddedOrder.compare(a, b);+ }++ public int compare(kelondroNode a, kelondroNode b) {+ return this.embeddedOrder.compare(a, b);+ }++ public int compare(Entry a, Entry b) {+ return this.embeddedOrder.compare(a, b);+ }+public int compare(byte[] a, byte[] b) {return this.embeddedOrder.compare(a, b);}@@ -91,4 +131,5 @@ public class indexContainerOrder implements kelondroOrder {if (!(otherOrder instanceof indexContainerOrder)) return false;return this.embeddedOrder.equals(((indexContainerOrder) otherOrder).embeddedOrder);}+}diff --git a/source/de/anomic/index/indexRAMRI.java b/source/de/anomic/index/indexRAMRI.javaindex 0ddd2abfd..cd52321f3 100644--- a/source/de/anomic/index/indexRAMRI.java+++ b/source/de/anomic/index/indexRAMRI.java@@ -278,14 +278,14 @@ public final class indexRAMRI implements indexRI {return cacheIndex.size();}- public synchronized kelondroCloneableIterator wordContainers(String startWordHash, boolean rot) {+ public synchronized kelondroCloneableIterator<indexContainer> wordContainers(String startWordHash, boolean rot) {// we return an iterator object that creates top-level-clones of the indexContainers// in the cache, so that manipulations of the iterated objects do not change// objects in the cache.return new wordContainerIterator(startWordHash, rot);}- public class wordContainerIterator implements kelondroCloneableIterator {+ public class wordContainerIterator implements kelondroCloneableIterator<indexContainer> {// this class exists, because the wCache cannot be iterated with rotation// and because every indexContainer Object that is iterated must be returned as top-level-clone@@ -301,7 +301,7 @@ public final class indexRAMRI implements indexRI {// The collection's iterator will return the values in the order that their corresponding keys appear in the tree.}- public Object clone(Object secondWordHash) {+ public wordContainerIterator clone(Object secondWordHash) {return new wordContainerIterator((String) secondWordHash, rot);}@@ -310,7 +310,7 @@ public final class indexRAMRI implements indexRI {return iterator.hasNext();}- public Object next() {+ public indexContainer next() {if (iterator.hasNext()) {return ((indexContainer) iterator.next()).topLevelClone();} else {diff --git a/source/de/anomic/index/indexRWIEntryOrder.java b/source/de/anomic/index/indexRWIEntryOrder.javaindex ceffcf1bb..7972d9e7a 100644--- a/source/de/anomic/index/indexRWIEntryOrder.java+++ b/source/de/anomic/index/indexRWIEntryOrder.java@@ -68,10 +68,10 @@ public class indexRWIEntryOrder extends kelondroAbstractOrder implements kelondrmmf1.run(); // execute other fork in this threadif (this.min == null) this.min = mmf1.entryMin; else indexRWIVarEntry.min(this.min, mmf1.entryMin);if (this.max == null) this.max = mmf1.entryMax; else indexRWIVarEntry.max(this.max, mmf1.entryMax);- Map.Entry entry;- Iterator di = mmf1.domcount().entrySet().iterator();+ Map.Entry<String, Integer> entry;+ Iterator<Map.Entry<String, Integer>> di = mmf1.domcount().entrySet().iterator();while (di.hasNext()) {- entry = (Map.Entry) di.next();+ entry = di.next();this.doms.addScore(entry.getKey(), ((Integer) entry.getValue()).intValue());}try {mmf0.join();} catch (InterruptedException e) {} // wait for fork thread to finish@@ -79,7 +79,7 @@ public class indexRWIEntryOrder extends kelondroAbstractOrder implements kelondrif (this.max == null) this.max = mmf0.entryMax; else indexRWIVarEntry.max(this.max, mmf0.entryMax);di = mmf0.domcount().entrySet().iterator();while (di.hasNext()) {- entry = (Map.Entry) di.next();+ entry = di.next();this.doms.addScore(entry.getKey(), ((Integer) entry.getValue()).intValue());}//long s1= System.currentTimeMillis(), sc = Math.max(1, s1 - s0);@@ -90,10 +90,10 @@ public class indexRWIEntryOrder extends kelondroAbstractOrder implements kelondrmmf.run(); // execute without multi-threadingif (this.min == null) this.min = mmf.entryMin; else indexRWIVarEntry.min(this.min, mmf.entryMin);if (this.max == null) this.max = mmf.entryMax; else indexRWIVarEntry.max(this.max, mmf.entryMax);- Map.Entry entry;- Iterator di = mmf.domcount().entrySet().iterator();+ Map.Entry<String, Integer> entry;+ Iterator<Map.Entry<String, Integer>> di = mmf.domcount().entrySet().iterator();while (di.hasNext()) {- entry = (Map.Entry) di.next();+ entry = di.next();this.doms.addScore(entry.getKey(), ((Integer) entry.getValue()).intValue());}//long s1= System.currentTimeMillis(), sc = Math.max(1, s1 - s0);@@ -151,25 +151,17 @@ public class indexRWIEntryOrder extends kelondroAbstractOrder implements kelondrreturn Long.MAX_VALUE - r; // returns a reversed number: the lower the number the better the ranking. This is used for simple sorting with a TreeMap}-- public int compare(Object a, Object b) {- if ((a instanceof indexRWIEntry) && (b instanceof indexRWIEntry)) {- return compare((indexRWIEntry) a, (indexRWIEntry) b);- } else {- return super.compare(a, b);- }- }-- public int compare(indexRWIEntry a, indexRWIEntry b) {- return 0;- }public int compare(byte[] a, byte[] b) {- return compare(new indexRWIRowEntry(a), new indexRWIRowEntry(b));+ long ca = cardinal(new indexRWIRowEntry(a));+ long cb = cardinal(new indexRWIRowEntry(b));+ return (ca > cb) ? 1 : (ca < cb) ? -1 : 0;}public int compare(byte[] a, int aoffset, int alength, byte[] b, int boffset, int blength) {- return compare(new indexRWIRowEntry(a, aoffset, false), new indexRWIRowEntry(b, boffset, false));+ long ca = cardinal(new indexRWIRowEntry(a, aoffset, false));+ long cb = cardinal(new indexRWIRowEntry(b, boffset, false));+ return (ca > cb) ? 1 : (ca < cb) ? -1 : 0;}public String signature() {@@ -189,14 +181,14 @@ public class indexRWIEntryOrder extends kelondroAbstractOrder implements kelondrprivate indexRWIVarEntry entryMin, entryMax;private indexContainer container;private int start, end;- private HashMap doms;+ private HashMap<String, Integer> doms;private Integer int1;public minmaxfinder(indexContainer container, int start /*including*/, int end /*excluding*/) {this.container = container;this.start = start;this.end = end;- this.doms = new HashMap();+ this.doms = new HashMap<String, Integer>();this.int1 = new Integer(1);}@@ -224,7 +216,7 @@ public class indexRWIEntryOrder extends kelondroAbstractOrder implements kelondr}}- public HashMap domcount() {+ public HashMap<String, Integer> domcount() {return this.doms;}}diff --git a/source/de/anomic/kelondro/kelondroAbstractOrder.java b/source/de/anomic/kelondro/kelondroAbstractOrder.javaindex 10af99c7b..1bdaa086a 100644--- a/source/de/anomic/kelondro/kelondroAbstractOrder.java+++ b/source/de/anomic/kelondro/kelondroAbstractOrder.java@@ -45,6 +45,8 @@package de.anomic.kelondro;+import de.anomic.index.indexContainer;+public abstract class kelondroAbstractOrder implements kelondroOrder {protected byte[] zero = null;@@ -62,20 +64,50 @@ public abstract class kelondroAbstractOrder implements kelondroOrder {}public int compare(Object a, Object b) {- if ((a instanceof byte[]) && (b instanceof byte[])) {- return compare((byte[]) a, (byte[]) b);- } else if ((a instanceof kelondroNode) && (b instanceof kelondroNode)) {- return compare(((kelondroNode) a).getKey(), ((kelondroNode) b).getKey());- } else if ((a instanceof String) && (b instanceof String)) {- return compare(((String) a).getBytes(), ((String) b).getBytes());- } else if ((a instanceof kelondroRow.Entry) && (b instanceof kelondroRow.Entry)) {- return compare(((kelondroRow.Entry) a).getColBytes(0), ((kelondroRow.Entry) b).getColBytes(0));- } /* else if ((a instanceof Integer) && (b instanceof Integer)) {- return ((Integer) a).compareTo((Integer) b);- } */ else- throw new IllegalArgumentException("Object type or Object type combination not supported: a=" + a + "[" + ((a == null) ? "" : a.getClass().getName()) + "], b=" + b + "[" + ((b == null) ? "" : b.getClass().getName()) + "]");+ if ((a instanceof byte[]) && (b instanceof byte[])) {+ return compare((byte[]) a, (byte[]) b);+ }+ if ((a instanceof Integer) && (b instanceof Integer)) {+ return compare((Integer) a, (Integer) b);+ }+ if ((a instanceof String) && (b instanceof String)) {+ return compare(((String) a).getBytes(), ((String) b).getBytes());+ }+ if ((a instanceof kelondroNode) && (b instanceof kelondroNode)) {+ return compare((kelondroNode) a, (kelondroNode) b);+ }+ if ((a instanceof kelondroRow.Entry) && (b instanceof kelondroRow.Entry)) {+ return compare((kelondroRow.Entry) a, (kelondroRow.Entry) b);+ }+ Class<? extends Object> ac = a.getClass();+ Class<? extends Object> bc = b.getClass();+ if (ac.equals(bc)) {+ throw new UnsupportedOperationException("compare not implemented for this object type: " + ac);+ } else {+ throw new UnsupportedOperationException("compare must be applied to same object classes; here a = " + ac + ", b = " + bc);+ }}-++ public int compare(kelondroNode a, kelondroNode b) {+ return compare(a.getKey(), b.getKey());+ }++ public int compare(String a, String b) {+ return compare(a.getBytes(), b.getBytes());+ }++ public int compare(kelondroRow.Entry a, kelondroRow.Entry b) {+ return a.compareTo(b);+ }++ public int compare(indexContainer a, indexContainer b) {+ return compare(a.getWordHash(), b.getWordHash());+ }++ public int compare(Integer a, Integer b) {+ return a.compareTo(b);+ }+public byte[] zero() {return zero;}diff --git a/source/de/anomic/kelondro/kelondroAbstractRA.java b/source/de/anomic/kelondro/kelondroAbstractRA.javaindex 543b1a339..aab3df449 100644--- a/source/de/anomic/kelondro/kelondroAbstractRA.java+++ b/source/de/anomic/kelondro/kelondroAbstractRA.java@@ -197,14 +197,14 @@ abstract class kelondroAbstractRA implements kelondroRA {}}- public void writeMap(final Map map, final String comment) throws IOException {+ public void writeMap(final Map<String, String> map, final String comment) throws IOException {this.seek(0);- final Iterator iter = map.entrySet().iterator();- Map.Entry entry;+ final Iterator<Map.Entry<String, String>> iter = map.entrySet().iterator();+ Map.Entry<String, String> entry;final serverByteBuffer bb = new serverByteBuffer(map.size() * 40);bb.append("# ").append(comment).append("\r\n");while (iter.hasNext()) {- entry = (Map.Entry) iter.next();+ entry = iter.next();bb.append(entry.getKey()).append('=');if (entry.getValue() != null) { bb.append(entry.getValue()); }bb.append("\r\n");@@ -213,11 +213,11 @@ abstract class kelondroAbstractRA implements kelondroRA {write(bb.getBytes());}- public Map readMap() throws IOException {+ public Map<String, String> readMap() throws IOException {this.seek(0);byte[] b = readFully();BufferedReader br = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(b)));- final TreeMap map = new TreeMap();+ final TreeMap<String, String> map = new TreeMap<String, String>();String line;int pos;while ((line = br.readLine()) != null) { // very slow readLine????diff --git a/source/de/anomic/kelondro/kelondroAbstractRecords.java b/source/de/anomic/kelondro/kelondroAbstractRecords.javaindex f7d6b7a85..0cec224d6 100644--- a/source/de/anomic/kelondro/kelondroAbstractRecords.java+++ b/source/de/anomic/kelondro/kelondroAbstractRecords.java@@ -39,6 +39,7 @@ import java.util.TreeSet;import java.util.logging.Level;import java.util.logging.Logger;+import de.anomic.kelondro.kelondroRow.EntryIndex;import de.anomic.server.logging.serverLog;public abstract class kelondroAbstractRecords implements kelondroRecords {@@ -704,11 +705,11 @@ public abstract class kelondroAbstractRecords implements kelondroRecords {return USAGE.FREEC;}- protected final Set deletedHandles(long maxTime) throws kelondroException, IOException {+ protected final Set<kelondroHandle> deletedHandles(long maxTime) throws kelondroException, IOException {// initialize set with deleted nodes; the set contains Handle-Objects// this may last only the given maxInitTime// if the initTime is exceeded, the method throws an kelondroException- TreeSet markedDeleted = new TreeSet();+ TreeSet<kelondroHandle> markedDeleted = new TreeSet<kelondroHandle>();long timeLimit = (maxTime < 0) ? Long.MAX_VALUE : System.currentTimeMillis() + maxTime;long seekp;synchronized (USAGE) {@@ -851,8 +852,8 @@ public abstract class kelondroAbstractRecords implements kelondroRecords {System.out.println(" Recordsize : " + this.recordsize + " bytes");System.out.println("--");System.out.println("DELETED HANDLES");- Set dh = deletedHandles(-1);- Iterator dhi = dh.iterator();+ Set<kelondroHandle> dh = deletedHandles(-1);+ Iterator<kelondroHandle> dhi = dh.iterator();kelondroHandle h;while (dhi.hasNext()) {h = (kelondroHandle) dhi.next();@@ -866,15 +867,15 @@ public abstract class kelondroAbstractRecords implements kelondroRecords {}- public final Iterator contentRows(long maxInitTime) throws kelondroException {+ public final Iterator<EntryIndex> contentRows(long maxInitTime) throws kelondroException {return new contentRowIterator(maxInitTime);}- public final class contentRowIterator implements Iterator {+ public final class contentRowIterator implements Iterator<EntryIndex> {// iterator that iterates all kelondroRow.Entry-objects in the file- // all records that are marked as deleted are ommitted+ // all records that are marked as deleted are omitted- private Iterator nodeIterator;+ private Iterator<kelondroNode> nodeIterator;public contentRowIterator(long maxInitTime) {nodeIterator = contentNodes(maxInitTime);@@ -884,7 +885,7 @@ public abstract class kelondroAbstractRecords implements kelondroRecords {return nodeIterator.hasNext();}- public Object next() {+ public EntryIndex next() {try {kelondroNode n = (kelondroNode) nodeIterator.next();return row().newEntryIndex(n.getValueRow(), n.handle().index);@@ -899,21 +900,21 @@ public abstract class kelondroAbstractRecords implements kelondroRecords {}- protected final Iterator contentNodes(long maxInitTime) throws kelondroException {+ protected final Iterator<kelondroNode> contentNodes(long maxInitTime) throws kelondroException {// returns an iterator of Node-objects that are not marked as 'deleted'try {return new contentNodeIterator(maxInitTime);} catch (IOException e) {- return new HashSet().iterator();+ return new HashSet<kelondroNode>().iterator();}}- protected final class contentNodeIterator implements Iterator {+ protected final class contentNodeIterator implements Iterator<kelondroNode> {// iterator that iterates all Node-objects in the file// all records that are marked as deleted are ommitted// this is probably also the fastest way to iterate all objects- private Set markedDeleted;+ private Set<kelondroHandle> markedDeleted;private kelondroHandle pos;private byte[] bulk;private int bulksize;@@ -937,7 +938,7 @@ public abstract class kelondroAbstractRecords implements kelondroRecords {next = (hasNext0()) ? next0() : null;}- public Object next() {+ public kelondroNode next() {kelondroNode n = next;next = next0();return n;diff --git a/source/de/anomic/kelondro/kelondroAttrSeq.java b/source/de/anomic/kelondro/kelondroAttrSeq.javaindex 83efcd4b2..0191edbcb 100644--- a/source/de/anomic/kelondro/kelondroAttrSeq.java+++ b/source/de/anomic/kelondro/kelondroAttrSeq.java@@ -69,7 +69,7 @@ public class kelondroAttrSeq {// class objectsprivate File file;- private Map entries;+ private Map<String, Object> entries; // value may be of type String or of type Entryprotected Structure structure;private String name;private long created;@@ -79,19 +79,19 @@ public class kelondroAttrSeq {public kelondroAttrSeq(File file, boolean tree) throws IOException {this.file = file;- this.structure = null;+ this.structure = null;this.created = -1;this.name = "";- this.entries = (tree) ? (Map) new TreeMap() : (Map) new HashMap();+ this.entries = (tree) ? (Map<String, Object>) new TreeMap<String, Object>() : (Map<String, Object>) new HashMap<String, Object>();readAttrFile(file);}public kelondroAttrSeq(String name, String struct, boolean tree) {this.file = null;- this.structure = new Structure(struct);+ this.structure = new Structure(struct);this.created = System.currentTimeMillis();this.name = name;- this.entries = (tree) ? (Map) new TreeMap() : (Map) new HashMap();+ this.entries = (tree) ? (Map<String, Object>) new TreeMap<String, Object>() : (Map<String, Object>) new HashMap<String, Object>();}public void setLogger(Logger newLogger) {@@ -188,12 +188,12 @@ public class kelondroAttrSeq {sb.append("# Created=" + this.created); sb.append((char) 13); sb.append((char) 10);sb.append("# Structure=" + this.structure.toString()); sb.append((char) 13); sb.append((char) 10);sb.append("# ---"); sb.append((char) 13); sb.append((char) 10);- Iterator i = entries.entrySet().iterator();- Map.Entry entry;+ Iterator<Map.Entry<String, Object>> i = entries.entrySet().iterator();+ Map.Entry<String, Object> entry;String k;Object v;while (i.hasNext()) {- entry = (Map.Entry) i.next();+ entry = i.next();k = (String) entry.getKey();v = entry.getValue();sb.append(k); sb.append('=');@@ -208,15 +208,15 @@ public class kelondroAttrSeq {}}- public Iterator keys() {+ public Iterator<String> keys() {return entries.keySet().iterator();}public Entry newEntry(String pivot, boolean tree) {- return new Entry(pivot, new HashMap(), (tree) ? (Set) new TreeSet() : (Set) new HashSet());+ return new Entry(pivot, new HashMap<String, Long>(), (tree) ? (Set<String>) new TreeSet<String>() : (Set<String>) new HashSet<String>());}- public Entry newEntry(String pivot, HashMap props, Set seq) {+ public Entry newEntry(String pivot, HashMap<String, Long> props, Set<String> seq) {return new Entry(pivot, props, seq);}@@ -280,7 +280,7 @@ public class kelondroAttrSeq {// parse property part definition:p = structure.indexOf(",'|'");if (p < 0) return;- ArrayList l = new ArrayList();+ ArrayList<kelondroColumn> l = new ArrayList<kelondroColumn>();String attr = structure.substring(0, p);String seqs = structure.substring(p + 5);StringTokenizer st = new StringTokenizer(attr, ",");@@ -303,7 +303,7 @@ public class kelondroAttrSeq {// parse sequence definition:if (seqs.startsWith("*")) seqs = seqs.substring(1);- l = new ArrayList();+ l = new ArrayList<kelondroColumn>();st = new StringTokenizer(seqs, ",");while (st.hasMoreTokens()) {a = new kelondroColumn(st.nextToken());@@ -357,11 +357,11 @@ public class kelondroAttrSeq {}public class Entry {- String pivot;- HashMap attrs;- Set seq;+ String pivot;+ HashMap<String, Long> attrs;+ Set<String> seq;- public Entry(String pivot, HashMap attrs, Set seq) {+ public Entry(String pivot, HashMap<String, Long> attrs, Set<String> seq) {this.pivot = pivot;this.attrs = attrs;this.seq = seq;@@ -369,8 +369,8 @@ public class kelondroAttrSeq {public Entry(String pivot, String attrseq, boolean tree) {this.pivot = pivot;- attrs = new HashMap();- seq = (tree) ? (Set) new TreeSet() : (Set) new HashSet();+ attrs = new HashMap<String, Long>();+ seq = (tree) ? (Set<String>) new TreeSet<String>() : (Set<String>) new HashSet<String>();for (int i = 0; i < structure.prop_names.length; i++) {attrs.put(structure.prop_names[i], new Long(kelondroBase64Order.enhancedCoder.decodeLong(attrseq.substring(structure.prop_pos[i], structure.prop_pos[i] + structure.prop_len[i]))));}@@ -389,7 +389,7 @@ public class kelondroAttrSeq {}}- public HashMap getAttrs() {+ public HashMap<String, Long> getAttrs() {return attrs;}@@ -403,20 +403,20 @@ public class kelondroAttrSeq {attrs.put(key, new Long(attr));}- public Set getSeqSet() {+ public Set<String> getSeqSet() {return seq;}public kelondroRowCollection getSeqCollection() {kelondroRowCollection collection = new kelondroRowCollection(structure.seqrow, seq.size());- Iterator i = seq.iterator();+ Iterator<String> i = seq.iterator();while (i.hasNext()) {- collection.addUnique(structure.seqrow.newEntry(((String) i.next()).getBytes()));+ collection.addUnique(structure.seqrow.newEntry(i.next().getBytes()));}return collection;}- public void setSeq(Set seq) {+ public void setSeq(Set<String> seq) {this.seq = seq;}@@ -433,7 +433,7 @@ public class kelondroAttrSeq {sb.append(kelondroBase64Order.enhancedCoder.encodeLongSmart((val == null) ? 0 : val.longValue(), structure.prop_len[i]));}sb.append('|');- Iterator q = seq.iterator();+ Iterator<String> q = seq.iterator();//long[] seqattrs;while (q.hasNext()) {sb.append((String) q.next());@@ -461,13 +461,9 @@ public class kelondroAttrSeq {kelondroAttrSeq crp = new kelondroAttrSeq(from_file, true);//crp.toFile(new File(args[1]));kelondroAttrSeq cro = new kelondroAttrSeq(crp.name + "/Transcoded from " + crp.file.getName(), crp.structure.toString(), true);- Iterator i = crp.entries.keySet().iterator();- String key;- kelondroAttrSeq.Entry entry;+ Iterator<String> i = crp.entries.keySet().iterator();while (i.hasNext()) {- key = (String) i.next();- entry = crp.getEntry(key);- cro.putEntry(entry);+ cro.putEntry(crp.getEntry(i.next()));}cro.toFile(to_file);}diff --git a/source/de/anomic/kelondro/kelondroBase64Order.java b/source/de/anomic/kelondro/kelondroBase64Order.javaindex 654296791..355e6deab 100644--- a/source/de/anomic/kelondro/kelondroBase64Order.java+++ b/source/de/anomic/kelondro/kelondroBase64Order.java@@ -51,7 +51,7 @@ import java.util.Comparator;import de.anomic.server.logging.serverLog;-public class kelondroBase64Order extends kelondroAbstractOrder implements kelondroOrder, kelondroCoding, Comparator {+public class kelondroBase64Order extends kelondroAbstractOrder implements kelondroOrder, kelondroCoding, Comparator<Object> {protected static final char[] alpha_standard = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".toCharArray();protected static final char[] alpha_enhanced = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".toCharArray();diff --git a/source/de/anomic/kelondro/kelondroBufferedIOChunks.java b/source/de/anomic/kelondro/kelondroBufferedIOChunks.javaindex 373ac65d5..58cca00b5 100644--- a/source/de/anomic/kelondro/kelondroBufferedIOChunks.java+++ b/source/de/anomic/kelondro/kelondroBufferedIOChunks.java@@ -54,7 +54,7 @@ public final class kelondroBufferedIOChunks extends kelondroAbstractIOChunks impprotected kelondroRA ra;private long bufferMaxSize, bufferCurrSize;private long commitTimeout;- private TreeMap buffer;+ private TreeMap<Long, byte[]> buffer;private long lastCommit = 0;private static final int overhead = 40;@@ -66,7 +66,7 @@ public final class kelondroBufferedIOChunks extends kelondroAbstractIOChunks impthis.bufferMaxSize = buffer;this.bufferCurrSize = 0;this.commitTimeout = commitTimeout;- this.buffer = new TreeMap();+ this.buffer = new TreeMap<Long, byte[]>();this.lastCommit = System.currentTimeMillis();}@@ -134,15 +134,15 @@ public final class kelondroBufferedIOChunks extends kelondroAbstractIOChunks imppublic synchronized void commit() throws IOException {synchronized (buffer) {if (buffer.size() == 0) return;- Iterator i = buffer.entrySet().iterator();- Map.Entry entry = (Map.Entry) i.next();+ Iterator<Map.Entry<Long, byte[]>> i = buffer.entrySet().iterator();+ Map.Entry<Long, byte[]> entry = i.next();long lastPos = ((Long) entry.getKey()).longValue();byte[] lastChunk = (byte[]) entry.getValue();long nextPos;byte[] nextChunk, tmpChunk;synchronized (this.ra) {while (i.hasNext()) {- entry = (Map.Entry) i.next();+ entry = i.next();nextPos = ((Long) entry.getKey()).longValue();nextChunk = (byte[]) entry.getValue();if (lastPos + lastChunk.length == nextPos) {diff --git a/source/de/anomic/kelondro/kelondroBytesIntMap.java b/source/de/anomic/kelondro/kelondroBytesIntMap.javaindex 12614ac89..3637eac43 100644--- a/source/de/anomic/kelondro/kelondroBytesIntMap.java+++ b/source/de/anomic/kelondro/kelondroBytesIntMap.java@@ -196,6 +196,35 @@ public class kelondroBytesIntMap {return index0.size() + index1.size();}+ public synchronized kelondroCloneableIterator keys(boolean up, byte[] firstKey) throws IOException {+ // returns the key-iterator of the underlying kelondroIndex+ // col[0] = key+ // col[1] = integer as {b265}+ if ((index0 != null) && (index1 == null)) {+ // finish initialization phase+ if (index0 instanceof kelondroRowSet) {+ ((kelondroRowSet) index0).sort();+ ((kelondroRowSet) index0).uniq();+ }+ index1 = new kelondroRowSet(rowdef, 0);+ //System.out.println("finished initialization phase at size = " + index0.size() + " in rows");+ //assert consistencyAnalysis0() : "consistency problem: " + consistencyAnalysis();+ return index0.keys(up, firstKey);+ }+ assert (index1 != null);+ if (index0 == null) {+ //assert consistencyAnalysis0() : "consistency problem: " + consistencyAnalysis();+ return index1.keys(up, firstKey);+ }+ //assert consistencyAnalysis0() : "consistency problem: " + consistencyAnalysis();+ return new kelondroMergeIterator(+ index0.keys(up, firstKey),+ index1.keys(up, firstKey),+ rowdef.objectOrder,+ kelondroMergeIterator.simpleMerge,+ true);+ }+public synchronized kelondroCloneableIterator rows(boolean up, byte[] firstKey) throws IOException {// returns the row-iterator of the underlying kelondroIndex// col[0] = keydiff --git a/source/de/anomic/kelondro/kelondroCache.java b/source/de/anomic/kelondro/kelondroCache.javaindex 636aae599..2c1dd2b2d 100644--- a/source/de/anomic/kelondro/kelondroCache.java+++ b/source/de/anomic/kelondro/kelondroCache.java@@ -49,7 +49,7 @@ public class kelondroCache implements kelondroIndex {// furthermore, if we access a kelondroFlexTable, we can use the ram index of the underlying index// static object tracker; stores information about object cache usage- private static final TreeMap objectTracker = new TreeMap();+ private static final TreeMap<String, kelondroCache> objectTracker = new TreeMap<String, kelondroCache>();private static long memStopGrow = 10000000; // a limit for the node cache to stop growing if less than this memory amount is availableprivate static long memStartShrink = 6000000; // a limit for the node cache to start with shrinking if less than this memory amount is available@@ -119,12 +119,12 @@ public class kelondroCache implements kelondroIndex {return memStartShrink ;}- public static final Iterator filenames() {+ public static final Iterator<String> filenames() {// iterates string objects; all file names from record trackerreturn objectTracker.keySet().iterator();}- public static final Map memoryStats(String filename) {+ public static final Map<String, String> memoryStats(String filename) {// returns a map for each file in the tracker;// the map represents properties for each record oobjects,// i.e. for cache memory allocation@@ -132,9 +132,9 @@ public class kelondroCache implements kelondroIndex {return theObjectsCache.memoryStats();}- private final Map memoryStats() {+ private final Map<String, String> memoryStats() {// returns statistical data about this object- HashMap map = new HashMap();+ HashMap<String, String> map = new HashMap<String, String>();map.put("objectHitChunkSize", (readHitCache == null) ? "0" : Integer.toString(readHitCache.rowdef.objectsize));map.put("objectHitCacheCount", (readHitCache == null) ? "0" : Integer.toString(readHitCache.size()));map.put("objectHitMem", (readHitCache == null) ? "0" : Integer.toString((int) (readHitCache.rowdef.objectsize * readHitCache.size() * kelondroRowCollection.growfactor)));@@ -166,9 +166,9 @@ public class kelondroCache implements kelondroIndex {private void flushUnique() throws IOException {if (writeBufferUnique == null) return;synchronized (writeBufferUnique) {- Iterator i = writeBufferUnique.rows();+ Iterator<kelondroRow.Entry> i = writeBufferUnique.rows();while (i.hasNext()) {- this.index.addUnique((kelondroRow.Entry) i.next());+ this.index.addUnique(i.next());this.cacheFlush++;}writeBufferUnique.clear();@@ -180,10 +180,10 @@ public class kelondroCache implements kelondroIndex {if (maxcount == 0) return;synchronized (writeBufferUnique) {kelondroRowCollection delete = new kelondroRowCollection(this.keyrow, maxcount);- Iterator i = writeBufferUnique.rows();+ Iterator<kelondroRow.Entry> i = writeBufferUnique.rows();kelondroRow.Entry row;while ((i.hasNext()) && (maxcount-- > 0)) {- row = (kelondroRow.Entry) i.next();+ row = i.next();delete.add(row.getPrimaryKeyBytes());this.index.addUnique(row);this.cacheFlush++;@@ -200,9 +200,9 @@ public class kelondroCache implements kelondroIndex {private void flushDoubles() throws IOException {if (writeBufferDoubles == null) return;synchronized (writeBufferDoubles) {- Iterator i = writeBufferDoubles.rows();+ Iterator<kelondroRow.Entry> i = writeBufferDoubles.rows();while (i.hasNext()) {- this.index.put((kelondroRow.Entry) i.next());+ this.index.put(i.next());this.cacheFlush++;}writeBufferDoubles.clear();@@ -214,10 +214,10 @@ public class kelondroCache implements kelondroIndex {if (maxcount == 0) return;synchronized (writeBufferDoubles) {kelondroRowCollection delete = new kelondroRowCollection(this.keyrow, maxcount);- Iterator i = writeBufferDoubles.rows();+ Iterator<kelondroRow.Entry> i = writeBufferDoubles.rows();kelondroRow.Entry row;while ((i.hasNext()) && (maxcount-- > 0)) {- row = (kelondroRow.Entry) i.next();+ row = i.next();delete.add(row.getPrimaryKeyBytes());this.index.addUnique(row);this.cacheFlush++;@@ -349,14 +349,14 @@ public class kelondroCache implements kelondroIndex {}}- public synchronized void putMultiple(List rows) throws IOException {- Iterator i = rows.iterator();- while (i.hasNext()) put ((Entry) i.next());+ public synchronized void putMultiple(List<Entry> rows) throws IOException {+ Iterator<Entry> i = rows.iterator();+ while (i.hasNext()) put(i.next());}- public synchronized void putMultiple(List rows, Date entryDate) throws IOException {- Iterator i = rows.iterator();- while (i.hasNext()) put ((Entry) i.next(), entryDate);+ public synchronized void putMultiple(List<Entry> rows, Date entryDate) throws IOException {+ Iterator<Entry> i = rows.iterator();+ while (i.hasNext()) put(i.next(), entryDate);}public synchronized Entry put(Entry row) throws IOException {@@ -531,8 +531,8 @@ public class kelondroCache implements kelondroIndex {}}- public synchronized void addUniqueMultiple(List rows) throws IOException {- Iterator i = rows.iterator();+ public synchronized void addUniqueMultiple(List<Entry> rows) throws IOException {+ Iterator<Entry> i = rows.iterator();while (i.hasNext()) addUnique((Entry) i.next());}@@ -620,7 +620,12 @@ public class kelondroCache implements kelondroIndex {return index.row();}- public synchronized kelondroCloneableIterator rows(boolean up, byte[] firstKey) throws IOException {+ public synchronized kelondroCloneableIterator<byte[]> keys(boolean up, byte[] firstKey) throws IOException {+ flushUnique();+ return index.keys(up, firstKey);+ }++ public synchronized kelondroCloneableIterator<kelondroRow.Entry> rows(boolean up, byte[] firstKey) throws IOException {flushUnique();return index.rows(up, firstKey);}diff --git a/source/de/anomic/kelondro/kelondroCachedRA.java b/source/de/anomic/kelondro/kelondroCachedRA.javaindex 7a005beaa..4cd74087e 100644--- a/source/de/anomic/kelondro/kelondroCachedRA.java+++ b/source/de/anomic/kelondro/kelondroCachedRA.java@@ -50,7 +50,7 @@ public class kelondroCachedRA extends kelondroAbstractRA implements kelondroRA {protected kelondroRA ra;protected kelondroMScoreCluster cacheScore;- protected HashMap cacheMemory;+ protected HashMap<Integer, byte[]> cacheMemory;private int cacheMaxElements;private int cacheElementSize;private long seekpos;@@ -58,7 +58,7 @@ public class kelondroCachedRA extends kelondroAbstractRA implements kelondroRA {public kelondroCachedRA(kelondroRA ra, int cachesize, int elementsize) {this.ra = ra;this.name = ra.name();- this.cacheMemory = new HashMap();+ this.cacheMemory = new HashMap<Integer, byte[]>();this.cacheScore = new kelondroMScoreCluster();this.cacheElementSize = elementsize;this.cacheMaxElements = cachesize / cacheElementSize;@@ -90,7 +90,7 @@ public class kelondroCachedRA extends kelondroAbstractRA implements kelondroRA {if (cache == null) {if (cacheMemory.size() >= cacheMaxElements) {// delete elements in buffer if buffer too big- Iterator it = cacheScore.scores(true);+ Iterator<Object> it = cacheScore.scores(true);Integer element = (Integer) it.next();writeCache((byte[]) cacheMemory.get(element), element.intValue());cacheMemory.remove(element);@@ -182,7 +182,7 @@ public class kelondroCachedRA extends kelondroAbstractRA implements kelondroRA {public void close() throws IOException {// write all unwritten buffersif (cacheMemory == null) return;- Iterator it = cacheScore.scores(true);+ Iterator<Object> it = cacheScore.scores(true);while (it.hasNext()) {Integer element = (Integer) it.next();writeCache((byte[]) cacheMemory.get(element), element.intValue());diff --git a/source/de/anomic/kelondro/kelondroCachedRecords.java b/source/de/anomic/kelondro/kelondroCachedRecords.javaindex 8d884189f..92be672cb 100644--- a/source/de/anomic/kelondro/kelondroCachedRecords.java+++ b/source/de/anomic/kelondro/kelondroCachedRecords.java@@ -41,7 +41,7 @@ public class kelondroCachedRecords extends kelondroAbstractRecords implements keprivate static final int element_in_cache = 4; // for kelondroCollectionObjectMap: 4; for HashMap: 52// static supervision objects: recognize and coordinate all activites- private static TreeMap recordTracker = new TreeMap(); // a String/filename - kelondroTray mapping+ private static TreeMap<String, kelondroCachedRecords> recordTracker = new TreeMap<String, kelondroCachedRecords>();private static long memStopGrow = 10000000; // a limit for the node cache to stop growing if less than this memory amount is availableprivate static long memStartShrink = 6000000; // a limit for the node cache to start with shrinking if less than this memory amount is available@@ -93,7 +93,7 @@ public class kelondroCachedRecords extends kelondroAbstractRecords implements kelong stop = System.currentTimeMillis() + preloadTime;int count = 0;try {- Iterator i = contentNodes(preloadTime);+ Iterator<kelondroNode> i = contentNodes(preloadTime);CacheNode n;while ((System.currentTimeMillis() < stop) && (cacheGrowStatus() == 2) && (i.hasNext())) {n = (CacheNode) i.next();@@ -143,12 +143,12 @@ public class kelondroCachedRecords extends kelondroAbstractRecords implements kereturn memStartShrink ;}- public static final Iterator filenames() {+ public static final Iterator<String> filenames() {// iterates string objects; all file names from record trackerreturn recordTracker.keySet().iterator();}- public static final Map memoryStats(String filename) {+ public static final Map<String, String> memoryStats(String filename) {// returns a map for each file in the tracker;// the map represents properties for each record oobjects,// i.e. for cache memory allocation@@ -156,10 +156,10 @@ public class kelondroCachedRecords extends kelondroAbstractRecords implements kereturn theRecord.memoryStats();}- private final Map memoryStats() {+ private final Map<String, String> memoryStats() {// returns statistical data about this objectif (cacheHeaders == null) return null;- HashMap map = new HashMap();+ HashMap<String, String> map = new HashMap<String, String>();map.put("nodeChunkSize", Integer.toString(this.headchunksize + element_in_cache));map.put("nodeCacheCount", Integer.toString(cacheHeaders.size()));map.put("nodeCacheMem", Integer.toString(cacheHeaders.size() * (this.headchunksize + element_in_cache)));@@ -202,10 +202,10 @@ public class kelondroCachedRecords extends kelondroAbstractRecords implements ke} else {System.out.println("### cache report: " + cacheHeaders.size() + " entries");- Iterator i = cacheHeaders.rows();+ Iterator<kelondroRow.Entry> i = cacheHeaders.rows();kelondroRow.Entry entry;while (i.hasNext()) {- entry = (kelondroRow.Entry) i.next();+ entry = i.next();// print from cacheSystem.out.print("#C ");@@ -260,7 +260,7 @@ public class kelondroCachedRecords extends kelondroAbstractRecords implements keprintCache();System.out.println("--");System.out.println("NODES");- Iterator i = new contentNodeIterator(-1);+ Iterator<kelondroNode> i = new contentNodeIterator(-1);kelondroNode n;while (i.hasNext()) {n = (kelondroNode) i.next();diff --git a/source/de/anomic/kelondro/kelondroCloneableIterator.java b/source/de/anomic/kelondro/kelondroCloneableIterator.javaindex ab450c77b..e9602c8db 100644--- a/source/de/anomic/kelondro/kelondroCloneableIterator.java+++ b/source/de/anomic/kelondro/kelondroCloneableIterator.java@@ -28,10 +28,10 @@ package de.anomic.kelondro;import java.util.Iterator;-public interface kelondroCloneableIterator extends Iterator {+public interface kelondroCloneableIterator<E> extends Iterator<E> {// clone the iterator using a modifier// the modifier can be i.e. a re-start position- public Object /* instance of kelondroCloneableIterator*/ clone(Object modifier);+ public kelondroCloneableIterator<E> clone(Object modifier);}diff --git a/source/de/anomic/kelondro/kelondroCloneableMapIterator.java b/source/de/anomic/kelondro/kelondroCloneableMapIterator.javaindex dd11c16cd..1ee939bfe 100644--- a/source/de/anomic/kelondro/kelondroCloneableMapIterator.java+++ b/source/de/anomic/kelondro/kelondroCloneableMapIterator.java@@ -30,15 +30,15 @@ package de.anomic.kelondro;import java.util.Iterator;import java.util.TreeMap;-public class kelondroCloneableMapIterator implements kelondroCloneableIterator {+public class kelondroCloneableMapIterator<E> implements kelondroCloneableIterator<E> {- TreeMap map;- Object next, last;+ TreeMap<E, ?> map;+ E next, last;Object start;- Iterator iter;+ Iterator<E> iter;- public kelondroCloneableMapIterator(TreeMap map, Object start) {+ public kelondroCloneableMapIterator(TreeMap<E, ?> map, E start) {// map must contain eiter a byte[]/Object or a String/Object mapping.// start must be either of type byte[] or String// this iterator iterates then only the key elements of the map@@ -54,7 +54,8 @@ public class kelondroCloneableMapIterator implements kelondroCloneableIterator {this.last = null;}- public Object clone(Object modifier) {+ @SuppressWarnings("unchecked")+ public kelondroCloneableMapIterator<E> clone(Object modifier) {return new kelondroCloneableMapIterator(map, modifier);}@@ -62,7 +63,7 @@ public class kelondroCloneableMapIterator implements kelondroCloneableIterator {return this.next != null;}- public Object next() {+ public E next() {// returns key-elements, not entry-elementsthis.last = this.next;if (this.iter.hasNext()) {diff --git a/source/de/anomic/kelondro/kelondroCollectionIndex.java b/source/de/anomic/kelondro/kelondroCollectionIndex.javaindex 01099734b..733a47a77 100644--- a/source/de/anomic/kelondro/kelondroCollectionIndex.java+++ b/source/de/anomic/kelondro/kelondroCollectionIndex.java@@ -44,6 +44,7 @@ import java.util.TimeZone;import java.util.TreeMap;import de.anomic.index.indexContainer;+import de.anomic.kelondro.kelondroRow.EntryIndex;import de.anomic.server.serverCodings;import de.anomic.server.serverFileUtils;import de.anomic.server.serverMemory;@@ -60,7 +61,7 @@ public class kelondroCollectionIndex {private String filenameStub;private File commonsPath;private int loadfactor;- private Map arrays; // Map of (partitionNumber"-"chunksize)/kelondroFixedWidthArray - Objects+ private Map<String, kelondroFixedWidthArray> arrays; // Map of (partitionNumber"-"chunksize)/kelondroFixedWidthArray - Objectsprivate kelondroRow payloadrow; // definition of the payload (chunks inside the collections)private int maxPartitions; // this is the maxmimum number of array files@@ -126,7 +127,7 @@ public class kelondroCollectionIndex {serverLog.logFine("STARTUP", "OPENING COLLECTION INDEX");// open index and array files- this.arrays = new HashMap(); // all entries will be dynamically created with getArray()+ this.arrays = new HashMap<String, kelondroFixedWidthArray>(); // all entries will be dynamically created with getArray()index = openIndexFile(path, filenameStub, indexOrder, preloadTime, loadfactor, rowdef, 0);openAllArrayFiles(false, indexOrder);} else {@@ -155,7 +156,7 @@ public class kelondroCollectionIndex {index = new kelondroFlexTable(path, filenameStub + ".index", preloadTime, indexRow(keyLength, indexOrder), initialSpace, true);// open array files- this.arrays = new HashMap(); // all entries will be dynamically created with getArray()+ this.arrays = new HashMap<String, kelondroFixedWidthArray>(); // all entries will be dynamically created with getArray()openAllArrayFiles(true, indexOrder);}}@@ -189,7 +190,7 @@ public class kelondroCollectionIndex {// loop over all elements in array and create index entry for each rowkelondroRow.EntryIndex aentry;kelondroRow.Entry ientry;- Iterator ei = array.contentRows(-1);+ Iterator<EntryIndex> ei = array.contentRows(-1);byte[] key;long start = System.currentTimeMillis();long lastlog = start;@@ -229,7 +230,7 @@ public class kelondroCollectionIndex {// save/check property file for this arrayFile propfile = propertyFile(path, filenameStub, loadfactor, rowdef.objectsize);- Map props = new HashMap();+ Map<String, String> props = new HashMap<String, String>();if (propfile.exists()) {props = serverFileUtils.loadHashMap(propfile);String stored_rowdef = (String) props.get("rowdef");@@ -369,25 +370,24 @@ public class kelondroCollectionIndex {// after calling this method there must be a index.put(indexrow);}- private ArrayList array_add_multiple(TreeMap array_add_map, int serialNumber, int chunkSize) throws IOException {+ private ArrayList<kelondroRow.Entry> array_add_multiple(TreeMap<Integer, ArrayList<Object[]>> array_add_map, int serialNumber, int chunkSize) throws IOException {// returns a List of kelondroRow.Entry entries for indexrow storage- Map.Entry entry;- Iterator i = array_add_map.entrySet().iterator();- Iterator j;- ArrayList actionList;+ Map.Entry<Integer, ArrayList<Object[]>> entry;+ Iterator<Map.Entry<Integer, ArrayList<Object[]>>> i = array_add_map.entrySet().iterator();+ Iterator<Object[]> j;+ ArrayList<Object[]> actionList;int partitionNumber;kelondroFixedWidthArray array;Object[] objs;byte[] key;kelondroRowCollection collection;kelondroRow.Entry indexrow;- ArrayList indexrows = new ArrayList();+ ArrayList<kelondroRow.Entry> indexrows = new ArrayList<kelondroRow.Entry>();while (i.hasNext()) {- entry = (Map.Entry) i.next();- actionList = (ArrayList) entry.getValue();- partitionNumber = ((Integer) entry.getKey()).intValue();+ entry = i.next();+ actionList = entry.getValue();+ partitionNumber = entry.getKey();array = getArray(partitionNumber, serialNumber, index.row().objectOrder, chunkSize);-j = actionList.iterator();while (j.hasNext()) {objs = (Object[]) j.next();@@ -441,28 +441,29 @@ public class kelondroCollectionIndex {// after calling this method there must be a index.put(indexrow);}- private ArrayList array_replace_multiple(TreeMap array_replace_map, int serialNumber, int chunkSize) throws IOException {- Map.Entry entry, e;- Iterator i = array_replace_map.entrySet().iterator();- Iterator j;- TreeMap actionMap;+ private ArrayList<kelondroRow.Entry> array_replace_multiple(TreeMap<Integer, TreeMap<Integer, Object[]>> array_replace_map, int serialNumber, int chunkSize) throws IOException {+ Map.Entry<Integer, TreeMap<Integer, Object[]>> entry;+ Map.Entry<Integer, Object[]> e;+ Iterator<Map.Entry<Integer, TreeMap<Integer, Object[]>>> i = array_replace_map.entrySet().iterator();+ Iterator<Map.Entry<Integer, Object[]>> j;+ TreeMap<Integer, Object[]> actionMap;int partitionNumber;kelondroFixedWidthArray array;- ArrayList indexrows = new ArrayList();+ ArrayList<kelondroRow.Entry> indexrows = new ArrayList<kelondroRow.Entry>();Object[] objs;int rowNumber;byte[] key;kelondroRowCollection collection;kelondroRow.Entry indexrow;while (i.hasNext()) {- entry = (Map.Entry) i.next();- actionMap = (TreeMap) entry.getValue();+ entry = i.next();+ actionMap = entry.getValue();partitionNumber = ((Integer) entry.getKey()).intValue();array = getArray(partitionNumber, serialNumber, index.row().objectOrder, chunkSize);j = actionMap.entrySet().iterator();while (j.hasNext()) {- e = (Map.Entry) j.next();+ e = j.next();rowNumber = ((Integer) e.getKey()).intValue();objs = (Object[]) e.getValue();key = (byte[]) objs[0];@@ -536,19 +537,19 @@ public class kelondroCollectionIndex {index.put(indexrow); // write modified indexrow}- public synchronized void mergeMultiple(List /* of indexContainer */ containerList) throws IOException, kelondroOutOfLimitsException {+ public synchronized void mergeMultiple(List<indexContainer> containerList) throws IOException, kelondroOutOfLimitsException {// merge a bulk of index containers// this method should be used to optimize the R/W head path length// separate the list in two halves:// - containers that do not exist yet in the collection// - containers that do exist in the collection and must be merged- Iterator i = containerList.iterator();+ Iterator<indexContainer> i = containerList.iterator();indexContainer container;byte[] key;- ArrayList newContainer = new ArrayList();- TreeMap existingContainer = new TreeMap(); // a mapping from Integer (partition) to a TreeMap (mapping from index to object triple)- TreeMap containerMap; // temporary map; mapping from index position to object triple with {key, container, indexrow}+ ArrayList<Object[]> newContainer = new ArrayList<Object[]>();+ TreeMap<Integer, TreeMap<Integer, Object[]>> existingContainer = new TreeMap<Integer, TreeMap<Integer, Object[]>>(); // a mapping from Integer (partition) to a TreeMap (mapping from index to object triple)+ TreeMap<Integer, Object[]> containerMap; // temporary map; mapping from index position to object triple with {key, container, indexrow}kelondroRow.Entry indexrow;int oldrownumber1; // index of the entry in arrayint oldPartitionNumber1; // points to array file@@ -565,8 +566,8 @@ public class kelondroCollectionIndex {} else {oldrownumber1 = (int) indexrow.getColLong(idx_col_indexpos);oldPartitionNumber1 = (int) indexrow.getColByte(idx_col_clusteridx);- containerMap = (TreeMap) existingContainer.get(new Integer(oldPartitionNumber1));- if (containerMap == null) containerMap = new TreeMap();+ containerMap = existingContainer.get(new Integer(oldPartitionNumber1));+ if (containerMap == null) containerMap = new TreeMap<Integer, Object[]>();containerMap.put(new Integer(oldrownumber1), new Object[]{key, container, indexrow});existingContainer.put(new Integer(oldPartitionNumber1), containerMap);}@@ -576,22 +577,22 @@ public class kelondroCollectionIndex {// this is done in such a way, that there is a optimized path for the R/W head// merge existing containers- Map.Entry tripleEntry;+ Map.Entry<Integer, Object[]> tripleEntry;Object[] record;- ArrayList indexrows_existing = new ArrayList();+ ArrayList<kelondroRow.Entry> indexrows_existing = new ArrayList<kelondroRow.Entry>();kelondroRowCollection collection;- TreeMap array_replace_map = new TreeMap();- TreeMap array_add_map = new TreeMap();- ArrayList actionList;- TreeMap actionMap;+ TreeMap<Integer, TreeMap<Integer, Object[]>> array_replace_map = new TreeMap<Integer, TreeMap<Integer, Object[]>>();+ TreeMap<Integer, ArrayList<Object[]>> array_add_map = new TreeMap<Integer, ArrayList<Object[]>>();+ ArrayList<Object[]> actionList;+ TreeMap<Integer, Object[]> actionMap;//boolean madegc = false;//System.out.println("DEBUG existingContainer: " + existingContainer.toString());while (existingContainer.size() > 0) {oldPartitionNumber1 = ((Integer) existingContainer.lastKey()).intValue();- containerMap = (TreeMap) existingContainer.remove(new Integer(oldPartitionNumber1));- Iterator j = containerMap.entrySet().iterator();+ containerMap = existingContainer.remove(new Integer(oldPartitionNumber1));+ Iterator<Map.Entry<Integer, Object[]>> j = containerMap.entrySet().iterator();while (j.hasNext()) {- tripleEntry = (Map.Entry) j.next();+ tripleEntry = j.next();oldrownumber1 = ((Integer) tripleEntry.getKey()).intValue();record = (Object[]) tripleEntry.getValue(); // {byte[], indexContainer, kelondroRow.Entry}@@ -628,8 +629,8 @@ public class kelondroCollectionIndex {// see if we need new space or if we can overwrite the old spaceif (oldPartitionNumber == newPartitionNumber) {- actionMap = (TreeMap) array_replace_map.get(new Integer(oldPartitionNumber));- if (actionMap == null) actionMap = new TreeMap();+ actionMap = array_replace_map.get(new Integer(oldPartitionNumber));+ if (actionMap == null) actionMap = new TreeMap<Integer, Object[]>();actionMap.put(new Integer(oldrownumber), new Object[]{key, collection, indexrow});array_replace_map.put(new Integer(oldPartitionNumber), actionMap);/*@@ -644,8 +645,8 @@ public class kelondroCollectionIndex {oldPartitionNumber, oldSerialNumber, this.payloadrow.objectsize,oldrownumber);- actionList = (ArrayList) array_add_map.get(new Integer(newPartitionNumber));- if (actionList == null) actionList = new ArrayList();+ actionList = array_add_map.get(new Integer(newPartitionNumber));+ if (actionList == null) actionList = new ArrayList<Object[]>();actionList.add(new Object[]{key, collection, indexrow});array_add_map.put(new Integer(newPartitionNumber), actionList);/*@@ -660,9 +661,9 @@ public class kelondroCollectionIndex {if (serverMemory.available() < minMem()) {// emergency flushindexrows_existing.addAll(array_replace_multiple(array_replace_map, 0, this.payloadrow.objectsize));- array_replace_map = new TreeMap(); // delete references+ array_replace_map = new TreeMap<Integer, TreeMap<Integer, Object[]>>(); // delete referencesindexrows_existing.addAll(array_add_multiple(array_add_map, 0, this.payloadrow.objectsize));- array_add_map = new TreeMap(); // delete references+ array_add_map = new TreeMap<Integer, ArrayList<Object[]>>(); // delete references//if (!madegc) {// prevent that this flush is made again even when there is enough memoryserverMemory.gc(10000, "kelendroCollectionIndex.mergeMultiple(...)"); // thq@@ -675,15 +676,15 @@ public class kelondroCollectionIndex {// finallly flush the collected collectionsindexrows_existing.addAll(array_replace_multiple(array_replace_map, 0, this.payloadrow.objectsize));- array_replace_map = new TreeMap(); // delete references+ array_replace_map = new TreeMap<Integer, TreeMap<Integer, Object[]>>(); // delete referencesindexrows_existing.addAll(array_add_multiple(array_add_map, 0, this.payloadrow.objectsize));- array_add_map = new TreeMap(); // delete references+ array_add_map = new TreeMap<Integer, ArrayList<Object[]>>(); // delete references// write new containers- i = newContainer.iterator();- ArrayList indexrows_new = new ArrayList();- while (i.hasNext()) {- record = (Object[]) i.next(); // {byte[], indexContainer}+ Iterator<Object[]> k = newContainer.iterator();+ ArrayList<kelondroRow.Entry> indexrows_new = new ArrayList<kelondroRow.Entry>();+ while (k.hasNext()) {+ record = k.next(); // {byte[], indexContainer}key = (byte[]) record[0];collection = (indexContainer) record[1];indexrow = array_new(key, collection); // modifies indexrow@@ -771,12 +772,12 @@ public class kelondroCollectionIndex {long t1 = 0, t2 = 0;// delete some entries, which are bad rated- Iterator i = collection.rows();+ Iterator<kelondroRow.Entry> i = collection.rows();kelondroRow.Entry entry;byte[] ref;t1 = System.currentTimeMillis();while (i.hasNext()) {- entry = (kelondroRow.Entry) i.next();+ entry = i.next();ref = entry.getColBytes(0);if ((ref.length != 12) || (!yacyURL.probablyRootURL(new String(ref)))) {t2 = System.currentTimeMillis();@@ -833,7 +834,7 @@ public class kelondroCollectionIndex {}- public synchronized int remove(byte[] key, Set removekeys) throws IOException, kelondroOutOfLimitsException {+ public synchronized int remove(byte[] key, Set<byte[]> removekeys) throws IOException, kelondroOutOfLimitsException {if ((removekeys == null) || (removekeys.size() == 0)) return 0;@@ -856,12 +857,9 @@ public class kelondroCollectionIndex {kelondroRowSet oldcollection = getwithparams(indexrow, oldchunksize, oldchunkcount, oldPartitionNumber, oldrownumber, serialNumber, false);// remove the keys from the set- Iterator i = removekeys.iterator();- Object k;+ Iterator<byte[]> i = removekeys.iterator();while (i.hasNext()) {- k = i.next();- if ((k instanceof byte[]) && (oldcollection.remove((byte[]) k, false) != null)) removed++;- if ((k instanceof String) && (oldcollection.remove(((String) k).getBytes(), false) != null)) removed++;+ if (oldcollection.remove(i.next(), false) != null) removed++;}oldcollection.sort();oldcollection.trim(false);@@ -983,7 +981,7 @@ public class kelondroCollectionIndex {return collection;}- public synchronized Iterator keycollections(byte[] startKey, byte[] secondKey, boolean rot) {+ public synchronized Iterator<Object[]> keycollections(byte[] startKey, byte[] secondKey, boolean rot) {// returns an iteration of {byte[], kelondroRowSet} Objectstry {return new keycollectionIterator(startKey, secondKey, rot);@@ -993,21 +991,21 @@ public class kelondroCollectionIndex {}}- public class keycollectionIterator implements Iterator {+ public class keycollectionIterator implements Iterator<Object[]> {- Iterator indexRowIterator;+ Iterator<kelondroRow.Entry> indexRowIterator;public keycollectionIterator(byte[] startKey, byte[] secondKey, boolean rot) throws IOException {// iterator of {byte[], kelondroRowSet} Objects- kelondroCloneableIterator i = index.rows(true, startKey);- indexRowIterator = (rot) ? new kelondroRotateIterator(i, secondKey) : i;+ kelondroCloneableIterator<kelondroRow.Entry> i = index.rows(true, startKey);+ indexRowIterator = (rot) ? new kelondroRotateIterator<kelondroRow.Entry>(i, secondKey) : i;}public boolean hasNext() {return indexRowIterator.hasNext();}- public Object next() {+ public Object[] next() {kelondroRow.Entry indexrow = (kelondroRow.Entry) indexRowIterator.next();assert (indexrow != null);if (indexrow == null) return null;@@ -1027,10 +1025,8 @@ public class kelondroCollectionIndex {public synchronized void close() {this.index.close();- Iterator i = arrays.values().iterator();- while (i.hasNext()) {- ((kelondroFixedWidthArray) i.next()).close();- }+ Iterator<kelondroFixedWidthArray> i = arrays.values().iterator();+ while (i.hasNext()) i.next().close();}public static void main(String[] args) {diff --git a/source/de/anomic/kelondro/kelondroDyn.java b/source/de/anomic/kelondro/kelondroDyn.javaindex 3e66863fa..4a0c6fad8 100644--- a/source/de/anomic/kelondro/kelondroDyn.java+++ b/source/de/anomic/kelondro/kelondroDyn.java@@ -150,25 +150,26 @@ public class kelondroDyn {return new String(rawKey, 0, n + 1);}- public class dynKeyIterator implements kelondroCloneableIterator {- // the iterator iterates all keys, which are byte[] objects- kelondroCloneableIterator ri;+ public class dynKeyIterator implements kelondroCloneableIterator<String> {+ // the iterator iterates all keys+ kelondroCloneableIterator<kelondroRow.Entry> ri;String nextKey;- public dynKeyIterator(kelondroCloneableIterator iter) {+ public dynKeyIterator(kelondroCloneableIterator<kelondroRow.Entry> iter) {ri = iter;nextKey = n();}-- public Object clone(Object modifier) {- return new dynKeyIterator((kelondroCloneableIterator) ri.clone(modifier));- }++ @SuppressWarnings("unchecked")+ public dynKeyIterator clone(Object modifier) {+ return new dynKeyIterator(ri.clone(modifier));+ }public boolean hasNext() {return nextKey != null;}- public Object next() {+ public String next() {String result = nextKey;nextKey = n();return origKey(result.getBytes());@@ -202,11 +203,11 @@ public class kelondroDyn {}}- public synchronized kelondroCloneableIterator dynKeys(boolean up, boolean rotating) throws IOException {+ public synchronized kelondroCloneableIterator<String> dynKeys(boolean up, boolean rotating) throws IOException {// iterates only the keys of the Nodes// enumerated objects are of type StringdynKeyIterator i = new dynKeyIterator(index.rows(up, null));- if (rotating) return new kelondroRotateIterator(i, null); else return i;+ if (rotating) return new kelondroRotateIterator<String>(i, null); else return i;}public synchronized dynKeyIterator dynKeys(boolean up, byte[] firstKey) throws IOException {@@ -471,9 +472,9 @@ public class kelondroDyn {try {kelondroDyn kd = new kelondroDyn(new File(args[0]), true, true, 0, 4 ,100, '_', kelondroNaturalOrder.naturalOrder, false, false, true);System.out.println(kd.sizeDyn() + " elements in DB");- Iterator i = kd.dynKeys(true, false);+ Iterator<String> i = kd.dynKeys(true, false);while (i.hasNext())- System.out.println((String) i.next());+ System.out.println(i.next());kd.close();} catch (IOException e) {e.printStackTrace();@@ -500,7 +501,7 @@ public class kelondroDyn {public static int countElementsDyn(kelondroDyn t) {int count = 0;try {- Iterator iter = t.dynKeys(true, false);+ Iterator<String> iter = t.dynKeys(true, false);while (iter.hasNext()) {count++; if (iter.next() == null) System.out.println("ERROR! null element found");}return count;} catch (IOException e) {diff --git a/source/de/anomic/kelondro/kelondroFlexSplitTable.java b/source/de/anomic/kelondro/kelondroFlexSplitTable.javaindex 0a0b6f56a..b4d24f570 100644--- a/source/de/anomic/kelondro/kelondroFlexSplitTable.java+++ b/source/de/anomic/kelondro/kelondroFlexSplitTable.java@@ -290,6 +290,15 @@ public class kelondroFlexSplitTable implements kelondroIndex {}}+ public synchronized kelondroCloneableIterator keys(boolean up, byte[] firstKey) throws IOException {+ HashSet set = new HashSet();+ Iterator i = tables.values().iterator();+ while (i.hasNext()) {+ set.add(((kelondroIndex) i.next()).keys(up, firstKey));+ }+ return kelondroMergeIterator.cascade(set, rowdef.objectOrder, kelondroMergeIterator.simpleMerge, up);+ }+public synchronized kelondroCloneableIterator rows(boolean up, byte[] firstKey) throws IOException {HashSet set = new HashSet();Iterator i = tables.values().iterator();diff --git a/source/de/anomic/kelondro/kelondroFlexTable.java b/source/de/anomic/kelondro/kelondroFlexTable.javaindex 072faed5d..42e486aa9 100644--- a/source/de/anomic/kelondro/kelondroFlexTable.java+++ b/source/de/anomic/kelondro/kelondroFlexTable.java@@ -344,6 +344,10 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondrreturn r;}+ public synchronized kelondroCloneableIterator keys(boolean up, byte[] firstKey) throws IOException {+ return index.keys(up, firstKey);+ }+public synchronized kelondroCloneableIterator rows(boolean up, byte[] firstKey) throws IOException {if (index == null) return new rowIterator(index, up, firstKey);assert this.size() == index.size() : "content.size() = " + this.size() + ", index.size() = " + index.size();@@ -362,7 +366,7 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondrindexIterator = index.rows(up, firstKey);}- public Object clone(Object modifier) {+ public rowIterator clone(Object modifier) {try {return new rowIterator(index, up, (byte[]) modifier);} catch (IOException e) {diff --git a/source/de/anomic/kelondro/kelondroHandle.java b/source/de/anomic/kelondro/kelondroHandle.javaindex 1d1f52b81..7de5bae7c 100644--- a/source/de/anomic/kelondro/kelondroHandle.java+++ b/source/de/anomic/kelondro/kelondroHandle.java@@ -26,7 +26,7 @@package de.anomic.kelondro;-public class kelondroHandle implements Comparable {+public class kelondroHandle implements Comparable<kelondroHandle> {public final static int NUL = Integer.MIN_VALUE; // the meta value for the kelondroTray' NUL abstraction@@ -62,7 +62,7 @@ public class kelondroHandle implements Comparable {return (this.index == ((kelondroHandle) h).index);}- public int compare(Object h0, Object h1) {+ public int compare(kelondroHandle h0, kelondroHandle h1) {assert (((kelondroHandle) h0).index != NUL);assert (((kelondroHandle) h1).index != NUL);if (((kelondroHandle) h0).index < ((kelondroHandle) h1).index) return -1;@@ -70,7 +70,7 @@ public class kelondroHandle implements Comparable {return 0;}- public int compareTo(Object h) {+ public int compareTo(kelondroHandle h) {// this is needed for a TreeMapassert (index != NUL) : "this.index is NUL in compareTo";assert (((kelondroHandle) h).index != NUL) : "handle.index is NUL in compareTo";diff --git a/source/de/anomic/kelondro/kelondroIndex.java b/source/de/anomic/kelondro/kelondroIndex.javaindex 46ae806ec..0c786ed42 100644--- a/source/de/anomic/kelondro/kelondroIndex.java+++ b/source/de/anomic/kelondro/kelondroIndex.java@@ -64,12 +64,13 @@ public interface kelondroIndex {public kelondroRow.Entry get(byte[] key) throws IOException;public kelondroRow.Entry put(kelondroRow.Entry row) throws IOException;public kelondroRow.Entry put(kelondroRow.Entry row, Date entryDate) throws IOException;- public void putMultiple(List /* of kelondroRow.Entry*/ rows) throws IOException; // for R/W head path optimization+ public void putMultiple(List<kelondroRow.Entry> rows) throws IOException; // for R/W head path optimizationpublic void addUnique(kelondroRow.Entry row) throws IOException; // no double-check- public void addUniqueMultiple(List /* of kelondroRow.Entry*/ rows) throws IOException; // no double-check+ public void addUniqueMultiple(List<kelondroRow.Entry> rows) throws IOException; // no double-checkpublic kelondroRow.Entry remove(byte[] key, boolean keepOrder) throws IOException;public kelondroRow.Entry removeOne() throws IOException;- public kelondroCloneableIterator rows(boolean up, byte[] firstKey) throws IOException;+ public kelondroCloneableIterator<byte[]> keys(boolean up, byte[] firstKey) throws IOException; // iterates only the key+ public kelondroCloneableIterator<kelondroRow.Entry> rows(boolean up, byte[] firstKey) throws IOException; // iterates the whole rowpublic void close();public void reset() throws IOException;}diff --git a/source/de/anomic/kelondro/kelondroIntBytesMap.java b/source/de/anomic/kelondro/kelondroIntBytesMap.javaindex b66c17f3f..a4f8d0d52 100644--- a/source/de/anomic/kelondro/kelondroIntBytesMap.java+++ b/source/de/anomic/kelondro/kelondroIntBytesMap.java@@ -176,13 +176,13 @@ public class kelondroIntBytesMap {return index0.size() + index1.size();}- public Iterator rows() {+ public Iterator<kelondroRow.Entry> rows() {if (index0 != null) {if (index1 == null) {// finish initialization phaseindex0.sort();index0.uniq();- index1 = new kelondroRowSet(rowdef, 0);+ index1 = new kelondroRowSet(rowdef, 0);}return index0.rows(true, null);}@@ -190,10 +190,10 @@ public class kelondroIntBytesMap {if (index0 == null) {return index1.rows(true, null);}- return new kelondroMergeIterator(+ return new kelondroMergeIterator<kelondroRow.Entry>(index0.rows(true, null),index1.rows(true, null),- rowdef.objectOrder,+ kelondroRow.entryComparator,kelondroMergeIterator.simpleMerge,true);}@@ -225,8 +225,8 @@ public class kelondroIntBytesMap {long r;Long R;int p, rc = 0;- ArrayList ra = new ArrayList();- HashSet jcontrol = new HashSet();+ ArrayList<Long> ra = new ArrayList<Long>();+ HashSet<Long> jcontrol = new HashSet<Long>();kelondroIntBytesMap kcontrol = new kelondroIntBytesMap(1, 0);for (int i = 0; i < 1000000; i++) {r = Math.abs(random.nextLong() % 10000);diff --git a/source/de/anomic/kelondro/kelondroMScoreCluster.java b/source/de/anomic/kelondro/kelondroMScoreCluster.javaindex aff658459..db8fbd52b 100644--- a/source/de/anomic/kelondro/kelondroMScoreCluster.java+++ b/source/de/anomic/kelondro/kelondroMScoreCluster.java@@ -50,14 +50,14 @@ import java.util.TreeMap;public final class kelondroMScoreCluster {- protected final TreeMap refkeyDB; // a mapping from a reference to the cluster key- protected final TreeMap keyrefDB; // a mapping from the cluster key to the reference+ protected final TreeMap<Object, Long> refkeyDB; // a mapping from a reference to the cluster key+ protected final TreeMap<Long, Object> keyrefDB; // a mapping from the cluster key to the referenceprivate long gcount;private int encnt;public kelondroMScoreCluster() {- refkeyDB = new TreeMap();- keyrefDB = new TreeMap();+ refkeyDB = new TreeMap<Object, Long>();+ keyrefDB = new TreeMap<Long, Object>();gcount = 0;encnt = 0;}@@ -165,7 +165,7 @@ public final class kelondroMScoreCluster {public synchronized void setScore(Object obj, int newScore) {if (obj == null) return;//System.out.println("setScore " + obj.getClass().getName());- Long usk = (Long) refkeyDB.remove(obj); // get unique score key, old entry is not needed any more+ Long usk = refkeyDB.remove(obj); // get unique score key, old entry is not needed any moreif (newScore < 0) throw new kelondroOutOfLimitsException(newScore);if (usk == null) {@@ -199,7 +199,7 @@ public final class kelondroMScoreCluster {public synchronized void addScore(Object obj, int incrementScore) {if (obj == null) return;//System.out.println("setScore " + obj.getClass().getName());- Long usk = (Long) refkeyDB.remove(obj); // get unique score key, old entry is not needed any more+ Long usk = refkeyDB.remove(obj); // get unique score key, old entry is not needed any moreif (usk == null) {// set new value@@ -236,7 +236,7 @@ public final class kelondroMScoreCluster {// deletes entry and returns previous scoreif (obj == null) return 0;//System.out.println("setScore " + obj.getClass().getName());- Long usk = (Long) refkeyDB.remove(obj); // get unique score key, old entry is not needed any more+ Long usk = refkeyDB.remove(obj); // get unique score key, old entry is not needed any moreif (usk == null) return 0;// delete old entry@@ -257,19 +257,19 @@ public final class kelondroMScoreCluster {public synchronized int getScore(Object obj) {if (obj == null) return 0;- Long cs = (Long) refkeyDB.get(obj);+ Long cs = refkeyDB.get(obj);if (cs == null) return 0;return (int) ((cs.longValue() & 0xFFFFFFFF00000000L) >> 32);}public synchronized int getMaxScore() {if (refkeyDB.size() == 0) return -1;- return (int) ((((Long) keyrefDB.lastKey()).longValue() & 0xFFFFFFFF00000000L) >> 32);+ return (int) ((keyrefDB.lastKey().longValue() & 0xFFFFFFFF00000000L) >> 32);}public synchronized int getMinScore() {if (refkeyDB.size() == 0) return -1;- return (int) ((((Long) keyrefDB.firstKey()).longValue() & 0xFFFFFFFF00000000L) >> 32);+ return (int) ((keyrefDB.firstKey().longValue() & 0xFFFFFFFF00000000L) >> 32);}public synchronized Object getMaxObject() {@@ -291,7 +291,7 @@ public final class kelondroMScoreCluster {public synchronized Object[] getScores(int maxCount, boolean up, int minScore, int maxScore) {if (maxCount > refkeyDB.size()) maxCount = refkeyDB.size();Object[] s = new Object[maxCount];- Iterator it = scores(up, minScore, maxScore);+ Iterator<Object> it = scores(up, minScore, maxScore);int i = 0;while ((i < maxCount) && (it.hasNext())) s[i++] = it.next();if (i < maxCount) {@@ -308,27 +308,28 @@ public final class kelondroMScoreCluster {return refkeyDB + " / " + keyrefDB;}- public synchronized Iterator scores(boolean up) {+ public synchronized Iterator<Object> scores(boolean up) {if (up) return new simpleScoreIterator();return new reverseScoreIterator();}- public synchronized Iterator scores(boolean up, int minScore, int maxScore) {+ public synchronized Iterator<Object> scores(boolean up, int minScore, int maxScore) {return new komplexScoreIterator(up, minScore, maxScore);}- private class komplexScoreIterator implements Iterator {+ private class komplexScoreIterator implements Iterator<Object> {boolean up;- TreeMap keyrefDBcopy;+ TreeMap<Long, Object> keyrefDBcopy;Object n;int min, max;- public komplexScoreIterator(boolean up, int minScore, int maxScore) {+ @SuppressWarnings("unchecked")+ public komplexScoreIterator(boolean up, int minScore, int maxScore) {this.up = up;this.min = minScore;this.max = maxScore;- this.keyrefDBcopy = (TreeMap) keyrefDB.clone(); // NoSuchElementException here?+ this.keyrefDBcopy = (TreeMap<Long, Object>) keyrefDB.clone(); // NoSuchElementException here?internalNext();}@@ -345,7 +346,7 @@ public final class kelondroMScoreCluster {score = (int) ((key.longValue() & 0xFFFFFFFF00000000L) >> 32);if ((score >= min) && (score <= max)) return;if (((up) && (score > max)) || ((!(up)) && (score < min))) {- keyrefDBcopy = new TreeMap();+ keyrefDBcopy = new TreeMap<Long, Object>();n = null;return;}@@ -365,10 +366,10 @@ public final class kelondroMScoreCluster {}- private class reverseScoreIterator implements Iterator {+ private class reverseScoreIterator implements Iterator<Object> {- SortedMap view;- Object key;+ SortedMap<Long, Object> view;+ Long key;public reverseScoreIterator() {view = keyrefDB;@@ -393,10 +394,10 @@ public final class kelondroMScoreCluster {}- private class simpleScoreIterator implements Iterator {+ private class simpleScoreIterator implements Iterator<Object> {- Iterator ii;- Map.Entry entry;+ Iterator<Map.Entry<Long, Object>> ii;+ Map.Entry<Long, Object> entry;public simpleScoreIterator() {ii = keyrefDB.entrySet().iterator();@@ -407,7 +408,7 @@ public final class kelondroMScoreCluster {}public Object next() {- entry = (Map.Entry) ii.next();+ entry = ii.next();//System.out.println("cluster simple iterator: score = " + ((((Long) entry.getKey()).longValue() & 0xFFFFFFFF00000000L) >> 32) + ", handle = " + (((Long) entry.getKey()).longValue() & 0xFFFFFFFFL) + ", value = " + entry.getValue());return entry.getValue();}diff --git a/source/de/anomic/kelondro/kelondroMergeIterator.java b/source/de/anomic/kelondro/kelondroMergeIterator.javaindex 2418507ce..c69f0f50d 100644--- a/source/de/anomic/kelondro/kelondroMergeIterator.java+++ b/source/de/anomic/kelondro/kelondroMergeIterator.java@@ -48,15 +48,15 @@ import java.util.ConcurrentModificationException;import java.util.Iterator;import java.util.Set;-public class kelondroMergeIterator implements kelondroCloneableIterator {+public class kelondroMergeIterator<E> implements kelondroCloneableIterator<E> {- Comparator comp;- kelondroCloneableIterator a, b;- Object na, nb;+ Comparator<E> comp;+ kelondroCloneableIterator<E> a, b;+ E na, nb;Method merger;boolean up;- public kelondroMergeIterator(kelondroCloneableIterator a, kelondroCloneableIterator b, Comparator c, Method m, boolean up) {+ public kelondroMergeIterator(kelondroCloneableIterator<E> a, kelondroCloneableIterator<E> b, Comparator<E> c, Method m, boolean up) {// this works currently only for String-type key iterationsthis.a = a;this.b = b;@@ -67,8 +67,9 @@ public class kelondroMergeIterator implements kelondroCloneableIterator {nextb();}- public Object clone(Object modifier) {- return new kelondroMergeIterator((kelondroCloneableIterator) a.clone(modifier), (kelondroCloneableIterator) b.clone(modifier), comp, merger, up);+ @SuppressWarnings("unchecked")+ public kelondroMergeIterator<E> clone(Object modifier) {+ return new kelondroMergeIterator<E>(a.clone(modifier), b.clone(modifier), comp, merger, up);}public void finalize() {@@ -99,8 +100,9 @@ public class kelondroMergeIterator implements kelondroCloneableIterator {return (na != null) || (nb != null);}- public Object next() {- Object s;+ @SuppressWarnings("unchecked")+ public E next() {+ E s;if (na == null) {s = nb;nextb();@@ -116,7 +118,7 @@ public class kelondroMergeIterator implements kelondroCloneableIterator {if (c == 0) {try {//System.out.print("MERGE OF " + na.toString() + " AND " + nb.toString() + ": ");- s = this.merger.invoke(null, new Object[]{na, nb});+ s = (E) this.merger.invoke(null, new Object[]{(Object) na, (Object) nb});//System.out.println("RESULT IS " + s.toString());} catch (IllegalArgumentException e) {e.printStackTrace();@@ -146,7 +148,7 @@ public class kelondroMergeIterator implements kelondroCloneableIterator {throw new java.lang.UnsupportedOperationException("merge does not support remove");}- public static kelondroCloneableIterator cascade(Set /*of*/ iterators, Comparator c, Method merger, boolean up) {+ public static kelondroCloneableIterator<?> cascade(Set<kelondroCloneableIterator<?>> /*of*/ iterators, Comparator<?> c, Method merger, boolean up) {// this extends the ability to combine two iterators// to the abiliy of combining a set of iteratorsif (iterators == null) return null;@@ -154,10 +156,11 @@ public class kelondroMergeIterator implements kelondroCloneableIterator {return cascade(iterators.iterator(), c, merger, up);}- private static kelondroCloneableIterator cascade(Iterator /*of*/ iiterators, Comparator c, Method merger, boolean up) {+ @SuppressWarnings("unchecked")+ private static kelondroCloneableIterator<?> cascade(Iterator<?> /*of*/ iiterators, Comparator<?> c, Method merger, boolean up) {if (iiterators == null) return null;if (!(iiterators.hasNext())) return null;- kelondroCloneableIterator one = (kelondroCloneableIterator) iiterators.next();+ kelondroCloneableIterator<?> one = (kelondroCloneableIterator<?>) iiterators.next();if (!(iiterators.hasNext())) return one;return new kelondroMergeIterator(one, cascade(iiterators, c, merger, up), c, merger, up);}@@ -165,7 +168,7 @@ public class kelondroMergeIterator implements kelondroCloneableIterator {public static Method simpleMerge = null;static {try {- Class c = Class.forName("de.anomic.kelondro.kelondroMergeIterator");+ Class<?> c = Class.forName("de.anomic.kelondro.kelondroMergeIterator");simpleMerge = c.getMethod("mergeEqualByReplace", new Class[]{Object.class, Object.class});} catch (SecurityException e) {System.out.println("Error while initializing simpleMerge: " + e.getMessage());diff --git a/source/de/anomic/kelondro/kelondroNaturalOrder.java b/source/de/anomic/kelondro/kelondroNaturalOrder.javaindex fac233958..a4fc38c9e 100644--- a/source/de/anomic/kelondro/kelondroNaturalOrder.java+++ b/source/de/anomic/kelondro/kelondroNaturalOrder.java@@ -47,7 +47,7 @@ package de.anomic.kelondro;import java.util.Comparator;-public final class kelondroNaturalOrder extends kelondroAbstractOrder implements kelondroOrder, Comparator, Cloneable {+public final class kelondroNaturalOrder extends kelondroAbstractOrder implements kelondroOrder, Comparator<Object>, Cloneable {public static final kelondroOrder naturalOrder = new kelondroNaturalOrder(true);diff --git a/source/de/anomic/kelondro/kelondroObjects.java b/source/de/anomic/kelondro/kelondroObjects.javaindex 84edd1d06..9ff5d5695 100644--- a/source/de/anomic/kelondro/kelondroObjects.java+++ b/source/de/anomic/kelondro/kelondroObjects.java@@ -35,14 +35,14 @@ public class kelondroObjects {private kelondroDyn dyn;private kelondroMScoreCluster cacheScore;- private HashMap cache;+ private HashMap<String, kelondroObjectsEntry> cache;private long startup;private int cachesize;public kelondroObjects(kelondroDyn dyn, int cachesize) {this.dyn = dyn;- this.cache = new HashMap();+ this.cache = new HashMap<String, kelondroObjectsEntry>();this.cacheScore = new kelondroMScoreCluster();this.startup = System.currentTimeMillis();this.cachesize = cachesize;@@ -50,7 +50,7 @@ public class kelondroObjects {public void reset() throws IOException {this.dyn.reset();- this.cache = new HashMap();+ this.cache = new HashMap<String, kelondroObjectsEntry>();this.cacheScore = new kelondroMScoreCluster();}@@ -132,15 +132,15 @@ public class kelondroObjects {}}- public synchronized kelondroCloneableIterator keys(final boolean up, final boolean rotating) throws IOException {+ public synchronized kelondroCloneableIterator<String> keys(final boolean up, final boolean rotating) throws IOException {// simple enumeration of key names without special orderingreturn dyn.dynKeys(up, rotating);}- public synchronized kelondroCloneableIterator keys(final boolean up, final boolean rotating, final byte[] firstKey, final byte[] secondKey) throws IOException {+ public synchronized kelondroCloneableIterator<String> keys(final boolean up, final boolean rotating, final byte[] firstKey, final byte[] secondKey) throws IOException {// simple enumeration of key names without special ordering- kelondroCloneableIterator i = dyn.dynKeys(up, firstKey);- if (rotating) return new kelondroRotateIterator(i, secondKey); else return i;+ kelondroCloneableIterator<String> i = dyn.dynKeys(up, firstKey);+ if (rotating) return new kelondroRotateIterator<String>(i, secondKey); else return i;}@@ -167,14 +167,14 @@ public class kelondroObjects {dyn.close();}- public class objectIterator implements Iterator {+ public class objectIterator implements Iterator<kelondroObjectsEntry> {// enumerates Map-Type elements// the key is also included in every map that is returned; it's key is 'key'- Iterator keyIterator;+ Iterator<String> keyIterator;boolean finish;- public objectIterator(Iterator keyIterator) {+ public objectIterator(Iterator<String> keyIterator) {this.keyIterator = keyIterator;this.finish = false;}@@ -183,7 +183,7 @@ public class kelondroObjects {return (!(finish)) && (keyIterator.hasNext());}- public Object next() {+ public kelondroObjectsEntry next() {final String nextKey = (String) keyIterator.next();if (nextKey == null) {finish = true;diff --git a/source/de/anomic/kelondro/kelondroOrder.java b/source/de/anomic/kelondro/kelondroOrder.javaindex b4b2aa345..3806e2423 100644--- a/source/de/anomic/kelondro/kelondroOrder.java+++ b/source/de/anomic/kelondro/kelondroOrder.java@@ -47,7 +47,9 @@ package de.anomic.kelondro;import java.util.Comparator;-public interface kelondroOrder extends Comparator {+import de.anomic.index.indexContainer;++public interface kelondroOrder extends Comparator<Object> {public boolean wellformed(byte[] a); // returns true if and only if a has only characters that belong to the implemented orderpublic boolean wellformed(byte[] a, int astart, int alength);@@ -63,7 +65,11 @@ public interface kelondroOrder extends Comparator {public long cardinal(byte[] key); // returns a cardinal number in the range of 0 .. Long.MAX_VALUEpublic int compare(byte[] a, byte[] b);-+ public int compare(String a, String b);+ public int compare(kelondroNode a, kelondroNode b);+ public int compare(indexContainer a, indexContainer b);+ public int compare(kelondroRow.Entry a, kelondroRow.Entry b);+public int compare(byte[] a, int aoffset, int alength, byte[] b, int boffset, int blength);public byte[] zero(); // returns the zero point of the Ordering; null if not defineddiff --git a/source/de/anomic/kelondro/kelondroRA.java b/source/de/anomic/kelondro/kelondroRA.javaindex d3834688d..e7eb06722 100644--- a/source/de/anomic/kelondro/kelondroRA.java+++ b/source/de/anomic/kelondro/kelondroRA.java@@ -91,8 +91,8 @@ public interface kelondroRA {public void writeLine(String line) throws IOException;public String readLine() throws IOException;- public void writeMap(Map props, String comment) throws IOException;- public Map readMap() throws IOException;+ public void writeMap(Map<String, String> props, String comment) throws IOException;+ public Map<String, String> readMap() throws IOException;public void writeArray(byte[] b) throws IOException;public byte[] readArray() throws IOException;diff --git a/source/de/anomic/kelondro/kelondroRotateIterator.java b/source/de/anomic/kelondro/kelondroRotateIterator.javaindex 7e55d50d3..ef64f3d19 100644--- a/source/de/anomic/kelondro/kelondroRotateIterator.java+++ b/source/de/anomic/kelondro/kelondroRotateIterator.java@@ -26,32 +26,33 @@package de.anomic.kelondro;-public class kelondroRotateIterator implements kelondroCloneableIterator {+public class kelondroRotateIterator<E> implements kelondroCloneableIterator<E> {- kelondroCloneableIterator a, clone;+ kelondroCloneableIterator<E> a, clone;Object modifier;- public kelondroRotateIterator(kelondroCloneableIterator a, Object modifier) {+ public kelondroRotateIterator(kelondroCloneableIterator<E> a, Object modifier) {// this works currently only for String-type key iterationsthis.a = a;this.modifier = modifier;- this.clone = (kelondroCloneableIterator) a.clone(modifier);+ this.clone = (kelondroCloneableIterator<E>) a.clone(modifier);}- public Object clone(Object modifier) {- return new kelondroRotateIterator(a, modifier);+ @SuppressWarnings("unchecked")+ public kelondroRotateIterator<E> clone(Object modifier) {+ return new kelondroRotateIterator<E>(a, modifier);}public boolean hasNext() {return true;}- public Object next() {+ public E next() {// attention: this iterator has no termination - on purpose.// it must be taken care that a calling method has a termination predicate different// from the hasNext() methodif (!(a.hasNext())) {- a = (kelondroCloneableIterator) clone.clone(modifier);+ a = (kelondroCloneableIterator<E>) clone.clone(modifier);}return a.next();}diff --git a/source/de/anomic/kelondro/kelondroRow.java b/source/de/anomic/kelondro/kelondroRow.javaindex 2387d5579..77f4544cb 100644--- a/source/de/anomic/kelondro/kelondroRow.java+++ b/source/de/anomic/kelondro/kelondroRow.java@@ -29,6 +29,7 @@ package de.anomic.kelondro;import java.io.UnsupportedEncodingException;import java.util.ArrayList;+import java.util.Comparator;import java.util.HashMap;import java.util.Map;import java.util.StringTokenizer;@@ -38,12 +39,12 @@ import de.anomic.server.logging.serverLog;public final class kelondroRow {- protected kelondroColumn[] row;- protected int[] colstart;- protected kelondroOrder objectOrder;- public int objectsize;- public int primaryKeyIndex, primaryKeyLength;- protected Map nickref = null; // a mapping from nicknames to Object[2]{kelondroColumn, Integer(colstart)}+ protected kelondroColumn[] row;+ protected int[] colstart;+ protected kelondroOrder objectOrder;+ public int objectsize;+ public int primaryKeyIndex, primaryKeyLength;+ protected Map<String, Object[]> nickref = null; // a mapping from nicknames to Object[2]{kelondroColumn, Integer(colstart)}public kelondroRow(kelondroColumn[] row, kelondroOrder objectOrder, int primaryKey) {assert objectOrder != null;@@ -73,7 +74,7 @@ public final class kelondroRow {// parse property part definition:int p = structure.indexOf('|');if (p < 0) p = structure.length();- ArrayList l = new ArrayList();+ ArrayList<kelondroColumn> l = new ArrayList<kelondroColumn>();String attr = structure.substring(0, p);StringTokenizer st = new StringTokenizer(attr, ",");while (st.hasMoreTokens()) {@@ -106,7 +107,7 @@ public final class kelondroRow {protected final void genNickRef() {if (nickref != null) return;- nickref = new HashMap(row.length);+ nickref = new HashMap<String, Object[]>(row.length);for (int i = 0; i < row.length; i++) nickref.put(row[i].nickname, new Object[]{row[i], new Integer(colstart[i])});}@@ -190,7 +191,17 @@ public final class kelondroRow {return new EntryIndex(rowinstance, index);}- public class Entry implements Comparable {+ public static final Comparator<Entry> entryComparator = new EntryComparator();++ public static class EntryComparator implements Comparator<Entry> {++ public int compare(Entry a, Entry b) {+ return a.compareTo(b);+ }++ }++ public class Entry implements Comparable<Entry> {private byte[] rowinstance;private int offset; // the offset where the row starts within rowinstance@@ -290,12 +301,9 @@ public final class kelondroRow {return row[column].cellwidth;}- public final int compareTo(Object o) {+ public final int compareTo(Entry o) {if (objectOrder == null) throw new kelondroException("objects cannot be compared, no order given");- if (o instanceof Entry) {- return objectOrder.compare(this.getPrimaryKeyBytes(), ((Entry) o).getPrimaryKeyBytes());- }- throw new UnsupportedOperationException("works only for kelondroRow.Entry objects");+ return objectOrder.compare(this.getPrimaryKeyBytes(), ((Entry) o).getPrimaryKeyBytes());}public final byte[] bytes() {diff --git a/source/de/anomic/kelondro/kelondroRowCollection.java b/source/de/anomic/kelondro/kelondroRowCollection.javaindex bac96567c..1b456c48c 100644--- a/source/de/anomic/kelondro/kelondroRowCollection.java+++ b/source/de/anomic/kelondro/kelondroRowCollection.java@@ -218,6 +218,19 @@ public class kelondroRowCollection {return lastTimeWrote;}+ public synchronized final byte[] getKey(int index) {+ assert (index >= 0) : "get: access with index " + index + " is below zero";+ assert (index < chunkcount) : "get: access with index " + index + " is above chunkcount " + chunkcount + "; sortBound = " + sortBound;+ assert (index * rowdef.objectsize < chunkcache.length);+ if ((chunkcache == null) || (rowdef == null)) return null; // case may appear during shutdown+ if (index >= chunkcount) return null;+ if (index * rowdef.objectsize >= chunkcache.length) return null;+ this.lastTimeRead = System.currentTimeMillis();+ byte[] b = new byte[this.rowdef.width(0)];+ System.arraycopy(chunkcache, index * rowdef.objectsize, b, 0, b.length);+ return b;+ }+public synchronized final kelondroRow.Entry get(int index) {assert (index >= 0) : "get: access with index " + index + " is below zero";assert (index < chunkcount) : "get: access with index " + index + " is above chunkcount " + chunkcount + "; sortBound = " + sortBound;@@ -255,10 +268,10 @@ public class kelondroRowCollection {addUnique(r, 0, r.length);}- public synchronized void addUniqueMultiple(List rows) {+ public synchronized void addUniqueMultiple(List<kelondroRow.Entry> rows) {assert this.sortBound == 0 : "sortBound = " + this.sortBound + ", chunkcount = " + this.chunkcount;- Iterator i = rows.iterator();- while (i.hasNext()) addUnique((kelondroRow.Entry) i.next());+ Iterator<kelondroRow.Entry> i = rows.iterator();+ while (i.hasNext()) addUnique(i.next());}public synchronized void add(byte[] a) {@@ -362,7 +375,40 @@ public class kelondroRowCollection {return chunkcount;}- public synchronized Iterator rows() {+ public synchronized Iterator<byte[]> keys() {+ // iterates byte[] - type entries+ return new keyIterator();+ }++ /**+ * Iterator for kelondroRowCollection.+ * It supports remove() though it doesn't contain the order of the underlying+ * collection during removes.+ *+ */+ public class keyIterator implements Iterator<byte[]> {++ private int p;++ public keyIterator() {+ p = 0;+ }++ public boolean hasNext() {+ return p < chunkcount;+ }++ public byte[] next() {+ return getKey(p++);+ }++ public void remove() {+ p--;+ removeRow(p, false);+ }+ }++ public synchronized Iterator<kelondroRow.Entry> rows() {// iterates kelondroRow.Entry - type entriesreturn new rowIterator();}@@ -373,7 +419,7 @@ public class kelondroRowCollection {* collection during removes.**/- public class rowIterator implements Iterator {+ public class rowIterator implements Iterator<kelondroRow.Entry> {private int p;@@ -385,7 +431,7 @@ public class kelondroRowCollection {return p < chunkcount;}- public Object next() {+ public kelondroRow.Entry next() {return get(p++);}@@ -395,10 +441,10 @@ public class kelondroRowCollection {}}- public synchronized void select(Set keys) {+ public synchronized void select(Set<kelondroRow.Entry> keys) {// removes all entries but the ones given by urlselectionif ((keys == null) || (keys.size() == 0)) return;- Iterator i = rows();+ Iterator<kelondroRow.Entry> i = rows();kelondroRow.Entry row;while (i.hasNext()) {row = (kelondroRow.Entry) i.next();@@ -568,8 +614,8 @@ public class kelondroRowCollection {public synchronized String toString() {StringBuffer s = new StringBuffer();- Iterator i = rows();- if (i.hasNext()) s.append(((kelondroRow.Entry) i.next()).toString());+ Iterator<kelondroRow.Entry> i = rows();+ if (i.hasNext()) s.append(i.next().toString());while (i.hasNext()) s.append(", " + ((kelondroRow.Entry) i.next()).toString());return new String(s);}diff --git a/source/de/anomic/kelondro/kelondroRowSet.java b/source/de/anomic/kelondro/kelondroRowSet.javaindex 711998efb..7ddef98bf 100644--- a/source/de/anomic/kelondro/kelondroRowSet.java+++ b/source/de/anomic/kelondro/kelondroRowSet.java@@ -92,9 +92,9 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroIndreturn entry;}- public synchronized void putMultiple(List rows) throws IOException {- Iterator i = rows.iterator();- while (i.hasNext()) put((kelondroRow.Entry) i.next());+ public synchronized void putMultiple(List<kelondroRow.Entry> rows) throws IOException {+ Iterator<kelondroRow.Entry> i = rows.iterator();+ while (i.hasNext()) put(i.next());}public kelondroRow.Entry put(kelondroRow.Entry row, Date entryDate) {@@ -246,17 +246,72 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroIndreturn profile;}- public synchronized Iterator rows() {+ public synchronized Iterator<byte[]> keys() {+ sort();+ return super.keys();+ }++ public synchronized kelondroCloneableIterator<byte[]> keys(boolean up, byte[] firstKey) {+ return new keyIterator(up, firstKey);+ }++ public class keyIterator implements kelondroCloneableIterator<byte[]> {++ private boolean up;+ private byte[] first;+ private int p, bound;++ public keyIterator(boolean up, byte[] firstKey) {+ // see that all elements are sorted+ sort();+ this.up = up;+ this.first = firstKey;+ this.bound = sortBound;+ if (first == null) {+ p = 0;+ } else {+ p = binaryPosition(first, 0, first.length); // check this to find bug in DHT selection enumeration+ //System.out.println("binaryposition for key " + new String(firstKey) + " is " + p);+ }+ }++ @SuppressWarnings("unchecked")+ public keyIterator clone(Object second) {+ return new keyIterator(up, (byte[]) second);+ }++ public boolean hasNext() {+ if (p < 0) return false;+ if (p >= size()) return false;+ if (up) {+ return p < bound;+ } else {+ return p >= 0;+ }+ }++ public byte[] next() {+ byte[] key = getKey(p);+ if (up) p++; else p--;+ return key;+ }++ public void remove() {+ throw new UnsupportedOperationException();+ }+ }++ public synchronized Iterator<kelondroRow.Entry> rows() {// iterates kelondroRow.Entry - type entriessort();return super.rows();}- public synchronized kelondroCloneableIterator rows(boolean up, byte[] firstKey) {+ public synchronized kelondroCloneableIterator<kelondroRow.Entry> rows(boolean up, byte[] firstKey) {return new rowIterator(up, firstKey);}- public class rowIterator implements kelondroCloneableIterator {+ public class rowIterator implements kelondroCloneableIterator<kelondroRow.Entry> {private boolean up;private byte[] first;@@ -276,7 +331,8 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd}}- public Object clone(Object second) {+ @SuppressWarnings("unchecked")+ public rowIterator clone(Object second) {return new rowIterator(up, (byte[]) second);}@@ -290,7 +346,7 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd}}- public Object next() {+ public kelondroRow.Entry next() {kelondroRow.Entry entry = get(p);if (up) p++; else p--;return entry;@@ -328,7 +384,7 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroIndfor (int ii = 0; ii < test.length; ii++) d.add(test[ii].getBytes());d.sort();d.remove("fuenf".getBytes(), 0, 5, false);- Iterator ii = d.rows();+ Iterator<kelondroRow.Entry> ii = d.rows();String s;System.out.print("INPUT-ITERATOR: ");kelondroRow.Entry entry;diff --git a/source/de/anomic/kelondro/kelondroSQLTable.java b/source/de/anomic/kelondro/kelondroSQLTable.javaindex f405c1f61..98d9730aa 100644--- a/source/de/anomic/kelondro/kelondroSQLTable.java+++ b/source/de/anomic/kelondro/kelondroSQLTable.java@@ -243,12 +243,12 @@ public class kelondroSQLTable implements kelondroIndex {}public kelondroCloneableIterator rows(boolean up, byte[] startKey) throws IOException {- // Objects are of type byte[][]+ // Objects are of type kelondroRow.Entryreturn null;}- public Iterator keys(boolean up, boolean rotating, byte[] startKey) {- // Objects are of type String+ public kelondroCloneableIterator keys(boolean up, byte[] startKey) {+ // Objects are of type byte[]return null;}diff --git a/source/de/anomic/kelondro/kelondroSplittedTree.java b/source/de/anomic/kelondro/kelondroSplittedTree.javaindex d0ef7b2a8..9dbdf98f8 100644--- a/source/de/anomic/kelondro/kelondroSplittedTree.java+++ b/source/de/anomic/kelondro/kelondroSplittedTree.java@@ -118,13 +118,14 @@ public class kelondroSplittedTree implements kelondroIndex {return ktfs[partition(key)].get(key);}- public synchronized void putMultiple(List rows) throws IOException {- Iterator i = rows.iterator();+ @SuppressWarnings("unchecked")+ public synchronized void putMultiple(List<kelondroRow.Entry> rows) throws IOException {+ Iterator<kelondroRow.Entry> i = rows.iterator();kelondroRow.Entry row;- ArrayList[] parts = new ArrayList[ktfs.length];- for (int j = 0; j < ktfs.length; j++) parts[j] = new ArrayList();+ ArrayList<kelondroRow.Entry>[] parts = new ArrayList[ktfs.length];+ for (int j = 0; j < ktfs.length; j++) parts[j] = new ArrayList<kelondroRow.Entry>();while (i.hasNext()) {- row = (kelondroRow.Entry) i.next();+ row = i.next();parts[partition(row.getColBytes(0))].add(row);}for (int j = 0; j < ktfs.length; j++) ktfs[j].putMultiple(parts[j]);@@ -142,7 +143,7 @@ public class kelondroSplittedTree implements kelondroIndex {throw new UnsupportedOperationException();}- public synchronized void addUniqueMultiple(List rows) throws IOException {+ public synchronized void addUniqueMultiple(List<kelondroRow.Entry> rows) throws IOException {throw new UnsupportedOperationException();}@@ -170,26 +171,27 @@ public class kelondroSplittedTree implements kelondroIndex {}}- public kelondroCloneableIterator rows(boolean up, byte[] firstKey) throws IOException {- return new ktfsIterator(up, firstKey);+ public kelondroCloneableIterator<kelondroRow.Entry> rows(boolean up, byte[] firstKey) throws IOException {+ return new rowIterator(up, firstKey);}- public class ktfsIterator implements kelondroCloneableIterator {+ public class rowIterator implements kelondroCloneableIterator<kelondroRow.Entry> {int c = 0;- Iterator ktfsI;+ Iterator<kelondroRow.Entry> ktfsI;boolean up;- public ktfsIterator(boolean up, byte[] firstKey) throws IOException {+ public rowIterator(boolean up, byte[] firstKey) throws IOException {this.up = up;c = (up) ? 0 : (ff - 1);if (firstKey != null) throw new UnsupportedOperationException("ktfsIterator does not work with a start key");ktfsI = ktfs[c].rows(up, firstKey); // FIXME: this works only correct with firstKey == null}- public Object clone(Object secondKey) {+ @SuppressWarnings("unchecked")+ public rowIterator clone(Object secondKey) {try {- return new ktfsIterator(up, (byte[]) secondKey);+ return new rowIterator(up, (byte[]) secondKey);} catch (IOException e) {return null;}@@ -201,7 +203,7 @@ public class kelondroSplittedTree implements kelondroIndex {((!(up)) && (c > 0)));}- public Object next() {+ public kelondroRow.Entry next() {if (ktfsI.hasNext()) return ktfsI.next();if (up) {if (c < (ff - 1)) {@@ -236,6 +238,73 @@ public class kelondroSplittedTree implements kelondroIndex {}+ public kelondroCloneableIterator<byte[]> keys(boolean up, byte[] firstKey) throws IOException {+ return new keyIterator(up, firstKey);+ }++ public class keyIterator implements kelondroCloneableIterator<byte[]> {++ int c = 0;+ Iterator<byte[]> ktfsI;+ boolean up;++ public keyIterator(boolean up, byte[] firstKey) throws IOException {+ this.up = up;+ c = (up) ? 0 : (ff - 1);+ if (firstKey != null) throw new UnsupportedOperationException("ktfsIterator does not work with a start key");+ ktfsI = ktfs[c].keys(up, firstKey); // FIXME: this works only correct with firstKey == null+ }++ @SuppressWarnings("unchecked")+ public keyIterator clone(Object secondKey) {+ try {+ return new keyIterator(up, (byte[]) secondKey);+ } catch (IOException e) {+ return null;+ }+ }++ public boolean hasNext() {+ return ((ktfsI.hasNext()) ||+ ((up) && (c < ff)) ||+ ((!(up)) && (c > 0)));+ }++ public byte[] next() {+ if (ktfsI.hasNext()) return ktfsI.next();+ if (up) {+ if (c < (ff - 1)) {+ c++;+ try {+ ktfsI = ktfs[c].keys(true, null);+ } catch (IOException e) {+ return null;+ }+ return ktfsI.next();+ } else {+ return null;+ }+ } else {+ if (c > 0) {+ c--;+ try {+ ktfsI = ktfs[c].keys(false, null);+ } catch (IOException e) {+ return null;+ }+ return ktfsI.next();+ } else {+ return null;+ }+ }+ }++ public void remove() {+ ktfsI.remove();+ }++ }+public kelondroOrder order() {return this.order;}diff --git a/source/de/anomic/kelondro/kelondroTree.java b/source/de/anomic/kelondro/kelondroTree.javaindex bc48ddbef..496ef337e 100644--- a/source/de/anomic/kelondro/kelondroTree.java+++ b/source/de/anomic/kelondro/kelondroTree.java@@ -229,7 +229,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndexfound = false;int c;- TreeMap visitedNodeKeys = new TreeMap(loopDetectionOrder); // to detect loops+ TreeSet<byte[]> visitedNodeKeys = new TreeSet<byte[]>(loopDetectionOrder); // to detect loops// System.out.println("Starting Compare Loop in Database " + filename); // debugwhile (thisHandle != null) {try {@@ -258,7 +258,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndexthrow new kelondroException("found key during search process with key == null");}}- if (visitedNodeKeys.containsKey(keybuffer)) {+ if (visitedNodeKeys.contains(keybuffer)) {// we have loops in the database.// to fix this, all affected nodes must be patchedthenode.setOHByte(magic, (byte) 1);@@ -285,7 +285,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndexchild = 1;thisHandle = thenode.getOHHandle(rightchild);}- visitedNodeKeys.put(keybuffer, null);+ visitedNodeKeys.add(keybuffer);}// System.out.println("DEBUG: search for " + new String(key) + " ended with status=" + ((found) ? "found" : "not-found") + ", node=" + ((thenode == null) ? "NULL" : thenode.toString()) + ", parent=" + ((parentnode == null) ? "NULL" : parentnode.toString()));// we reached a node where we must insert the new value@@ -330,9 +330,9 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndexreturn (lc.equals(childn.handle()));}- public synchronized void putMultiple(List rows) throws IOException {- Iterator i = rows.iterator();- while (i.hasNext()) put ((Entry) i.next());+ public synchronized void putMultiple(List<Entry> rows) throws IOException {+ Iterator<Entry> i = rows.iterator();+ while (i.hasNext()) put(i.next());}public kelondroRow.Entry put(kelondroRow.Entry row, Date entryDate) throws IOException {@@ -489,9 +489,9 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndexthis.put(row, entryDate);}- public synchronized void addUniqueMultiple(List rows) throws IOException {- Iterator i = rows.iterator();- while (i.hasNext()) addUnique((kelondroRow.Entry) i.next());+ public synchronized void addUniqueMultiple(List<kelondroRow.Entry> rows) throws IOException {+ Iterator<kelondroRow.Entry> i = rows.iterator();+ while (i.hasNext()) addUnique(i.next());}private void assignChild(kelondroNode parentNode, kelondroNode childNode, int childType) throws IOException {@@ -761,7 +761,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndexprotected CacheNode firstNode(CacheNode node) throws IOException {if (node == null) throw new IllegalArgumentException("firstNode: node=null");kelondroHandle h = node.getOHHandle(leftchild);- HashSet visitedNodeKeys = new HashSet(); // to detect loops+ HashSet<String> visitedNodeKeys = new HashSet<String>(); // to detect loopsString nodeKey;while (h != null) {try {@@ -787,7 +787,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndexprotected CacheNode lastNode(CacheNode node) throws IOException {if (node == null) throw new IllegalArgumentException("lastNode: node=null");kelondroHandle h = node.getOHHandle(rightchild);- HashSet visitedNodeKeys = new HashSet(); // to detect loops+ HashSet<String> visitedNodeKeys = new HashSet<String>(); // to detect loopsString nodeKey;while (h != null) {try {@@ -804,12 +804,12 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndexreturn node;}- private class nodeIterator implements Iterator {+ private class nodeIterator implements Iterator<CacheNode> {// we implement an iteration! (not a recursive function as the structure would suggest...)// the iterator iterates Node objectsCacheNode nextNode = null;boolean up, rot;- LinkedList nodeStack;+ LinkedList<Object[]> nodeStack;int count;public nodeIterator(boolean up, boolean rotating) throws IOException {@@ -876,7 +876,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndexthis.nextNode = start;// fill node stack for start node- nodeStack = new LinkedList();+ nodeStack = new LinkedList<Object[]>();kelondroHandle searchHandle = getHandle(root);if (searchHandle == null) {nextNode = null; return;}@@ -907,7 +907,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndexreturn (rot && (size() > 0)) || (nextNode != null);}- public Object next() {+ public CacheNode next() {count++;if ((rot) && (nextNode == null)) try {init((up) ? firstNode() : lastNode());@@ -916,7 +916,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex}if (nextNode == null) throw new kelondroException(filename, "nodeIterator.next: no more entries available");if ((count > size()) && (!(rot))) throw new kelondroException(filename, "nodeIterator.next: internal loopback; database corrupted");- Object ret = nextNode;+ CacheNode ret = nextNode;// middle-casetry {@@ -925,7 +925,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndexif (childHandle != null) {//System.out.println("go to other leg, stack size=" + nodeStack.size());// we have walked one leg of the tree; now go to the other one: step down to next child- HashSet visitedNodeHandles = new HashSet(); // to detect loops+ HashSet<kelondroHandle> visitedNodeHandles = new HashSet<kelondroHandle>(); // to detect loopsnodeStack.addLast(new Object[]{nextNode, new Integer(childtype)});nextNode = new CacheNode(childHandle, nextNode, childtype, false);childtype = (up) ? leftchild : rightchild;@@ -986,44 +986,44 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex}}- public TreeMap rowMap(boolean up, byte[] firstKey, boolean including, int count) throws IOException {+ public TreeMap<byte[], kelondroRow.Entry> rowMap(boolean up, 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) row().objectOrder.clone();setOrder.direction(up);setOrder.rotate(firstKey);- TreeMap rows = new TreeMap(setOrder);- kelondroNode n;+ TreeMap<byte[], kelondroRow.Entry> rows = new TreeMap<byte[], kelondroRow.Entry>(setOrder);+ CacheNode n;String key;synchronized (this) {- Iterator i = (firstKey == null) ? new nodeIterator(up, false) : new nodeIterator(up, false, firstKey, including);+ Iterator<CacheNode> i = (firstKey == null) ? new nodeIterator(up, false) : new nodeIterator(up, false, firstKey, including);while ((rows.size() < count) && (i.hasNext())) {- n = (kelondroNode) i.next();+ n = i.next();if (n == null) return rows;key = new String(n.getKey());- if (rows.put(key, row().newEntry(n.getValueRow())) != null) return rows; // protection against loops+ if (rows.put(key.getBytes(), row().newEntry(n.getValueRow())) != null) return rows; // protection against loops}}return rows;}- public TreeSet keySet(boolean up, boolean rotating, byte[] firstKey, boolean including, int count) throws IOException {+ public TreeSet<byte[]> keySet(boolean up, boolean rotating, byte[] firstKey, boolean including, int count) throws IOException {// returns an ordered set of keys; objects are of type StringkelondroOrder setOrder = (kelondroOrder) row().objectOrder.clone();setOrder.direction(up);setOrder.rotate(firstKey);- TreeSet set = new TreeSet(setOrder);+ TreeSet<byte[]> set = new TreeSet<byte[]>(setOrder);kelondroNode n;synchronized (this) {- Iterator i = (firstKey == null) ? new nodeIterator(up, rotating) : new nodeIterator(up, rotating, firstKey, including);+ Iterator<CacheNode> i = (firstKey == null) ? new nodeIterator(up, rotating) : new nodeIterator(up, rotating, firstKey, including);while ((set.size() < count) && (i.hasNext())) {n = (kelondroNode) i.next();- if ((n != null) && (n.getKey() != null)) set.add(new String(n.getKey()));+ if ((n != null) && (n.getKey() != null)) set.add(n.getKey());}}return set;}- public kelondroCloneableIterator rows(boolean up, byte[] firstKey) throws IOException {+ public kelondroCloneableIterator<kelondroRow.Entry> rows(boolean up, byte[] firstKey) throws IOException {// iterates the rows of the Nodes// enumerated objects are of type byte[][]// iterates the elements in a sorted way.@@ -1031,14 +1031,14 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndexreturn new rowIterator(up, firstKey, this.size());}- public class rowIterator implements kelondroCloneableIterator {+ public class rowIterator implements kelondroCloneableIterator<kelondroRow.Entry> {int chunkSize;boolean inc;long count;byte[] lastKey;- TreeMap rowBuffer;- Iterator bufferIterator;+ TreeMap<byte[], kelondroRow.Entry> rowBuffer;+ Iterator<Map.Entry<byte[], kelondroRow.Entry>> bufferIterator;long guessedCountLimit;public rowIterator(boolean up, byte[] firstKey, long guessedCountLimit) throws IOException {@@ -1054,7 +1054,8 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndexlastIteratorCount = 0;}- public Object clone(Object secondStart) {+ @SuppressWarnings("unchecked")+ public rowIterator clone(Object secondStart) {try {return new rowIterator(inc, (byte[]) secondStart, guessedCountLimit);} catch (IOException e) {@@ -1066,10 +1067,10 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndexreturn ((bufferIterator != null) && (bufferIterator.hasNext()) && (count < size()));}- public Object next() {+ public kelondroRow.Entry next() {if (!(bufferIterator.hasNext())) return null;- Map.Entry entry = (Map.Entry) bufferIterator.next();- lastKey = ((String) entry.getKey()).getBytes();+ Map.Entry<byte[], kelondroRow.Entry> entry = bufferIterator.next();+ lastKey = (byte[]) entry.getKey();// check if this was the last entry in the rowBufferif (!(bufferIterator.hasNext())) {@@ -1099,7 +1100,80 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex}}-++ public kelondroCloneableIterator<byte[]> keys(boolean up, byte[] firstKey) throws IOException {+ return new keyIterator(up, firstKey, this.size());+ }++ public class keyIterator implements kelondroCloneableIterator<byte[]> {++ int chunkSize;+ boolean inc;+ long count;+ byte[] lastKey;+ TreeSet<byte[]> keyBuffer;+ Iterator<byte[]> bufferIterator;+ long guessedCountLimit;++ public keyIterator(boolean up, byte[] firstKey, long guessedCountLimit) throws IOException {+ this.guessedCountLimit = guessedCountLimit;+ inc = up;+ count = 0;+ lastKey = null;+ //System.out.println("*** rowIterator: " + filename + ": readAheadChunkSize = " + readAheadChunkSize + ", lastIteratorCount = " + lastIteratorCount);+ readAheadChunkSize = Math.min(1000, 3 + (int) ((3 * readAheadChunkSize + lastIteratorCount) / 4));+ chunkSize = (int) Math.min(readAheadChunkSize / 3, guessedCountLimit);+ keyBuffer = keySet(inc, false, firstKey, true, chunkSize);+ bufferIterator = keyBuffer.iterator();+ lastIteratorCount = 0;+ }++ @SuppressWarnings("unchecked")+ public keyIterator clone(Object secondStart) {+ try {+ return new keyIterator(inc, (byte[]) secondStart, guessedCountLimit);+ } catch (IOException e) {+ return null;+ }+ }++ public boolean hasNext() {+ return ((bufferIterator != null) && (bufferIterator.hasNext()) && (count < size()));+ }++ public byte[] next() {+ if (!(bufferIterator.hasNext())) return null;+ lastKey = bufferIterator.next();++ // check if this was the last entry in the rowBuffer+ if (!(bufferIterator.hasNext())) {+ // assign next buffer chunk+ try {+ lastKey[lastKey.length - 1]++;+ keyBuffer = keySet(inc, false, lastKey, false, chunkSize);+ bufferIterator = keyBuffer.iterator();+ } catch (IOException e) {+ keyBuffer = null;+ bufferIterator = null;+ }+ }++ // return the row+ count++;+ lastIteratorCount++;+ return lastKey;+ }++ public void remove() {+ if (lastKey != null) try {+ kelondroTree.this.remove(lastKey, true);+ } catch (IOException e) {+ // do nothing+ }+ }++ }+public int imp(File file, String separator) throws IOException {// imports a value-separated file, returns number of records that have been read@@ -1156,16 +1230,16 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndexsuper.print();int height = height();System.out.println("HEIGHT = " + height);- Vector thisline = new Vector();+ Vector<kelondroHandle> thisline = new Vector<kelondroHandle>();thisline.add(getHandle(root));- Vector nextline;+ Vector<kelondroHandle> nextline;kelondroHandle handle;kelondroNode node;int linelength, width = (1 << (height - 1)) * (row().width(0) + 1);String key;for (int h = 1; h < height; h++) {linelength = width / (thisline.size() * 2);- nextline = new Vector();+ nextline = new Vector<kelondroHandle>();for (int i = 0; i < thisline.size(); i++) {handle = (kelondroHandle) thisline.elementAt(i);if (handle == null) {@@ -1296,9 +1370,9 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex} else if (args[0].equals("-n")) {kelondroTree fm = new kelondroTree(new File(args[1]), true, 10, new kelondroRow("byte[] a-4, byte[] b-4", kelondroNaturalOrder.naturalOrder, 0));//byte[][] keys = fm.getSequentialKeys(args[2].getBytes(), 500, true);- Iterator rowIt = fm.rows(true, (args[2].length() == 0) ? null : args[2].getBytes());- Vector v = new Vector();- while (rowIt.hasNext()) v.add(new String(((byte[][]) rowIt.next())[0]));+ Iterator<kelondroRow.Entry> rowIt = fm.rows(true, (args[2].length() == 0) ? null : args[2].getBytes());+ Vector<String> v = new Vector<String>();+ while (rowIt.hasNext()) v.add(rowIt.next().getColString(0, null));ret = v.toString().getBytes();fm.close();}@@ -1456,7 +1530,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndexb = testWord('L'); tt.put(b, b);int c = countElements(tt);System.out.println("elements: " + c);- Iterator i = tt.rows(true, testWord('G'));+ Iterator<kelondroRow.Entry> i = tt.rows(true, testWord('G'));for (int j = 0; j < c; j++) {System.out.println("Row " + j + ": " + new String(((kelondroRow.Entry) i.next()).getColBytes(0)));}@@ -1566,11 +1640,11 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndexpublic static int countElements(kelondroTree t) {int count = 0;try {- Iterator iter = t.rows(true, null);+ Iterator<kelondroRow.Entry> iter = t.rows(true, null);kelondroRow.Entry row;while (iter.hasNext()) {count++;- row = (kelondroRow.Entry) iter.next();+ row = iter.next();if (row == null) System.out.println("ERROR! null element found");// else System.out.println("counted element: " + new// String(n.getKey()));@@ -1579,4 +1653,5 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex}return count;}+}diff --git a/source/de/anomic/plasma/plasmaCrawlLURL.java b/source/de/anomic/plasma/plasmaCrawlLURL.javaindex 110459a8c..71c44b9c8 100644--- a/source/de/anomic/plasma/plasmaCrawlLURL.java+++ b/source/de/anomic/plasma/plasmaCrawlLURL.java@@ -329,7 +329,7 @@ public final class plasmaCrawlLURL {this.error = false;}- public Object clone(Object secondHash) {+ public kiter clone(Object secondHash) {try {return new kiter(up, (String) secondHash);} catch (IOException e) {diff --git a/source/de/anomic/plasma/plasmaSearchQuery.java b/source/de/anomic/plasma/plasmaSearchQuery.javaindex 24db9459e..e506900e7 100644--- a/source/de/anomic/plasma/plasmaSearchQuery.java+++ b/source/de/anomic/plasma/plasmaSearchQuery.java@@ -51,7 +51,6 @@ import de.anomic.htmlFilter.htmlFilterAbstractScraper;import de.anomic.kelondro.kelondroBase64Order;import de.anomic.kelondro.kelondroBitfield;import de.anomic.kelondro.kelondroMSetTools;-import de.anomic.kelondro.kelondroNaturalOrder;import de.anomic.server.serverCharBuffer;import de.anomic.yacy.yacySeedDB;@@ -74,7 +73,7 @@ public final class plasmaSearchQuery {public static final kelondroBitfield catchall_constraint = new kelondroBitfield(4, "______");public String queryString;- public TreeSet queryHashes, excludeHashes;+ public TreeSet<String> queryHashes, excludeHashes;private int linesPerPage, offset;public String prefer;public int contentdom;@@ -91,8 +90,8 @@ public final class plasmaSearchQuery {public plasmaSearchQuery(String queryString, int lines, kelondroBitfield constraint) {if ((queryString.length() == 12) && (kelondroBase64Order.enhancedCoder.wellformed(queryString.getBytes()))) {this.queryString = null;- this.queryHashes = new TreeSet();- this.excludeHashes = new TreeSet();+ this.queryHashes = new TreeSet<String>();+ this.excludeHashes = new TreeSet<String>();this.queryHashes.add(queryString);} else {this.queryString = queryString;@@ -174,7 +173,7 @@ public plasmaSearchQuery(String queryString, TreeSet queryHashes, TreeSet excludreturn (this.domType == SEARCHDOM_LOCAL) ? "local" : "global";}- public static TreeSet hashes2Set(String query) {+ public static TreeSet<String> hashes2Set(String query) {if (query == null) return new TreeSet(kelondroBase64Order.enhancedCoder);final TreeSet keyhashes = new TreeSet(kelondroBase64Order.enhancedCoder);for (int i = 0; i < (query.length() / yacySeedDB.commonHashLength); i++) {@@ -208,16 +207,16 @@ public plasmaSearchQuery(String queryString, TreeSet queryHashes, TreeSet excludreturn new String(sb);}- public static final boolean matches(String text, TreeSet keyhashes) {+ public static final boolean matches(String text, TreeSet<String> keyhashes) {// returns true if any of the word hashes in keyhashes appear in the String text// to do this, all words in the string must be recognized and transcoded to word hashes- TreeSet wordhashes = plasmaCondenser.words2hashes(plasmaCondenser.getWords(text).keySet());+ TreeSet<String> wordhashes = plasmaCondenser.words2hashes(plasmaCondenser.getWords(text).keySet());return kelondroMSetTools.anymatch(wordhashes, keyhashes);}- public static TreeSet[] cleanQuery(String querystring) {+ public static TreeSet<String>[] cleanQuery(String querystring) {// returns two sets: a query set and a exclude set- if ((querystring == null) || (querystring.length() == 0)) return new TreeSet[]{new TreeSet(kelondroBase64Order.enhancedCoder), new TreeSet(kelondroBase64Order.enhancedCoder)};+ if ((querystring == null) || (querystring.length() == 0)) return new TreeSet[]{new TreeSet<String>(), new TreeSet<String>()};// convert Umlautequerystring = htmlFilterAbstractScraper.convertUmlaute(new serverCharBuffer(querystring.toCharArray())).toString();@@ -231,8 +230,8 @@ public plasmaSearchQuery(String queryString, TreeSet queryHashes, TreeSet exclud}// the string is clean now, but we must generate a set out of it- final TreeSet query = new TreeSet(kelondroNaturalOrder.naturalOrder);- final TreeSet exclude = new TreeSet(kelondroNaturalOrder.naturalOrder);+ final TreeSet<String> query = new TreeSet<String>();+ final TreeSet<String> exclude = new TreeSet<String>();final String[] a = querystring.split(" ");for (int i = 0; i < a.length; i++) {if (a[i].startsWith("-")) {diff --git a/source/de/anomic/plasma/plasmaSearchRankingProcess.java b/source/de/anomic/plasma/plasmaSearchRankingProcess.javaindex 134da2cb2..fd3ef83c3 100644--- a/source/de/anomic/plasma/plasmaSearchRankingProcess.java+++ b/source/de/anomic/plasma/plasmaSearchRankingProcess.java@@ -39,6 +39,7 @@ import de.anomic.htmlFilter.htmlFilterContentScraper;import de.anomic.index.indexContainer;import de.anomic.index.indexRWIEntry;import de.anomic.index.indexRWIEntryOrder;+import de.anomic.index.indexRWIRowEntry;import de.anomic.index.indexURLEntry;import de.anomic.kelondro.kelondroBinSearch;import de.anomic.kelondro.kelondroMScoreCluster;@@ -51,9 +52,9 @@ public final class plasmaSearchRankingProcess {public static kelondroBinSearch[] ybrTables = null; // block-rank tablesprivate static boolean useYBR = true;- private TreeMap sortedRWIEntries; // key = ranking (Long); value = indexRWIEntry; if sortorder < 2 then key is instance of String- private HashMap doubleDomCache; // key = domhash (6 bytes); value = TreeMap like sortedRWIEntries- private HashMap handover; // key = urlhash, value = urlstring; used for double-check of urls that had been handed over to search process+ private TreeMap<Object, indexRWIEntry> sortedRWIEntries; // key = ranking (Long); value = indexRWIEntry; if sortorder < 2 then key is instance of String+ private HashMap<String, TreeMap<Object, indexRWIEntry>> doubleDomCache; // key = domhash (6 bytes); value = TreeMap like sortedRWIEntries+ private HashMap<String, String> handover; // key = urlhash, value = urlstring; used for double-check of urls that had been handed over to search processprivate plasmaSearchQuery query;private plasmaSearchRankingProfile ranking;private int sortorder;@@ -61,30 +62,30 @@ public final class plasmaSearchRankingProcess {private int maxentries;private int globalcount;private indexRWIEntryOrder order;- private HashMap urlhashes; // map for double-check; String/Long relation, addresses ranking number (backreference for deletion)+ private HashMap<String, Object> urlhashes; // map for double-check; String/Long relation, addresses ranking number (backreference for deletion)private kelondroMScoreCluster ref; // reference score computation for the commonSense heuristicprivate int[] flagcount; // flag counter- private TreeSet misses; // contains url-hashes that could not been found in the LURL-DB+ private TreeSet<String> misses; // contains url-hashes that could not been found in the LURL-DBprivate plasmaWordIndex wordIndex;- private Map[] localSearchContainerMaps;+ private Map<String, indexContainer>[] localSearchContainerMaps;public plasmaSearchRankingProcess(plasmaWordIndex wordIndex, plasmaSearchQuery query, plasmaSearchRankingProfile ranking, int sortorder, int maxentries) {// we collect the urlhashes and construct a list with urlEntry objects// attention: if minEntries is too high, this method will not terminate within the maxTime// sortorder: 0 = hash, 1 = url, 2 = rankingthis.localSearchContainerMaps = null;- this.sortedRWIEntries = new TreeMap();- this.doubleDomCache = new HashMap();- this.handover = new HashMap();+ this.sortedRWIEntries = new TreeMap<Object, indexRWIEntry>();+ this.doubleDomCache = new HashMap<String, TreeMap<Object, indexRWIEntry>>();+ this.handover = new HashMap<String, String>();this.filteredCount = 0;this.order = null;this.query = query;this.ranking = ranking;this.maxentries = maxentries;this.globalcount = 0;- this.urlhashes = new HashMap();+ this.urlhashes = new HashMap<String, Object>();this.ref = new kelondroMScoreCluster();- this.misses = new TreeSet();+ this.misses = new TreeSet<String>();this.wordIndex = wordIndex;this.sortorder = sortorder;this.flagcount = new int[32];@@ -116,7 +117,7 @@ public final class plasmaSearchRankingProcess {if (sortorder == 2) {insert(index, true);} else {- final Iterator en = index.entries();+ final Iterator<indexRWIRowEntry> en = index.entries();// generate a new map where the urls are sorted (not by hash but by the url text)indexRWIEntry ientry;@@ -181,7 +182,7 @@ public final class plasmaSearchRankingProcess {// normalize entries and get rankingtimer = System.currentTimeMillis();- Iterator i = container.entries();+ Iterator<indexRWIRowEntry> i = container.entries();indexRWIEntry iEntry, l;long biggestEntry = 0;//long s0 = System.currentTimeMillis();diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.javaindex 88ffe8de2..1dffd4718 100644--- a/source/de/anomic/plasma/plasmaSwitchboard.java+++ b/source/de/anomic/plasma/plasmaSwitchboard.java@@ -152,13 +152,13 @@ import de.anomic.server.serverSwitch;import de.anomic.server.serverThread;import de.anomic.server.logging.serverLog;import de.anomic.tools.crypt;-import de.anomic.yacy.yacyURL;-import de.anomic.yacy.yacyVersion;import de.anomic.yacy.yacyClient;import de.anomic.yacy.yacyCore;import de.anomic.yacy.yacyNewsPool;import de.anomic.yacy.yacyNewsRecord;import de.anomic.yacy.yacySeed;+import de.anomic.yacy.yacyURL;+import de.anomic.yacy.yacyVersion;public final class plasmaSwitchboard extends serverAbstractSwitch implements serverSwitch {diff --git a/source/de/anomic/plasma/plasmaWordIndex.java b/source/de/anomic/plasma/plasmaWordIndex.javaindex 479e10ec1..4b3dff84f 100644--- a/source/de/anomic/plasma/plasmaWordIndex.java+++ b/source/de/anomic/plasma/plasmaWordIndex.java@@ -51,8 +51,8 @@ import de.anomic.kelondro.kelondroMergeIterator;import de.anomic.kelondro.kelondroOrder;import de.anomic.kelondro.kelondroRotateIterator;import de.anomic.plasma.urlPattern.plasmaURLPattern;-import de.anomic.server.logging.serverLog;import de.anomic.server.serverMemory;+import de.anomic.server.logging.serverLog;import de.anomic.yacy.yacyDHTAction;import de.anomic.yacy.yacySeedDB;import de.anomic.yacy.yacyURL;@@ -363,14 +363,14 @@ public final class plasmaWordIndex implements indexRI {return container;}- public Map getContainers(Set wordHashes, Set urlselection, boolean deleteIfEmpty, boolean interruptIfEmpty) {+ public Map<String, indexContainer> getContainers(Set<String> wordHashes, Set<String> urlselection, boolean deleteIfEmpty, boolean interruptIfEmpty) {// return map of wordhash:indexContainer// retrieve entities that belong to the hashes- HashMap containers = new HashMap();+ HashMap<String, indexContainer> containers = new HashMap<String, indexContainer>();String singleHash;indexContainer singleContainer;- Iterator i = wordHashes.iterator();+ Iterator<String> i = wordHashes.iterator();while (i.hasNext()) {// get next word hash:@@ -380,24 +380,24 @@ public final class plasmaWordIndex implements indexRI {singleContainer = getContainer(singleHash, urlselection);// check result- if (((singleContainer == null) || (singleContainer.size() == 0)) && (interruptIfEmpty)) return new HashMap();+ if (((singleContainer == null) || (singleContainer.size() == 0)) && (interruptIfEmpty)) return new HashMap<String, indexContainer>();containers.put(singleHash, singleContainer);}return containers;}- public Map[] localSearchContainers(plasmaSearchQuery query, Set urlselection) {+ public Map<String, indexContainer>[] localSearchContainers(plasmaSearchQuery query, Set<String> urlselection) {// search for the set of hashes and return a map of of wordhash:indexContainer containing the seach result// retrieve entities that belong to the hashes- Map inclusionContainers = (query.queryHashes.size() == 0) ? new HashMap() : getContainers(+ Map<String, indexContainer> inclusionContainers = (query.queryHashes.size() == 0) ? new HashMap<String, indexContainer>() : getContainers(query.queryHashes,urlselection,true,true);- if ((inclusionContainers.size() != 0) && (inclusionContainers.size() < query.queryHashes.size())) inclusionContainers = new HashMap(); // prevent that only a subset is returned- Map exclusionContainers = (inclusionContainers.size() == 0) ? new HashMap() : getContainers(+ if ((inclusionContainers.size() != 0) && (inclusionContainers.size() < query.queryHashes.size())) inclusionContainers = new HashMap<String, indexContainer>(); // prevent that only a subset is returned+ Map<String, indexContainer> exclusionContainers = (inclusionContainers.size() == 0) ? new HashMap<String, indexContainer>() : getContainers(query.excludeHashes,urlselection,true,diff --git a/source/de/anomic/server/serverFileUtils.java b/source/de/anomic/server/serverFileUtils.javaindex 8e5ed3763..b14fe4c59 100644--- a/source/de/anomic/server/serverFileUtils.java+++ b/source/de/anomic/server/serverFileUtils.java@@ -351,8 +351,8 @@ public final class serverFileUtils {return source;}- public static HashSet loadList(File file) {- HashSet set = new HashSet();+ public static HashSet<String> loadList(File file) {+ HashSet<String> set = new HashSet<String>();BufferedReader br = null;try {br = new BufferedReader(new InputStreamReader(new FileInputStream(file)));@@ -369,7 +369,7 @@ public final class serverFileUtils {return set;}- public static Map loadHashMap(File f) {+ public static Map<String, String> loadHashMap(File f) {// load propstry {byte[] b = read(f);@@ -379,35 +379,19 @@ public final class serverFileUtils {return null;}}-- /*- public static Map loadHashMap(File f) {- // load props- Properties prop = new Properties();- BufferedInputStream bufferedIn = null;- try {- prop.load(bufferedIn = new BufferedInputStream(new FileInputStream(f)));- } catch (IOException e1) {- System.err.println("ERROR: " + f.toString() + " not found in settings path");- prop = null;- } finally {- if (bufferedIn != null)try{bufferedIn.close();}catch(Exception e){}- }- return (Hashtable) prop;- }- */- public static void saveMap(File file, Map props, String comment) throws IOException {++ public static void saveMap(File file, Map<String, String> props, String comment) throws IOException {PrintWriter pw = null;File tf = new File(file.toString() + "." + (System.currentTimeMillis() % 1000));pw = new PrintWriter(new BufferedOutputStream(new FileOutputStream(tf)));pw.println("# " + comment);- Iterator i = props.entrySet().iterator();+ Iterator<Map.Entry<String, String>> i = props.entrySet().iterator();String key, value;- Map.Entry entry;+ Map.Entry<String, String> entry;while (i.hasNext()) {- entry = (Map.Entry) i.next();- key = (String) entry.getKey();- value = ((String) entry.getValue()).replaceAll("\n", "\\\\n");+ entry = i.next();+ key = entry.getKey();+ value = entry.getValue().replaceAll("\n", "\\\\n");pw.println(key + "=" + value);}pw.println("# EOF");@@ -416,8 +400,8 @@ public final class serverFileUtils {tf.renameTo(file);}- public static Set loadSet(File file, int chunksize, boolean tree) throws IOException {- Set set = (tree) ? (Set) new TreeSet() : (Set) new HashSet();+ public static Set<String> loadSet(File file, int chunksize, boolean tree) throws IOException {+ Set<String> set = (tree) ? (Set<String>) new TreeSet<String>() : (Set<String>) new HashSet<String>();byte[] b = read(file);for (int i = 0; (i + chunksize) <= b.length; i++) {set.add(new String(b, i, chunksize));@@ -425,8 +409,8 @@ public final class serverFileUtils {return set;}- public static Set loadSet(File file, String sep, boolean tree) throws IOException {- Set set = (tree) ? (Set) new TreeSet() : (Set) new HashSet();+ public static Set<String> loadSet(File file, String sep, boolean tree) throws IOException {+ Set<String> set = (tree) ? (Set<String>) new TreeSet<String>() : (Set<String>) new HashSet<String>();byte[] b = read(file);StringTokenizer st = new StringTokenizer(new String(b, "UTF-8"), sep);while (st.hasMoreTokens()) {@@ -435,7 +419,7 @@ public final class serverFileUtils {return set;}- public static void saveSet(File file, String format, Set set, String sep) throws IOException {+ public static void saveSet(File file, String format, Set<String> set, String sep) throws IOException {File tf = new File(file.toString() + ".tmp" + (System.currentTimeMillis() % 1000));OutputStream os = null;if ((format == null) || (format.equals("plain"))) {@@ -449,7 +433,7 @@ public final class serverFileUtils {zos.putNextEntry(new ZipEntry(name + ".txt"));os = zos;}- for (Iterator i = set.iterator(); i.hasNext(); ) {+ for (Iterator<String> i = set.iterator(); i.hasNext(); ) {os.write((i.next().toString()).getBytes());if (sep != null) os.write(sep.getBytes());}@@ -472,10 +456,10 @@ public final class serverFileUtils {zos.putNextEntry(new ZipEntry(name + ".txt"));os = zos;}- Iterator i = set.rows();+ Iterator<kelondroRow.Entry> i = set.rows();String key;if (i.hasNext()) {- key = new String(((kelondroRow.Entry) i.next()).getColBytes(0));+ key = new String(i.next().getColBytes(0));os.write(key.getBytes());}while (i.hasNext()) {diff --git a/source/de/anomic/tools/nxTools.java b/source/de/anomic/tools/nxTools.javaindex b819d86e3..d9b11663a 100644--- a/source/de/anomic/tools/nxTools.java+++ b/source/de/anomic/tools/nxTools.java@@ -53,30 +53,29 @@ import java.util.Vector;public class nxTools {- public static HashMap table(Vector list) {- Enumeration i = list.elements();- int pos;- String line;- HashMap props = new HashMap(list.size());- while (i.hasMoreElements()) {- line = ((String) i.nextElement()).trim();- //System.out.println("NXTOOLS_PROPS - LINE:" + line);- pos = line.indexOf("=");- if (pos > 0) props.put(line.substring(0, pos).trim(), line.substring(pos + 1).trim());+ public static HashMap<String, String> table(Vector<String> list) {+ Enumeration<String> i = list.elements();+ int pos;+ String line;+ HashMap<String, String> props = new HashMap<String, String>(list.size());+ while (i.hasMoreElements()) {+ line = ((String) i.nextElement()).trim();+ pos = line.indexOf("=");+ if (pos > 0) props.put(line.substring(0, pos).trim(), line.substring(pos + 1).trim());+ }+ return props;}- return props;- }- public static HashMap table(byte[] a, String encoding) {+ public static HashMap<String, String> table(byte[] a, String encoding) {return table(strings(a, encoding));}- public static HashMap table(ArrayList list) {- if (list == null) return new HashMap();- Iterator i = list.iterator();+ public static HashMap<String, String> table(ArrayList<String> list) {+ if (list == null) return new HashMap<String, String>();+ Iterator<String> i = list.iterator();int pos;String line;- HashMap props = new HashMap(list.size());+ HashMap<String, String> props = new HashMap<String, String>(list.size());while (i.hasNext()) {line = ((String) i.next()).trim();if (line.startsWith("#")) continue; // exclude comments@@ -87,29 +86,29 @@ public class nxTools {return props;}- public static Vector grep(Vector list, int afterContext, String pattern) {- Enumeration i = list.elements();- int ac = 0;- String line;- Vector result = new Vector();- while (i.hasMoreElements()) {- line = (String) i.nextElement();- if (line.indexOf(pattern) >= 0) {- result.add(line);- ac = afterContext + 1;- } else if (ac > 0) {- result.add(line);- }- ac--;+ public static Vector<String> grep(Vector<String> list, int afterContext, String pattern) {+ Enumeration<String> i = list.elements();+ int ac = 0;+ String line;+ Vector<String> result = new Vector<String>();+ while (i.hasMoreElements()) {+ line = (String) i.nextElement();+ if (line.indexOf(pattern) >= 0) {+ result.add(line);+ ac = afterContext + 1;+ } else if (ac > 0) {+ result.add(line);+ }+ ac--;+ }+ return result;}- return result;- }- public static ArrayList grep(ArrayList list, int afterContext, String pattern) {- Iterator i = list.iterator();+ public static ArrayList<String> grep(ArrayList<String> list, int afterContext, String pattern) {+ Iterator<String> i = list.iterator();int ac = 0;String line;- ArrayList result = new ArrayList();+ ArrayList<String> result = new ArrayList<String>();while (i.hasNext()) {line = (String) i.next();if (line.indexOf(pattern) >= 0) {@@ -123,12 +122,12 @@ public class nxTools {return result;}- public static String tail1(Vector list) {- if ((list == null) || (list.size() == 0)) return "";- return (String) list.lastElement();+ public static String tail1(Vector<String> list) {+ if ((list == null) || (list.size() == 0)) return "";+ return (String) list.lastElement();}- public static String tail1(ArrayList list) {+ public static String tail1(ArrayList<String> list) {if ((list == null) || (list.size() == 0)) return "";return (String) list.get(list.size()-1);}@@ -151,15 +150,15 @@ public class nxTools {return null;}- public static ArrayList strings(byte[] a) {+ public static ArrayList<String> strings(byte[] a) {return strings(a, null);}- public static ArrayList strings(byte[] a, String encoding) {- if (a == null) return new ArrayList();+ public static ArrayList<String> strings(byte[] a, String encoding) {+ if (a == null) return new ArrayList<String>();int s = 0;int e;- ArrayList v = new ArrayList();+ ArrayList<String> v = new ArrayList<String>();byte b;while (s < a.length) {// find eol