Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

refactoring of kelondro database classes (to be continued)

orbiterbf93767ec6a8
diff --git a/htroot/AccessTracker_p.java b/htroot/AccessTracker_p.java
index dfb737387..42bea7718 100644
--- a/htroot/AccessTracker_p.java
+++ b/htroot/AccessTracker_p.java
@@ -34,7 +34,7 @@ import java.util.TreeSet;
import java.util.Map.Entry;
import de.anomic.http.httpRequestHeader;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.DateFormatter;
import de.anomic.net.natLib;
import de.anomic.plasma.plasmaSearchQuery;
import de.anomic.plasma.plasmaSwitchboard;
@@ -108,7 +108,7 @@ public class AccessTracker_p {
while (ii.hasNext()) {
entry = ii.next();
prop.putHTML("page_list_" + entCount + "_host", host);
- prop.put("page_list_" + entCount + "_date", kelondroDate.formatShortSecond(new Date((entry.getKey()).longValue())));
+ prop.put("page_list_" + entCount + "_date", DateFormatter.formatShortSecond(new Date((entry.getKey()).longValue())));
prop.putHTML("page_list_" + entCount + "_path", entry.getValue());
entCount++;
}
@@ -124,7 +124,7 @@ public class AccessTracker_p {
while (ii.hasNext()) {
entry = ii.next();
prop.putHTML("page_list_" + entCount + "_host", host);
- prop.put("page_list_" + entCount + "_date", kelondroDate.formatShortSecond(new Date((entry.getKey()).longValue())));
+ prop.put("page_list_" + entCount + "_date", DateFormatter.formatShortSecond(new Date((entry.getKey()).longValue())));
prop.putHTML("page_list_" + entCount + "_path", entry.getValue());
entCount++;
}
@@ -155,7 +155,7 @@ public class AccessTracker_p {
prop.put("page_list_" + entCount + "_dark", ((dark) ? 1 : 0) );
dark =! dark;
prop.putHTML("page_list_" + entCount + "_host", searchProfile.host);
- prop.put("page_list_" + entCount + "_date", kelondroDate.formatShortSecond(new Date(searchProfile.handle.longValue())));
+ prop.put("page_list_" + entCount + "_date", DateFormatter.formatShortSecond(new Date(searchProfile.handle.longValue())));
prop.put("page_list_" + entCount + "_timestamp", searchProfile.handle.longValue());
if (page == 2) {
// local search
@@ -218,7 +218,7 @@ public class AccessTracker_p {
final Iterator<Long> ii = handles.iterator();
while (ii.hasNext()) {
final Long timestamp = ii.next();
- prop.put("page_list_" + entCount + "_dates_" + dateCount + "_date", kelondroDate.formatShortSecond(new Date(timestamp.longValue())));
+ prop.put("page_list_" + entCount + "_dates_" + dateCount + "_date", DateFormatter.formatShortSecond(new Date(timestamp.longValue())));
prop.put("page_list_" + entCount + "_dates_" + dateCount + "_timestamp", timestamp.toString());
dateCount++;
}
diff --git a/htroot/Blog.java b/htroot/Blog.java
index ef19352a9..64af8a30a 100644
--- a/htroot/Blog.java
+++ b/htroot/Blog.java
@@ -37,7 +37,7 @@ import java.util.Iterator;
import de.anomic.data.blogBoard;
import de.anomic.data.userDB;
import de.anomic.http.httpRequestHeader;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.DateFormatter;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -344,7 +344,7 @@ public class Blog {
}
prop.put("mode_entries_" + number + "_date", dateString(entry.getDate()));
- prop.put("mode_entries_" + number + "_rfc822date", kelondroDate.formatRFC1123(entry.getDate()));
+ prop.put("mode_entries_" + number + "_rfc822date", DateFormatter.formatRFC1123(entry.getDate()));
prop.put("mode_entries_" + number + "_pageid", entry.getKey());
prop.put("mode_entries_" + number + "_address", address);
prop.put("mode_entries_" + number + "_ip", entry.getIp());
diff --git a/htroot/Bookmarks.java b/htroot/Bookmarks.java
index c0ca98d6c..4f7b316bd 100644
--- a/htroot/Bookmarks.java
+++ b/htroot/Bookmarks.java
@@ -42,7 +42,7 @@ import de.anomic.data.userDB;
import de.anomic.data.bookmarksDB.Tag;
import de.anomic.http.httpRequestHeader;
import de.anomic.index.indexURLReference;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.DateFormatter;
import de.anomic.plasma.plasmaParserDocument;
import de.anomic.plasma.plasmaSnippetCache;
import de.anomic.plasma.plasmaSwitchboard;
@@ -292,8 +292,8 @@ public class Bookmarks {
prop.put("bookmarks_"+count+"_link",bookmark.getUrl());
prop.putHTML("bookmarks_"+count+"_title", bookmark.getTitle());
prop.putHTML("bookmarks_"+count+"_description", bookmark.getDescription());
- prop.put("bookmarks_"+count+"_date", kelondroDate.formatISO8601(new Date(bookmark.getTimeStamp())));
- prop.put("bookmarks_"+count+"_rfc822date", kelondroDate.formatRFC1123(new Date(bookmark.getTimeStamp())));
+ prop.put("bookmarks_"+count+"_date", DateFormatter.formatISO8601(new Date(bookmark.getTimeStamp())));
+ prop.put("bookmarks_"+count+"_rfc822date", DateFormatter.formatRFC1123(new Date(bookmark.getTimeStamp())));
prop.put("bookmarks_"+count+"_public", (bookmark.getPublic() ? "1" : "0"));
//List Tags.
diff --git a/htroot/ConfigAccounts_p.java b/htroot/ConfigAccounts_p.java
index ba1549395..8b6c4a7d0 100644
--- a/htroot/ConfigAccounts_p.java
+++ b/htroot/ConfigAccounts_p.java
@@ -33,8 +33,8 @@ import java.util.Iterator;
import de.anomic.data.userDB;
import de.anomic.http.httpRequestHeader;
import de.anomic.http.httpd;
-import de.anomic.kelondro.kelondroBase64Order;
-import de.anomic.kelondro.kelondroDigest;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.Digest;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -57,7 +57,7 @@ public class ConfigAccounts_p {
// may be overwritten if new password is given
if ((user.length() > 0) && (pw1.length() > 3) && (pw1.equals(pw2))) {
// check passed. set account:
- env.setConfig(httpd.ADMIN_ACCOUNT_B64MD5, kelondroDigest.encodeMD5Hex(kelondroBase64Order.standardCoder.encodeString(user + ":" + pw1)));
+ env.setConfig(httpd.ADMIN_ACCOUNT_B64MD5, Digest.encodeMD5Hex(Base64Order.standardCoder.encodeString(user + ":" + pw1)));
env.setConfig("adminAccount", "");
}
@@ -73,7 +73,7 @@ public class ConfigAccounts_p {
// if not, set a random password
if (post != null && env.getConfig(httpd.ADMIN_ACCOUNT_B64MD5, "").length() == 0) {
// make a 'random' password
- env.setConfig(httpd.ADMIN_ACCOUNT_B64MD5, "0000" + kelondroDigest.encodeMD5Hex(System.getProperties().toString() + System.currentTimeMillis()));
+ env.setConfig(httpd.ADMIN_ACCOUNT_B64MD5, "0000" + Digest.encodeMD5Hex(System.getProperties().toString() + System.currentTimeMillis()));
env.setConfig("adminAccount", "");
}
}
@@ -171,7 +171,7 @@ public class ConfigAccounts_p {
if( post.get("current_user").equals("newuser")){ //new user
if(!pw1.equals("")){ //change only if set
- mem.put(userDB.Entry.MD5ENCODED_USERPWD_STRING, kelondroDigest.encodeMD5Hex(username+":"+pw1));
+ mem.put(userDB.Entry.MD5ENCODED_USERPWD_STRING, Digest.encodeMD5Hex(username+":"+pw1));
}
mem.put(userDB.Entry.USER_FIRSTNAME, firstName);
mem.put(userDB.Entry.USER_LASTNAME, lastName);
@@ -196,7 +196,7 @@ public class ConfigAccounts_p {
if(entry != null){
try{
if(! pw1.equals("")){
- entry.setProperty(userDB.Entry.MD5ENCODED_USERPWD_STRING, kelondroDigest.encodeMD5Hex(username+":"+pw1));
+ entry.setProperty(userDB.Entry.MD5ENCODED_USERPWD_STRING, Digest.encodeMD5Hex(username+":"+pw1));
}
entry.setProperty(userDB.Entry.USER_FIRSTNAME, firstName);
entry.setProperty(userDB.Entry.USER_LASTNAME, lastName);
diff --git a/htroot/Connections_p.java b/htroot/Connections_p.java
index cc3a859a3..0855937a3 100644
--- a/htroot/Connections_p.java
+++ b/htroot/Connections_p.java
@@ -37,7 +37,7 @@ import de.anomic.http.HttpConnectionInfo;
import de.anomic.http.JakartaCommonsHttpClient;
import de.anomic.http.httpRequestHeader;
import de.anomic.http.httpd;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.DateFormatter;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverCore;
import de.anomic.server.serverHandler;
@@ -183,7 +183,7 @@ public final class Connections_p {
prop.put("list_" + idx + "_proto", prot);
if (sessionTime > 1000*60) {
prop.put("list_" + idx + "_ms", "0");
- prop.put("list_" + idx + "_ms_duration",kelondroDate.formatInterval(sessionTime));
+ prop.put("list_" + idx + "_ms_duration",DateFormatter.formatInterval(sessionTime));
} else {
prop.put("list_" + idx + "_ms", "1");
prop.putNum("list_" + idx + "_ms_duration", sessionTime);
diff --git a/htroot/CookieMonitorIncoming_p.java b/htroot/CookieMonitorIncoming_p.java
index ce98ca8df..e87e5eda6 100644
--- a/htroot/CookieMonitorIncoming_p.java
+++ b/htroot/CookieMonitorIncoming_p.java
@@ -29,7 +29,7 @@ import java.util.Iterator;
import java.util.Map;
import de.anomic.http.httpRequestHeader;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.DateFormatter;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -78,7 +78,7 @@ public class CookieMonitorIncoming_p {
prop.put("list_" + entCount + "_dark", dark ? "1" : "0");
dark =! dark;
prop.put("list_" + entCount + "_host", host);
- prop.put("list_" + entCount + "_date", kelondroDate.formatRFC1123(date));
+ prop.put("list_" + entCount + "_date", DateFormatter.formatRFC1123(date));
prop.put("list_" + entCount + "_client", client);
while (tmpCount < cookies.length){
prop.putHTML("list_" + entCount + "_cookies_" + tmpCount + "_item", ((String) cookies[tmpCount]));
diff --git a/htroot/CookieMonitorOutgoing_p.java b/htroot/CookieMonitorOutgoing_p.java
index 9afd68815..b2efd2b45 100644
--- a/htroot/CookieMonitorOutgoing_p.java
+++ b/htroot/CookieMonitorOutgoing_p.java
@@ -29,7 +29,7 @@ import java.util.Iterator;
import java.util.Map;
import de.anomic.http.httpRequestHeader;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.DateFormatter;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -78,7 +78,7 @@ public class CookieMonitorOutgoing_p {
prop.put("list_" + entCount + "_dark", dark ? "1" : "0" );
dark =! dark;
prop.put("list_" + entCount + "_host", host);
- prop.put("list_" + entCount + "_date", kelondroDate.formatRFC1123(date));
+ prop.put("list_" + entCount + "_date", DateFormatter.formatRFC1123(date));
prop.put("list_" + entCount + "_client", client);
while (tmpCount < cookies.length){
prop.putHTML("list_" + entCount + "_cookies_" + tmpCount + "_item", ((String) cookies[tmpCount]));
diff --git a/htroot/IndexControlRWIs_p.java b/htroot/IndexControlRWIs_p.java
index 00372ed19..9b85d4038 100644
--- a/htroot/IndexControlRWIs_p.java
+++ b/htroot/IndexControlRWIs_p.java
@@ -42,7 +42,7 @@ import de.anomic.index.indexRWIEntry;
import de.anomic.index.indexRWIRowEntry;
import de.anomic.index.indexURLReference;
import de.anomic.index.indexWord;
-import de.anomic.kelondro.kelondroBitfield;
+import de.anomic.kelondro.coding.Bitfield;
import de.anomic.plasma.plasmaSearchAPI;
import de.anomic.plasma.plasmaSearchEvent;
import de.anomic.plasma.plasmaSearchRankingProcess;
@@ -168,7 +168,7 @@ public class IndexControlRWIs_p {
if (keystring.length() == 0 || !indexWord.word2hash(keystring).equals(keyhash)) {
prop.put("keystring", "&lt;not possible to compute word from hash&gt;");
}
- final kelondroBitfield flags = plasmaSearchAPI.compileFlags(post);
+ final Bitfield flags = plasmaSearchAPI.compileFlags(post);
final int count = (post.get("lines", "all").equals("all")) ? -1 : post.getInt("lines", -1);
final plasmaSearchRankingProcess ranking = plasmaSearchAPI.genSearchresult(prop, sb, keyhash, flags);
plasmaSearchAPI.genURLList(prop, keyhash, keystring, ranking, flags, count);
diff --git a/htroot/IndexControlURLs_p.java b/htroot/IndexControlURLs_p.java
index 617044271..edaa35a27 100644
--- a/htroot/IndexControlURLs_p.java
+++ b/htroot/IndexControlURLs_p.java
@@ -33,9 +33,9 @@ import java.util.Iterator;
import de.anomic.http.httpRequestHeader;
import de.anomic.index.indexRepositoryReference;
import de.anomic.index.indexURLReference;
-import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroRotateIterator;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.DateFormatter;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -72,7 +72,7 @@ public class IndexControlURLs_p {
prop.put("reload", 1);
} else {
prop.put("lurlexport", 1);
- prop.put("lurlexport_exportfile", sb.getRootPath() + "/DATA/EXPORT/" + kelondroDate.formatShortSecond());
+ prop.put("lurlexport_exportfile", sb.getRootPath() + "/DATA/EXPORT/" + DateFormatter.formatShortSecond());
if (export == null) {
// there has never been an export
prop.put("lurlexportfinished", 0);
@@ -181,7 +181,7 @@ public class IndexControlURLs_p {
// generate list
if (post.containsKey("urlhashsimilar")) {
try {
- final Iterator<indexURLReference> entryIt = new kelondroRotateIterator<indexURLReference>(sb.webIndex.entriesURL(true, urlhash), new String(kelondroBase64Order.zero((urlhash == null ? 0 : urlhash.length()))), sb.webIndex.size());
+ final Iterator<indexURLReference> entryIt = new kelondroRotateIterator<indexURLReference>(sb.webIndex.entriesURL(true, urlhash), new String(Base64Order.zero((urlhash == null ? 0 : urlhash.length()))), sb.webIndex.size());
final StringBuilder result = new StringBuilder("Sequential List of URL-Hashes:<br />");
indexURLReference entry;
int i = 0;
diff --git a/htroot/IndexCreateIndexingQueue_p.java b/htroot/IndexCreateIndexingQueue_p.java
index b6ed4578c..3093d6134 100644
--- a/htroot/IndexCreateIndexingQueue_p.java
+++ b/htroot/IndexCreateIndexingQueue_p.java
@@ -30,7 +30,7 @@ import java.util.Iterator;
import de.anomic.crawler.IndexingStack;
import de.anomic.crawler.ZURL;
import de.anomic.http.httpRequestHeader;
-import de.anomic.kelondro.kelondroMemory;
+import de.anomic.kelondro.tools.MemoryControl;
import de.anomic.plasma.plasmaHTCache;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
@@ -123,7 +123,7 @@ public class IndexCreateIndexingQueue_p {
prop.put("indexing-queue_list_"+entryCount+"_modified", pcentry.getModificationDate().toString());
prop.putHTML("indexing-queue_list_"+entryCount+"_anchor", (pcentry.anchorName()==null)?"":pcentry.anchorName());
prop.putHTML("indexing-queue_list_"+entryCount+"_url", pcentry.url().toNormalform(false, true));
- prop.put("indexing-queue_list_"+entryCount+"_size", kelondroMemory.bytesToString(entrySize));
+ prop.put("indexing-queue_list_"+entryCount+"_size", MemoryControl.bytesToString(entrySize));
prop.put("indexing-queue_list_"+entryCount+"_inProcess", inProcess ? "1" :"0");
prop.put("indexing-queue_list_"+entryCount+"_inProcess_hash", pcentry.urlHash());
dark = !dark;
@@ -133,7 +133,7 @@ public class IndexCreateIndexingQueue_p {
prop.putNum("indexing-queue_show", entryCount);//show shown entries
prop.putNum("indexing-queue_num", totalCount); //num entries in queue
- prop.put("indexing-queue_totalSize", kelondroMemory.bytesToString(totalSize));//num entries in queue
+ prop.put("indexing-queue_totalSize", MemoryControl.bytesToString(totalSize));//num entries in queue
prop.putNum("indexing-queue_list", entryCount);
}
diff --git a/htroot/IndexImport_p.java b/htroot/IndexImport_p.java
index ae87b2803..f4e31f170 100644
--- a/htroot/IndexImport_p.java
+++ b/htroot/IndexImport_p.java
@@ -35,8 +35,8 @@ import java.util.Date;
import de.anomic.crawler.Importer;
import de.anomic.crawler.NoticeURLImporter;
import de.anomic.http.httpRequestHeader;
-import de.anomic.kelondro.kelondroDate;
-import de.anomic.kelondro.kelondroByteBuffer;
+import de.anomic.kelondro.coding.DateFormatter;
+import de.anomic.kelondro.tools.ByteBuffer;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -65,7 +65,7 @@ public final class IndexImport_p {
return prop;
}
} catch (final Exception e) {
- final kelondroByteBuffer errorMsg = new kelondroByteBuffer(100);
+ final ByteBuffer errorMsg = new ByteBuffer(100);
final PrintStream errorOut = new PrintStream(errorMsg);
e.printStackTrace(errorOut);
@@ -138,8 +138,8 @@ public final class IndexImport_p {
// other information
prop.putNum("running.jobs_" + i + "_percent", currThread.getProcessingStatusPercent());
- prop.put("running.jobs_" + i + "_elapsed", kelondroDate.formatInterval(currThread.getElapsedTime()));
- prop.put("running.jobs_" + i + "_estimated", kelondroDate.formatInterval(currThread.getEstimatedTime()));
+ prop.put("running.jobs_" + i + "_elapsed", DateFormatter.formatInterval(currThread.getElapsedTime()));
+ prop.put("running.jobs_" + i + "_estimated", DateFormatter.formatInterval(currThread.getEstimatedTime()));
prop.putHTML("running.jobs_" + i + "_status", currThread.getStatus().replaceAll("\n", "<br>"));
// job number of the importer thread
@@ -166,7 +166,7 @@ public final class IndexImport_p {
prop.put("finished.jobs_" + i + "_runningStatus", "0");
}
prop.putNum("finished.jobs_" + i + "_percent", currThread.getProcessingStatusPercent());
- prop.put("finished.jobs_" + i + "_elapsed", kelondroDate.formatInterval(currThread.getElapsedTime()));
+ prop.put("finished.jobs_" + i + "_elapsed", DateFormatter.formatInterval(currThread.getElapsedTime()));
prop.putHTML("finished.jobs_" + i + "_status", currThread.getStatus().replaceAll("\n", "<br>"));
}
prop.put("finished.jobs",finishedJobs.length);
diff --git a/htroot/IndexTransfer_p.java b/htroot/IndexTransfer_p.java
index be38c2aaf..05e7edc05 100644
--- a/htroot/IndexTransfer_p.java
+++ b/htroot/IndexTransfer_p.java
@@ -35,7 +35,7 @@ import java.util.NoSuchElementException;
import java.util.TreeMap;
import de.anomic.http.httpRequestHeader;
-import de.anomic.kelondro.kelondroMemory;
+import de.anomic.kelondro.tools.MemoryControl;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -95,7 +95,7 @@ public final class IndexTransfer_p {
prop.putNum("running_twEntityCount", sb.transferIdxThread.getTransferedContainerCount());
prop.putNum("running_twEntryCount", sb.transferIdxThread.getTransferedEntryCount());
- prop.put("running_twPayloadSize", kelondroMemory.bytesToString(sb.transferIdxThread.getTransferedBytes()));
+ prop.put("running_twPayloadSize", MemoryControl.bytesToString(sb.transferIdxThread.getTransferedBytes()));
prop.putNum("running_twEntityPercent", sb.transferIdxThread.getTransferedContainerPercent());
prop.putNum("running_twEntrySpeed", sb.transferIdxThread.getTransferedEntrySpeed());
diff --git a/htroot/Messages_p.java b/htroot/Messages_p.java
index 3fb079a0f..d07e03e3b 100644
--- a/htroot/Messages_p.java
+++ b/htroot/Messages_p.java
@@ -34,7 +34,7 @@ import java.util.TreeMap;
import de.anomic.data.messageBoard;
import de.anomic.http.httpRequestHeader;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.DateFormatter;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverFileUtils;
import de.anomic.server.serverObjects;
@@ -131,7 +131,7 @@ public class Messages_p {
prop.put("mode_messages_"+count+"_peerAddress", peerAddress);
// set the rfc822 date
- prop.put("mode_messages_"+count+"_rfc822Date", kelondroDate.formatRFC1123(message.date()));
+ prop.put("mode_messages_"+count+"_rfc822Date", DateFormatter.formatRFC1123(message.date()));
// also write out the message body (needed for the RSS feed)
try {
diff --git a/htroot/Network.java b/htroot/Network.java
index bc5eeb1fd..aa0ce7ec2 100644
--- a/htroot/Network.java
+++ b/htroot/Network.java
@@ -38,7 +38,7 @@ import java.util.regex.PatternSyntaxException;
import de.anomic.crawler.HTTPLoader;
import de.anomic.http.HttpClient;
import de.anomic.http.httpRequestHeader;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.DateFormatter;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaSwitchboardConstants;
import de.anomic.server.serverCodings;
@@ -128,7 +128,7 @@ public class Network {
myqph = 60d * seed.getQPM();
prop.put("table_my-version", seed.get(yacySeed.VERSION, "-"));
prop.put("table_my-utc", seed.get(yacySeed.UTC, "-"));
- prop.put("table_my-uptime", kelondroDate.formatInterval(60000 * Long.parseLong(seed.get(yacySeed.UPTIME, ""))));
+ prop.put("table_my-uptime", DateFormatter.formatInterval(60000 * Long.parseLong(seed.get(yacySeed.UPTIME, ""))));
prop.putNum("table_my-LCount", LCount);
prop.putNum("table_my-ICount", ICount);
prop.putNum("table_my-RCount", RCount);
@@ -421,7 +421,7 @@ public class Network {
prop.putHTML(STR_TABLE_LIST + conCount + "_version", yacyVersion.combined2prettyVersion(seed.get(yacySeed.VERSION, "0.1"), shortname));
prop.putNum(STR_TABLE_LIST + conCount + "_lastSeen", /*seed.getLastSeenString() + " " +*/ lastseen);
prop.put(STR_TABLE_LIST + conCount + "_utc", seed.get(yacySeed.UTC, "-"));
- prop.putHTML(STR_TABLE_LIST + conCount + "_uptime", kelondroDate.formatInterval(60000 * Long.parseLong(seed.get(yacySeed.UPTIME, "0"))));
+ prop.putHTML(STR_TABLE_LIST + conCount + "_uptime", DateFormatter.formatInterval(60000 * Long.parseLong(seed.get(yacySeed.UPTIME, "0"))));
prop.putNum(STR_TABLE_LIST + conCount + "_LCount", seed.getLong(yacySeed.LCOUNT, 0));
prop.putNum(STR_TABLE_LIST + conCount + "_ICount", seed.getLong(yacySeed.ICOUNT, 0));
prop.putNum(STR_TABLE_LIST + conCount + "_RCount", seed.getLong(yacySeed.RCOUNT, 0));
diff --git a/htroot/News.java b/htroot/News.java
index accb54869..ff2022cd2 100644
--- a/htroot/News.java
+++ b/htroot/News.java
@@ -30,7 +30,7 @@ import java.util.Map;
import java.util.Map.Entry;
import de.anomic.http.httpRequestHeader;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.DateFormatter;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -115,10 +115,10 @@ public class News {
final String category = record.category();
prop.put("table_list_" + i + "_id", record.id());
prop.putHTML("table_list_" + i + "_ori", (seed == null) ? record.originator() : seed.getName());
- prop.put("table_list_" + i + "_cre", kelondroDate.formatShortSecond(record.created()));
- prop.put("table_list_" + i + "_crerfcdate", kelondroDate.formatRFC1123(record.created()));
+ prop.put("table_list_" + i + "_cre", DateFormatter.formatShortSecond(record.created()));
+ prop.put("table_list_" + i + "_crerfcdate", DateFormatter.formatRFC1123(record.created()));
prop.putHTML("table_list_" + i + "_cat", category);
- prop.put("table_list_" + i + "_rec", (record.received() == null) ? "-" : kelondroDate.formatShortSecond(record.received()));
+ prop.put("table_list_" + i + "_rec", (record.received() == null) ? "-" : DateFormatter.formatShortSecond(record.received()));
prop.put("table_list_" + i + "_dis", record.distributed());
final Map<String, String> attributeMap = record.attributes();
diff --git a/htroot/PerformanceMemory_p.java b/htroot/PerformanceMemory_p.java
index b50328234..cadeb4524 100644
--- a/htroot/PerformanceMemory_p.java
+++ b/htroot/PerformanceMemory_p.java
@@ -34,7 +34,7 @@ import de.anomic.kelondro.kelondroCache;
import de.anomic.kelondro.kelondroCachedRecords;
import de.anomic.kelondro.kelondroEcoTable;
import de.anomic.kelondro.kelondroFlexTable;
-import de.anomic.kelondro.kelondroMemory;
+import de.anomic.kelondro.tools.MemoryControl;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverDomains;
import de.anomic.server.serverFileUtils;
@@ -62,15 +62,15 @@ public class PerformanceMemory_p {
}
}
- final long memoryFreeNow = kelondroMemory.free();
+ final long memoryFreeNow = MemoryControl.free();
final long memoryFreeAfterInitBGC = Long.parseLong(env.getConfig("memoryFreeAfterInitBGC", "0"));
final long memoryFreeAfterInitAGC = Long.parseLong(env.getConfig("memoryFreeAfterInitAGC", "0"));
final long memoryFreeAfterStartup = Long.parseLong(env.getConfig("memoryFreeAfterStartup", "0"));
- final long memoryTotalNow = kelondroMemory.total();
+ final long memoryTotalNow = MemoryControl.total();
final long memoryTotalAfterInitBGC = Long.parseLong(env.getConfig("memoryTotalAfterInitBGC", "0"));
final long memoryTotalAfterInitAGC = Long.parseLong(env.getConfig("memoryTotalAfterInitAGC", "0"));
final long memoryTotalAfterStartup = Long.parseLong(env.getConfig("memoryTotalAfterStartup", "0"));
- final long memoryMax = kelondroMemory.max();
+ final long memoryMax = MemoryControl.max();
prop.putNum("memoryMax", memoryMax / MB);
prop.putNum("memoryAvailAfterStartup", (memoryMax - memoryTotalAfterStartup + memoryFreeAfterStartup) / MB);
@@ -104,7 +104,7 @@ public class PerformanceMemory_p {
prop.put("TableList_" + c + "_tableIndexPath", ((p = filename.indexOf("DATA")) < 0) ? filename : filename.substring(p));
prop.put("TableList_" + c + "_tableIndexChunkSize", map.get("tableIndexChunkSize"));
prop.putNum("TableList_" + c + "_tableIndexCount", map.get("tableIndexCount"));
- prop.put("TableList_" + c + "_tableIndexMem", kelondroMemory.bytesToString(mem));
+ prop.put("TableList_" + c + "_tableIndexMem", MemoryControl.bytesToString(mem));
c++;
}
prop.put("TableList", c);
@@ -122,12 +122,12 @@ public class PerformanceMemory_p {
mem = Long.parseLong(map.get("tableKeyMem"));
totalmem += mem;
- prop.put("EcoList_" + c + "_tableKeyMem", kelondroMemory.bytesToString(mem));
+ prop.put("EcoList_" + c + "_tableKeyMem", MemoryControl.bytesToString(mem));
prop.put("EcoList_" + c + "_tableKeyChunkSize", map.get("tableKeyChunkSize"));
mem = Long.parseLong(map.get("tableValueMem"));
totalmem += mem;
- prop.put("EcoList_" + c + "_tableValueMem", kelondroMemory.bytesToString(mem));
+ prop.put("EcoList_" + c + "_tableValueMem", MemoryControl.bytesToString(mem));
prop.put("EcoList_" + c + "_tableValueChunkSize", map.get("tableValueChunkSize"));
c++;
@@ -147,7 +147,7 @@ public class PerformanceMemory_p {
prop.put("NodeList_" + c + "_nodeCachePath", ((p = filename.indexOf("DATA")) < 0) ? filename : filename.substring(p));
prop.put("NodeList_" + c + "_nodeChunkSize", map.get("nodeChunkSize"));
prop.putNum("NodeList_" + c + "_nodeCacheCount", map.get("nodeCacheCount"));
- prop.put("NodeList_" + c + "_nodeCacheMem", kelondroMemory.bytesToString(mem));
+ prop.put("NodeList_" + c + "_nodeCacheMem", MemoryControl.bytesToString(mem));
prop.putNum("NodeList_" + c + "_nodeCacheReadHit", map.get("nodeCacheReadHit"));
prop.putNum("NodeList_" + c + "_nodeCacheReadMiss", map.get("nodeCacheReadMiss"));
prop.putNum("NodeList_" + c + "_nodeCacheWriteUnique", map.get("nodeCacheWriteUnique"));
@@ -175,7 +175,7 @@ public class PerformanceMemory_p {
totalhitmem += hitmem;
prop.put("ObjectList_" + c + "_objectHitChunkSize", map.get("objectHitChunkSize"));
prop.putNum("ObjectList_" + c + "_objectHitCacheCount", map.get("objectHitCacheCount"));
- prop.put("ObjectList_" + c + "_objectHitCacheMem", kelondroMemory.bytesToString(hitmem));
+ prop.put("ObjectList_" + c + "_objectHitCacheMem", MemoryControl.bytesToString(hitmem));
prop.putNum("ObjectList_" + c + "_objectHitCacheReadHit", map.get("objectHitCacheReadHit"));
prop.putNum("ObjectList_" + c + "_objectHitCacheReadMiss", map.get("objectHitCacheReadMiss"));
prop.putNum("ObjectList_" + c + "_objectHitCacheWriteUnique", map.get("objectHitCacheWriteUnique"));
@@ -188,7 +188,7 @@ public class PerformanceMemory_p {
totalmissmem += missmem;
prop.put("ObjectList_" + c + "_objectMissChunkSize", map.get("objectMissChunkSize"));
prop.putNum("ObjectList_" + c + "_objectMissCacheCount", map.get("objectMissCacheCount"));
- prop.putHTML("ObjectList_" + c + "_objectMissCacheMem", kelondroMemory.bytesToString(missmem));
+ prop.putHTML("ObjectList_" + c + "_objectMissCacheMem", MemoryControl.bytesToString(missmem));
prop.putNum("ObjectList_" + c + "_objectMissCacheReadHit", map.get("objectMissCacheReadHit"));
prop.putNum("ObjectList_" + c + "_objectMissCacheReadMiss", map.get("objectMissCacheReadMiss"));
prop.putNum("ObjectList_" + c + "_objectMissCacheWriteUnique", map.get("objectMissCacheWriteUnique"));
diff --git a/htroot/SettingsAck_p.java b/htroot/SettingsAck_p.java
index 7e569ac5b..b964e43bb 100644
--- a/htroot/SettingsAck_p.java
+++ b/htroot/SettingsAck_p.java
@@ -42,10 +42,10 @@ import de.anomic.http.httpRequestHeader;
import de.anomic.http.httpRemoteProxyConfig;
import de.anomic.http.httpd;
import de.anomic.http.httpdProxyHandler;
-import de.anomic.kelondro.kelondroBase64Order;
-import de.anomic.kelondro.kelondroDigest;
-import de.anomic.kelondro.kelondroDate;
-import de.anomic.kelondro.kelondroMemory;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.DateFormatter;
+import de.anomic.kelondro.coding.Digest;
+import de.anomic.kelondro.tools.MemoryControl;
import de.anomic.plasma.plasmaParser;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverCore;
@@ -95,7 +95,7 @@ public class SettingsAck_p {
return prop;
}
// check passed. set account:
- env.setConfig(httpd.ADMIN_ACCOUNT_B64MD5, kelondroDigest.encodeMD5Hex(kelondroBase64Order.standardCoder.encodeString(user + ":" + pw1)));
+ env.setConfig(httpd.ADMIN_ACCOUNT_B64MD5, Digest.encodeMD5Hex(Base64Order.standardCoder.encodeString(user + ":" + pw1)));
env.setConfig("adminAccount", "");
prop.put("info", "5");//admin account changed
prop.putHTML("info_user", user);
@@ -558,9 +558,9 @@ public class SettingsAck_p {
}
// everything is ok
- prop.put("info_crawler.clientTimeout",(crawlerTimeout==0) ? "0" :kelondroDate.formatInterval(crawlerTimeout));
- prop.put("info_crawler.http.maxFileSize",(maxHttpSize==-1)? "-1":kelondroMemory.bytesToString(maxHttpSize));
- prop.put("info_crawler.ftp.maxFileSize", (maxFtpSize==-1) ? "-1":kelondroMemory.bytesToString(maxFtpSize));
+ prop.put("info_crawler.clientTimeout",(crawlerTimeout==0) ? "0" :DateFormatter.formatInterval(crawlerTimeout));
+ prop.put("info_crawler.http.maxFileSize",(maxHttpSize==-1)? "-1":MemoryControl.bytesToString(maxHttpSize));
+ prop.put("info_crawler.ftp.maxFileSize", (maxFtpSize==-1) ? "-1":MemoryControl.bytesToString(maxFtpSize));
prop.put("info", "28");
return prop;
}
diff --git a/htroot/Status.java b/htroot/Status.java
index e0e85f7b0..7f6cfd83e 100644
--- a/htroot/Status.java
+++ b/htroot/Status.java
@@ -33,8 +33,8 @@ import de.anomic.http.httpRequestHeader;
import de.anomic.http.httpd;
import de.anomic.http.httpdByteCountInputStream;
import de.anomic.http.httpdByteCountOutputStream;
-import de.anomic.kelondro.kelondroDate;
-import de.anomic.kelondro.kelondroMemory;
+import de.anomic.kelondro.coding.DateFormatter;
+import de.anomic.kelondro.tools.MemoryControl;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaSwitchboardConstants;
import de.anomic.server.serverCore;
@@ -130,7 +130,7 @@ public class Status {
// free disk space
if ((adminaccess) && (!sb.observer.getDisksOK()))
{
- final String minFree = kelondroMemory.bytesToString(sb.observer.getMinFreeDiskSpace());
+ final String minFree = MemoryControl.bytesToString(sb.observer.getMinFreeDiskSpace());
prop.put("warningDiskSpaceLow", "1");
prop.put("warningDiskSpaceLow_minSpace", minFree);
}
@@ -187,7 +187,7 @@ public class Status {
} else {
final long uptime = 60000 * Long.parseLong(sb.webIndex.seedDB.mySeed().get(yacySeed.UPTIME, "0"));
prop.put("peerStatistics", "1");
- prop.put("peerStatistics_uptime", kelondroDate.formatInterval(uptime));
+ prop.put("peerStatistics_uptime", DateFormatter.formatInterval(uptime));
prop.putNum("peerStatistics_pagesperminute", sb.webIndex.seedDB.mySeed().getPPM());
prop.putNum("peerStatistics_queriesperhour", Math.round(6000d * sb.webIndex.seedDB.mySeed().getQPM()) / 100d);
prop.putNum("peerStatistics_links", sb.webIndex.seedDB.mySeed().getLinkCount());
@@ -246,7 +246,7 @@ public class Status {
prop.putHTML("seedServer_seedFile", sb.getConfig("seedFilePath", ""));
}
prop.put("seedServer_lastUpload",
- kelondroDate.formatInterval(System.currentTimeMillis() - sb.webIndex.seedDB.lastSeedUpload_timeStamp));
+ DateFormatter.formatInterval(System.currentTimeMillis() - sb.webIndex.seedDB.lastSeedUpload_timeStamp));
} else {
prop.put(SEEDSERVER, "0"); // disabled
}
@@ -271,15 +271,15 @@ public class Status {
}
// memory usage and system attributes
- prop.put("freeMemory", kelondroMemory.bytesToString(kelondroMemory.free()));
- prop.put("totalMemory", kelondroMemory.bytesToString(kelondroMemory.total()));
- prop.put("maxMemory", kelondroMemory.bytesToString(kelondroMemory.max()));
+ prop.put("freeMemory", MemoryControl.bytesToString(MemoryControl.free()));
+ prop.put("totalMemory", MemoryControl.bytesToString(MemoryControl.total()));
+ prop.put("maxMemory", MemoryControl.bytesToString(MemoryControl.max()));
prop.put("processors", serverProcessor.availableCPU);
// proxy traffic
//prop.put("trafficIn",bytesToString(httpdByteCountInputStream.getGlobalCount()));
- prop.put("trafficProxy", kelondroMemory.bytesToString(httpdByteCountOutputStream.getAccountCount("PROXY")));
- prop.put("trafficCrawler", kelondroMemory.bytesToString(httpdByteCountInputStream.getAccountCount("CRAWLER")));
+ prop.put("trafficProxy", MemoryControl.bytesToString(httpdByteCountOutputStream.getAccountCount("PROXY")));
+ prop.put("trafficCrawler", MemoryControl.bytesToString(httpdByteCountInputStream.getAccountCount("CRAWLER")));
// connection information
final serverCore httpd = (serverCore) sb.getThread("10_httpd");
diff --git a/htroot/Supporter.java b/htroot/Supporter.java
index cb4678a39..860d92209 100644
--- a/htroot/Supporter.java
+++ b/htroot/Supporter.java
@@ -33,11 +33,11 @@ import java.util.Iterator;
import de.anomic.http.httpRequestHeader;
import de.anomic.index.indexReferenceBlacklist;
-import de.anomic.kelondro.kelondroMScoreCluster;
-import de.anomic.kelondro.kelondroNaturalOrder;
-import de.anomic.kelondro.kelondroRow;
-import de.anomic.kelondro.kelondroDate;
-import de.anomic.kelondro.kelondroRow.Entry;
+import de.anomic.kelondro.coding.DateFormatter;
+import de.anomic.kelondro.coding.NaturalOrder;
+import de.anomic.kelondro.index.Row;
+import de.anomic.kelondro.index.Row.Entry;
+import de.anomic.kelondro.tools.ScoreCluster;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -103,8 +103,8 @@ public class Supporter {
accumulateVotes(sb, negativeHashes, positiveHashes, yacyNewsPool.INCOMING_DB);
//accumulateVotes(negativeHashes, positiveHashes, yacyNewsPool.OUTGOING_DB);
//accumulateVotes(negativeHashes, positiveHashes, yacyNewsPool.PUBLISHED_DB);
- final kelondroMScoreCluster<String> ranking = new kelondroMScoreCluster<String>(); // score cluster for url hashes
- final kelondroRow rowdef = new kelondroRow("String url-255, String title-120, String description-120, String refid-" + (kelondroDate.PATTERN_SHORT_SECOND.length() + 12), kelondroNaturalOrder.naturalOrder, 0);
+ final ScoreCluster<String> ranking = new ScoreCluster<String>(); // score cluster for url hashes
+ final Row rowdef = new Row("String url-255, String title-120, String description-120, String refid-" + (DateFormatter.PATTERN_SHORT_SECOND.length() + 12), NaturalOrder.naturalOrder, 0);
final HashMap<String, Entry> Supporter = new HashMap<String, Entry>(); // a mapping from an url hash to a kelondroRow.Entry with display properties
accumulateSupporter(sb, Supporter, ranking, rowdef, negativeHashes, positiveHashes, yacyNewsPool.INCOMING_DB);
//accumulateSupporter(Supporter, ranking, rowdef, negativeHashes, positiveHashes, yacyNewsPool.OUTGOING_DB);
@@ -113,7 +113,7 @@ public class Supporter {
// read out surftipp array and create property entries
final Iterator<String> k = ranking.scores(false);
int i = 0;
- kelondroRow.Entry row;
+ Row.Entry row;
String url, urlhash, refid, title, description;
boolean voted;
while (k.hasNext()) {
@@ -196,14 +196,14 @@ public class Supporter {
private static void accumulateSupporter(
final plasmaSwitchboard sb,
- final HashMap<String, Entry> Supporter, final kelondroMScoreCluster<String> ranking, final kelondroRow rowdef,
+ final HashMap<String, Entry> Supporter, final ScoreCluster<String> ranking, final Row rowdef,
final HashMap<String, Integer> negativeHashes, final HashMap<String, Integer> positiveHashes, final int dbtype) {
final int maxCount = Math.min(1000, sb.webIndex.newsPool.size(dbtype));
yacyNewsRecord record;
final Iterator<yacyNewsRecord> recordIterator = sb.webIndex.newsPool.recordIterator(dbtype, true);
int j = 0;
String url = "", urlhash;
- kelondroRow.Entry entry;
+ Row.Entry entry;
int score = 0;
Integer vote;
yacySeed seed;
diff --git a/htroot/Surftips.java b/htroot/Surftips.java
index 90af30644..e5d8e5963 100644
--- a/htroot/Surftips.java
+++ b/htroot/Surftips.java
@@ -33,11 +33,11 @@ import java.util.Iterator;
import de.anomic.http.httpRequestHeader;
import de.anomic.index.indexReferenceBlacklist;
-import de.anomic.kelondro.kelondroMScoreCluster;
-import de.anomic.kelondro.kelondroNaturalOrder;
-import de.anomic.kelondro.kelondroRow;
-import de.anomic.kelondro.kelondroDate;
-import de.anomic.kelondro.kelondroRow.Entry;
+import de.anomic.kelondro.coding.DateFormatter;
+import de.anomic.kelondro.coding.NaturalOrder;
+import de.anomic.kelondro.index.Row;
+import de.anomic.kelondro.index.Row.Entry;
+import de.anomic.kelondro.tools.ScoreCluster;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -111,8 +111,8 @@ public class Surftips {
accumulateVotes(sb , negativeHashes, positiveHashes, yacyNewsPool.INCOMING_DB);
//accumulateVotes(negativeHashes, positiveHashes, yacyNewsPool.OUTGOING_DB);
//accumulateVotes(negativeHashes, positiveHashes, yacyNewsPool.PUBLISHED_DB);
- final kelondroMScoreCluster<String> ranking = new kelondroMScoreCluster<String>(); // score cluster for url hashes
- final kelondroRow rowdef = new kelondroRow("String url-255, String title-120, String description-120, String refid-" + (kelondroDate.PATTERN_SHORT_SECOND.length() + 12), kelondroNaturalOrder.naturalOrder, 0);
+ final ScoreCluster<String> ranking = new ScoreCluster<String>(); // score cluster for url hashes
+ final Row rowdef = new Row("String url-255, String title-120, String description-120, String refid-" + (DateFormatter.PATTERN_SHORT_SECOND.length() + 12), NaturalOrder.naturalOrder, 0);
final HashMap<String, Entry> surftips = new HashMap<String, Entry>(); // a mapping from an url hash to a kelondroRow.Entry with display properties
accumulateSurftips(sb, surftips, ranking, rowdef, negativeHashes, positiveHashes, yacyNewsPool.INCOMING_DB);
//accumulateSurftips(surftips, ranking, rowdef, negativeHashes, positiveHashes, yacyNewsPool.OUTGOING_DB);
@@ -121,7 +121,7 @@ public class Surftips {
// read out surftipp array and create property entries
final Iterator<String> k = ranking.scores(false);
int i = 0;
- kelondroRow.Entry row;
+ Row.Entry row;
String url, urlhash, refid, title, description;
boolean voted;
while (k.hasNext()) {
@@ -205,14 +205,14 @@ public class Surftips {
private static void accumulateSurftips(
final plasmaSwitchboard sb,
- final HashMap<String, Entry> surftips, final kelondroMScoreCluster<String> ranking, final kelondroRow rowdef,
+ final HashMap<String, Entry> surftips, final ScoreCluster<String> ranking, final Row rowdef,
final HashMap<String, Integer> negativeHashes, final HashMap<String, Integer> positiveHashes, final int dbtype) {
final int maxCount = Math.min(1000, sb.webIndex.newsPool.size(dbtype));
yacyNewsRecord record;
final Iterator<yacyNewsRecord> recordIterator = sb.webIndex.newsPool.recordIterator(dbtype, true);
int j = 0;
String url = "", urlhash;
- kelondroRow.Entry entry;
+ Row.Entry entry;
int score = 0;
Integer vote;
while ((recordIterator.hasNext()) && (j++ < maxCount)) {
diff --git a/htroot/User.java b/htroot/User.java
index 958dc098e..31b12826c 100644
--- a/htroot/User.java
+++ b/htroot/User.java
@@ -33,8 +33,8 @@ import de.anomic.data.userDB;
import de.anomic.http.httpRequestHeader;
import de.anomic.http.httpResponseHeader;
import de.anomic.http.httpd;
-import de.anomic.kelondro.kelondroBase64Order;
-import de.anomic.kelondro.kelondroDigest;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.Digest;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -95,8 +95,8 @@ public class User{
entry=sb.userDB.passwordAuth(username, password);
final boolean staticAdmin = sb.getConfig(httpd.ADMIN_ACCOUNT_B64MD5, "").equals(
- kelondroDigest.encodeMD5Hex(
- kelondroBase64Order.standardCoder.encodeString(username + ":" + password)
+ Digest.encodeMD5Hex(
+ Base64Order.standardCoder.encodeString(username + ":" + password)
)
);
String cookie="";
@@ -123,11 +123,11 @@ public class User{
if(post!= null && entry != null){
if(post.containsKey("changepass")){
prop.put("status", "1"); //password
- if(entry.getMD5EncodedUserPwd().equals(kelondroDigest.encodeMD5Hex(entry.getUserName()+":"+post.get("oldpass", "")))){
+ if(entry.getMD5EncodedUserPwd().equals(Digest.encodeMD5Hex(entry.getUserName()+":"+post.get("oldpass", "")))){
if(post.get("newpass").equals(post.get("newpass2"))){
if(!post.get("newpass", "").equals("")){
try {
- entry.setProperty(userDB.Entry.MD5ENCODED_USERPWD_STRING, kelondroDigest.encodeMD5Hex(entry.getUserName()+":"+post.get("newpass", "")));
+ entry.setProperty(userDB.Entry.MD5ENCODED_USERPWD_STRING, Digest.encodeMD5Hex(entry.getUserName()+":"+post.get("newpass", "")));
prop.put("status_password", "0"); //changes
} catch (final IOException e) {}
}else{
diff --git a/htroot/ViewProfile.java b/htroot/ViewProfile.java
index 67d454ec8..2db185e71 100644
--- a/htroot/ViewProfile.java
+++ b/htroot/ViewProfile.java
@@ -37,7 +37,7 @@ import java.util.Map;
import java.util.Properties;
import de.anomic.http.httpRequestHeader;
-import de.anomic.kelondro.kelondroBase64Order;
+import de.anomic.kelondro.coding.Base64Order;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -162,7 +162,7 @@ public class ViewProfile {
((String) entry.getValue()).replaceAll("\r", "").replaceAll("\\\\n", "\n"),
address
);
- prop.put("success_" + key + "_b64value",kelondroBase64Order.standardCoder.encodeString((String) entry.getValue()));
+ prop.put("success_" + key + "_b64value",Base64Order.standardCoder.encodeString((String) entry.getValue()));
}else{
prop.putHTML("success_" + key + "_value", value); //put replaces HTML Chars by entities.
}
diff --git a/htroot/WebStructurePicture_p.java b/htroot/WebStructurePicture_p.java
index 46b567370..ac8f0688d 100644
--- a/htroot/WebStructurePicture_p.java
+++ b/htroot/WebStructurePicture_p.java
@@ -31,7 +31,7 @@ import java.util.Iterator;
import java.util.Map;
import de.anomic.http.httpRequestHeader;
-import de.anomic.kelondro.kelondroBase64Order;
+import de.anomic.kelondro.coding.Base64Order;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaWebStructure;
import de.anomic.server.serverObjects;
@@ -145,7 +145,7 @@ public class WebStructurePicture_p {
targets.add(new String[] {targethash, targethost});
if (graph.getPoint(targethost) != null) continue;
// set a new point. It is placed on a circle around the host point
- final double angle = kelondroBase64Order.enhancedCoder.cardinal((targethash + "____").getBytes()) / maxlongd * 2 * Math.PI;
+ final double angle = Base64Order.enhancedCoder.cardinal((targethash + "____").getBytes()) / maxlongd * 2 * Math.PI;
//System.out.println("ANGLE = " + angle);
rr = radius * 0.25 * (1 - targetrefs / (double) maxtargetrefs);
re = radius * 0.5 * (thisrefs / (double) maxthisrefs);
diff --git a/htroot/api/bookmarks/get_bookmarks.java b/htroot/api/bookmarks/get_bookmarks.java
index 6e8b59f05..20368c032 100644
--- a/htroot/api/bookmarks/get_bookmarks.java
+++ b/htroot/api/bookmarks/get_bookmarks.java
@@ -7,7 +7,7 @@ import de.anomic.data.bookmarksDB;
import de.anomic.data.userDB;
import de.anomic.htmlFilter.htmlFilterCharacterCoding;
import de.anomic.http.httpRequestHeader;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.DateFormatter;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -138,8 +138,8 @@ public class get_bookmarks {
if(bookmark!=null) {
prop.put("display_bookmarks_"+count+"_id",count);
prop.put("display_bookmarks_"+count+"_link",bookmark.getUrl());
- prop.put("display_bookmarks_"+count+"_date", kelondroDate.formatISO8601(new Date(bookmark.getTimeStamp())));
- prop.put("display_bookmarks_"+count+"_rfc822date", kelondroDate.formatRFC1123(new Date(bookmark.getTimeStamp())));
+ prop.put("display_bookmarks_"+count+"_date", DateFormatter.formatISO8601(new Date(bookmark.getTimeStamp())));
+ prop.put("display_bookmarks_"+count+"_rfc822date", DateFormatter.formatRFC1123(new Date(bookmark.getTimeStamp())));
prop.put("display_bookmarks_"+count+"_public", (bookmark.getPublic() ? "0" : "1"));
prop.put("display_bookmarks_"+count+"_hash", bookmark.getUrlHash());
prop.put("display_bookmarks_"+count+"_comma", ",");
@@ -232,7 +232,7 @@ public class get_bookmarks {
date=new Date(bookmark.getTimeStamp());
prop.put("display_xbel_"+count+"_elements", "<bookmark id=\"" + bookmark.getUrlHash()
+ "\" href=\"" + htmlFilterCharacterCoding.unicode2xml(bookmark.getUrl(), true)
- + "\" added=\"" + htmlFilterCharacterCoding.unicode2xml(kelondroDate.formatISO8601(date), true)+"\">");
+ + "\" added=\"" + htmlFilterCharacterCoding.unicode2xml(DateFormatter.formatISO8601(date), true)+"\">");
count++;
prop.put("display_xbel_"+count+"_elements", "<title>");
count++;
diff --git a/htroot/api/bookmarks/posts/all.java b/htroot/api/bookmarks/posts/all.java
index cf1a61027..ddd926131 100755
--- a/htroot/api/bookmarks/posts/all.java
+++ b/htroot/api/bookmarks/posts/all.java
@@ -4,8 +4,8 @@ import java.util.Iterator;
import de.anomic.data.bookmarksDB;
import de.anomic.http.httpRequestHeader;
-import de.anomic.kelondro.kelondroDigest;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.DateFormatter;
+import de.anomic.kelondro.coding.Digest;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -35,9 +35,9 @@ public class all {
prop.putXML("posts_"+count+"_url", bookmark.getUrl());
prop.putXML("posts_"+count+"_title", bookmark.getTitle());
prop.putXML("posts_"+count+"_description", bookmark.getDescription());
- prop.putXML("posts_"+count+"_md5", kelondroDigest.encodeMD5Hex(bookmark.getUrl()));
+ prop.putXML("posts_"+count+"_md5", Digest.encodeMD5Hex(bookmark.getUrl()));
date=new Date(bookmark.getTimeStamp());
- prop.putXML("posts_"+count+"_time", kelondroDate.formatISO8601(date));
+ prop.putXML("posts_"+count+"_time", DateFormatter.formatISO8601(date));
prop.putXML("posts_"+count+"_tags", bookmark.getTagsString().replaceAll(","," "));
// additional XML tags
diff --git a/htroot/api/bookmarks/posts/get.java b/htroot/api/bookmarks/posts/get.java
index 5d3fcb065..f48f14a16 100755
--- a/htroot/api/bookmarks/posts/get.java
+++ b/htroot/api/bookmarks/posts/get.java
@@ -7,8 +7,8 @@ import java.util.Iterator;
import de.anomic.data.bookmarksDB;
import de.anomic.http.httpRequestHeader;
-import de.anomic.kelondro.kelondroDigest;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.DateFormatter;
+import de.anomic.kelondro.coding.Digest;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -29,7 +29,7 @@ public class get {
if(post != null && post.containsKey("date")){
date=post.get("date");
}else{
- date=kelondroDate.formatISO8601(new Date(System.currentTimeMillis()));
+ date=DateFormatter.formatISO8601(new Date(System.currentTimeMillis()));
}
// if an extended xml should be used
@@ -39,7 +39,7 @@ public class get {
Date parsedDate = null;
try {
- parsedDate = kelondroDate.parseISO8601(date);
+ parsedDate = DateFormatter.parseISO8601(date);
} catch (final ParseException e) {
parsedDate = new Date();
}
@@ -49,13 +49,13 @@ public class get {
bookmarksDB.Bookmark bookmark=null;
while(it.hasNext()){
bookmark=switchboard.bookmarksDB.getBookmark(it.next());
- if(kelondroDate.formatISO8601(new Date(bookmark.getTimeStamp())).equals(date) &&
+ if(DateFormatter.formatISO8601(new Date(bookmark.getTimeStamp())).equals(date) &&
tag==null || bookmark.getTags().contains(tag) &&
isAdmin || bookmark.getPublic()){
prop.putHTML("posts_"+count+"_url", bookmark.getUrl());
prop.putHTML("posts_"+count+"_title", bookmark.getTitle());
prop.putHTML("posts_"+count+"_description", bookmark.getDescription());
- prop.put("posts_"+count+"_md5", kelondroDigest.encodeMD5Hex(bookmark.getUrl()));
+ prop.put("posts_"+count+"_md5", Digest.encodeMD5Hex(bookmark.getUrl()));
prop.put("posts_"+count+"_time", date);
prop.putHTML("posts_"+count+"_tags", bookmark.getTagsString().replaceAll(","," "));
diff --git a/htroot/api/bookmarks/xbel/xbel.java b/htroot/api/bookmarks/xbel/xbel.java
index fda0ae35d..968d11209 100755
--- a/htroot/api/bookmarks/xbel/xbel.java
+++ b/htroot/api/bookmarks/xbel/xbel.java
@@ -6,7 +6,7 @@ import java.util.Iterator;
import de.anomic.data.bookmarksDB;
import de.anomic.htmlFilter.htmlFilterCharacterCoding;
import de.anomic.http.httpRequestHeader;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.DateFormatter;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -109,7 +109,7 @@ public class xbel {
date=new Date(bookmark.getTimeStamp());
prop.put("xbel_"+count+"_elements", "<bookmark id=\"" + bookmark.getUrlHash()
+ "\" href=\"" + htmlFilterCharacterCoding.unicode2xml(bookmark.getUrl(), true)
- + "\" added=\"" + htmlFilterCharacterCoding.unicode2xml(kelondroDate.formatISO8601(date), true)+"\">");
+ + "\" added=\"" + htmlFilterCharacterCoding.unicode2xml(DateFormatter.formatISO8601(date), true)+"\">");
count++;
prop.put("xbel_"+count+"_elements", "<title>");
count++;
diff --git a/htroot/api/status_p.java b/htroot/api/status_p.java
index 7803e33e8..8284e311a 100644
--- a/htroot/api/status_p.java
+++ b/htroot/api/status_p.java
@@ -3,7 +3,7 @@
import de.anomic.http.httpRequestHeader;
import de.anomic.http.httpdByteCountInputStream;
import de.anomic.http.httpdByteCountOutputStream;
-import de.anomic.kelondro.kelondroMemory;
+import de.anomic.kelondro.tools.MemoryControl;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaSwitchboardConstants;
import de.anomic.server.serverObjects;
@@ -33,9 +33,9 @@ public class status_p {
//
// memory usage and system attributes
- prop.putNum("freeMemory", kelondroMemory.free());
- prop.putNum("totalMemory", kelondroMemory.total());
- prop.putNum("maxMemory", kelondroMemory.max());
+ prop.putNum("freeMemory", MemoryControl.free());
+ prop.putNum("totalMemory", MemoryControl.total());
+ prop.putNum("maxMemory", MemoryControl.max());
prop.putNum("processors", serverProcessor.availableCPU);
// proxy traffic
diff --git a/htroot/rct_p.java b/htroot/rct_p.java
index a80be1539..8b2d6cd03 100644
--- a/htroot/rct_p.java
+++ b/htroot/rct_p.java
@@ -32,7 +32,7 @@ import java.util.Iterator;
import de.anomic.crawler.CrawlEntry;
import de.anomic.http.httpRequestHeader;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.DateFormatter;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -68,7 +68,7 @@ public class rct_p {
}
Date loaddate;
try {
- loaddate = kelondroDate.parseShortSecond(item.getPubDate());
+ loaddate = DateFormatter.parseShortSecond(item.getPubDate());
} catch (final ParseException e) {
loaddate = new Date();
}
diff --git a/htroot/yacy/query.java b/htroot/yacy/query.java
index 7cb696feb..4ed124c7b 100644
--- a/htroot/yacy/query.java
+++ b/htroot/yacy/query.java
@@ -28,7 +28,7 @@
// if the shell's current path is HTROOT
import de.anomic.http.httpRequestHeader;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.DateFormatter;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -69,7 +69,7 @@ public final class query {
final String obj = post.get("object", ""); // keyword for query subject
final String env = post.get("env", ""); // argument to query
- prop.put("mytime", kelondroDate.formatShortSecond());
+ prop.put("mytime", DateFormatter.formatShortSecond());
// check if we are the right target and requester has correct information about this peer
if (sb.webIndex.seedDB.mySeed() == null || !sb.webIndex.seedDB.mySeed().hash.equals(youare)) {
diff --git a/htroot/yacy/search.java b/htroot/yacy/search.java
index 0909a071c..78a4b2289 100644
--- a/htroot/yacy/search.java
+++ b/htroot/yacy/search.java
@@ -36,9 +36,9 @@ import java.util.TreeSet;
import de.anomic.http.httpRequestHeader;
import de.anomic.index.indexContainer;
-import de.anomic.kelondro.kelondroBase64Order;
-import de.anomic.kelondro.kelondroBitfield;
import de.anomic.kelondro.kelondroSortStack;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.Bitfield;
import de.anomic.net.natLib;
import de.anomic.plasma.plasmaProfiling;
import de.anomic.plasma.plasmaSearchEvent;
@@ -99,7 +99,7 @@ public final class search {
String profile = post.get("profile", ""); // remote profile hand-over
if (profile.length() > 0) profile = crypt.simpleDecode(profile, null);
//final boolean includesnippet = post.get("includesnippet", "false").equals("true");
- kelondroBitfield constraint = ((post.containsKey("constraint")) && (post.get("constraint", "").length() > 0)) ? new kelondroBitfield(4, post.get("constraint", "______")) : null;
+ Bitfield constraint = ((post.containsKey("constraint")) && (post.get("constraint", "").length() > 0)) ? new Bitfield(4, post.get("constraint", "______")) : null;
if (constraint != null) {
// check bad handover parameter from older versions
boolean allon = true;
@@ -165,7 +165,7 @@ public final class search {
// prepare search
final TreeSet<String> queryhashes = plasmaSearchQuery.hashes2Set(query);
- final TreeSet<String> excludehashes = (exclude.length() == 0) ? new TreeSet<String>(kelondroBase64Order.enhancedComparator) : plasmaSearchQuery.hashes2Set(exclude);
+ final TreeSet<String> excludehashes = (exclude.length() == 0) ? new TreeSet<String>(Base64Order.enhancedComparator) : plasmaSearchQuery.hashes2Set(exclude);
final long timestamp = System.currentTimeMillis();
// prepare a search profile
@@ -180,7 +180,7 @@ public final class search {
plasmaSearchEvent theSearch = null;
if ((query.length() == 0) && (abstractSet != null)) {
// this is _not_ a normal search, only a request for index abstracts
- theQuery = new plasmaSearchQuery(null, abstractSet, new TreeSet<String>(kelondroBase64Order.enhancedComparator), null, rankingProfile, maxdist, prefer, plasmaSearchQuery.contentdomParser(contentdom), language, false, count, 0, filter, plasmaSearchQuery.SEARCHDOM_LOCAL, null, -1, null, false, yacyURL.TLD_any_zone_filter, client, false);
+ theQuery = new plasmaSearchQuery(null, abstractSet, new TreeSet<String>(Base64Order.enhancedComparator), null, rankingProfile, maxdist, prefer, plasmaSearchQuery.contentdomParser(contentdom), language, false, count, 0, filter, plasmaSearchQuery.SEARCHDOM_LOCAL, null, -1, null, false, yacyURL.TLD_any_zone_filter, client, false);
theQuery.domType = plasmaSearchQuery.SEARCHDOM_LOCAL;
yacyCore.log.logInfo("INIT HASH SEARCH (abstracts only): " + plasmaSearchQuery.anonymizedQueryHashes(theQuery.queryHashes) + " - " + theQuery.displayResults() + " links");
diff --git a/htroot/yacy/transfer.java b/htroot/yacy/transfer.java
index 03b4f8527..1d289f15c 100644
--- a/htroot/yacy/transfer.java
+++ b/htroot/yacy/transfer.java
@@ -28,8 +28,8 @@ import java.io.File;
import java.io.IOException;
import de.anomic.http.httpRequestHeader;
-import de.anomic.kelondro.kelondroBase64Order;
-import de.anomic.kelondro.kelondroDigest;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.Digest;
import de.anomic.plasma.plasmaRankingDistribution;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverFileUtils;
@@ -85,14 +85,14 @@ public final class transfer {
// consolidation of cr files
//System.out.println("yacy/transfer:post=" + post.toString());
//String cansendprotocol = (String) post.get("can-send-protocol", "http");
- final String access = kelondroBase64Order.enhancedCoder.encode(kelondroDigest.encodeMD5Raw(otherpeer + ":" + filename)) + ":" + kelondroBase64Order.enhancedCoder.encode(kelondroDigest.encodeMD5Raw("" + System.currentTimeMillis()));
+ final String access = Base64Order.enhancedCoder.encode(Digest.encodeMD5Raw(otherpeer + ":" + filename)) + ":" + Base64Order.enhancedCoder.encode(Digest.encodeMD5Raw("" + System.currentTimeMillis()));
prop.put("response", "ok");
prop.put("process_access", access);
prop.put("process_address", sb.webIndex.seedDB.mySeed().getPublicAddress());
prop.put("process_protocol", "http");
prop.put("process_path", ""); // currently empty; the store process will find a path
prop.put("process_maxsize", "-1"); // if response is too big we return the size of the file
- sb.rankingPermissions.put(kelondroDigest.encodeMD5Hex(kelondroBase64Order.standardCoder.encodeString(access)), filename);
+ sb.rankingPermissions.put(Digest.encodeMD5Hex(Base64Order.standardCoder.encodeString(access)), filename);
if (sb.getLog().isFine()) sb.getLog().logFine("RankingTransmission: granted peer " + otherpeerName + " to send CR file " + filename);
}
return prop;
@@ -120,7 +120,7 @@ public final class transfer {
try {
if (file.getCanonicalPath().startsWith(path.getCanonicalPath())){
serverFileUtils.copy(fileString.getBytes(), file);
- final String md5t = kelondroDigest.encodeMD5Hex(file);
+ final String md5t = Digest.encodeMD5Hex(file);
if (md5t.equals(md5)) {
prop.put("response", "ok");
if (sb.getLog().isFine()) sb.getLog().logFine("RankingTransmission: received from peer " + otherpeerName + " CR file " + filename);
diff --git a/htroot/yacy/transferURL.java b/htroot/yacy/transferURL.java
index 90d9942bd..33d92ce93 100644
--- a/htroot/yacy/transferURL.java
+++ b/htroot/yacy/transferURL.java
@@ -32,7 +32,7 @@ import java.text.ParseException;
import de.anomic.http.httpRequestHeader;
import de.anomic.index.indexReferenceBlacklist;
import de.anomic.index.indexURLReference;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.DateFormatter;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverCore;
import de.anomic.server.serverObjects;
@@ -49,7 +49,7 @@ public final class transferURL {
public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) throws InterruptedException {
final long start = System.currentTimeMillis();
long freshdate = 0;
- try {freshdate = kelondroDate.parseShortDay("20061101").getTime();} catch (final ParseException e1) {}
+ try {freshdate = DateFormatter.parseShortDay("20061101").getTime();} catch (final ParseException e1) {}
// return variable that accumulates replacements
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
diff --git a/htroot/yacy/urls.java b/htroot/yacy/urls.java
index fcb8284b2..57fd02b85 100644
--- a/htroot/yacy/urls.java
+++ b/htroot/yacy/urls.java
@@ -31,7 +31,7 @@ import de.anomic.crawler.CrawlEntry;
import de.anomic.crawler.NoticedURL;
import de.anomic.http.httpRequestHeader;
import de.anomic.index.indexURLReference;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.DateFormatter;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -93,7 +93,7 @@ public class urls {
prop.putHTML("item_" + c + "_referrer", (referrer == null) ? "" : referrer.toNormalform(true, false));
prop.putHTML("item_" + c + "_description", entry.name());
prop.put("item_" + c + "_author", "");
- prop.put("item_" + c + "_pubDate", kelondroDate.formatShortSecond(entry.appdate()));
+ prop.put("item_" + c + "_pubDate", DateFormatter.formatShortSecond(entry.appdate()));
prop.put("item_" + c + "_guid", entry.url().hash());
c++;
maxCount--;
@@ -123,7 +123,7 @@ public class urls {
prop.putHTML("item_" + c + "_referrer", (referrer == null) ? "" : referrer.toNormalform(true, false));
prop.putHTML("item_" + c + "_description", comp.dc_title());
prop.put("item_" + c + "_author", comp.dc_creator());
- prop.put("item_" + c + "_pubDate", kelondroDate.formatShortSecond(entry.moddate()));
+ prop.put("item_" + c + "_pubDate", DateFormatter.formatShortSecond(entry.moddate()));
prop.put("item_" + c + "_guid", entry.hash());
c++;
}
diff --git a/htroot/yacysearch.java b/htroot/yacysearch.java
index e5009639a..4275cc45f 100644
--- a/htroot/yacysearch.java
+++ b/htroot/yacysearch.java
@@ -33,9 +33,9 @@ import java.util.TreeSet;
import de.anomic.http.httpRequestHeader;
import de.anomic.index.indexURLReference;
import de.anomic.index.indexWord;
-import de.anomic.kelondro.kelondroBitfield;
-import de.anomic.kelondro.kelondroMSetTools;
-import de.anomic.kelondro.kelondroMemory;
+import de.anomic.kelondro.coding.Bitfield;
+import de.anomic.kelondro.tools.SetTools;
+import de.anomic.kelondro.tools.MemoryControl;
import de.anomic.plasma.plasmaCondenser;
import de.anomic.plasma.plasmaParserDocument;
import de.anomic.plasma.plasmaProfiling;
@@ -140,9 +140,9 @@ public class yacysearch {
String prefermask = (post == null ? "" : post.get("prefermaskfilter", ""));
if ((prefermask.length() > 0) && (prefermask.indexOf(".*") < 0)) prefermask = ".*" + prefermask + ".*";
- kelondroBitfield constraint = (post != null && post.containsKey("constraint") && post.get("constraint", "").length() > 0) ? new kelondroBitfield(4, post.get("constraint", "______")) : null;
+ Bitfield constraint = (post != null && post.containsKey("constraint") && post.get("constraint", "").length() > 0) ? new Bitfield(4, post.get("constraint", "______")) : null;
if (indexof) {
- constraint = new kelondroBitfield(4);
+ constraint = new Bitfield(4);
constraint.set(plasmaCondenser.flag_cat_indexof, true);
}
@@ -204,7 +204,7 @@ public class yacysearch {
if ((!block) && (post == null || post.get("cat", "href").equals("href"))) {
// check available memory and clean up if necessary
- if (!kelondroMemory.request(8000000L, false)) {
+ if (!MemoryControl.request(8000000L, false)) {
sb.webIndex.clearCache();
plasmaSearchEvent.cleanupEvents(true);
}
@@ -282,9 +282,9 @@ public class yacysearch {
int maxDistance = (querystring.indexOf('"') >= 0) ? maxDistance = query.length - 1 : Integer.MAX_VALUE;
// filter out stopwords
- final TreeSet<String> filtered = kelondroMSetTools.joinConstructive(query[0], plasmaSwitchboard.stopwords);
+ final TreeSet<String> filtered = SetTools.joinConstructive(query[0], plasmaSwitchboard.stopwords);
if (filtered.size() > 0) {
- kelondroMSetTools.excludeDestructive(query[0], plasmaSwitchboard.stopwords);
+ SetTools.excludeDestructive(query[0], plasmaSwitchboard.stopwords);
}
// if a minus-button was hit, remove a special reference first
diff --git a/htroot/yacysearchtrailer.java b/htroot/yacysearchtrailer.java
index 2b31ba38d..6b9f51ee0 100644
--- a/htroot/yacysearchtrailer.java
+++ b/htroot/yacysearchtrailer.java
@@ -29,8 +29,8 @@ import java.util.Set;
import java.util.TreeSet;
import de.anomic.http.httpRequestHeader;
-import de.anomic.kelondro.kelondroMSetTools;
-import de.anomic.kelondro.kelondroNaturalOrder;
+import de.anomic.kelondro.coding.NaturalOrder;
+import de.anomic.kelondro.tools.SetTools;
import de.anomic.plasma.plasmaProfiling;
import de.anomic.plasma.plasmaSearchEvent;
import de.anomic.plasma.plasmaSearchQuery;
@@ -65,7 +65,7 @@ public class yacysearchtrailer {
final Set<String> references = theSearch.references(20);
if (references.size() > 0) {
// get the topwords
- final TreeSet<String> topwords = new TreeSet<String>(kelondroNaturalOrder.naturalComparator);
+ final TreeSet<String> topwords = new TreeSet<String>(NaturalOrder.naturalComparator);
String tmp = "";
final Iterator<String> i = references.iterator();
while (i.hasNext()) {
@@ -76,15 +76,15 @@ public class yacysearchtrailer {
}
// filter out the badwords
- final TreeSet<String> filteredtopwords = kelondroMSetTools.joinConstructive(topwords, plasmaSwitchboard.badwords);
+ final TreeSet<String> filteredtopwords = SetTools.joinConstructive(topwords, plasmaSwitchboard.badwords);
if (filteredtopwords.size() > 0) {
- kelondroMSetTools.excludeDestructive(topwords, plasmaSwitchboard.badwords);
+ SetTools.excludeDestructive(topwords, plasmaSwitchboard.badwords);
}
// avoid stopwords being topwords
if (env.getConfig("filterOutStopwordsFromTopwords", "true").equals("true")) {
if ((plasmaSwitchboard.stopwords != null) && (plasmaSwitchboard.stopwords.size() > 0)) {
- kelondroMSetTools.excludeDestructive(topwords, plasmaSwitchboard.stopwords);
+ SetTools.excludeDestructive(topwords, plasmaSwitchboard.stopwords);
}
}
diff --git a/source/dbtest.java b/source/dbtest.java
index 471bf1faf..441e9c908 100644
--- a/source/dbtest.java
+++ b/source/dbtest.java
@@ -12,18 +12,18 @@ import java.util.Random;
import javax.imageio.ImageIO;
-import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroCloneableIterator;
import de.anomic.kelondro.kelondroEcoTable;
-import de.anomic.kelondro.kelondroIndex;
import de.anomic.kelondro.kelondroIntBytesMap;
-import de.anomic.kelondro.kelondroNaturalOrder;
-import de.anomic.kelondro.kelondroRow;
-import de.anomic.kelondro.kelondroRowSet;
import de.anomic.kelondro.kelondroSQLTable;
import de.anomic.kelondro.kelondroSplitTable;
import de.anomic.kelondro.kelondroTree;
-import de.anomic.kelondro.kelondroMemory;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.NaturalOrder;
+import de.anomic.kelondro.index.Row;
+import de.anomic.kelondro.index.RowSet;
+import de.anomic.kelondro.index.ObjectIndex;
+import de.anomic.kelondro.tools.MemoryControl;
import de.anomic.server.serverInstantBusyThread;
import de.anomic.ymage.ymageChart;
@@ -42,8 +42,8 @@ public class dbtest {
public static byte[] randomHash(final long r0, final long r1) {
// a long can have 64 bit, but a 12-byte hash can have 6 * 12 = 72 bits
// so we construct a generic Hash using two long values
- final String s = (kelondroBase64Order.enhancedCoder.encodeLong(Math.abs(r0), 6) +
- kelondroBase64Order.enhancedCoder.encodeLong(Math.abs(r1), 6));
+ final String s = (Base64Order.enhancedCoder.encodeLong(Math.abs(r0), 6) +
+ Base64Order.enhancedCoder.encodeLong(Math.abs(r1), 6));
return s.getBytes();
}
@@ -90,21 +90,21 @@ public class dbtest {
}
public static abstract class STJob implements Runnable {
- private final kelondroIndex table_test, table_reference;
+ private final ObjectIndex table_test, table_reference;
private final long source;
- public STJob(final kelondroIndex table_test, final kelondroIndex table_reference, final long aSource) {
+ public STJob(final ObjectIndex table_test, final ObjectIndex table_reference, final long aSource) {
this.table_test = table_test;
this.table_reference = table_reference;
this.source = aSource;
}
- public kelondroIndex getTable_test() {
+ public ObjectIndex getTable_test() {
return this.table_test;
}
- public kelondroIndex getTable_reference() {
+ public ObjectIndex getTable_reference() {
return this.table_reference;
}
@@ -116,13 +116,13 @@ public class dbtest {
}
public static final class WriteJob extends STJob {
- public WriteJob(final kelondroIndex table_test, final kelondroIndex table_reference, final long aSource) {
+ public WriteJob(final ObjectIndex table_test, final ObjectIndex table_reference, final long aSource) {
super(table_test, table_reference, aSource);
}
public void run() {
final STEntry entry = new STEntry(this.getSource());
- System.out.println("write: " + kelondroNaturalOrder.arrayList(entry.getKey(), 0, entry.getKey().length));
+ System.out.println("write: " + NaturalOrder.arrayList(entry.getKey(), 0, entry.getKey().length));
try {
getTable_test().put(getTable_test().row().newEntry(new byte[][] { entry.getKey(), entry.getValue() , entry.getValue() }));
if (getTable_reference() != null) getTable_reference().put(getTable_test().row().newEntry(new byte[][] { entry.getKey(), entry.getValue() , entry.getValue() }));
@@ -135,13 +135,13 @@ public class dbtest {
}
public static final class RemoveJob extends STJob {
- public RemoveJob(final kelondroIndex table_test, final kelondroIndex table_reference, final long aSource) {
+ public RemoveJob(final ObjectIndex table_test, final ObjectIndex table_reference, final long aSource) {
super(table_test, table_reference, aSource);
}
public void run() {
final STEntry entry = new STEntry(this.getSource());
- System.out.println("remove: " + kelondroNaturalOrder.arrayList(entry.getKey(), 0, entry.getKey().length));
+ System.out.println("remove: " + NaturalOrder.arrayList(entry.getKey(), 0, entry.getKey().length));
try {
getTable_test().remove(entry.getKey());
if (getTable_reference() != null) getTable_reference().remove(entry.getKey());
@@ -154,14 +154,14 @@ public class dbtest {
}
public static final class ReadJob extends STJob {
- public ReadJob(final kelondroIndex table_test, final kelondroIndex table_reference, final long aSource) {
+ public ReadJob(final ObjectIndex table_test, final ObjectIndex table_reference, final long aSource) {
super(table_test, table_reference, aSource);
}
public void run() {
final STEntry entry = new STEntry(this.getSource());
try {
- kelondroRow.Entry entryBytes = getTable_test().get(entry.getKey());
+ Row.Entry entryBytes = getTable_test().get(entry.getKey());
if (entryBytes != null) {
final STEntry dbEntry = new STEntry(entryBytes.getColBytes(0), entryBytes.getColBytes(1));
if (!dbEntry.isValid()) {
@@ -191,9 +191,9 @@ public class dbtest {
}
}
- public static kelondroIndex selectTableType(final String dbe, final String tablename, final kelondroRow testRow) throws Exception {
+ public static ObjectIndex selectTableType(final String dbe, final String tablename, final Row testRow) throws Exception {
if (dbe.equals("kelondroRowSet")) {
- return new kelondroRowSet(testRow, 0);
+ return new RowSet(testRow, 0);
}
if (dbe.equals("kelondroSplitTable")) {
final File tablepath = new File(tablename).getParentFile();
@@ -211,7 +211,7 @@ public class dbtest {
return null;
}
- public static boolean checkEquivalence(final kelondroIndex test, final kelondroIndex reference) throws IOException {
+ public static boolean checkEquivalence(final ObjectIndex test, final ObjectIndex reference) throws IOException {
if (reference == null) return true;
if (test.size() == reference.size()) {
System.out.println("* Testing equivalence of test table to reference table, " + test.size() + " entries");
@@ -220,9 +220,9 @@ public class dbtest {
return false;
}
boolean eq = true;
- kelondroRow.Entry test_entry, reference_entry;
+ Row.Entry test_entry, reference_entry;
- Iterator<kelondroRow.Entry> i = test.rows(true, null);
+ Iterator<Row.Entry> i = test.rows(true, null);
System.out.println("* Testing now by enumeration over test table");
final long ts = System.currentTimeMillis();
while (i.hasNext()) {
@@ -259,7 +259,7 @@ public class dbtest {
boolean assertionenabled = false;
assert assertionenabled = true;
if (assertionenabled) System.out.println("*** Asserts are enabled"); else System.out.println("*** HINT: YOU SHOULD ENABLE ASSERTS! (include -ea in start arguments");
- final long mb = kelondroMemory.available() / 1024 / 1024;
+ final long mb = MemoryControl.available() / 1024 / 1024;
System.out.println("*** RAM = " + mb + " MB");
System.out.print(">java " +
((assertionenabled) ? "-ea " : "") +
@@ -284,9 +284,9 @@ public class dbtest {
profiler.start();
// create the database access
- final kelondroRow testRow = new kelondroRow("byte[] key-" + keylength + ", byte[] dummy-" + keylength + ", value-" + valuelength, kelondroBase64Order.enhancedCoder, 0);
- final kelondroIndex table_test = selectTableType(dbe_test, tablename_test, testRow);
- final kelondroIndex table_reference = (dbe_reference == null) ? null : selectTableType(dbe_reference, tablename_reference, testRow);
+ final Row testRow = new Row("byte[] key-" + keylength + ", byte[] dummy-" + keylength + ", value-" + valuelength, Base64Order.enhancedCoder, 0);
+ final ObjectIndex table_test = selectTableType(dbe_test, tablename_test, testRow);
+ final ObjectIndex table_reference = (dbe_reference == null) ? null : selectTableType(dbe_reference, tablename_reference, testRow);
final long afterinit = System.currentTimeMillis();
System.out.println("Test for db-engine " + dbe_test + " started to create file " + tablename_test + " with test " + command);
@@ -321,7 +321,7 @@ public class dbtest {
final long count = Long.parseLong(args[4]);
final long randomstart = Long.parseLong(args[5]);
final Random random = new Random(randomstart);
- kelondroRow.Entry entry;
+ Row.Entry entry;
byte[] key;
for (int i = 0; i < count; i++) {
key = randomHash(random);
@@ -376,24 +376,24 @@ public class dbtest {
System.out.println("Loop " + loop + ": Write = " + write + ", Remove = " + remove);
System.out.println(" bevore GC: " +
- "free = " + kelondroMemory.free() +
- ", max = " + kelondroMemory.max() +
- ", total = " + kelondroMemory.total());
+ "free = " + MemoryControl.free() +
+ ", max = " + MemoryControl.max() +
+ ", total = " + MemoryControl.total());
System.gc();
System.out.println(" after GC: " +
- "free = " + kelondroMemory.free() +
- ", max = " + kelondroMemory.max() +
- ", total = " + kelondroMemory.total());
+ "free = " + MemoryControl.free() +
+ ", max = " + MemoryControl.max() +
+ ", total = " + MemoryControl.total());
loop++;
}
}
if (command.equals("list")) {
- kelondroCloneableIterator<kelondroRow.Entry> i = null;
+ kelondroCloneableIterator<Row.Entry> i = null;
if (table_test instanceof kelondroTree) i = ((kelondroTree) table_test).rows(true, null);
if (table_test instanceof kelondroSQLTable) i = ((kelondroSQLTable) table_test).rows(true, null);
if(i != null) {
- kelondroRow.Entry row;
+ Row.Entry row;
while (i.hasNext()) {
row = i.next();
for (int j = 0; j < row.columns(); j++) System.out.print(row.getColString(j, null) + ",");
@@ -538,7 +538,7 @@ final class memprofiler extends Thread {
while(run) {
memChart.setColor("FF0000");
seconds1 = (int) ((System.currentTimeMillis() - start) / 1000);
- kilobytes1 = (int) (kelondroMemory.used() / 1024);
+ kilobytes1 = (int) (MemoryControl.used() / 1024);
memChart.chartLine(ymageChart.DIMENSION_BOTTOM, ymageChart.DIMENSION_LEFT, seconds0, kilobytes0, seconds1, kilobytes1);
seconds0 = seconds1;
kilobytes0 = kilobytes1;
diff --git a/source/de/anomic/crawler/Balancer.java b/source/de/anomic/crawler/Balancer.java
index 21b974008..19de92a10 100644
--- a/source/de/anomic/crawler/Balancer.java
+++ b/source/de/anomic/crawler/Balancer.java
@@ -32,11 +32,11 @@ import java.util.Map;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
-import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroEcoTable;
-import de.anomic.kelondro.kelondroIndex;
-import de.anomic.kelondro.kelondroRow;
import de.anomic.kelondro.kelondroStack;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.index.Row;
+import de.anomic.kelondro.index.ObjectIndex;
import de.anomic.server.logging.serverLog;
import de.anomic.yacy.yacySeedDB;
@@ -47,14 +47,14 @@ public class Balancer {
private static final int EcoFSBufferSize = 200;
// definition of payload for fileStack
- private static final kelondroRow stackrow = new kelondroRow("byte[] urlhash-" + yacySeedDB.commonHashLength, kelondroBase64Order.enhancedCoder, 0);
+ private static final Row stackrow = new Row("byte[] urlhash-" + yacySeedDB.commonHashLength, Base64Order.enhancedCoder, 0);
// class variables
private final ConcurrentHashMap<String, LinkedList<String>>
domainStacks; // a map from domain name part to Lists with url hashs
private final ArrayList<String> urlRAMStack; // a list that is flushed first
private kelondroStack urlFileStack; // a file with url hashes
- private kelondroIndex urlFileIndex;
+ private ObjectIndex urlFileIndex;
private final File cacheStacksPath;
private final String stackname;
private boolean top; // to alternate between top and bottom of the file stack
@@ -153,7 +153,7 @@ public class Balancer {
public synchronized CrawlEntry get(final String urlhash) throws IOException {
assert urlhash != null;
if (urlFileIndex == null) return null; // case occurs during shutdown
- final kelondroRow.Entry entry = urlFileIndex.get(urlhash.getBytes());
+ final Row.Entry entry = urlFileIndex.get(urlhash.getBytes());
if (entry == null) return null;
return new CrawlEntry(entry);
}
@@ -164,9 +164,9 @@ public class Balancer {
// returns number of deletions
// first find a list of url hashes that shall be deleted
- final Iterator<kelondroRow.Entry> i = urlFileIndex.rows(true, null);
+ final Iterator<Row.Entry> i = urlFileIndex.rows(true, null);
final HashSet<String> urlHashes = new HashSet<String>();
- kelondroRow.Entry rowEntry;
+ Row.Entry rowEntry;
CrawlEntry crawlEntry;
final long terminate = (timeout > 0) ? System.currentTimeMillis() + timeout : Long.MAX_VALUE;
while (i.hasNext() && (System.currentTimeMillis() < terminate)) {
@@ -193,7 +193,7 @@ public class Balancer {
final int s = urlFileIndex.size();
int removedCounter = 0;
for (final String urlhash: urlHashes) {
- final kelondroRow.Entry entry = urlFileIndex.remove(urlhash.getBytes());
+ final Row.Entry entry = urlFileIndex.remove(urlhash.getBytes());
if (entry != null) removedCounter++;
}
if (removedCounter == 0) return 0;
@@ -211,7 +211,7 @@ public class Balancer {
// iterate through the file stack
// in general this is a bad idea. But this can only be avoided by avoidance of this method
- final Iterator<kelondroRow.Entry> j = urlFileStack.stackIterator(true);
+ final Iterator<Row.Entry> j = urlFileStack.stackIterator(true);
while (j.hasNext()) {
h = new String(j.next().getColBytes(0));
if (urlHashes.contains(h)) j.remove();
@@ -327,7 +327,7 @@ public class Balancer {
// flush some entries from disc to ram stack
try {
// one from the top:
- kelondroRow.Entry t = urlFileStack.pop();
+ Row.Entry t = urlFileStack.pop();
if (t == null) break;
pushHashToDomainStacks(new String(t.getColBytes(0)), false);
count--;
@@ -348,7 +348,7 @@ public class Balancer {
// flush some entries from disc to ram stack
try {
// one from the top:
- kelondroRow.Entry t = urlFileStack.pop();
+ Row.Entry t = urlFileStack.pop();
if (t == null) break;
urlRAMStack.add(new String(t.getColBytes(0)));
if (urlFileStack.size() == 0) break;
@@ -540,7 +540,7 @@ public class Balancer {
// 3rd: take entry from file
if ((result == null) && (urlFileStack.size() > 0)) {
- final kelondroRow.Entry nextentry = (top) ? urlFileStack.top() : urlFileStack.bot();
+ final Row.Entry nextentry = (top) ? urlFileStack.top() : urlFileStack.bot();
if (nextentry == null) {
// emergency case: this means that something with the stack organization is wrong
// the file appears to be broken. We kill the file.
@@ -571,7 +571,7 @@ public class Balancer {
// finally: check minimumDelta and if necessary force a sleep
final int s = urlFileIndex.size();
- kelondroRow.Entry rowEntry = urlFileIndex.remove(result.getBytes());
+ Row.Entry rowEntry = urlFileIndex.remove(result.getBytes());
if (rowEntry == null) {
throw new IOException("get() found a valid urlhash, but failed to fetch the corresponding url entry - total size = " + size() + ", fileStack.size() = " + urlFileStack.size() + ", ramStack.size() = " + urlRAMStack.size() + ", domainStacks.size() = " + domainStacks.size());
}
@@ -630,7 +630,7 @@ public class Balancer {
final ArrayList<CrawlEntry> list = new ArrayList<CrawlEntry>();
for (int i = 0; i < count; i++) {
final String urlhash = urlRAMStack.get(i);
- final kelondroRow.Entry entry = urlFileIndex.get(urlhash.getBytes());
+ final Row.Entry entry = urlFileIndex.get(urlhash.getBytes());
if (entry == null) break;
list.add(new CrawlEntry(entry));
}
@@ -643,7 +643,7 @@ public class Balancer {
private class EntryIterator implements Iterator<CrawlEntry> {
- private Iterator<kelondroRow.Entry> rowIterator;
+ private Iterator<Row.Entry> rowIterator;
public EntryIterator() throws IOException {
rowIterator = urlFileIndex.rows(true, null);
@@ -654,7 +654,7 @@ public class Balancer {
}
public CrawlEntry next() {
- final kelondroRow.Entry entry = rowIterator.next();
+ final Row.Entry entry = rowIterator.next();
try {
return (entry == null) ? null : new CrawlEntry(entry);
} catch (final IOException e) {
diff --git a/source/de/anomic/crawler/CrawlEntry.java b/source/de/anomic/crawler/CrawlEntry.java
index d1789cafa..79cd35ced 100755
--- a/source/de/anomic/crawler/CrawlEntry.java
+++ b/source/de/anomic/crawler/CrawlEntry.java
@@ -31,10 +31,10 @@ import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.concurrent.ConcurrentHashMap;
-import de.anomic.kelondro.kelondroBase64Order;
-import de.anomic.kelondro.kelondroBitfield;
-import de.anomic.kelondro.kelondroNaturalOrder;
-import de.anomic.kelondro.kelondroRow;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.Bitfield;
+import de.anomic.kelondro.coding.NaturalOrder;
+import de.anomic.kelondro.index.Row;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverProcessorJob;
import de.anomic.yacy.yacySeedDB;
@@ -43,7 +43,7 @@ import de.anomic.yacy.yacyURL;
public class CrawlEntry extends serverProcessorJob {
// row definition for balancer-related NURL-entries
- public final static kelondroRow rowdef = new kelondroRow(
+ public final static Row rowdef = new Row(
"String urlhash-" + yacySeedDB.commonHashLength + ", " + // the url's hash
"String initiator-" + yacySeedDB.commonHashLength + ", " + // the crawling initiator
"String urlstring-256, " + // the url as string
@@ -59,7 +59,7 @@ public class CrawlEntry extends serverProcessorJob {
"Cardinal loaddate-8 {b256}," + // time when the file was loaded
"Cardinal serverdate-8 {b256}," + // time when that the server returned as document date
"Cardinal modifiedSince-8 {b256}", // time that was given to server as ifModifiedSince
- kelondroBase64Order.enhancedCoder,
+ Base64Order.enhancedCoder,
0
);
@@ -79,7 +79,7 @@ public class CrawlEntry extends serverProcessorJob {
private int depth; // the prefetch depth so far, starts at 0
private int anchors; // number of anchors of the parent
private int forkfactor; // sum of anchors of all ancestors
- private kelondroBitfield flags;
+ private Bitfield flags;
private int handle;
private String statusMessage;
private int initialHash; // to provide a object hash that does not change even if the url changes because of redirection
@@ -142,7 +142,7 @@ public class CrawlEntry extends serverProcessorJob {
this.depth = depth;
this.anchors = anchors;
this.forkfactor = forkfactor;
- this.flags = new kelondroBitfield(rowdef.width(10));
+ this.flags = new Bitfield(rowdef.width(10));
this.handle = 0;
this.serverdate = 0;
this.imsdate = 0;
@@ -151,12 +151,12 @@ public class CrawlEntry extends serverProcessorJob {
this.status = serverProcessorJob.STATUS_INITIATED;
}
- public CrawlEntry(final kelondroRow.Entry entry) throws IOException {
+ public CrawlEntry(final Row.Entry entry) throws IOException {
assert (entry != null);
insertEntry(entry);
}
- private void insertEntry(final kelondroRow.Entry entry) throws IOException {
+ private void insertEntry(final Row.Entry entry) throws IOException {
final String urlstring = entry.getColString(2, null);
if (urlstring == null) throw new IOException ("url string is null");
this.initiator = entry.getColString(1, null);
@@ -168,7 +168,7 @@ public class CrawlEntry extends serverProcessorJob {
this.depth = (int) entry.getColLong(7);
this.anchors = (int) entry.getColLong(8);
this.forkfactor = (int) entry.getColLong(9);
- this.flags = new kelondroBitfield(entry.getColBytes(10));
+ this.flags = new Bitfield(entry.getColBytes(10));
this.handle = Integer.parseInt(entry.getColString(11, null), 16);
this.loaddate = entry.getColLong(12);
this.serverdate = entry.getColLong(13);
@@ -198,11 +198,11 @@ public class CrawlEntry extends serverProcessorJob {
return d;
}
- public kelondroRow.Entry toRow() {
- final byte[] appdatestr = kelondroNaturalOrder.encodeLong(appdate, rowdef.width(5));
- final byte[] loaddatestr = kelondroNaturalOrder.encodeLong(loaddate, rowdef.width(12));
- final byte[] serverdatestr = kelondroNaturalOrder.encodeLong(serverdate, rowdef.width(13));
- final byte[] imsdatestr = kelondroNaturalOrder.encodeLong(imsdate, rowdef.width(14));
+ public Row.Entry toRow() {
+ final byte[] appdatestr = NaturalOrder.encodeLong(appdate, rowdef.width(5));
+ final byte[] loaddatestr = NaturalOrder.encodeLong(loaddate, rowdef.width(12));
+ final byte[] serverdatestr = NaturalOrder.encodeLong(serverdate, rowdef.width(13));
+ final byte[] imsdatestr = NaturalOrder.encodeLong(imsdate, rowdef.width(14));
// store the hash in the hash cache
byte[] namebytes;
try {
@@ -218,9 +218,9 @@ public class CrawlEntry extends serverProcessorJob {
namebytes,
appdatestr,
(this.profileHandle == null) ? null : this.profileHandle.getBytes(),
- kelondroNaturalOrder.encodeLong(this.depth, rowdef.width(7)),
- kelondroNaturalOrder.encodeLong(this.anchors, rowdef.width(8)),
- kelondroNaturalOrder.encodeLong(this.forkfactor, rowdef.width(9)),
+ NaturalOrder.encodeLong(this.depth, rowdef.width(7)),
+ NaturalOrder.encodeLong(this.anchors, rowdef.width(8)),
+ NaturalOrder.encodeLong(this.forkfactor, rowdef.width(9)),
this.flags.bytes(),
normalizeHandle(this.handle).getBytes(),
loaddatestr,
diff --git a/source/de/anomic/crawler/CrawlProfile.java b/source/de/anomic/crawler/CrawlProfile.java
index 37dbfe137..9a51903c6 100644
--- a/source/de/anomic/crawler/CrawlProfile.java
+++ b/source/de/anomic/crawler/CrawlProfile.java
@@ -33,12 +33,12 @@ import java.util.regex.Pattern;
import de.anomic.kelondro.kelondroBLOB;
import de.anomic.kelondro.kelondroBLOBHeap;
-import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroCloneableIterator;
-import de.anomic.kelondro.kelondroDigest;
import de.anomic.kelondro.kelondroException;
import de.anomic.kelondro.kelondroMap;
-import de.anomic.kelondro.kelondroNaturalOrder;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.Digest;
+import de.anomic.kelondro.coding.NaturalOrder;
import de.anomic.yacy.yacySeedDB;
import de.anomic.yacy.yacyURL;
@@ -66,7 +66,7 @@ public class CrawlProfile {
public CrawlProfile(final File file) throws IOException {
this.profileTableFile = file;
profileTableFile.getParentFile().mkdirs();
- final kelondroBLOB dyn = new kelondroBLOBHeap(profileTableFile, yacySeedDB.commonHashLength, kelondroNaturalOrder.naturalOrder, 1024 * 64);
+ final kelondroBLOB dyn = new kelondroBLOBHeap(profileTableFile, yacySeedDB.commonHashLength, NaturalOrder.naturalOrder, 1024 * 64);
profileTable = new kelondroMap(dyn, 500);
}
@@ -77,7 +77,7 @@ public class CrawlProfile {
profileTableFile.getParentFile().mkdirs();
kelondroBLOB dyn = null;
try {
- dyn = new kelondroBLOBHeap(profileTableFile, yacySeedDB.commonHashLength, kelondroNaturalOrder.naturalOrder, 1024 * 64);
+ dyn = new kelondroBLOBHeap(profileTableFile, yacySeedDB.commonHashLength, NaturalOrder.naturalOrder, 1024 * 64);
} catch (IOException e) {
e.printStackTrace();
}
@@ -295,7 +295,7 @@ public class CrawlProfile {
final boolean remoteIndexing,
final boolean xsstopw, final boolean xdstopw, final boolean xpstopw) {
if (name == null || name.length() == 0) throw new NullPointerException("name must not be null");
- final String handle = (startURL == null) ? kelondroBase64Order.enhancedCoder.encode(kelondroDigest.encodeMD5Raw(Long.toString(System.currentTimeMillis()))).substring(0, yacySeedDB.commonHashLength) : startURL.hash();
+ final String handle = (startURL == null) ? Base64Order.enhancedCoder.encode(Digest.encodeMD5Raw(Long.toString(System.currentTimeMillis()))).substring(0, yacySeedDB.commonHashLength) : startURL.hash();
mem = new HashMap<String, String>();
mem.put(HANDLE, handle);
mem.put(NAME, name);
diff --git a/source/de/anomic/crawler/CrawlQueues.java b/source/de/anomic/crawler/CrawlQueues.java
index ae867d3b6..a8ad217ca 100644
--- a/source/de/anomic/crawler/CrawlQueues.java
+++ b/source/de/anomic/crawler/CrawlQueues.java
@@ -38,7 +38,7 @@ import java.util.concurrent.ConcurrentHashMap;
import de.anomic.index.indexDocumentMetadata;
import de.anomic.kelondro.kelondroFlexWidthArray;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.DateFormatter;
import de.anomic.plasma.plasmaParser;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaSwitchboardConstants;
@@ -390,7 +390,7 @@ public class CrawlQueues {
referrer = null;
}
try {
- loaddate = kelondroDate.parseShortSecond(item.getPubDate());
+ loaddate = DateFormatter.parseShortSecond(item.getPubDate());
} catch (final ParseException e) {
loaddate = new Date();
}
diff --git a/source/de/anomic/crawler/FTPLoader.java b/source/de/anomic/crawler/FTPLoader.java
index b9f22af48..533c6f104 100644
--- a/source/de/anomic/crawler/FTPLoader.java
+++ b/source/de/anomic/crawler/FTPLoader.java
@@ -36,7 +36,7 @@ import de.anomic.http.httpRequestHeader;
import de.anomic.http.httpResponseHeader;
import de.anomic.http.httpdProxyCacheEntry;
import de.anomic.index.indexDocumentMetadata;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.DateFormatter;
import de.anomic.net.ftpc;
import de.anomic.plasma.plasmaHTCache;
import de.anomic.plasma.plasmaParser;
@@ -61,7 +61,7 @@ public class FTPLoader {
httpRequestHeader requestHeader = new httpRequestHeader();
if (entry.referrerhash() != null) requestHeader.put(httpRequestHeader.REFERER, sb.getURL(entry.referrerhash()).toNormalform(true, false));
httpResponseHeader responseHeader = new httpResponseHeader();
- responseHeader.put(httpResponseHeader.LAST_MODIFIED, kelondroDate.formatRFC1123(fileDate));
+ responseHeader.put(httpResponseHeader.LAST_MODIFIED, DateFormatter.formatRFC1123(fileDate));
responseHeader.put(httpResponseHeader.CONTENT_TYPE, mimeType);
indexDocumentMetadata metadata = new httpdProxyCacheEntry(
entry.depth(), entry.url(), entry.name(), "OK",
diff --git a/source/de/anomic/crawler/IndexingStack.java b/source/de/anomic/crawler/IndexingStack.java
index 902adce04..82489a603 100644
--- a/source/de/anomic/crawler/IndexingStack.java
+++ b/source/de/anomic/crawler/IndexingStack.java
@@ -36,11 +36,11 @@ import java.util.concurrent.ConcurrentHashMap;
import de.anomic.http.httpResponseHeader;
import de.anomic.index.indexURLReference;
-import de.anomic.kelondro.kelondroBase64Order;
-import de.anomic.kelondro.kelondroNaturalOrder;
-import de.anomic.kelondro.kelondroRow;
import de.anomic.kelondro.kelondroStack;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.DateFormatter;
+import de.anomic.kelondro.coding.NaturalOrder;
+import de.anomic.kelondro.index.Row;
import de.anomic.plasma.plasmaHTCache;
import de.anomic.plasma.plasmaSwitchboardConstants;
import de.anomic.plasma.plasmaWordIndex;
@@ -66,7 +66,7 @@ public class IndexingStack {
initQueueStack();
}
- public static final kelondroRow rowdef = new kelondroRow(
+ public static final Row rowdef = new Row(
"String url-256, " + // the url
"String refhash-" + yacySeedDB.commonHashLength + ", " + // the url's referrer hash
"Cardinal modifiedsince-11 {b64e}, " + // from ifModifiedSince
@@ -75,7 +75,7 @@ public class IndexingStack {
"Cardinal depth-2 {b64e}, " + // the prefetch depth so far, starts at 0
"String profile-" + yacySeedDB.commonHashLength + ", " + // the name of the prefetch profile handle
"String urldescr-80",
- kelondroNaturalOrder.naturalOrder,
+ NaturalOrder.naturalOrder,
0);
private void initQueueStack() {
@@ -99,10 +99,10 @@ public class IndexingStack {
sbQueueStack.push(sbQueueStack.row().newEntry(new byte[][]{
entry.url.toString().getBytes(),
(entry.referrerHash == null) ? "".getBytes() : entry.referrerHash.getBytes(),
- kelondroBase64Order.enhancedCoder.encodeLong((entry.ifModifiedSince == null) ? 0 : entry.ifModifiedSince.getTime(), 11).getBytes(),
+ Base64Order.enhancedCoder.encodeLong((entry.ifModifiedSince == null) ? 0 : entry.ifModifiedSince.getTime(), 11).getBytes(),
new byte[]{entry.flags},
(entry.initiator == null) ? "".getBytes() : entry.initiator.getBytes(),
- kelondroBase64Order.enhancedCoder.encodeLong(entry.depth, rowdef.width(5)).getBytes(),
+ Base64Order.enhancedCoder.encodeLong(entry.depth, rowdef.width(5)).getBytes(),
(entry.profileHandle == null) ? "".getBytes() : entry.profileHandle.getBytes(),
(entry.anchorName == null) ? "-".getBytes("UTF-8") : entry.anchorName.getBytes("UTF-8")
}));
@@ -110,14 +110,14 @@ public class IndexingStack {
public synchronized QueueEntry pop() throws IOException {
if (sbQueueStack.size() == 0) return null;
- final kelondroRow.Entry b = sbQueueStack.pot();
+ final Row.Entry b = sbQueueStack.pot();
if (b == null) return null;
return new QueueEntry(b);
}
public synchronized QueueEntry remove(final String urlHash) {
- final Iterator<kelondroRow.Entry> i = sbQueueStack.stackIterator(true);
- kelondroRow.Entry rowentry;
+ final Iterator<Row.Entry> i = sbQueueStack.stackIterator(true);
+ Row.Entry rowentry;
QueueEntry entry;
while (i.hasNext()) {
rowentry = i.next();
@@ -158,7 +158,7 @@ public class IndexingStack {
public class entryIterator implements Iterator<QueueEntry> {
- Iterator<kelondroRow.Entry> rows;
+ Iterator<Row.Entry> rows;
public entryIterator(final boolean up) {
rows = sbQueueStack.stackIterator(up);
@@ -240,7 +240,7 @@ public class IndexingStack {
this.status = QUEUE_STATE_FRESH;
}
- public QueueEntry(final kelondroRow.Entry row) {
+ public QueueEntry(final Row.Entry row) {
final long ims = row.getColLong(2);
final byte flags = row.getColByte(3);
try {
@@ -263,7 +263,7 @@ public class IndexingStack {
}
public QueueEntry(final byte[][] row) throws IOException {
- final long ims = (row[2] == null) ? 0 : kelondroBase64Order.enhancedCoder.decodeLong(new String(row[2], "UTF-8"));
+ final long ims = (row[2] == null) ? 0 : Base64Order.enhancedCoder.decodeLong(new String(row[2], "UTF-8"));
final byte flags = (row[3] == null) ? 0 : row[3][0];
try {
this.url = new yacyURL(new String(row[0], "UTF-8"), null);
@@ -274,7 +274,7 @@ public class IndexingStack {
this.ifModifiedSince = (ims == 0) ? null : new Date(ims);
this.flags = ((flags & 1) == 1) ? (byte) 1 : (byte) 0;
this.initiator = (row[4] == null) ? null : new String(row[4], "UTF-8");
- this.depth = (int) kelondroBase64Order.enhancedCoder.decodeLong(new String(row[5], "UTF-8"));
+ this.depth = (int) Base64Order.enhancedCoder.decodeLong(new String(row[5], "UTF-8"));
this.profileHandle = new String(row[6], "UTF-8");
this.anchorName = (row[7] == null) ? null : (new String(row[7], "UTF-8")).trim();
@@ -474,7 +474,7 @@ public class IndexingStack {
// parse date
Date d = responseHeader.lastModified();
if (d == null) {
- d = new Date(kelondroDate.correctedUTCTime());
+ d = new Date(DateFormatter.correctedUTCTime());
}
// finally, we shall treat the cache as stale if the modification time is after the if-.. time
if (d.after(ifModifiedSince)) {
@@ -499,7 +499,7 @@ public class IndexingStack {
// sometimes, the expires date is set to the past to prevent that a page is cached
// we use that information to see if we should index it
final Date expires = responseHeader.expires();
- if (expires != null && expires.before(new Date(kelondroDate.correctedUTCTime()))) {
+ if (expires != null && expires.before(new Date(DateFormatter.correctedUTCTime()))) {
return "Stale_(Expired)";
}
@@ -532,7 +532,7 @@ public class IndexingStack {
}
try {
final long ttl = 1000 * Long.parseLong(cacheControl.substring(8)); // milliseconds to live
- if (kelondroDate.correctedUTCTime() - date.getTime() > ttl) {
+ if (DateFormatter.correctedUTCTime() - date.getTime() > ttl) {
//System.out.println("***not indexed because cache-control");
return "Stale_(expired_by_cache-control)";
}
diff --git a/source/de/anomic/crawler/ResultURLs.java b/source/de/anomic/crawler/ResultURLs.java
index d5d325494..2c18c2695 100644
--- a/source/de/anomic/crawler/ResultURLs.java
+++ b/source/de/anomic/crawler/ResultURLs.java
@@ -40,8 +40,8 @@ import java.util.LinkedList;
import java.util.List;
import de.anomic.index.indexURLReference;
-import de.anomic.kelondro.kelondroBitfield;
-import de.anomic.kelondro.kelondroMScoreCluster;
+import de.anomic.kelondro.coding.Bitfield;
+import de.anomic.kelondro.tools.ScoreCluster;
import de.anomic.server.logging.serverLog;
import de.anomic.yacy.yacySeedDB;
import de.anomic.yacy.yacyURL;
@@ -58,12 +58,12 @@ public final class ResultURLs {
private final LinkedList<String> lcrawlResultStack; // 5 - local index: result of local crawling
private final LinkedList<String> gcrawlResultStack; // 6 - local index: triggered external
- private final kelondroMScoreCluster<String> externResultDomains;
- private final kelondroMScoreCluster<String> searchResultDomains;
- private final kelondroMScoreCluster<String> transfResultDomains;
- private final kelondroMScoreCluster<String> proxyResultDomains;
- private final kelondroMScoreCluster<String> lcrawlResultDomains;
- private final kelondroMScoreCluster<String> gcrawlResultDomains;
+ private final ScoreCluster<String> externResultDomains;
+ private final ScoreCluster<String> searchResultDomains;
+ private final ScoreCluster<String> transfResultDomains;
+ private final ScoreCluster<String> proxyResultDomains;
+ private final ScoreCluster<String> lcrawlResultDomains;
+ private final ScoreCluster<String> gcrawlResultDomains;
public ResultURLs() {
// init result stacks
@@ -74,12 +74,12 @@ public final class ResultURLs {
lcrawlResultStack = new LinkedList<String>();
gcrawlResultStack = new LinkedList<String>();
// init result domain statistics
- externResultDomains = new kelondroMScoreCluster<String>();
- searchResultDomains = new kelondroMScoreCluster<String>();
- transfResultDomains = new kelondroMScoreCluster<String>();
- proxyResultDomains = new kelondroMScoreCluster<String>();
- lcrawlResultDomains = new kelondroMScoreCluster<String>();
- gcrawlResultDomains = new kelondroMScoreCluster<String>();
+ externResultDomains = new ScoreCluster<String>();
+ searchResultDomains = new ScoreCluster<String>();
+ transfResultDomains = new ScoreCluster<String>();
+ proxyResultDomains = new ScoreCluster<String>();
+ lcrawlResultDomains = new ScoreCluster<String>();
+ gcrawlResultDomains = new ScoreCluster<String>();
}
public synchronized void stack(final indexURLReference e, final String initiatorHash, final String executorHash, final int stackType) {
@@ -96,7 +96,7 @@ public final class ResultURLs {
return;
}
try {
- final kelondroMScoreCluster<String> domains = getDomains(stackType);
+ final ScoreCluster<String> domains = getDomains(stackType);
if (domains != null) {
domains.incScore(e.comp().url().getHost());
}
@@ -113,7 +113,7 @@ public final class ResultURLs {
}
public synchronized int getDomainListSize(final int stack) {
- final kelondroMScoreCluster<String> domains = getDomains(stack);
+ final ScoreCluster<String> domains = getDomains(stack);
if (domains == null) return 0;
return domains.size();
}
@@ -240,7 +240,7 @@ public final class ResultURLs {
return null;
}
}
- private kelondroMScoreCluster<String> getDomains(final int stack) {
+ private ScoreCluster<String> getDomains(final int stack) {
switch (stack) {
case 1: return externResultDomains;
case 2: return searchResultDomains;
@@ -274,7 +274,7 @@ public final class ResultURLs {
public synchronized void clearStack(final int stack) {
final List<String> resultStack = getStack(stack);
if (resultStack != null) resultStack.clear();
- final kelondroMScoreCluster<String> resultDomains = getDomains(stack);
+ final ScoreCluster<String> resultDomains = getDomains(stack);
if (resultDomains != null) {
// we do not clear this completely, just remove most of the less important entries
resultDomains.shrinkToMaxSize(100);
@@ -305,7 +305,7 @@ public final class ResultURLs {
final ResultURLs results = new ResultURLs();
try {
final yacyURL url = new yacyURL("http", "www.yacy.net", 80, "/");
- final indexURLReference urlRef = new indexURLReference(url, "YaCy Homepage", "", "", "", new Date(), new Date(), new Date(), "", new byte[] {}, 123, 42, '?', new kelondroBitfield(), "de", 0, 0, 0, 0, 0, 0);
+ final indexURLReference urlRef = new indexURLReference(url, "YaCy Homepage", "", "", "", new Date(), new Date(), new Date(), "", new byte[] {}, 123, 42, '?', new Bitfield(), "de", 0, 0, 0, 0, 0, 0);
int stackNo = 1;
System.out.println("valid test:\n=======");
// add
diff --git a/source/de/anomic/crawler/RobotsTxt.java b/source/de/anomic/crawler/RobotsTxt.java
index b164d9443..fbe6f276d 100644
--- a/source/de/anomic/crawler/RobotsTxt.java
+++ b/source/de/anomic/crawler/RobotsTxt.java
@@ -47,9 +47,9 @@ import de.anomic.kelondro.kelondroBLOB;
import de.anomic.kelondro.kelondroBLOBHeap;
import de.anomic.kelondro.kelondroException;
import de.anomic.kelondro.kelondroMap;
-import de.anomic.kelondro.kelondroNaturalOrder;
-import de.anomic.kelondro.kelondroDate;
-import de.anomic.kelondro.kelondroByteBuffer;
+import de.anomic.kelondro.coding.DateFormatter;
+import de.anomic.kelondro.coding.NaturalOrder;
+import de.anomic.kelondro.tools.ByteBuffer;
import de.anomic.server.serverFileUtils;
import de.anomic.server.logging.serverLog;
import de.anomic.yacy.yacyURL;
@@ -69,7 +69,7 @@ public class RobotsTxt {
robotsTableFile.getParentFile().mkdirs();
kelondroBLOB blob = null;
try {
- blob = new kelondroBLOBHeap(robotsTableFile, 64, kelondroNaturalOrder.naturalOrder, 1024 * 1024);
+ blob = new kelondroBLOBHeap(robotsTableFile, 64, NaturalOrder.naturalOrder, 1024 * 1024);
} catch (final IOException e) {
e.printStackTrace();
}
@@ -84,7 +84,7 @@ public class RobotsTxt {
robotsTableFile.getParentFile().mkdirs();
kelondroBLOB blob = null;
try {
- blob = new kelondroBLOBHeap(robotsTableFile, 64, kelondroNaturalOrder.naturalOrder, 1024 * 1024);
+ blob = new kelondroBLOBHeap(robotsTableFile, 64, NaturalOrder.naturalOrder, 1024 * 1024);
} catch (final IOException e) {
e.printStackTrace();
}
@@ -518,7 +518,7 @@ public class RobotsTxt {
oldEtag = entry.getETag();
reqHeaders = new httpRequestHeader();
final Date modDate = entry.getModDate();
- if (modDate != null) reqHeaders.put(httpRequestHeader.IF_MODIFIED_SINCE, kelondroDate.formatRFC1123(entry.getModDate()));
+ if (modDate != null) reqHeaders.put(httpRequestHeader.IF_MODIFIED_SINCE, DateFormatter.formatRFC1123(entry.getModDate()));
}
@@ -551,7 +551,7 @@ public class RobotsTxt {
}
// downloading the content
- final kelondroByteBuffer sbb = new kelondroByteBuffer();
+ final ByteBuffer sbb = new ByteBuffer();
try {
serverFileUtils.copyToStream(new BufferedInputStream(res.getDataAsStream()), new BufferedOutputStream(sbb));
} finally {
diff --git a/source/de/anomic/crawler/ZURL.java b/source/de/anomic/crawler/ZURL.java
index 789a0598a..5284ecc2b 100755
--- a/source/de/anomic/crawler/ZURL.java
+++ b/source/de/anomic/crawler/ZURL.java
@@ -32,12 +32,12 @@ import java.util.Date;
import java.util.Iterator;
import java.util.LinkedList;
-import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroEcoTable;
import de.anomic.kelondro.kelondroFlexWidthArray;
-import de.anomic.kelondro.kelondroIndex;
-import de.anomic.kelondro.kelondroRow;
-import de.anomic.kelondro.kelondroRowSet;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.index.Row;
+import de.anomic.kelondro.index.RowSet;
+import de.anomic.kelondro.index.ObjectIndex;
import de.anomic.yacy.yacySeedDB;
import de.anomic.yacy.yacyURL;
@@ -46,18 +46,18 @@ public class ZURL {
private static final int EcoFSBufferSize = 200;
private static final int maxStackSize = 300;
- public final static kelondroRow rowdef = new kelondroRow(
+ public final static Row rowdef = new Row(
"String urlhash-" + yacySeedDB.commonHashLength + ", " + // the url's hash
"String executor-" + yacySeedDB.commonHashLength + ", " + // the crawling executor
"Cardinal workdate-8 {b256}, " + // the time when the url was last time tried to load
"Cardinal workcount-4 {b256}, " + // number of load retries
"String anycause-132, " + // string describing load failure
"byte[] entry-" + CrawlEntry.rowdef.objectsize, // extra space
- kelondroBase64Order.enhancedCoder,
+ Base64Order.enhancedCoder,
0);
// the class object
- kelondroIndex urlIndex = null;
+ ObjectIndex urlIndex = null;
private final LinkedList<String> stack = new LinkedList<String>(); // strings: url
public ZURL(final File cachePath, final String tablename, final boolean startWithEmptyFile) {
@@ -75,7 +75,7 @@ public class ZURL {
public ZURL() {
// creates a new ZUR in RAM
- urlIndex = new kelondroRowSet(rowdef, 0);
+ urlIndex = new RowSet(rowdef, 0);
}
public int size() {
@@ -134,7 +134,7 @@ public class ZURL {
public synchronized Entry getEntry(final String urlhash) {
try {
if (urlIndex == null) return null;
- final kelondroRow.Entry entry = urlIndex.get(urlhash.getBytes());
+ final Row.Entry entry = urlIndex.get(urlhash.getBytes());
if (entry == null) return null;
return new Entry(entry);
} catch (final IOException e) {
@@ -181,7 +181,7 @@ public class ZURL {
stored = false;
}
- public Entry(final kelondroRow.Entry entry) throws IOException {
+ public Entry(final Row.Entry entry) throws IOException {
assert (entry != null);
this.executor = entry.getColString(1, "UTF-8");
this.workdate = new Date(entry.getColLong(2));
@@ -197,7 +197,7 @@ public class ZURL {
// stores the values from the object variables into the database
if (this.stored) return;
if (this.bentry == null) return;
- final kelondroRow.Entry newrow = rowdef.newEntry();
+ final Row.Entry newrow = rowdef.newEntry();
newrow.setCol(0, this.bentry.url().hash().getBytes());
newrow.setCol(1, this.executor.getBytes());
newrow.setCol(2, this.workdate.getTime());
@@ -245,7 +245,7 @@ public class ZURL {
public class kiter implements Iterator<Entry> {
// enumerates entry elements
- Iterator<kelondroRow.Entry> i;
+ Iterator<Row.Entry> i;
boolean error = false;
public kiter(final boolean up, final String firstHash) throws IOException {
@@ -259,7 +259,7 @@ public class ZURL {
}
public Entry next() throws RuntimeException {
- final kelondroRow.Entry e = i.next();
+ final Row.Entry e = i.next();
if (e == null) return null;
try {
return new Entry(e);
diff --git a/source/de/anomic/data/SitemapParser.java b/source/de/anomic/data/SitemapParser.java
index f58dc257e..6c64a52ea 100644
--- a/source/de/anomic/data/SitemapParser.java
+++ b/source/de/anomic/data/SitemapParser.java
@@ -46,7 +46,7 @@ import de.anomic.http.JakartaCommonsHttpResponse;
import de.anomic.http.httpRequestHeader;
import de.anomic.http.httpdByteCountInputStream;
import de.anomic.index.indexURLReference;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.DateFormatter;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.logging.serverLog;
import de.anomic.yacy.yacyURL;
@@ -299,7 +299,7 @@ public class SitemapParser extends DefaultHandler {
} else if (this.currentElement.equalsIgnoreCase(SITEMAP_URL_LASTMOD)) {
final String dateStr = new String(buf, offset, len);
try {
- this.lastMod = kelondroDate.parseISO8601(dateStr);
+ this.lastMod = DateFormatter.parseISO8601(dateStr);
} catch (final ParseException e) {
this.logger.logInfo("Unable to parse datestring '" + dateStr + "'");
}
diff --git a/source/de/anomic/data/URLFetcherStack.java b/source/de/anomic/data/URLFetcherStack.java
index 376b84f18..ddbc09488 100644
--- a/source/de/anomic/data/URLFetcherStack.java
+++ b/source/de/anomic/data/URLFetcherStack.java
@@ -28,11 +28,11 @@ import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Iterator;
-import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroException;
-import de.anomic.kelondro.kelondroRow;
import de.anomic.kelondro.kelondroStack;
-import de.anomic.kelondro.kelondroRow.EntryIndex;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.index.Row;
+import de.anomic.kelondro.index.Row.EntryIndex;
import de.anomic.server.logging.serverLog;
import de.anomic.yacy.yacyURL;
@@ -40,9 +40,9 @@ public class URLFetcherStack {
public static final String DBFILE = "urlRemote2.stack";
- private static final kelondroRow rowdef = new kelondroRow(
+ private static final Row rowdef = new Row(
"String urlstring-256",
- kelondroBase64Order.enhancedCoder,
+ Base64Order.enhancedCoder,
0
);
private final kelondroStack db;
@@ -79,7 +79,7 @@ public class URLFetcherStack {
public yacyURL pop() {
try {
- final kelondroRow.Entry r = this.db.pop();
+ final Row.Entry r = this.db.pop();
if (r == null) return null;
final String url = r.getColString(0, null);
try {
@@ -99,7 +99,7 @@ public class URLFetcherStack {
try {
final ArrayList<String> ar = new ArrayList<String>();
final Iterator<EntryIndex> it = db.contentRows(500);
- kelondroRow.EntryIndex ei;
+ Row.EntryIndex ei;
for (int i=0; i<count && it.hasNext(); i++) {
ei = it.next();
if (ei == null) continue;
diff --git a/source/de/anomic/data/blogBoard.java b/source/de/anomic/data/blogBoard.java
index 3f665a6b4..4e6feac8c 100644
--- a/source/de/anomic/data/blogBoard.java
+++ b/source/de/anomic/data/blogBoard.java
@@ -48,11 +48,11 @@ import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import de.anomic.kelondro.kelondroBLOBTree;
-import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroException;
import de.anomic.kelondro.kelondroMap;
-import de.anomic.kelondro.kelondroNaturalOrder;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.DateFormatter;
+import de.anomic.kelondro.coding.NaturalOrder;
import de.anomic.server.logging.serverLog;
public class blogBoard {
@@ -65,7 +65,7 @@ public class blogBoard {
public blogBoard(final File actpath) {
new File(actpath.getParent()).mkdir();
if (database == null) {
- database = new kelondroMap(new kelondroBLOBTree(actpath, true, true, keyLength, recordSize, '_', kelondroNaturalOrder.naturalOrder, true, false, false), 500);
+ database = new kelondroMap(new kelondroBLOBTree(actpath, true, true, keyLength, recordSize, '_', NaturalOrder.naturalOrder, true, false, false), 500);
}
}
@@ -201,7 +201,7 @@ public class blogBoard {
}
try {
- date = kelondroDate.parseShortSecond(StrDate);
+ date = DateFormatter.parseShortSecond(StrDate);
} catch (final ParseException e1) {
date = new Date();
}
@@ -376,7 +376,7 @@ public class blogBoard {
public byte[] getSubject() {
final String m = record.get("subject");
if (m == null) return new byte[0];
- final byte[] b = kelondroBase64Order.enhancedCoder.decode(m, "de.anomic.data.blogBoard.subject()");
+ final byte[] b = Base64Order.enhancedCoder.decode(m, "de.anomic.data.blogBoard.subject()");
if (b == null) return "".getBytes();
return b;
}
@@ -385,7 +385,7 @@ public class blogBoard {
if (subject == null)
record.put("subject","");
else
- record.put("subject", kelondroBase64Order.enhancedCoder.encode(subject));
+ record.put("subject", Base64Order.enhancedCoder.encode(subject));
}
public Date getDate() {
@@ -395,7 +395,7 @@ public class blogBoard {
if (serverLog.isFinest("Blog")) serverLog.logFinest("Blog", "ERROR: date field missing in blogBoard");
return new Date();
}
- return kelondroDate.parseShortSecond(date);
+ return DateFormatter.parseShortSecond(date);
} catch (final ParseException e) {
return new Date();
}
@@ -404,14 +404,14 @@ public class blogBoard {
private void setDate(Date date) {
if(date == null)
date = new Date();
- record.put("date", kelondroDate.formatShortSecond(date));
+ record.put("date", DateFormatter.formatShortSecond(date));
}
public String getTimestamp() {
final String timestamp = record.get("date");
if (timestamp == null) {
if (serverLog.isFinest("Blog")) serverLog.logFinest("Blog", "ERROR: date field missing in blogBoard");
- return kelondroDate.formatShortSecond();
+ return DateFormatter.formatShortSecond();
}
return timestamp;
}
@@ -419,7 +419,7 @@ public class blogBoard {
public byte[] getAuthor() {
final String author = record.get("author");
if (author == null) return new byte[0];
- final byte[] b = kelondroBase64Order.enhancedCoder.decode(author, "de.anomic.data.blogBoard.author()");
+ final byte[] b = Base64Order.enhancedCoder.decode(author, "de.anomic.data.blogBoard.author()");
if (b == null) return "".getBytes();
return b;
}
@@ -428,7 +428,7 @@ public class blogBoard {
if (author == null)
record.put("author","");
else
- record.put("author", kelondroBase64Order.enhancedCoder.encode(author));
+ record.put("author", Base64Order.enhancedCoder.encode(author));
}
public int getCommentsSize() {
@@ -468,7 +468,7 @@ public class blogBoard {
public byte[] getPage() {
final String page = record.get("page");
if (page == null) return new byte[0];
- final byte[] page_as_byte = kelondroBase64Order.enhancedCoder.decode(page, "de.anomic.data.blogBoard.page()");
+ final byte[] page_as_byte = Base64Order.enhancedCoder.decode(page, "de.anomic.data.blogBoard.page()");
if (page_as_byte == null) return "".getBytes();
return page_as_byte;
}
@@ -477,7 +477,7 @@ public class blogBoard {
if (page == null)
record.put("page", "");
else
- record.put("page", kelondroBase64Order.enhancedCoder.encode(page));
+ record.put("page", Base64Order.enhancedCoder.encode(page));
}
public void addComment(final String commentID) {
diff --git a/source/de/anomic/data/blogBoardComments.java b/source/de/anomic/data/blogBoardComments.java
index 3aec9d112..beb9e2191 100644
--- a/source/de/anomic/data/blogBoardComments.java
+++ b/source/de/anomic/data/blogBoardComments.java
@@ -47,9 +47,9 @@ import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import de.anomic.kelondro.kelondroBLOBTree;
-import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroMap;
-import de.anomic.kelondro.kelondroNaturalOrder;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.NaturalOrder;
import de.anomic.server.logging.serverLog;
public class blogBoardComments {
@@ -67,7 +67,7 @@ public class blogBoardComments {
public blogBoardComments(final File actpath) {
new File(actpath.getParent()).mkdir();
if (database == null) {
- database = new kelondroMap(new kelondroBLOBTree(actpath, true, true, keyLength, recordSize, '_', kelondroNaturalOrder.naturalOrder, false, false, false), 500);
+ database = new kelondroMap(new kelondroBLOBTree(actpath, true, true, keyLength, recordSize, '_', NaturalOrder.naturalOrder, false, false, false), 500);
}
}
public int size() {
@@ -245,12 +245,12 @@ public class blogBoardComments {
if (subject == null)
record.put("subject","");
else
- record.put("subject", kelondroBase64Order.enhancedCoder.encode(subject));
+ record.put("subject", Base64Order.enhancedCoder.encode(subject));
}
public byte[] getSubject() {
final String subject = record.get("subject");
if (subject == null) return new byte[0];
- final byte[] subject_bytes = kelondroBase64Order.enhancedCoder.decode(subject, "de.anomic.data.blogBoardComments.subject()");
+ final byte[] subject_bytes = Base64Order.enhancedCoder.decode(subject, "de.anomic.data.blogBoardComments.subject()");
if (subject_bytes == null) return "".getBytes();
return subject_bytes;
}
@@ -286,13 +286,13 @@ public class blogBoardComments {
if (author == null)
record.put("author","");
else
- record.put("author", kelondroBase64Order.enhancedCoder.encode(author));
+ record.put("author", Base64Order.enhancedCoder.encode(author));
}
public byte[] getAuthor() {
final String author = record.get("author");
if (author == null)
return new byte[0];
- final byte[] author_byte = kelondroBase64Order.enhancedCoder.decode(author, "de.anomic.data.blogBoardComments.author()");
+ final byte[] author_byte = Base64Order.enhancedCoder.decode(author, "de.anomic.data.blogBoardComments.author()");
if (author_byte == null)
return "".getBytes();
return author_byte;
@@ -312,13 +312,13 @@ public class blogBoardComments {
if (page == null)
record.put("page", "");
else
- record.put("page", kelondroBase64Order.enhancedCoder.encode(page));
+ record.put("page", Base64Order.enhancedCoder.encode(page));
}
public byte[] getPage() {
final String page = record.get("page");
if (page == null)
return new byte[0];
- final byte[] page_byte = kelondroBase64Order.enhancedCoder.decode(page, "de.anomic.data.blogBoardComments.page()");
+ final byte[] page_byte = Base64Order.enhancedCoder.decode(page, "de.anomic.data.blogBoardComments.page()");
if (page_byte == null)
return "".getBytes();
return page_byte;
diff --git a/source/de/anomic/data/bookmarksDB.java b/source/de/anomic/data/bookmarksDB.java
index 684ebc878..05e25c24e 100644
--- a/source/de/anomic/data/bookmarksDB.java
+++ b/source/de/anomic/data/bookmarksDB.java
@@ -69,8 +69,8 @@ import de.anomic.kelondro.kelondroBLOBTree;
import de.anomic.kelondro.kelondroCloneableIterator;
import de.anomic.kelondro.kelondroException;
import de.anomic.kelondro.kelondroMap;
-import de.anomic.kelondro.kelondroNaturalOrder;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.DateFormatter;
+import de.anomic.kelondro.coding.NaturalOrder;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverBusyThread;
import de.anomic.server.serverFileUtils;
@@ -112,17 +112,17 @@ public class bookmarksDB {
tagCache=new HashMap<String, Tag>();
bookmarksFile.getParentFile().mkdirs();
//this.bookmarksTable = new kelondroMap(kelondroDyn.open(bookmarksFile, bufferkb * 1024, preloadTime, 12, 256, '_', true, false));
- this.bookmarksTable = new kelondroMap(new kelondroBLOBTree(bookmarksFile, true, true, 12, 256, '_', kelondroNaturalOrder.naturalOrder, true, false, false), 1000);
+ this.bookmarksTable = new kelondroMap(new kelondroBLOBTree(bookmarksFile, true, true, 12, 256, '_', NaturalOrder.naturalOrder, true, false, false), 1000);
// tags
tagsFile.getParentFile().mkdirs();
final boolean tagsFileExisted = tagsFile.exists();
- this.tagsTable = new kelondroMap(new kelondroBLOBTree(tagsFile, true, true, 12, 256, '_', kelondroNaturalOrder.naturalOrder, true, false, false), 500);
+ this.tagsTable = new kelondroMap(new kelondroBLOBTree(tagsFile, true, true, 12, 256, '_', NaturalOrder.naturalOrder, true, false, false), 500);
if (!tagsFileExisted) rebuildTags();
// dates
final boolean datesExisted = datesFile.exists();
- this.datesTable = new kelondroMap(new kelondroBLOBTree(datesFile, true, true, 20, 256, '_', kelondroNaturalOrder.naturalOrder, true, false, false), 500);
+ this.datesTable = new kelondroMap(new kelondroBLOBTree(datesFile, true, true, 20, 256, '_', NaturalOrder.naturalOrder, true, false, false), 500);
if (!datesExisted) rebuildDates();
// autoReCrawl
@@ -218,7 +218,7 @@ public class bookmarksDB {
long interTime = (System.currentTimeMillis()-bm.getTimeStamp())%schedule;
Date date=new Date(bm.getTimeStamp());
- serverLog.logInfo("BOOKMARKS", "autoReCrawl - checking schedule for: "+"["+kelondroDate.formatISO8601(date)+"] "+bm.getUrl());
+ serverLog.logInfo("BOOKMARKS", "autoReCrawl - checking schedule for: "+"["+DateFormatter.formatISO8601(date)+"] "+bm.getUrl());
if (interTime >= 0 && interTime < sleepTime) {
try {
@@ -873,7 +873,7 @@ public class bookmarksDB {
Date parsedDate = null;
try {
- parsedDate = kelondroDate.parseISO8601(time);
+ parsedDate = DateFormatter.parseISO8601(time);
} catch (final ParseException e) {
parsedDate = new Date();
}
diff --git a/source/de/anomic/data/messageBoard.java b/source/de/anomic/data/messageBoard.java
index a19961f7a..7462ba560 100644
--- a/source/de/anomic/data/messageBoard.java
+++ b/source/de/anomic/data/messageBoard.java
@@ -32,9 +32,9 @@ import java.util.Map;
import java.util.TimeZone;
import de.anomic.kelondro.kelondroBLOBTree;
-import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroMap;
-import de.anomic.kelondro.kelondroNaturalOrder;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.NaturalOrder;
public class messageBoard {
@@ -54,7 +54,7 @@ public class messageBoard {
public messageBoard(final File path) {
new File(path.getParent()).mkdir();
if (database == null) {
- database = new kelondroMap(new kelondroBLOBTree(path, true, true, categoryLength + dateFormat.length() + 2, recordSize, '_', kelondroNaturalOrder.naturalOrder, true, false, false), 500);
+ database = new kelondroMap(new kelondroBLOBTree(path, true, true, categoryLength + dateFormat.length() + 2, recordSize, '_', NaturalOrder.naturalOrder, true, false, false), 500);
}
sn = 0;
}
@@ -115,7 +115,7 @@ public class messageBoard {
if (message == null)
record.put("message", "");
else
- record.put("message", kelondroBase64Order.enhancedCoder.encode(message));
+ record.put("message", Base64Order.enhancedCoder.encode(message));
record.put("read", "false");
}
@@ -176,7 +176,7 @@ public class messageBoard {
final String m = record.get("message");
if (m == null) return new byte[0];
record.put("read", "true");
- return kelondroBase64Order.enhancedCoder.decode(m, "de.anomic.data.messageBoard.message()");
+ return Base64Order.enhancedCoder.decode(m, "de.anomic.data.messageBoard.message()");
}
public boolean read() {
diff --git a/source/de/anomic/data/userDB.java b/source/de/anomic/data/userDB.java
index 9e3cf8028..904933af1 100644
--- a/source/de/anomic/data/userDB.java
+++ b/source/de/anomic/data/userDB.java
@@ -37,12 +37,12 @@ import java.util.Random;
import de.anomic.http.httpRequestHeader;
import de.anomic.kelondro.kelondroBLOBTree;
-import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroCloneableIterator;
-import de.anomic.kelondro.kelondroDigest;
import de.anomic.kelondro.kelondroException;
import de.anomic.kelondro.kelondroMap;
-import de.anomic.kelondro.kelondroNaturalOrder;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.Digest;
+import de.anomic.kelondro.coding.NaturalOrder;
public final class userDB {
@@ -57,7 +57,7 @@ public final class userDB {
public userDB(final File userTableFile) {
this.userTableFile = userTableFile;
userTableFile.getParentFile().mkdirs();
- this.userTable = new kelondroMap(new kelondroBLOBTree(userTableFile, true, true, 128, 256, '_', kelondroNaturalOrder.naturalOrder, true, false, false), 10);
+ this.userTable = new kelondroMap(new kelondroBLOBTree(userTableFile, true, true, 128, 256, '_', NaturalOrder.naturalOrder, true, false, false), 10);
}
void resetDatabase() {
@@ -65,7 +65,7 @@ public final class userDB {
if (userTable != null) userTable.close();
if (!(userTableFile.delete())) throw new RuntimeException("cannot delete user database");
userTableFile.getParentFile().mkdirs();
- userTable = new kelondroMap(new kelondroBLOBTree(userTableFile, true, true, 256, 512, '_', kelondroNaturalOrder.naturalOrder, true, false, false), 10);
+ userTable = new kelondroMap(new kelondroBLOBTree(userTableFile, true, true, 256, 512, '_', NaturalOrder.naturalOrder, true, false, false), 10);
}
public void close() {
@@ -121,7 +121,7 @@ public final class userDB {
auth=auth.trim().substring(6);
try{
- auth=kelondroBase64Order.standardCoder.decodeString(auth, "de.anomic.data.userDB.proxyAuth()");
+ auth=Base64Order.standardCoder.decodeString(auth, "de.anomic.data.userDB.proxyAuth()");
}catch(final RuntimeException e){} //no valid Base64
final String[] tmp=auth.split(":");
if(tmp.length == 2){
@@ -197,7 +197,7 @@ public final class userDB {
}
public Entry passwordAuth(final String user, final String password){
final Entry entry=this.getEntry(user);
- if( entry != null && entry.getMD5EncodedUserPwd().equals(kelondroDigest.encodeMD5Hex(user+":"+password)) ){
+ if( entry != null && entry.getMD5EncodedUserPwd().equals(Digest.encodeMD5Hex(user+":"+password)) ){
if(entry.isLoggedOut()){
try{
entry.setProperty(Entry.LOGGED_OUT, "false");
diff --git a/source/de/anomic/data/wikiBoard.java b/source/de/anomic/data/wikiBoard.java
index 27716b2e0..13107d1fa 100644
--- a/source/de/anomic/data/wikiBoard.java
+++ b/source/de/anomic/data/wikiBoard.java
@@ -32,9 +32,9 @@ import java.util.Map;
import java.util.TimeZone;
import de.anomic.kelondro.kelondroBLOBTree;
-import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroMap;
-import de.anomic.kelondro.kelondroNaturalOrder;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.NaturalOrder;
public class wikiBoard {
@@ -55,11 +55,11 @@ public class wikiBoard {
public wikiBoard(final File actpath, final File bkppath) {
new File(actpath.getParent()).mkdirs();
if (datbase == null) {
- datbase = new kelondroMap(new kelondroBLOBTree(actpath, true, true, keyLength, recordSize, '_', kelondroNaturalOrder.naturalOrder, true, false, false), 500);
+ datbase = new kelondroMap(new kelondroBLOBTree(actpath, true, true, keyLength, recordSize, '_', NaturalOrder.naturalOrder, true, false, false), 500);
}
new File(bkppath.getParent()).mkdirs();
if (bkpbase == null) {
- bkpbase = new kelondroMap(new kelondroBLOBTree(bkppath, true, true, keyLength + dateFormat.length(), recordSize, '_', kelondroNaturalOrder.naturalOrder, true, false, false), 500);
+ bkpbase = new kelondroMap(new kelondroBLOBTree(bkppath, true, true, keyLength + dateFormat.length(), recordSize, '_', NaturalOrder.naturalOrder, true, false, false), 500);
}
}
@@ -125,15 +125,15 @@ public class wikiBoard {
if (key.length() > keyLength) key = key.substring(0, keyLength);
record.put("date", dateString());
if ((author == null) || (author.length() == 0)) author = "anonymous";
- record.put("author", kelondroBase64Order.enhancedCoder.encode(author.getBytes("UTF-8")));
+ record.put("author", Base64Order.enhancedCoder.encode(author.getBytes("UTF-8")));
if ((ip == null) || (ip.length() == 0)) ip = "";
record.put("ip", ip);
if ((reason == null) || (reason.length() == 0)) reason = "";
- record.put("reason", kelondroBase64Order.enhancedCoder.encode(reason.getBytes("UTF-8")));
+ record.put("reason", Base64Order.enhancedCoder.encode(reason.getBytes("UTF-8")));
if (page == null)
record.put("page", "");
else
- record.put("page", kelondroBase64Order.enhancedCoder.encode(page));
+ record.put("page", Base64Order.enhancedCoder.encode(page));
authors.put(ip, author);
//System.out.println("DEBUG: setting author " + author + " for ip = " + ip + ", authors = " + authors.toString());
}
@@ -165,7 +165,7 @@ public class wikiBoard {
public String author() {
final String a = record.get("author");
if (a == null) return "anonymous";
- final byte[] b = kelondroBase64Order.enhancedCoder.decode(a, "de.anomic.data.wikiBoard.author()");
+ final byte[] b = Base64Order.enhancedCoder.decode(a, "de.anomic.data.wikiBoard.author()");
if (b == null) return "anonymous";
return new String(b);
}
@@ -173,7 +173,7 @@ public class wikiBoard {
public String reason() {
final String r = record.get("reason");
if (r == null) return "";
- final byte[] b = kelondroBase64Order.enhancedCoder.decode(r, "de.anomic.data.wikiBoard.reason()");
+ final byte[] b = Base64Order.enhancedCoder.decode(r, "de.anomic.data.wikiBoard.reason()");
if (b == null) return "unknown";
return new String(b);
}
@@ -181,7 +181,7 @@ public class wikiBoard {
public byte[] page() {
final String m = record.get("page");
if (m == null) return new byte[0];
- final byte[] b = kelondroBase64Order.enhancedCoder.decode(m, "de.anomic.data.wikiBoard.page()");
+ final byte[] b = Base64Order.enhancedCoder.decode(m, "de.anomic.data.wikiBoard.page()");
if (b == null) return "".getBytes();
return b;
}
@@ -221,13 +221,13 @@ public class wikiBoard {
}
void setChild(final String subject) {
- record.put("child", kelondroBase64Order.enhancedCoder.encode(subject.getBytes()));
+ record.put("child", Base64Order.enhancedCoder.encode(subject.getBytes()));
}
private String getChildName() {
final String c = record.get("child");
if (c == null) return null;
- final byte[] subject = kelondroBase64Order.enhancedCoder.decode(c, "de.anomic.data.wikiBoard.getChildName()");
+ final byte[] subject = Base64Order.enhancedCoder.decode(c, "de.anomic.data.wikiBoard.getChildName()");
if (subject == null) return null;
return new String(subject);
}
@@ -235,7 +235,7 @@ public class wikiBoard {
public boolean hasChild() {
final String c = record.get("child");
if (c == null) return false;
- final byte[] subject = kelondroBase64Order.enhancedCoder.decode(c, "de.anomic.data.wikiBoard.hasChild()");
+ final byte[] subject = Base64Order.enhancedCoder.decode(c, "de.anomic.data.wikiBoard.hasChild()");
return (subject != null);
}
diff --git a/source/de/anomic/htmlFilter/htmlFilterContentTransformer.java b/source/de/anomic/htmlFilter/htmlFilterContentTransformer.java
index 5b355d4d4..49e9763f5 100644
--- a/source/de/anomic/htmlFilter/htmlFilterContentTransformer.java
+++ b/source/de/anomic/htmlFilter/htmlFilterContentTransformer.java
@@ -35,7 +35,7 @@ import java.util.Properties;
import java.util.TreeSet;
import de.anomic.http.httpTemplate;
-import de.anomic.kelondro.kelondroByteBuffer;
+import de.anomic.kelondro.tools.ByteBuffer;
import de.anomic.server.serverCharBuffer;
public class htmlFilterContentTransformer extends htmlFilterAbstractTransformer implements htmlFilterTransformer {
@@ -116,8 +116,8 @@ public class htmlFilterContentTransformer extends htmlFilterAbstractTransformer
public ArrayList<String> getStrings(final byte[] text){
final ArrayList<String> result = new ArrayList<String>();
- final kelondroByteBuffer sbb = new kelondroByteBuffer(text);
- final kelondroByteBuffer[] sbbs = httpTemplate.splitQuotations(sbb);
+ final ByteBuffer sbb = new ByteBuffer(text);
+ final ByteBuffer[] sbbs = httpTemplate.splitQuotations(sbb);
for (int i = 0; i < sbbs.length; i++) {
// TODO: avoid empty if statements
if (sbbs[i].isWhitespace(true)) {
diff --git a/source/de/anomic/http/JakartaCommonsHttpClient.java b/source/de/anomic/http/JakartaCommonsHttpClient.java
index 9b38d46af..eeba9f530 100644
--- a/source/de/anomic/http/JakartaCommonsHttpClient.java
+++ b/source/de/anomic/http/JakartaCommonsHttpClient.java
@@ -58,7 +58,7 @@ import org.apache.commons.httpclient.params.HttpMethodParams;
import org.apache.commons.httpclient.protocol.Protocol;
import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
-import de.anomic.kelondro.kelondroBase64Order;
+import de.anomic.kelondro.coding.Base64Order;
import de.anomic.server.logging.serverLog;
/**
@@ -536,7 +536,7 @@ public class JakartaCommonsHttpClient {
serverLog.logWarning("HTTPC", "Proxy authentication contains invalid characters, trying anyway");
}
final String remoteProxyPwd = hostProxyConfig.getProxyPwd();
- final String credentials = kelondroBase64Order.standardCoder.encodeString(remoteProxyUser.replace(":",
+ final String credentials = Base64Order.standardCoder.encodeString(remoteProxyUser.replace(":",
"") +
":" + remoteProxyPwd);
method.setRequestHeader(httpRequestHeader.PROXY_AUTHORIZATION, "Basic " + credentials);
diff --git a/source/de/anomic/http/httpChunkedInputStream.java b/source/de/anomic/http/httpChunkedInputStream.java
index 2e3575f95..15fe9b9a0 100644
--- a/source/de/anomic/http/httpChunkedInputStream.java
+++ b/source/de/anomic/http/httpChunkedInputStream.java
@@ -30,7 +30,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import de.anomic.kelondro.kelondroByteBuffer;
+import de.anomic.kelondro.tools.ByteBuffer;
/**
* Some parts of this class code was copied from <a href="http://www.devdaily.com/java/jwarehouse/commons-httpclient-2.0/src/java/org/apache/commons/httpclient/ChunkedInputStream.shtml">Apache httpclient Project.</a>
@@ -122,9 +122,9 @@ public final class httpChunkedInputStream extends InputStream {
private void readTrailer() throws IOException {
BufferedReader reader = null;
- kelondroByteBuffer bout = null;
+ ByteBuffer bout = null;
try {
- bout = new kelondroByteBuffer();
+ bout = new ByteBuffer();
do {
int ch;
while ((ch = this.inputStream.read()) >= 0) {
@@ -148,7 +148,7 @@ public final class httpChunkedInputStream extends InputStream {
private static int readChunkFromStream(final InputStream in) throws IOException {
- final kelondroByteBuffer baos = new kelondroByteBuffer();
+ final ByteBuffer baos = new ByteBuffer();
int state = READ_CHUNK_STATE_NORMAL;
while (state != READ_CHUNK_STATE_FINISHED) {
final int b = in.read();
diff --git a/source/de/anomic/http/httpChunkedOutputStream.java b/source/de/anomic/http/httpChunkedOutputStream.java
index 255093a6a..5e5cf71ed 100644
--- a/source/de/anomic/http/httpChunkedOutputStream.java
+++ b/source/de/anomic/http/httpChunkedOutputStream.java
@@ -29,7 +29,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import de.anomic.kelondro.kelondroByteBuffer;
+import de.anomic.kelondro.tools.ByteBuffer;
import de.anomic.server.serverCore;
import de.anomic.server.serverFileUtils;
@@ -77,7 +77,7 @@ public final class httpChunkedOutputStream extends FilterOutputStream {
this.out.flush();
}
- public void write(final kelondroByteBuffer b, final int off, final int len) throws IOException {
+ public void write(final ByteBuffer b, final int off, final int len) throws IOException {
if (this.finished) throw new IOException("ChunkedOutputStream already finalized.");
if (len == 0) return;
diff --git a/source/de/anomic/http/httpHeader.java b/source/de/anomic/http/httpHeader.java
index c8ad516a4..fe5ad1f8e 100644
--- a/source/de/anomic/http/httpHeader.java
+++ b/source/de/anomic/http/httpHeader.java
@@ -50,7 +50,7 @@ import java.util.Properties;
import java.util.TreeMap;
import java.util.Vector;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.DateFormatter;
import de.anomic.yacy.yacyURL;
@@ -375,7 +375,7 @@ public class httpHeader extends TreeMap<String, String> implements Map<String, S
protected Date headerDate(final String kind) {
if (containsKey(kind)) {
- Date parsedDate = kelondroDate.parseHTTPDate(get(kind));
+ Date parsedDate = DateFormatter.parseHTTPDate(get(kind));
if (parsedDate == null) parsedDate = new Date();
return parsedDate;
}
diff --git a/source/de/anomic/http/httpRequestHeader.java b/source/de/anomic/http/httpRequestHeader.java
index 9bbae55e3..96884ddf5 100755
--- a/source/de/anomic/http/httpRequestHeader.java
+++ b/source/de/anomic/http/httpRequestHeader.java
@@ -31,7 +31,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.DateFormatter;
import de.anomic.server.serverCore;
public class httpRequestHeader extends httpHeader {
@@ -94,7 +94,7 @@ public class httpRequestHeader extends httpHeader {
public Object ifRange() {
if (containsKey(IF_RANGE)) {
- final Date rangeDate = kelondroDate.parseHTTPDate(get(IF_RANGE));
+ final Date rangeDate = DateFormatter.parseHTTPDate(get(IF_RANGE));
if (rangeDate != null)
return rangeDate;
diff --git a/source/de/anomic/http/httpSSI.java b/source/de/anomic/http/httpSSI.java
index 8305c4cfd..570451555 100644
--- a/source/de/anomic/http/httpSSI.java
+++ b/source/de/anomic/http/httpSSI.java
@@ -31,15 +31,15 @@ import java.io.IOException;
import java.io.OutputStream;
import java.util.Properties;
-import de.anomic.kelondro.kelondroByteBuffer;
+import de.anomic.kelondro.tools.ByteBuffer;
public class httpSSI {
- public static void writeSSI(final kelondroByteBuffer in, final OutputStream out, final String authorization, final String requesthost) throws IOException {
+ public static void writeSSI(final ByteBuffer in, final OutputStream out, final String authorization, final String requesthost) throws IOException {
writeSSI(in, 0, out, authorization, requesthost);
}
- public static void writeSSI(final kelondroByteBuffer in, int off, final OutputStream out, final String authorization, final String requesthost) throws IOException {
+ public static void writeSSI(final ByteBuffer in, int off, final OutputStream out, final String authorization, final String requesthost) throws IOException {
int p = in.indexOf("<!--#".getBytes(), off);
int q;
while (p >= 0) {
@@ -60,7 +60,7 @@ public class httpSSI {
}
}
- private static void parseSSI(final kelondroByteBuffer in, final int off, final int len, final OutputStream out, final String authorization, final String requesthost) {
+ private static void parseSSI(final ByteBuffer in, final int off, final int len, final OutputStream out, final String authorization, final String requesthost) {
if (in.startsWith("<!--#include virtual=\"".getBytes(), off)) {
final int q = in.indexOf("\"".getBytes(), off + 22);
if (q > 0) {
diff --git a/source/de/anomic/http/httpTemplate.java b/source/de/anomic/http/httpTemplate.java
index 105642624..49cc231ce 100644
--- a/source/de/anomic/http/httpTemplate.java
+++ b/source/de/anomic/http/httpTemplate.java
@@ -60,7 +60,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
-import de.anomic.kelondro.kelondroByteBuffer;
+import de.anomic.kelondro.tools.ByteBuffer;
import de.anomic.server.serverFileUtils;
import de.anomic.server.logging.serverLog;
@@ -153,15 +153,15 @@ public final class httpTemplate {
new Object[] {iOpen, iClose}
};
- public final static kelondroByteBuffer[] splitQuotations(final kelondroByteBuffer text) {
- final List<kelondroByteBuffer> l = splitQuotation(text, 0);
- final kelondroByteBuffer[] sbbs = new kelondroByteBuffer[l.size()];
+ public final static ByteBuffer[] splitQuotations(final ByteBuffer text) {
+ final List<ByteBuffer> l = splitQuotation(text, 0);
+ final ByteBuffer[] sbbs = new ByteBuffer[l.size()];
for (int i = 0; i < l.size(); i++) sbbs[i] = l.get(i);
return sbbs;
}
- private final static List<kelondroByteBuffer> splitQuotation(kelondroByteBuffer text, int qoff) {
- final ArrayList<kelondroByteBuffer> l = new ArrayList<kelondroByteBuffer>();
+ private final static List<ByteBuffer> splitQuotation(ByteBuffer text, int qoff) {
+ final ArrayList<ByteBuffer> l = new ArrayList<ByteBuffer>();
if (qoff >= meta_quotation.length) {
if (text.length() > 0) l.add(text);
return l;
@@ -174,22 +174,22 @@ public final class httpTemplate {
q = text.indexOf(right, p + 1);
if (q >= 0) {
// found a pattern
- l.addAll(splitQuotation(new kelondroByteBuffer(text.getBytes(0, p)), qoff));
- l.add(new kelondroByteBuffer(text.getBytes(p, q + right.length - p)));
- text = new kelondroByteBuffer(text.getBytes(q + right.length));
+ l.addAll(splitQuotation(new ByteBuffer(text.getBytes(0, p)), qoff));
+ l.add(new ByteBuffer(text.getBytes(p, q + right.length - p)));
+ text = new ByteBuffer(text.getBytes(q + right.length));
} else {
// found only pattern start, no closing parantesis (a syntax error that is silently accepted here)
- l.addAll(splitQuotation(new kelondroByteBuffer(text.getBytes(0, p)), qoff));
- l.addAll(splitQuotation(new kelondroByteBuffer(text.getBytes(p)), qoff));
+ l.addAll(splitQuotation(new ByteBuffer(text.getBytes(0, p)), qoff));
+ l.addAll(splitQuotation(new ByteBuffer(text.getBytes(p)), qoff));
text.clear();
}
}
// find double-points
while ((text.length() > 0) && ((p = text.indexOf(dpdpa)) >= 0)) {
- l.addAll(splitQuotation(new kelondroByteBuffer(text.getBytes(0, p)), qoff));
- l.add(new kelondroByteBuffer(dpdpa));
- l.addAll(splitQuotation(new kelondroByteBuffer(text.getBytes(p + 2)), qoff));
+ l.addAll(splitQuotation(new ByteBuffer(text.getBytes(0, p)), qoff));
+ l.add(new ByteBuffer(dpdpa));
+ l.addAll(splitQuotation(new ByteBuffer(text.getBytes(p + 2)), qoff));
text.clear();
}
@@ -252,7 +252,7 @@ public final class httpTemplate {
byte[] multi_key;
byte[] replacement;
int bb;
- final kelondroByteBuffer structure = new kelondroByteBuffer();
+ final ByteBuffer structure = new ByteBuffer();
while (transferUntil(pis, out, hash)) {
bb = pis.read();
keyStream.reset();
@@ -306,7 +306,7 @@ public final class httpTemplate {
// #(
} else if ((bb & 0xFF) == lrbr) { //alternative
int others=0;
- final kelondroByteBuffer text= new kelondroByteBuffer();
+ final ByteBuffer text= new ByteBuffer();
transferUntil(pis, keyStream, aClose);
key = keyStream.toByteArray(); //Caution: Key does not contain prefix
@@ -425,7 +425,7 @@ public final class httpTemplate {
// #%
} else if ((bb & 0xFF) == ps) { //include
- final kelondroByteBuffer include = new kelondroByteBuffer();
+ final ByteBuffer include = new ByteBuffer();
keyStream.reset(); //reset stream
if(transferUntil(pis, keyStream, iClose)){
byte[] filename = keyStream.toByteArray();
@@ -493,7 +493,7 @@ public final class httpTemplate {
}
private final static byte[] newPrefix(final byte[] oldPrefix, final byte[] key) {
- final kelondroByteBuffer newPrefix = new kelondroByteBuffer();
+ final ByteBuffer newPrefix = new ByteBuffer();
newPrefix.append(oldPrefix)
.append(key)
.append("_".getBytes());
@@ -507,7 +507,7 @@ public final class httpTemplate {
}
private final static byte[] newPrefix(final byte[] oldPrefix, final byte[] multi_key, final int i) {
- final kelondroByteBuffer newPrefix = new kelondroByteBuffer();
+ final ByteBuffer newPrefix = new ByteBuffer();
newPrefix.append(oldPrefix)
.append(multi_key)
.append("_".getBytes())
@@ -522,7 +522,7 @@ public final class httpTemplate {
}
private final static String getPatternKey(final byte[] prefix, final byte[] key) {
- final kelondroByteBuffer patternKey = new kelondroByteBuffer();
+ final ByteBuffer patternKey = new ByteBuffer();
patternKey.append(prefix).append(key);
try {
return new String(patternKey.getBytes(),"UTF-8");
@@ -538,7 +538,7 @@ public final class httpTemplate {
}
private final static byte[] appendBytes(final byte[] b1, final byte[] b2, final byte[] b3, final byte[] b4) {
- final kelondroByteBuffer byteArray = new kelondroByteBuffer();
+ final ByteBuffer byteArray = new ByteBuffer();
byteArray.append(b1)
.append(b2);
if (b3 != null) byteArray.append(b3);
diff --git a/source/de/anomic/http/httpd.java b/source/de/anomic/http/httpd.java
index 55ff4acb9..4ac6056cd 100644
--- a/source/de/anomic/http/httpd.java
+++ b/source/de/anomic/http/httpd.java
@@ -62,10 +62,10 @@ import org.apache.commons.httpclient.ContentLengthInputStream;
import de.anomic.data.userDB;
import de.anomic.htmlFilter.htmlFilterCharacterCoding;
-import de.anomic.kelondro.kelondroBase64Order;
-import de.anomic.kelondro.kelondroDigest;
-import de.anomic.kelondro.kelondroDate;
-import de.anomic.kelondro.kelondroByteBuffer;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.DateFormatter;
+import de.anomic.kelondro.coding.Digest;
+import de.anomic.kelondro.tools.ByteBuffer;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverCodings;
import de.anomic.server.serverCore;
@@ -296,7 +296,7 @@ public final class httpd implements serverHandler, Cloneable {
//if (authorization.length() < 6) return 1; // no authentication information given
final String adminAccountBase64MD5 = sw.getConfig(ADMIN_ACCOUNT_B64MD5, "");
if (adminAccountBase64MD5.length() == 0) return 2; // no password stored
- if (adminAccountBase64MD5.equals(kelondroDigest.encodeMD5Hex(authorization))) return 4; // hard-authenticated, all ok
+ if (adminAccountBase64MD5.equals(Digest.encodeMD5Hex(authorization))) return 4; // hard-authenticated, all ok
return 1;
}
@@ -318,7 +318,7 @@ public final class httpd implements serverHandler, Cloneable {
this.session.out.write((httpResponseHeader.CONTENT_LENGTH + ": 0\r\n").getBytes());
this.session.out.write("\r\n".getBytes());
return false;
- } else if (!this.serverAccountBase64MD5.equals(kelondroDigest.encodeMD5Hex(auth.trim().substring(6)))) {
+ } else if (!this.serverAccountBase64MD5.equals(Digest.encodeMD5Hex(auth.trim().substring(6)))) {
// wrong password given: ask for authenticate again
log.logInfo("Wrong log-in for account 'server' in HTTPD.GET " + this.prop.getProperty("PATH") + " from IP " + this.clientIP);
this.session.out.write((httpVersion + " 401 log-in required" + serverCore.CRLF_STRING +
@@ -357,7 +357,7 @@ public final class httpd implements serverHandler, Cloneable {
// pw = addressed peer hash (b64-hash)
final String auth = (String) header.get(httpRequestHeader.PROXY_AUTHORIZATION,"xxxxxx");
if (getAlternativeResolver() != null) {
- final String test = kelondroBase64Order.standardCoder.encodeString(getAlternativeResolver().myName() + ":" + getAlternativeResolver().myID());
+ final String test = Base64Order.standardCoder.encodeString(getAlternativeResolver().myName() + ":" + getAlternativeResolver().myID());
if (!test.equals(auth.trim().substring(6))) return false;
}
@@ -1192,7 +1192,7 @@ public final class httpd implements serverHandler, Cloneable {
// building the stacktrace
if (stackTrace != null) {
tp.put("printStackTrace",1);
- final kelondroByteBuffer errorMsg = new kelondroByteBuffer(100);
+ final ByteBuffer errorMsg = new ByteBuffer(100);
stackTrace.printStackTrace(new PrintStream(errorMsg));
tp.put("printStackTrace_exception", stackTrace.toString());
tp.put("printStackTrace_stacktrace", new String(errorMsg.getBytes(),"UTF-8"));
@@ -1202,7 +1202,7 @@ public final class httpd implements serverHandler, Cloneable {
// Generated Tue, 23 Aug 2005 11:19:14 GMT by brain.wg (squid/2.5.STABLE3)
// adding some system information
- final String systemDate = kelondroDate.formatRFC1123(new Date());
+ final String systemDate = DateFormatter.formatRFC1123(new Date());
tp.put("date", systemDate);
// rewrite the file
@@ -1302,9 +1302,9 @@ public final class httpd implements serverHandler, Cloneable {
final Date now = new Date(System.currentTimeMillis());
headers.put(httpResponseHeader.SERVER, "AnomicHTTPD (www.anomic.de)");
- headers.put(httpResponseHeader.DATE, kelondroDate.formatRFC1123(now));
+ headers.put(httpResponseHeader.DATE, DateFormatter.formatRFC1123(now));
if (moddate.after(now)) moddate = now;
- headers.put(httpResponseHeader.LAST_MODIFIED, kelondroDate.formatRFC1123(moddate));
+ headers.put(httpResponseHeader.LAST_MODIFIED, DateFormatter.formatRFC1123(moddate));
if (nocache) {
if (httpVersion.toUpperCase().equals(httpHeader.HTTP_VERSION_1_1)) headers.put(httpResponseHeader.CACHE_CONTROL, "no-cache");
@@ -1318,7 +1318,7 @@ public final class httpd implements serverHandler, Cloneable {
headers.put(httpHeader.CONTENT_TYPE, contentType);
if (contentLength > 0) headers.put(httpResponseHeader.CONTENT_LENGTH, Long.toString(contentLength));
//if (cookie != null) headers.put(httpResponseHeader.SET_COOKIE, cookie);
- if (expires != null) headers.put(httpResponseHeader.EXPIRES, kelondroDate.formatRFC1123(expires));
+ if (expires != null) headers.put(httpResponseHeader.EXPIRES, DateFormatter.formatRFC1123(expires));
if (contentEnc != null) headers.put(httpResponseHeader.CONTENT_ENCODING, contentEnc);
if (transferEnc != null) headers.put(httpResponseHeader.TRANSFER_ENCODING, transferEnc);
@@ -1369,7 +1369,7 @@ public final class httpd implements serverHandler, Cloneable {
// prepare header
if (!responseHeader.containsKey(httpHeader.DATE))
- responseHeader.put(httpHeader.DATE, kelondroDate.formatRFC1123(new Date()));
+ responseHeader.put(httpHeader.DATE, DateFormatter.formatRFC1123(new Date()));
if (!responseHeader.containsKey(httpHeader.CONTENT_TYPE))
responseHeader.put(httpHeader.CONTENT_TYPE, "text/html; charset=UTF-8"); // fix this
if (!responseHeader.containsKey(httpRequestHeader.CONNECTION) && conProp.containsKey(httpHeader.CONNECTION_PROP_PERSISTENT))
diff --git a/source/de/anomic/http/httpdFileHandler.java b/source/de/anomic/http/httpdFileHandler.java
index 3bf1b35f6..b45607414 100644
--- a/source/de/anomic/http/httpdFileHandler.java
+++ b/source/de/anomic/http/httpdFileHandler.java
@@ -82,8 +82,8 @@ import java.util.zip.GZIPOutputStream;
import de.anomic.htmlFilter.htmlFilterContentScraper;
import de.anomic.htmlFilter.htmlFilterInputStream;
-import de.anomic.kelondro.kelondroDate;
-import de.anomic.kelondro.kelondroByteBuffer;
+import de.anomic.kelondro.coding.DateFormatter;
+import de.anomic.kelondro.tools.ByteBuffer;
import de.anomic.plasma.plasmaParser;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaSwitchboardConstants;
@@ -228,7 +228,7 @@ public final class httpdFileHandler {
ext = path.substring(pos + 1).toLowerCase();
}
headers.put(httpResponseHeader.SERVER, "AnomicHTTPD (www.anomic.de)");
- headers.put(httpResponseHeader.DATE, kelondroDate.formatRFC1123(new Date()));
+ headers.put(httpResponseHeader.DATE, DateFormatter.formatRFC1123(new Date()));
if(!(plasmaParser.mediaExtContains(ext))){
headers.put(httpResponseHeader.PRAGMA, "no-cache");
}
@@ -473,7 +473,7 @@ public final class httpdFileHandler {
aBuffer.append("<a href=\"" + path + list[i] + "\">" + list[i] + "</a><br>");
if ((author != null) && (author.length() > 0)) aBuffer.append("Author: " + author + "<br>");
if ((description != null) && (description.length() > 0)) aBuffer.append("Description: " + description + "<br>");
- aBuffer.append(kelondroDate.formatShortDay(new Date(f.lastModified())) + ", " + size + ((images > 0) ? ", " + images + " images" : "") + ((links > 0) ? ", " + links + " links" : "") + "<br></li>\n");
+ aBuffer.append(DateFormatter.formatShortDay(new Date(f.lastModified())) + ", " + size + ((images > 0) ? ", " + images + " images" : "") + ((links > 0) ? ", " + links + " links" : "") + "<br></li>\n");
}
}
aBuffer.append(" </ul>\n</body>\n</html>\n");
@@ -530,7 +530,7 @@ public final class httpdFileHandler {
targetDate = new Date(System.currentTimeMillis());
nocache = true;
final String mimeType = mimeTable.getProperty(targetExt, "text/html");
- final kelondroByteBuffer result = ymageMatrix.exportImage(yp.getImage(), targetExt);
+ final ByteBuffer result = ymageMatrix.exportImage(yp.getImage(), targetExt);
// write the array to the client
httpd.sendRespondHeader(conProp, out, httpVersion, 200, null, mimeType, result.length(), targetDate, null, null, null, null, nocache);
@@ -550,7 +550,7 @@ public final class httpdFileHandler {
int height = i.getHeight(null); if (height < 0) height = 96; // bad hack
final BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
bi.createGraphics().drawImage(i, 0, 0, width, height, null);
- final kelondroByteBuffer result = ymageMatrix.exportImage(bi, targetExt);
+ final ByteBuffer result = ymageMatrix.exportImage(bi, targetExt);
// write the array to the client
httpd.sendRespondHeader(conProp, out, httpVersion, 200, null, mimeType, result.length(), targetDate, null, null, null, null, nocache);
@@ -787,7 +787,7 @@ public final class httpdFileHandler {
templatePatterns.put(servletProperties.PEER_STAT_VERSION, switchboard.getConfig("version", ""));
templatePatterns.put(servletProperties.PEER_STAT_UPTIME, ((System.currentTimeMillis() - serverCore.startupTime) / 1000) / 60); // uptime in minutes
templatePatterns.putHTML(servletProperties.PEER_STAT_CLIENTNAME, switchboard.getConfig("peerName", "anomic"));
- templatePatterns.put(servletProperties.PEER_STAT_MYTIME, kelondroDate.formatShortSecond());
+ templatePatterns.put(servletProperties.PEER_STAT_MYTIME, DateFormatter.formatShortSecond());
//System.out.println("respond props: " + ((tp == null) ? "null" : tp.toString())); // debug
} catch (final InvocationTargetException e) {
if (e.getCause() instanceof InterruptedException) {
@@ -876,7 +876,7 @@ public final class httpdFileHandler {
final boolean chunked = !method.equals(httpHeader.METHOD_HEAD) && !yacyClient && httpVersion.equals(httpHeader.HTTP_VERSION_1_1);
if (chunked) {
// send page in chunks and parse SSIs
- final kelondroByteBuffer o = new kelondroByteBuffer();
+ final ByteBuffer o = new ByteBuffer();
// apply templates
httpTemplate.writeTemplate(fis, o, templatePatterns, "-UNRESOLVED_PATTERN-".getBytes("UTF-8"));
httpd.sendRespondHeader(conProp, out, httpVersion, 200, null, mimeType, -1, targetDate, null, (templatePatterns == null) ? new httpResponseHeader() : templatePatterns.getOutgoingHeader(), null, "chunked", nocache);
@@ -889,10 +889,10 @@ public final class httpdFileHandler {
// send page as whole thing, SSIs are not possible
final String contentEncoding = (zipContent) ? "gzip" : null;
// apply templates
- final kelondroByteBuffer o1 = new kelondroByteBuffer();
+ final ByteBuffer o1 = new ByteBuffer();
httpTemplate.writeTemplate(fis, o1, templatePatterns, "-UNRESOLVED_PATTERN-".getBytes("UTF-8"));
- final kelondroByteBuffer o = new kelondroByteBuffer();
+ final ByteBuffer o = new ByteBuffer();
if (zipContent) {
GZIPOutputStream zippedOut = new GZIPOutputStream(o);
diff --git a/source/de/anomic/http/httpdProxyCacheEntry.java b/source/de/anomic/http/httpdProxyCacheEntry.java
index ec16bbd04..83a9df64a 100755
--- a/source/de/anomic/http/httpdProxyCacheEntry.java
+++ b/source/de/anomic/http/httpdProxyCacheEntry.java
@@ -30,7 +30,7 @@ import java.util.Date;
import de.anomic.crawler.CrawlProfile;
import de.anomic.index.indexDocumentMetadata;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.DateFormatter;
import de.anomic.plasma.plasmaHTCache;
import de.anomic.yacy.yacyURL;
@@ -193,7 +193,7 @@ public class httpdProxyCacheEntry implements indexDocumentMetadata {
docDate = responseHeader.lastModified();
if (docDate == null) docDate = responseHeader.date();
}
- if (docDate == null) docDate = new Date(kelondroDate.correctedUTCTime());
+ if (docDate == null) docDate = new Date(DateFormatter.correctedUTCTime());
return docDate;
}
@@ -322,7 +322,7 @@ public class httpdProxyCacheEntry implements indexDocumentMetadata {
if (date == null) return "stale_no_date_given_in_response";
try {
final long ttl = 1000 * Long.parseLong(cacheControl.substring(8)); // milliseconds to live
- if (kelondroDate.correctedUTCTime() - date.getTime() > ttl) {
+ if (DateFormatter.correctedUTCTime() - date.getTime() > ttl) {
//System.out.println("***not indexed because cache-control");
return "stale_expired";
}
@@ -382,8 +382,8 @@ public class httpdProxyCacheEntry implements indexDocumentMetadata {
if (!responseHeader.containsKey(httpResponseHeader.LAST_MODIFIED)) { return false; }
// parse date
Date d1, d2;
- d2 = responseHeader.lastModified(); if (d2 == null) { d2 = new Date(kelondroDate.correctedUTCTime()); }
- d1 = requestHeader.ifModifiedSince(); if (d1 == null) { d1 = new Date(kelondroDate.correctedUTCTime()); }
+ d2 = responseHeader.lastModified(); if (d2 == null) { d2 = new Date(DateFormatter.correctedUTCTime()); }
+ d1 = requestHeader.ifModifiedSince(); if (d1 == null) { d1 = new Date(DateFormatter.correctedUTCTime()); }
// finally, we shall treat the cache as stale if the modification time is after the if-.. time
if (d2.after(d1)) { return false; }
}
@@ -424,7 +424,7 @@ public class httpdProxyCacheEntry implements indexDocumentMetadata {
final Date expires = responseHeader.expires();
if (expires != null) {
// System.out.println("EXPIRES-TEST: expires=" + expires + ", NOW=" + serverDate.correctedGMTDate() + ", url=" + url);
- if (expires.before(new Date(kelondroDate.correctedUTCTime()))) { return false; }
+ if (expires.before(new Date(DateFormatter.correctedUTCTime()))) { return false; }
}
final Date lastModified = responseHeader.lastModified();
cacheControl = responseHeader.get(httpResponseHeader.CACHE_CONTROL);
@@ -438,13 +438,13 @@ public class httpdProxyCacheEntry implements indexDocumentMetadata {
// file may only be treated as fresh for one more month, not more.
Date date = responseHeader.date();
if (lastModified != null) {
- if (date == null) { date = new Date(kelondroDate.correctedUTCTime()); }
+ if (date == null) { date = new Date(DateFormatter.correctedUTCTime()); }
final long age = date.getTime() - lastModified.getTime();
if (age < 0) { return false; }
// TTL (Time-To-Live) is age/10 = (d2.getTime() - d1.getTime()) / 10
// the actual living-time is serverDate.correctedGMTDate().getTime() - d2.getTime()
// therefore the cache is stale, if serverDate.correctedGMTDate().getTime() - d2.getTime() > age/10
- if (kelondroDate.correctedUTCTime() - date.getTime() > age / 10) { return false; }
+ if (DateFormatter.correctedUTCTime() - date.getTime() > age / 10) { return false; }
}
// -cache-control in cached response
@@ -463,7 +463,7 @@ public class httpdProxyCacheEntry implements indexDocumentMetadata {
if (date == null) { return false; }
try {
final long ttl = 1000 * Long.parseLong(cacheControl.substring(8)); // milliseconds to live
- if (kelondroDate.correctedUTCTime() - date.getTime() > ttl) {
+ if (DateFormatter.correctedUTCTime() - date.getTime() > ttl) {
return false;
}
} catch (final Exception e) {
diff --git a/source/de/anomic/http/httpdProxyHandler.java b/source/de/anomic/http/httpdProxyHandler.java
index 77a9b733e..22c943b3d 100644
--- a/source/de/anomic/http/httpdProxyHandler.java
+++ b/source/de/anomic/http/httpdProxyHandler.java
@@ -76,7 +76,7 @@ import de.anomic.htmlFilter.htmlFilterContentTransformer;
import de.anomic.htmlFilter.htmlFilterTransformer;
import de.anomic.index.indexDocumentMetadata;
import de.anomic.index.indexReferenceBlacklist;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.DateFormatter;
import de.anomic.plasma.plasmaHTCache;
import de.anomic.plasma.plasmaParser;
import de.anomic.plasma.plasmaSwitchboard;
@@ -660,7 +660,7 @@ public final class httpdProxyHandler {
prepareResponseHeader(cachedResponseHeader, httpVer);
// replace date field in old header by actual date, this is according to RFC
- cachedResponseHeader.put(httpHeader.DATE, kelondroDate.formatRFC1123(new Date()));
+ cachedResponseHeader.put(httpHeader.DATE, DateFormatter.formatRFC1123(new Date()));
// if (((String)requestHeader.get(httpHeader.ACCEPT_ENCODING,"")).indexOf("gzip") != -1) {
// chunked = new httpChunkedOutputStream(respond);
diff --git a/source/de/anomic/icap/icapd.java b/source/de/anomic/icap/icapd.java
index 9c4af5432..249d838ea 100644
--- a/source/de/anomic/icap/icapd.java
+++ b/source/de/anomic/icap/icapd.java
@@ -41,7 +41,7 @@ import de.anomic.http.httpRequestHeader;
import de.anomic.http.httpResponseHeader;
import de.anomic.http.httpdProxyCacheEntry;
import de.anomic.index.indexDocumentMetadata;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.DateFormatter;
import de.anomic.plasma.plasmaHTCache;
import de.anomic.plasma.plasmaParser;
import de.anomic.plasma.plasmaSwitchboard;
@@ -125,7 +125,7 @@ public class icapd implements serverHandler, Cloneable {
final icapHeader newHeaders = new icapHeader();
newHeaders.put(icapHeader.SERVER,"YaCy/" + sb.getConfig("vString",""));
- newHeaders.put(icapHeader.DATE, kelondroDate.formatRFC1123(new Date()));
+ newHeaders.put(icapHeader.DATE, DateFormatter.formatRFC1123(new Date()));
newHeaders.put(icapHeader.ISTAG, "\"" + sb.getConfig("vString","") + "\"");
return newHeaders;
diff --git a/source/de/anomic/index/indexAbstractReferenceBlacklist.java b/source/de/anomic/index/indexAbstractReferenceBlacklist.java
index ca4b70702..043a28522 100644
--- a/source/de/anomic/index/indexAbstractReferenceBlacklist.java
+++ b/source/de/anomic/index/indexAbstractReferenceBlacklist.java
@@ -40,7 +40,7 @@ import java.util.Set;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
-import de.anomic.kelondro.kelondroMSetTools;
+import de.anomic.kelondro.tools.SetTools;
import de.anomic.yacy.yacyURL;
public abstract class indexAbstractReferenceBlacklist implements indexReferenceBlacklist {
@@ -159,7 +159,7 @@ public abstract class indexAbstractReferenceBlacklist implements indexReferenceB
} catch (final IOException e) { /* */ }
// join all blacklists from files into one internal blacklist map
- loadedBlacklist = kelondroMSetTools.loadMapMultiValsPerKey(file.toString(), sep).entrySet();
+ loadedBlacklist = SetTools.loadMapMultiValsPerKey(file.toString(), sep).entrySet();
for (final Iterator<Map.Entry<String, ArrayList<String>>> mi = loadedBlacklist.iterator(); mi.hasNext(); ) {
loadedEntry = mi.next();
loadedPaths = loadedEntry.getValue();
diff --git a/source/de/anomic/index/indexCell.java b/source/de/anomic/index/indexCell.java
index ba2e14704..0788416eb 100644
--- a/source/de/anomic/index/indexCell.java
+++ b/source/de/anomic/index/indexCell.java
@@ -33,8 +33,8 @@ import java.util.Set;
import de.anomic.kelondro.kelondroCloneableIterator;
import de.anomic.kelondro.kelondroMergeIterator;
-import de.anomic.kelondro.kelondroOrder;
-import de.anomic.kelondro.kelondroRow;
+import de.anomic.kelondro.coding.kelondroOrder;
+import de.anomic.kelondro.index.Row;
/*
* an index cell is a part of the horizontal index in the new segment-oriented index
@@ -57,7 +57,7 @@ public final class indexCell implements indexRI {
@SuppressWarnings("unchecked")
public indexCell(
final File cellPath,
- final kelondroRow payloadrow,
+ final Row payloadrow,
final int maxRamEntries
) throws IOException {
this.array = new indexContainerBLOBArray(cellPath, payloadrow);
diff --git a/source/de/anomic/index/indexCollectionRI.java b/source/de/anomic/index/indexCollectionRI.java
index 7afd93bb8..b2e5dea96 100644
--- a/source/de/anomic/index/indexCollectionRI.java
+++ b/source/de/anomic/index/indexCollectionRI.java
@@ -32,25 +32,25 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
-import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroCloneableIterator;
import de.anomic.kelondro.kelondroCollectionIndex;
import de.anomic.kelondro.kelondroOutOfLimitsException;
-import de.anomic.kelondro.kelondroRow;
-import de.anomic.kelondro.kelondroRowSet;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.index.Row;
+import de.anomic.kelondro.index.RowSet;
import de.anomic.server.logging.serverLog;
public class indexCollectionRI implements indexRI {
kelondroCollectionIndex collectionIndex;
- public indexCollectionRI(final File path, final String filenameStub, final int maxpartition, final kelondroRow payloadrow, boolean useCommons) {
+ public indexCollectionRI(final File path, final String filenameStub, final int maxpartition, final Row payloadrow, boolean useCommons) {
try {
collectionIndex = new kelondroCollectionIndex(
path,
filenameStub,
12 /*keyLength*/,
- kelondroBase64Order.enhancedCoder,
+ Base64Order.enhancedCoder,
4 /*loadfactor*/,
maxpartition,
payloadrow,
@@ -89,7 +89,7 @@ public class indexCollectionRI implements indexRI {
public wordContainersIterator(final String startWordHash, final boolean rot) {
this.rot = rot;
- this.wci = collectionIndex.keycollections(startWordHash.getBytes(), kelondroBase64Order.zero(startWordHash.length()), rot);
+ this.wci = collectionIndex.keycollections(startWordHash.getBytes(), Base64Order.zero(startWordHash.length()), rot);
}
public wordContainersIterator clone(final Object secondWordHash) {
@@ -104,7 +104,7 @@ public class indexCollectionRI implements indexRI {
final Object[] oo = wci.next();
if (oo == null) return null;
final byte[] key = (byte[]) oo[0];
- final kelondroRowSet collection = (kelondroRowSet) oo[1];
+ final RowSet collection = (RowSet) oo[1];
if (collection == null) return null;
return new indexContainer(new String(key), collection);
}
@@ -121,7 +121,7 @@ public class indexCollectionRI implements indexRI {
public indexContainer getContainer(final String wordHash, final Set<String> urlselection) {
try {
- final kelondroRowSet collection = collectionIndex.get(wordHash.getBytes());
+ final RowSet collection = collectionIndex.get(wordHash.getBytes());
if (collection != null) collection.select(urlselection);
if ((collection == null) || (collection.size() == 0)) return null;
return new indexContainer(wordHash, collection);
@@ -132,7 +132,7 @@ public class indexCollectionRI implements indexRI {
public indexContainer deleteContainer(final String wordHash) {
try {
- final kelondroRowSet collection = collectionIndex.delete(wordHash.getBytes());
+ final RowSet collection = collectionIndex.delete(wordHash.getBytes());
if (collection == null) return null;
return new indexContainer(wordHash, collection);
} catch (final IOException e) {
diff --git a/source/de/anomic/index/indexContainer.java b/source/de/anomic/index/indexContainer.java
index 8c7c6d8a4..224a2ac5e 100644
--- a/source/de/anomic/index/indexContainer.java
+++ b/source/de/anomic/index/indexContainer.java
@@ -34,22 +34,22 @@ import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
-import de.anomic.kelondro.kelondroBase64Order;
-import de.anomic.kelondro.kelondroRow;
-import de.anomic.kelondro.kelondroRowSet;
-import de.anomic.kelondro.kelondroByteBuffer;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.index.Row;
+import de.anomic.kelondro.index.RowSet;
+import de.anomic.kelondro.tools.ByteBuffer;
import de.anomic.plasma.plasmaWordIndex;
-public class indexContainer extends kelondroRowSet {
+public class indexContainer extends RowSet {
private String wordHash;
- public indexContainer(final String wordHash, final kelondroRowSet collection) {
+ public indexContainer(final String wordHash, final RowSet collection) {
super(collection);
this.wordHash = wordHash;
}
- public indexContainer(final String wordHash, final kelondroRow rowdef, final int objectCount) {
+ public indexContainer(final String wordHash, final Row rowdef, final int objectCount) {
super(rowdef, objectCount);
this.wordHash = wordHash;
this.lastTimeWrote = 0;
@@ -111,7 +111,7 @@ public class indexContainer extends kelondroRowSet {
public indexRWIEntry put(final indexRWIRowEntry entry) {
assert entry.toKelondroEntry().objectsize() == super.rowdef.objectsize;
- final kelondroRow.Entry r = super.put(entry.toKelondroEntry());
+ final Row.Entry r = super.put(entry.toKelondroEntry());
if (r == null) return null;
return new indexRWIRowEntry(r);
}
@@ -119,7 +119,7 @@ public class indexContainer extends kelondroRowSet {
public boolean putRecent(final indexRWIRowEntry entry) {
assert entry.toKelondroEntry().objectsize() == super.rowdef.objectsize;
// returns true if the new entry was added, false if it already existed
- final kelondroRow.Entry oldEntryRow = this.put(entry.toKelondroEntry());
+ final Row.Entry oldEntryRow = this.put(entry.toKelondroEntry());
if (oldEntryRow == null) {
return true;
}
@@ -151,7 +151,7 @@ public class indexContainer extends kelondroRowSet {
}
public indexRWIEntry get(final String urlHash) {
- final kelondroRow.Entry entry = this.get(urlHash.getBytes());
+ final Row.Entry entry = this.get(urlHash.getBytes());
if (entry == null) return null;
return new indexRWIRowEntry(entry);
}
@@ -162,7 +162,7 @@ public class indexContainer extends kelondroRowSet {
* if the entry was not found, return null.
*/
public indexRWIEntry remove(final String urlHash) {
- final kelondroRow.Entry entry = remove(urlHash.getBytes());
+ final Row.Entry entry = remove(urlHash.getBytes());
if (entry == null) return null;
return new indexRWIRowEntry(entry);
}
@@ -181,7 +181,7 @@ public class indexContainer extends kelondroRowSet {
public class entryIterator implements Iterator<indexRWIRowEntry> {
- Iterator<kelondroRow.Entry> rowEntryIterator;
+ Iterator<Row.Entry> rowEntryIterator;
public entryIterator() {
rowEntryIterator = iterator();
@@ -192,7 +192,7 @@ public class indexContainer extends kelondroRowSet {
}
public indexRWIRowEntry next() {
- final kelondroRow.Entry rentry = rowEntryIterator.next();
+ final Row.Entry rentry = rowEntryIterator.next();
if (rentry == null) return null;
return new indexRWIRowEntry(rentry);
}
@@ -462,11 +462,11 @@ public class indexContainer extends kelondroRowSet {
}
public int hashCode() {
- return (int) kelondroBase64Order.enhancedCoder.decodeLong(this.wordHash.substring(0, 4));
+ return (int) Base64Order.enhancedCoder.decodeLong(this.wordHash.substring(0, 4));
}
- public static final kelondroByteBuffer compressIndex(final indexContainer inputContainer, final indexContainer excludeContainer, final long maxtime) {
+ public static final ByteBuffer compressIndex(final indexContainer inputContainer, final indexContainer excludeContainer, final long maxtime) {
// collect references according to domains
final long timeout = (maxtime < 0) ? Long.MAX_VALUE : System.currentTimeMillis() + maxtime;
final TreeMap<String, String> doms = new TreeMap<String, String>();
@@ -488,7 +488,7 @@ public class indexContainer extends kelondroRowSet {
}
}
// construct a result string
- final kelondroByteBuffer bb = new kelondroByteBuffer(inputContainer.size() * 6);
+ final ByteBuffer bb = new ByteBuffer(inputContainer.size() * 6);
bb.append('{');
final Iterator<Map.Entry<String, String>> i = doms.entrySet().iterator();
Map.Entry<String, String> entry;
@@ -506,7 +506,7 @@ public class indexContainer extends kelondroRowSet {
return bb;
}
- public static final void decompressIndex(final TreeMap<String, String> target, kelondroByteBuffer ci, final String peerhash) {
+ public static final void decompressIndex(final TreeMap<String, String> target, ByteBuffer ci, final String peerhash) {
// target is a mapping from url-hashes to a string of peer-hashes
if ((ci.byteAt(0) == '{') && (ci.byteAt(ci.length() - 1) == '}')) {
//System.out.println("DEBUG-DECOMPRESS: input is " + ci.toString());
diff --git a/source/de/anomic/index/indexContainerBLOBArray.java b/source/de/anomic/index/indexContainerBLOBArray.java
index 6958bc7ac..47c0bba8a 100644
--- a/source/de/anomic/index/indexContainerBLOBArray.java
+++ b/source/de/anomic/index/indexContainerBLOBArray.java
@@ -35,12 +35,12 @@ import java.util.List;
import de.anomic.kelondro.kelondroBLOB;
import de.anomic.kelondro.kelondroBLOBArray;
import de.anomic.kelondro.kelondroCloneableIterator;
-import de.anomic.kelondro.kelondroRow;
-import de.anomic.kelondro.kelondroRowSet;
+import de.anomic.kelondro.index.Row;
+import de.anomic.kelondro.index.RowSet;
public final class indexContainerBLOBArray {
- private final kelondroRow payloadrow;
+ private final Row payloadrow;
private final kelondroBLOBArray array;
/**
@@ -55,7 +55,7 @@ public final class indexContainerBLOBArray {
*/
public indexContainerBLOBArray(
final File heapLocation,
- final kelondroRow payloadrow) throws IOException {
+ final Row payloadrow) throws IOException {
this.payloadrow = payloadrow;
this.array = new kelondroBLOBArray(
heapLocation,
@@ -85,7 +85,7 @@ public final class indexContainerBLOBArray {
this.array.mountBLOB(location);
}
- public kelondroRow rowdef() {
+ public Row rowdef() {
return this.payloadrow;
}
@@ -181,9 +181,9 @@ public final class indexContainerBLOBArray {
List<byte[]> entries = this.array.getAll(key.getBytes());
if (entries == null || entries.size() == 0) return null;
byte[] a = entries.remove(0);
- indexContainer c = new indexContainer(key, kelondroRowSet.importRowSet(a, payloadrow));
+ indexContainer c = new indexContainer(key, RowSet.importRowSet(a, payloadrow));
while (entries.size() > 0) {
- c = c.merge(new indexContainer(key, kelondroRowSet.importRowSet(entries.remove(0), payloadrow)));
+ c = c.merge(new indexContainer(key, RowSet.importRowSet(entries.remove(0), payloadrow)));
}
return c;
}
@@ -215,7 +215,7 @@ public final class indexContainerBLOBArray {
public byte[] rewrite(byte[] b) {
if (b == null) return null;
- indexContainer c = rewriter.rewrite(new indexContainer(this.wordHash, kelondroRowSet.importRowSet(b, payloadrow)));
+ indexContainer c = rewriter.rewrite(new indexContainer(this.wordHash, RowSet.importRowSet(b, payloadrow)));
if (c == null) return null;
return c.exportCollection();
}
diff --git a/source/de/anomic/index/indexContainerOrder.java b/source/de/anomic/index/indexContainerOrder.java
index 3eadf5233..db71f4002 100644
--- a/source/de/anomic/index/indexContainerOrder.java
+++ b/source/de/anomic/index/indexContainerOrder.java
@@ -26,10 +26,10 @@
package de.anomic.index;
-import de.anomic.kelondro.kelondroAbstractOrder;
-import de.anomic.kelondro.kelondroOrder;
+import de.anomic.kelondro.coding.AbstractOrder;
+import de.anomic.kelondro.coding.kelondroOrder;
-public class indexContainerOrder extends kelondroAbstractOrder<indexContainer> implements kelondroOrder<indexContainer>, Cloneable {
+public class indexContainerOrder extends AbstractOrder<indexContainer> implements kelondroOrder<indexContainer>, Cloneable {
private final kelondroOrder<byte[]> embeddedOrder;
diff --git a/source/de/anomic/index/indexContainerRAMHeap.java b/source/de/anomic/index/indexContainerRAMHeap.java
index f105a17c4..5963cff8b 100755
--- a/source/de/anomic/index/indexContainerRAMHeap.java
+++ b/source/de/anomic/index/indexContainerRAMHeap.java
@@ -41,16 +41,16 @@ import java.util.TreeMap;
import de.anomic.kelondro.kelondroBLOBHeapReader;
import de.anomic.kelondro.kelondroBLOBHeapWriter;
-import de.anomic.kelondro.kelondroBase64Order;
-import de.anomic.kelondro.kelondroByteOrder;
import de.anomic.kelondro.kelondroCloneableIterator;
-import de.anomic.kelondro.kelondroRow;
-import de.anomic.kelondro.kelondroRowSet;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.ByteOrder;
+import de.anomic.kelondro.index.Row;
+import de.anomic.kelondro.index.RowSet;
import de.anomic.server.logging.serverLog;
public final class indexContainerRAMHeap {
- private final kelondroRow payloadrow;
+ private final Row payloadrow;
private SortedMap<String, indexContainer> cache;
/**
@@ -60,12 +60,12 @@ public final class indexContainerRAMHeap {
* @param payloadrow
* @param log
*/
- public indexContainerRAMHeap(final kelondroRow payloadrow) {
+ public indexContainerRAMHeap(final Row payloadrow) {
this.payloadrow = payloadrow;
this.cache = null;
}
- public kelondroRow rowdef() {
+ public Row rowdef() {
return this.payloadrow;
}
@@ -83,7 +83,7 @@ public final class indexContainerRAMHeap {
* another dump reading afterwards is not possible
*/
public void initWriteMode() {
- this.cache = Collections.synchronizedSortedMap(new TreeMap<String, indexContainer>(new kelondroByteOrder.StringOrder(payloadrow.getOrdering())));
+ this.cache = Collections.synchronizedSortedMap(new TreeMap<String, indexContainer>(new ByteOrder.StringOrder(payloadrow.getOrdering())));
}
/**
@@ -96,7 +96,7 @@ public final class indexContainerRAMHeap {
public void initWriteModeFromHeap(final File heapFile) throws IOException {
serverLog.logInfo("indexContainerRAMHeap", "restoring dump for rwi heap '" + heapFile.getName() + "'");
final long start = System.currentTimeMillis();
- this.cache = Collections.synchronizedSortedMap(new TreeMap<String, indexContainer>(new kelondroByteOrder.StringOrder(payloadrow.getOrdering())));
+ this.cache = Collections.synchronizedSortedMap(new TreeMap<String, indexContainer>(new ByteOrder.StringOrder(payloadrow.getOrdering())));
int urlCount = 0;
synchronized (cache) {
for (final indexContainer container : new heapFileEntries(heapFile, this.payloadrow)) {
@@ -117,7 +117,7 @@ public final class indexContainerRAMHeap {
public void initWriteModeFromBLOB(final File blobFile) throws IOException {
serverLog.logInfo("indexContainerRAMHeap", "restoring rwi blob dump '" + blobFile.getName() + "'");
final long start = System.currentTimeMillis();
- this.cache = Collections.synchronizedSortedMap(new TreeMap<String, indexContainer>(new kelondroByteOrder.StringOrder(payloadrow.getOrdering())));
+ this.cache = Collections.synchronizedSortedMap(new TreeMap<String, indexContainer>(new ByteOrder.StringOrder(payloadrow.getOrdering())));
int urlCount = 0;
synchronized (cache) {
for (final indexContainer container : new blobFileEntries(blobFile, this.payloadrow)) {
@@ -137,7 +137,7 @@ public final class indexContainerRAMHeap {
assert this.cache != null;
serverLog.logInfo("indexContainerRAMHeap", "creating alternative rwi heap dump '" + heapFile.getName() + "', " + cache.size() + " rwi's");
if (heapFile.exists()) heapFile.delete();
- final kelondroBLOBHeapWriter dump = new kelondroBLOBHeapWriter(heapFile, payloadrow.primaryKeyLength, kelondroBase64Order.enhancedCoder);
+ final kelondroBLOBHeapWriter dump = new kelondroBLOBHeapWriter(heapFile, payloadrow.primaryKeyLength, Base64Order.enhancedCoder);
final long startTime = System.currentTimeMillis();
long wordcount = 0, urlcount = 0;
String wordHash;
@@ -172,10 +172,10 @@ public final class indexContainerRAMHeap {
public static class heapFileEntries implements Iterator<indexContainer>, Iterable<indexContainer> {
DataInputStream is;
byte[] word;
- kelondroRow payloadrow;
+ Row payloadrow;
indexContainer nextContainer;
- public heapFileEntries(final File heapFile, final kelondroRow payloadrow) throws IOException {
+ public heapFileEntries(final File heapFile, final Row payloadrow) throws IOException {
if (!(heapFile.exists())) throw new IOException("file " + heapFile + " does not exist");
is = new DataInputStream(new BufferedInputStream(new FileInputStream(heapFile), 1024*1024));
word = new byte[payloadrow.primaryKeyLength];
@@ -190,7 +190,7 @@ public final class indexContainerRAMHeap {
private indexContainer next0() {
try {
is.readFully(word);
- return new indexContainer(new String(word), kelondroRowSet.importRowSet(is, payloadrow));
+ return new indexContainer(new String(word), RowSet.importRowSet(is, payloadrow));
} catch (final IOException e) {
return null;
}
@@ -229,9 +229,9 @@ public final class indexContainerRAMHeap {
*/
public static class blobFileEntries implements Iterator<indexContainer>, Iterable<indexContainer> {
Iterator<Map.Entry<String, byte[]>> blobs;
- kelondroRow payloadrow;
+ Row payloadrow;
- public blobFileEntries(final File blobFile, final kelondroRow payloadrow) throws IOException {
+ public blobFileEntries(final File blobFile, final Row payloadrow) throws IOException {
this.blobs = new kelondroBLOBHeapReader.entries(blobFile, payloadrow.primaryKeyLength);
this.payloadrow = payloadrow;
}
@@ -247,7 +247,7 @@ public final class indexContainerRAMHeap {
public indexContainer next() {
Map.Entry<String, byte[]> entry = blobs.next();
byte[] payload = entry.getValue();
- return new indexContainer(entry.getKey(), kelondroRowSet.importRowSet(payload, payloadrow));
+ return new indexContainer(entry.getKey(), RowSet.importRowSet(payload, payloadrow));
}
public void remove() {
diff --git a/source/de/anomic/index/indexRAMRI.java b/source/de/anomic/index/indexRAMRI.java
index 1c10e96d8..cdbce1488 100644
--- a/source/de/anomic/index/indexRAMRI.java
+++ b/source/de/anomic/index/indexRAMRI.java
@@ -33,16 +33,16 @@ import java.util.Iterator;
import java.util.Set;
import de.anomic.kelondro.kelondroCloneableIterator;
-import de.anomic.kelondro.kelondroMScoreCluster;
-import de.anomic.kelondro.kelondroRow;
-import de.anomic.kelondro.kelondroMemory;
+import de.anomic.kelondro.index.Row;
+import de.anomic.kelondro.tools.ScoreCluster;
+import de.anomic.kelondro.tools.MemoryControl;
import de.anomic.server.logging.serverLog;
public final class indexRAMRI implements indexRI, indexRIReader, Iterable<indexContainer> {
// class variables
- private final kelondroMScoreCluster<String> hashScore;
- private final kelondroMScoreCluster<String> hashDate;
+ private final ScoreCluster<String> hashScore;
+ private final ScoreCluster<String> hashDate;
private long initTime;
private int cacheEntityMaxCount; // the maximum number of cache slots for RWI entries
public int cacheReferenceCountLimit; // the maximum number of references to a single RWI entity
@@ -54,7 +54,7 @@ public final class indexRAMRI implements indexRI, indexRIReader, Iterable<indexC
@SuppressWarnings("unchecked")
public indexRAMRI(
final File databaseRoot,
- final kelondroRow payloadrow,
+ final Row payloadrow,
final int entityCacheMaxSize,
final int wCacheReferenceCountLimitInit,
final long wCacheReferenceAgeLimitInit,
@@ -63,8 +63,8 @@ public final class indexRAMRI implements indexRI, indexRIReader, Iterable<indexC
// creates a new index cache
// the cache has a back-end where indexes that do not fit in the cache are flushed
- this.hashScore = new kelondroMScoreCluster<String>();
- this.hashDate = new kelondroMScoreCluster<String>();
+ this.hashScore = new ScoreCluster<String>();
+ this.hashDate = new ScoreCluster<String>();
this.initTime = System.currentTimeMillis();
this.cacheEntityMaxCount = entityCacheMaxSize;
this.cacheReferenceCountLimit = wCacheReferenceCountLimitInit;
@@ -181,7 +181,7 @@ public final class indexRAMRI implements indexRI, indexRIReader, Iterable<indexC
return hash;
}
// cases with respect to memory situation
- if (kelondroMemory.free() < 100000) {
+ if (MemoryControl.free() < 100000) {
// urgent low-memory case
hash = hashScore.getMaxObject(); // flush high-score entries (saves RAM)
} else {
diff --git a/source/de/anomic/index/indexRWIEntry.java b/source/de/anomic/index/indexRWIEntry.java
index 91d0fa917..91912bd86 100644
--- a/source/de/anomic/index/indexRWIEntry.java
+++ b/source/de/anomic/index/indexRWIEntry.java
@@ -26,7 +26,7 @@
package de.anomic.index;
-import de.anomic.kelondro.kelondroBitfield;
+import de.anomic.kelondro.coding.Bitfield;
public interface indexRWIEntry {
@@ -76,7 +76,7 @@ public interface indexRWIEntry {
public int urlcomps();
- public kelondroBitfield flags();
+ public Bitfield flags();
public double termFrequency();
diff --git a/source/de/anomic/index/indexRWIEntryOrder.java b/source/de/anomic/index/indexRWIEntryOrder.java
index c0f034e42..f942a1b43 100644
--- a/source/de/anomic/index/indexRWIEntryOrder.java
+++ b/source/de/anomic/index/indexRWIEntryOrder.java
@@ -31,8 +31,8 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
-import de.anomic.kelondro.kelondroBitfield;
-import de.anomic.kelondro.kelondroMScoreCluster;
+import de.anomic.kelondro.coding.Bitfield;
+import de.anomic.kelondro.tools.ScoreCluster;
import de.anomic.plasma.plasmaCondenser;
import de.anomic.plasma.plasmaSearchRankingProcess;
import de.anomic.plasma.plasmaSearchRankingProfile;
@@ -42,7 +42,7 @@ import de.anomic.yacy.yacyURL;
public class indexRWIEntryOrder {
private indexRWIVarEntry min, max;
private final plasmaSearchRankingProfile ranking;
- private final kelondroMScoreCluster<String> doms; // collected for "authority" heuristic
+ private final ScoreCluster<String> doms; // collected for "authority" heuristic
private int maxdomcount;
private String language;
@@ -50,7 +50,7 @@ public class indexRWIEntryOrder {
this.min = null;
this.max = null;
this.ranking = profile;
- this.doms = new kelondroMScoreCluster<String>();
+ this.doms = new ScoreCluster<String>();
this.maxdomcount = 0;
this.language = language;
}
@@ -115,7 +115,7 @@ public class indexRWIEntryOrder {
public long cardinal(final indexRWIVarEntry t) {
//return Long.MAX_VALUE - preRanking(ranking, iEntry, this.entryMin, this.entryMax, this.searchWords);
// the normalizedEntry must be a normalized indexEntry
- final kelondroBitfield flags = t.flags();
+ final Bitfield flags = t.flags();
final long tf = ((max.termFrequency() == min.termFrequency()) ? 0 : (((int)(((t.termFrequency()-min.termFrequency())*256.0)/(max.termFrequency() - min.termFrequency())))) << ranking.coeff_termfrequency);
//System.out.println("tf(" + t.urlHash + ") = " + Math.floor(1000 * t.termFrequency()) + ", min = " + Math.floor(1000 * min.termFrequency()) + ", max = " + Math.floor(1000 * max.termFrequency()) + ", tf-normed = " + tf);
final long r =
diff --git a/source/de/anomic/index/indexRWIRowEntry.java b/source/de/anomic/index/indexRWIRowEntry.java
index d3df34790..7eca6db81 100644
--- a/source/de/anomic/index/indexRWIRowEntry.java
+++ b/source/de/anomic/index/indexRWIRowEntry.java
@@ -26,41 +26,41 @@
package de.anomic.index;
-import de.anomic.kelondro.kelondroBase64Order;
-import de.anomic.kelondro.kelondroBitfield;
-import de.anomic.kelondro.kelondroColumn;
-import de.anomic.kelondro.kelondroMicroDate;
-import de.anomic.kelondro.kelondroRow;
-import de.anomic.kelondro.kelondroRow.Entry;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.Bitfield;
+import de.anomic.kelondro.coding.MicroDate;
+import de.anomic.kelondro.index.Column;
+import de.anomic.kelondro.index.Row;
+import de.anomic.kelondro.index.Row.Entry;
import de.anomic.yacy.yacySeedDB;
public final class indexRWIRowEntry implements indexRWIEntry, Cloneable {
// this object stores attributes to URL references inside RWI collections
- public static final kelondroRow urlEntryRow = new kelondroRow(new kelondroColumn[]{
- new kelondroColumn("h", kelondroColumn.celltype_string, kelondroColumn.encoder_bytes, yacySeedDB.commonHashLength, "urlhash"),
- new kelondroColumn("a", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 2, "lastModified"),
- new kelondroColumn("s", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 2, "freshUntil"),
- new kelondroColumn("u", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "wordsInTitle"),
- new kelondroColumn("w", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 2, "wordsInText"),
- new kelondroColumn("p", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 2, "phrasesInText"),
- new kelondroColumn("d", kelondroColumn.celltype_binary, kelondroColumn.encoder_bytes, 1, "doctype"),
- new kelondroColumn("l", kelondroColumn.celltype_string, kelondroColumn.encoder_bytes, 2, "language"),
- new kelondroColumn("x", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "llocal"),
- new kelondroColumn("y", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "lother"),
- new kelondroColumn("m", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "urlLength"),
- new kelondroColumn("n", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "urlComps"),
- new kelondroColumn("g", kelondroColumn.celltype_binary, kelondroColumn.encoder_bytes, 1, "typeofword"),
- new kelondroColumn("z", kelondroColumn.celltype_bitfield, kelondroColumn.encoder_bytes, 4, "flags"),
- new kelondroColumn("c", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "hitcount"),
- new kelondroColumn("t", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 2, "posintext"),
- new kelondroColumn("r", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "posinphrase"),
- new kelondroColumn("o", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "posofphrase"),
- new kelondroColumn("i", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "worddistance"),
- new kelondroColumn("k", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "reserve")
+ public static final Row urlEntryRow = new Row(new Column[]{
+ new Column("h", Column.celltype_string, Column.encoder_bytes, yacySeedDB.commonHashLength, "urlhash"),
+ new Column("a", Column.celltype_cardinal, Column.encoder_b256, 2, "lastModified"),
+ new Column("s", Column.celltype_cardinal, Column.encoder_b256, 2, "freshUntil"),
+ new Column("u", Column.celltype_cardinal, Column.encoder_b256, 1, "wordsInTitle"),
+ new Column("w", Column.celltype_cardinal, Column.encoder_b256, 2, "wordsInText"),
+ new Column("p", Column.celltype_cardinal, Column.encoder_b256, 2, "phrasesInText"),
+ new Column("d", Column.celltype_binary, Column.encoder_bytes, 1, "doctype"),
+ new Column("l", Column.celltype_string, Column.encoder_bytes, 2, "language"),
+ new Column("x", Column.celltype_cardinal, Column.encoder_b256, 1, "llocal"),
+ new Column("y", Column.celltype_cardinal, Column.encoder_b256, 1, "lother"),
+ new Column("m", Column.celltype_cardinal, Column.encoder_b256, 1, "urlLength"),
+ new Column("n", Column.celltype_cardinal, Column.encoder_b256, 1, "urlComps"),
+ new Column("g", Column.celltype_binary, Column.encoder_bytes, 1, "typeofword"),
+ new Column("z", Column.celltype_bitfield, Column.encoder_bytes, 4, "flags"),
+ new Column("c", Column.celltype_cardinal, Column.encoder_b256, 1, "hitcount"),
+ new Column("t", Column.celltype_cardinal, Column.encoder_b256, 2, "posintext"),
+ new Column("r", Column.celltype_cardinal, Column.encoder_b256, 1, "posinphrase"),
+ new Column("o", Column.celltype_cardinal, Column.encoder_b256, 1, "posofphrase"),
+ new Column("i", Column.celltype_cardinal, Column.encoder_b256, 1, "worddistance"),
+ new Column("k", Column.celltype_cardinal, Column.encoder_b256, 1, "reserve")
},
- kelondroBase64Order.enhancedCoder,
+ Base64Order.enhancedCoder,
0);
// available chars: b,e,j,q
@@ -88,7 +88,7 @@ public final class indexRWIRowEntry implements indexRWIEntry, Cloneable {
private static final int col_reserve1 = 18; // i 1 reserve1
private static final int col_reserve2 = 19; // k 1 reserve2
- private final kelondroRow.Entry entry;
+ private final Row.Entry entry;
public indexRWIRowEntry(final String urlHash,
final int urlLength, // byte-length of complete URL
@@ -106,14 +106,14 @@ public final class indexRWIRowEntry implements indexRWIEntry, Cloneable {
final char doctype, // type of document
final int outlinksSame, // outlinks to same domain
final int outlinksOther, // outlinks to other domain
- final kelondroBitfield flags // attributes to the url and to the word according the url
+ final Bitfield flags // attributes to the url and to the word according the url
) {
assert (urlHash.length() == 12) : "urlhash = " + urlHash;
if ((language == null) || (language.length() != urlEntryRow.width(col_language))) language = "uk";
this.entry = urlEntryRow.newEntry();
- final int mddlm = kelondroMicroDate.microDateDays(lastmodified);
- final int mddct = kelondroMicroDate.microDateDays(updatetime);
+ final int mddlm = MicroDate.microDateDays(lastmodified);
+ final int mddct = MicroDate.microDateDays(updatetime);
this.entry.setCol(col_urlhash, urlHash, null);
this.entry.setCol(col_lastModified, mddlm);
this.entry.setCol(col_freshUntil, Math.max(0, mddlm + (mddct - mddlm) * 2)); // TTL computation
@@ -153,7 +153,7 @@ public final class indexRWIRowEntry implements indexRWIEntry, Cloneable {
this.entry = urlEntryRow.newEntry(row, offset, clone);
}
- public indexRWIRowEntry(final kelondroRow.Entry rentry) {
+ public indexRWIRowEntry(final Row.Entry rentry) {
// FIXME: see if cloning is necessary
this.entry = rentry;
}
@@ -181,11 +181,11 @@ public final class indexRWIRowEntry implements indexRWIEntry, Cloneable {
}
public long lastModified() {
- return kelondroMicroDate.reverseMicroDateDays((int) this.entry.getColLong(col_lastModified));
+ return MicroDate.reverseMicroDateDays((int) this.entry.getColLong(col_lastModified));
}
public long freshUntil() {
- return kelondroMicroDate.reverseMicroDateDays((int) this.entry.getColLong(col_freshUntil));
+ return MicroDate.reverseMicroDateDays((int) this.entry.getColLong(col_freshUntil));
}
public int hitcount() {
@@ -240,8 +240,8 @@ public final class indexRWIRowEntry implements indexRWIEntry, Cloneable {
return (int) this.entry.getColLong(col_urlComps);
}
- public kelondroBitfield flags() {
- return new kelondroBitfield(this.entry.getColBytes(col_flags));
+ public Bitfield flags() {
+ return new Bitfield(this.entry.getColBytes(col_flags));
}
public double termFrequency() {
diff --git a/source/de/anomic/index/indexRWIVarEntry.java b/source/de/anomic/index/indexRWIVarEntry.java
index d7e03b132..15c1e1652 100644
--- a/source/de/anomic/index/indexRWIVarEntry.java
+++ b/source/de/anomic/index/indexRWIVarEntry.java
@@ -26,12 +26,12 @@
package de.anomic.index;
-import de.anomic.kelondro.kelondroBitfield;
-import de.anomic.kelondro.kelondroMicroDate;
+import de.anomic.kelondro.coding.Bitfield;
+import de.anomic.kelondro.coding.MicroDate;
public class indexRWIVarEntry implements indexRWIEntry, Cloneable {
- public kelondroBitfield flags;
+ public Bitfield flags;
public long freshUntil, lastModified;
public String language, urlHash;
public char type;
@@ -57,13 +57,13 @@ public class indexRWIVarEntry implements indexRWIEntry, Cloneable {
final char doctype, // type of document
final int outlinksSame, // outlinks to same domain
final int outlinksOther, // outlinks to other domain
- final kelondroBitfield flags, // attributes to the url and to the word according the url
+ final Bitfield flags, // attributes to the url and to the word according the url
final int worddistance,
final double termfrequency
) {
if ((language == null) || (language.length() != 2)) language = "uk";
- final int mddlm = kelondroMicroDate.microDateDays(lastmodified);
- final int mddct = kelondroMicroDate.microDateDays(updatetime);
+ final int mddlm = MicroDate.microDateDays(lastmodified);
+ final int mddct = MicroDate.microDateDays(updatetime);
this.flags = flags;
this.freshUntil = Math.max(0, mddlm + (mddct - mddlm) * 2);
this.lastModified = lastmodified;
@@ -145,7 +145,7 @@ public class indexRWIVarEntry implements indexRWIEntry, Cloneable {
this.termFrequency = this.termFrequency + oe.termFrequency;
}
- public kelondroBitfield flags() {
+ public Bitfield flags() {
return flags;
}
diff --git a/source/de/anomic/index/indexRepositoryReference.java b/source/de/anomic/index/indexRepositoryReference.java
index 005f9091e..72d596ada 100644
--- a/source/de/anomic/index/indexRepositoryReference.java
+++ b/source/de/anomic/index/indexRepositoryReference.java
@@ -45,17 +45,17 @@ import de.anomic.http.JakartaCommonsHttpResponse;
import de.anomic.http.httpRemoteProxyConfig;
import de.anomic.kelondro.kelondroCache;
import de.anomic.kelondro.kelondroCloneableIterator;
-import de.anomic.kelondro.kelondroIndex;
-import de.anomic.kelondro.kelondroMScoreCluster;
-import de.anomic.kelondro.kelondroRow;
import de.anomic.kelondro.kelondroSplitTable;
+import de.anomic.kelondro.index.Row;
+import de.anomic.kelondro.index.ObjectIndex;
+import de.anomic.kelondro.tools.ScoreCluster;
import de.anomic.server.logging.serverLog;
import de.anomic.yacy.yacyURL;
public final class indexRepositoryReference {
// class objects
- kelondroIndex urlIndexFile;
+ ObjectIndex urlIndexFile;
private Export exportthread = null; // will have a export thread assigned if exporter is running
private File location = null;
ArrayList<hostStat> statsDump = null;
@@ -101,7 +101,7 @@ public final class indexRepositoryReference {
if (urlHash == null) return null;
assert urlIndexFile != null;
try {
- final kelondroRow.Entry entry = urlIndexFile.get(urlHash.getBytes());
+ final Row.Entry entry = urlIndexFile.get(urlHash.getBytes());
if (entry == null) return null;
return new indexURLReference(entry, searchedWord, ranking);
} catch (final IOException e) {
@@ -138,7 +138,7 @@ public final class indexRepositoryReference {
public synchronized boolean remove(final String urlHash) {
if (urlHash == null) return false;
try {
- final kelondroRow.Entry r = urlIndexFile.remove(urlHash.getBytes());
+ final Row.Entry r = urlIndexFile.remove(urlHash.getBytes());
if (r != null) statsDump = null;
return r != null;
} catch (final IOException e) {
@@ -158,7 +158,7 @@ public final class indexRepositoryReference {
public class kiter implements kelondroCloneableIterator<indexURLReference> {
// enumerates entry elements
- private final Iterator<kelondroRow.Entry> iter;
+ private final Iterator<Row.Entry> iter;
private final boolean error;
boolean up;
@@ -183,7 +183,7 @@ public final class indexRepositoryReference {
}
public final indexURLReference next() {
- kelondroRow.Entry e = null;
+ Row.Entry e = null;
if (this.iter == null) { return null; }
if (this.iter.hasNext()) { e = this.iter.next(); }
if (e == null) { return null; }
@@ -231,7 +231,7 @@ public final class indexRepositoryReference {
String oldUrlStr = null;
try {
// getting the url data as byte array
- final kelondroRow.Entry entry = urlIndexFile.get(urlHash.getBytes());
+ final Row.Entry entry = urlIndexFile.get(urlHash.getBytes());
// getting the wrong url string
oldUrlStr = entry.getColString(1, null).trim();
@@ -544,7 +544,7 @@ public final class indexRepositoryReference {
HashMap<String, hashStat> map = domainSampleCollector();
// order elements by size
- kelondroMScoreCluster<String> s = new kelondroMScoreCluster<String>();
+ ScoreCluster<String> s = new ScoreCluster<String>();
for (Map.Entry<String, hashStat> e: map.entrySet()) {
s.addScore(e.getValue().urlhash, e.getValue().count);
}
diff --git a/source/de/anomic/index/indexURLReference.java b/source/de/anomic/index/indexURLReference.java
index 5d7bed286..300c648c4 100644
--- a/source/de/anomic/index/indexURLReference.java
+++ b/source/de/anomic/index/indexURLReference.java
@@ -34,13 +34,13 @@ import java.util.Date;
import java.util.Properties;
import de.anomic.crawler.CrawlEntry;
-import de.anomic.kelondro.kelondroBase64Order;
-import de.anomic.kelondro.kelondroBitfield;
import de.anomic.kelondro.kelondroException;
-import de.anomic.kelondro.kelondroNaturalOrder;
-import de.anomic.kelondro.kelondroRow;
-import de.anomic.kelondro.kelondroDigest;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.Bitfield;
+import de.anomic.kelondro.coding.DateFormatter;
+import de.anomic.kelondro.coding.Digest;
+import de.anomic.kelondro.coding.NaturalOrder;
+import de.anomic.kelondro.index.Row;
import de.anomic.plasma.plasmaSearchQuery;
import de.anomic.server.serverCharBuffer;
import de.anomic.server.serverCodings;
@@ -52,7 +52,7 @@ public class indexURLReference {
// this object stores attributes for URL entries
- public static final kelondroRow rowdef = new kelondroRow(
+ public static final Row rowdef = new Row(
"String hash-12, " + // the url's hash
"String comp-360, " + // components: the url, description, author and tags. As 5th element, an ETag is possible
"Cardinal mod-4 {b256}, " + // last-modified from the httpd
@@ -71,7 +71,7 @@ public class indexURLReference {
"Cardinal laudio-2 {b256}, " + // # of embedded audio links; for audio: track number; for video: number of audio tracks
"Cardinal lvideo-2 {b256}, " + // # of embedded video links
"Cardinal lapp-2 {b256}", // # of embedded links to applications
- kelondroBase64Order.enhancedCoder,
+ Base64Order.enhancedCoder,
0);
/* ===========================================================================
@@ -114,7 +114,7 @@ public class indexURLReference {
/** of embedded links to applications */
private static final int col_lapp = 17;
- private final kelondroRow.Entry entry;
+ private final Row.Entry entry;
private final String snippet;
private indexRWIEntry word; // this is only used if the url is transported via remote search requests
private final long ranking; // during generation of a search result this value is set
@@ -133,7 +133,7 @@ public class indexURLReference {
final long size,
final int wc,
final char dt,
- final kelondroBitfield flags,
+ final Bitfield flags,
final String lang,
final int llocal,
final int lother,
@@ -177,7 +177,7 @@ public class indexURLReference {
private void encodeDate(final int col, final Date d) {
// calculates the number of days since 1.1.1970 and returns this as 4-byte array
- this.entry.setCol(col, kelondroNaturalOrder.encodeLong(d.getTime() / 86400000, 4));
+ this.entry.setCol(col, NaturalOrder.encodeLong(d.getTime() / 86400000, 4));
}
private Date decodeDate(final int col) {
@@ -198,7 +198,7 @@ public class indexURLReference {
}
}
- public indexURLReference(final kelondroRow.Entry entry, final indexRWIEntry searchedWord, final long ranking) {
+ public indexURLReference(final Row.Entry entry, final indexRWIEntry searchedWord, final long ranking) {
this.entry = entry;
this.snippet = null;
this.word = searchedWord;
@@ -224,17 +224,17 @@ public class indexURLReference {
this.entry.setCol(col_hash, url.hash(), null); // FIXME potential null pointer access
this.entry.setCol(col_comp, encodeComp(url, descr, dc_creator, tags, ETag));
try {
- encodeDate(col_mod, kelondroDate.parseShortDay(prop.getProperty("mod", "20000101")));
+ encodeDate(col_mod, DateFormatter.parseShortDay(prop.getProperty("mod", "20000101")));
} catch (final ParseException e) {
encodeDate(col_mod, new Date());
}
try {
- encodeDate(col_load, kelondroDate.parseShortDay(prop.getProperty("load", "20000101")));
+ encodeDate(col_load, DateFormatter.parseShortDay(prop.getProperty("load", "20000101")));
} catch (final ParseException e) {
encodeDate(col_load, new Date());
}
try {
- encodeDate(col_fresh, kelondroDate.parseShortDay(prop.getProperty("fresh", "20000101")));
+ encodeDate(col_fresh, DateFormatter.parseShortDay(prop.getProperty("fresh", "20000101")));
} catch (final ParseException e) {
encodeDate(col_fresh, new Date());
}
@@ -243,12 +243,12 @@ public class indexURLReference {
} catch (UnsupportedEncodingException e1) {
this.entry.setCol(col_referrer, prop.getProperty("referrer", "").getBytes());
}
- this.entry.setCol(col_md5, kelondroDigest.decodeHex(prop.getProperty("md5", "")));
+ this.entry.setCol(col_md5, Digest.decodeHex(prop.getProperty("md5", "")));
this.entry.setCol(col_size, Integer.parseInt(prop.getProperty("size", "0")));
this.entry.setCol(col_wc, Integer.parseInt(prop.getProperty("wc", "0")));
this.entry.setCol(col_dt, new byte[]{(byte) prop.getProperty("dt", "t").charAt(0)});
final String flags = prop.getProperty("flags", "AAAAAA");
- this.entry.setCol(col_flags, (flags.length() > 6) ? plasmaSearchQuery.empty_constraint.bytes() : (new kelondroBitfield(4, flags)).bytes());
+ this.entry.setCol(col_flags, (flags.length() > 6) ? plasmaSearchQuery.empty_constraint.bytes() : (new Bitfield(4, flags)).bytes());
try {
this.entry.setCol(col_lang, prop.getProperty("lang", "uk").getBytes("UTF-8"));
} catch (UnsupportedEncodingException e) {
@@ -264,7 +264,7 @@ public class indexURLReference {
this.word = null;
if (prop.containsKey("word")) throw new kelondroException("old database structure is not supported");
if (prop.containsKey("wi")) {
- this.word = new indexRWIRowEntry(kelondroBase64Order.enhancedCoder.decodeString(prop.getProperty("wi", ""), "de.anomic.index.indexURLEntry.indexURLEntry()"));
+ this.word = new indexRWIRowEntry(Base64Order.enhancedCoder.decodeString(prop.getProperty("wi", ""), "de.anomic.index.indexURLEntry.indexURLEntry()"));
}
this.ranking = 0;
}
@@ -293,9 +293,9 @@ public class indexURLReference {
s.append(",author=").append(crypt.simpleEncode(comp.dc_creator()));
s.append(",tags=").append(crypt.simpleEncode(comp.dc_subject()));
s.append(",ETag=").append(crypt.simpleEncode(comp.ETag()));
- s.append(",mod=").append(kelondroDate.formatShortDay(moddate()));
- s.append(",load=").append(kelondroDate.formatShortDay(loaddate()));
- s.append(",fresh=").append(kelondroDate.formatShortDay(freshdate()));
+ s.append(",mod=").append(DateFormatter.formatShortDay(moddate()));
+ s.append(",load=").append(DateFormatter.formatShortDay(loaddate()));
+ s.append(",fresh=").append(DateFormatter.formatShortDay(freshdate()));
s.append(",referrer=").append(referrerHash());
s.append(",md5=").append(md5());
s.append(",size=").append(size());
@@ -312,7 +312,7 @@ public class indexURLReference {
if (this.word != null) {
// append also word properties
- s.append(",wi=").append(kelondroBase64Order.enhancedCoder.encodeString(word.toPropertyForm()));
+ s.append(",wi=").append(Base64Order.enhancedCoder.encodeString(word.toPropertyForm()));
}
return s;
@@ -325,7 +325,7 @@ public class indexURLReference {
}
}
- public kelondroRow.Entry toRowEntry() {
+ public Row.Entry toRowEntry() {
return this.entry;
}
@@ -371,7 +371,7 @@ public class indexURLReference {
public String md5() {
// returns the md5 in hex representation
- return kelondroDigest.encodeHex(entry.getColBytes(col_md5));
+ return Digest.encodeHex(entry.getColBytes(col_md5));
}
public char doctype() {
@@ -386,8 +386,8 @@ public class indexURLReference {
return (int) this.entry.getColLong(col_size);
}
- public kelondroBitfield flags() {
- return new kelondroBitfield(this.entry.getColBytes(col_flags));
+ public Bitfield flags() {
+ return new Bitfield(this.entry.getColBytes(col_flags));
}
public int wordCount() {
diff --git a/source/de/anomic/index/indexWord.java b/source/de/anomic/index/indexWord.java
index be0f8f607..6130b8709 100644
--- a/source/de/anomic/index/indexWord.java
+++ b/source/de/anomic/index/indexWord.java
@@ -33,9 +33,9 @@ import java.util.Locale;
import java.util.Set;
import java.util.TreeSet;
-import de.anomic.kelondro.kelondroBase64Order;
-import de.anomic.kelondro.kelondroBitfield;
-import de.anomic.kelondro.kelondroDigest;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.Bitfield;
+import de.anomic.kelondro.coding.Digest;
import de.anomic.yacy.yacySeedDB;
public class indexWord {
@@ -47,7 +47,7 @@ public class indexWord {
public int posInPhrase; // position of word in phrase
public int numOfPhrase; // number of phrase. 'normal' phrases begin with number 100
HashSet<Integer> phrases; // a set of handles to all phrases where this word appears
- public kelondroBitfield flags; // the flag bits for each word
+ public Bitfield flags; // the flag bits for each word
public indexWord(final int handle, final int pip, final int nop) {
this.count = 1;
@@ -82,14 +82,14 @@ public class indexWord {
public static final String word2hash(final String word) {
String h = hashCache.get(word);
if (h != null) return h;
- h = kelondroBase64Order.enhancedCoder.encode(kelondroDigest.encodeMD5Raw(word.toLowerCase(Locale.ENGLISH))).substring(0, yacySeedDB.commonHashLength);
+ h = Base64Order.enhancedCoder.encode(Digest.encodeMD5Raw(word.toLowerCase(Locale.ENGLISH))).substring(0, yacySeedDB.commonHashLength);
hashCache.put(word, h); // prevent expensive MD5 computation and encoding
if (hashCache.size() > 100000) hashCache.clear(); // prevent memory laeak
return h;
}
public static final Set<String> words2hashSet(final String[] words) {
- final TreeSet<String> hashes = new TreeSet<String>(kelondroBase64Order.enhancedComparator);
+ final TreeSet<String> hashes = new TreeSet<String>(Base64Order.enhancedComparator);
for (int i = 0; i < words.length; i++) hashes.add(word2hash(words[i]));
return hashes;
}
@@ -102,7 +102,7 @@ public class indexWord {
public static final TreeSet<String> words2hashes(final Set<String> words) {
final Iterator<String> i = words.iterator();
- final TreeSet<String> hashes = new TreeSet<String>(kelondroBase64Order.enhancedComparator);
+ final TreeSet<String> hashes = new TreeSet<String>(Base64Order.enhancedComparator);
while (i.hasNext()) hashes.add(word2hash(i.next()));
return hashes;
}
diff --git a/source/de/anomic/kelondro/kelondroAbstractOrder.java b/source/de/anomic/kelondro/coding/AbstractOrder.java
similarity index 94%
rename from source/de/anomic/kelondro/kelondroAbstractOrder.java
rename to source/de/anomic/kelondro/coding/AbstractOrder.java
index 96055579e..2054a80ac 100644
--- a/source/de/anomic/kelondro/kelondroAbstractOrder.java
+++ b/source/de/anomic/kelondro/coding/AbstractOrder.java
@@ -24,10 +24,11 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.kelondro;
+package de.anomic.kelondro.coding;
-public abstract class kelondroAbstractOrder<A> implements kelondroOrder<A> {
+
+public abstract class AbstractOrder<A> implements kelondroOrder<A> {
protected A zero = null;
protected boolean asc = true;
diff --git a/source/de/anomic/kelondro/kelondroBase64Order.java b/source/de/anomic/kelondro/coding/Base64Order.java
similarity index 84%
rename from source/de/anomic/kelondro/kelondroBase64Order.java
rename to source/de/anomic/kelondro/coding/Base64Order.java
index c35427448..0d77280c7 100644
--- a/source/de/anomic/kelondro/kelondroBase64Order.java
+++ b/source/de/anomic/kelondro/coding/Base64Order.java
@@ -6,9 +6,9 @@
// Frankfurt, Germany, 2005
// created 03.01.2006
//
-// $LastChangedDate$
-// $LastChangedRevision$
-// $LastChangedBy$
+// $LastChangedDate: 2009-01-30 15:48:11 +0100 (Fr, 30 Jan 2009) $
+// $LastChangedRevision: 5539 $
+// $LastChangedBy: orbiter $
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -25,14 +25,14 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.kelondro;
+package de.anomic.kelondro.coding;
import java.io.UnsupportedEncodingException;
import java.util.Comparator;
import de.anomic.server.logging.serverLog;
-public class kelondroBase64Order extends kelondroAbstractOrder<byte[]> implements kelondroByteOrder, kelondroCoding, Comparator<byte[]>, Cloneable {
+public class Base64Order extends AbstractOrder<byte[]> implements ByteOrder, Coding, Comparator<byte[]>, Cloneable {
protected static final char[] alpha_standard = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".toCharArray();
protected static final char[] alpha_enhanced = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".toCharArray();
@@ -52,16 +52,16 @@ public class kelondroBase64Order extends kelondroAbstractOrder<byte[]> implement
private final serverLog log;
- public static final kelondroBase64Order standardCoder = new kelondroBase64Order(true, true);
- public static final kelondroBase64Order enhancedCoder = new kelondroBase64Order(true, false);
- public static final Comparator<String> standardComparator = new kelondroByteOrder.StringOrder(standardCoder);
- public static final Comparator<String> enhancedComparator = new kelondroByteOrder.StringOrder(enhancedCoder);
+ public static final Base64Order standardCoder = new Base64Order(true, true);
+ public static final Base64Order enhancedCoder = new Base64Order(true, false);
+ public static final Comparator<String> standardComparator = new ByteOrder.StringOrder(standardCoder);
+ public static final Comparator<String> enhancedComparator = new ByteOrder.StringOrder(enhancedCoder);
private final boolean rfc1113compliant;
private final char[] alpha;
private final byte[] ahpla;
- public kelondroBase64Order(final boolean up, final boolean rfc1113compliant) {
+ public Base64Order(final boolean up, final boolean rfc1113compliant) {
// if we choose not to be rfc1113compliant,
// then we get shorter base64 results which are also filename-compatible
this.rfc1113compliant = rfc1113compliant;
@@ -79,7 +79,7 @@ public class kelondroBase64Order extends kelondroAbstractOrder<byte[]> implement
}
public kelondroOrder<byte[]> clone() {
- final kelondroBase64Order o = new kelondroBase64Order(this.asc, this.rfc1113compliant);
+ final Base64Order o = new Base64Order(this.asc, this.rfc1113compliant);
o.rotate(zero);
return o;
}
@@ -98,11 +98,11 @@ public class kelondroBase64Order extends kelondroAbstractOrder<byte[]> implement
return true;
}
- public final static kelondroByteOrder bySignature(final String signature) {
- if (signature.equals("Bd")) return new kelondroBase64Order(false, false);
- if (signature.equals("bd")) return new kelondroBase64Order(false, true);
- if (signature.equals("Bu")) return new kelondroBase64Order(true, false);
- if (signature.equals("bu")) return new kelondroBase64Order(true, true);
+ public final static ByteOrder bySignature(final String signature) {
+ if (signature.equals("Bd")) return new Base64Order(false, false);
+ if (signature.equals("bd")) return new Base64Order(false, true);
+ if (signature.equals("Bu")) return new Base64Order(true, false);
+ if (signature.equals("bu")) return new Base64Order(true, true);
return null;
}
@@ -312,22 +312,22 @@ public class kelondroBase64Order extends kelondroAbstractOrder<byte[]> implement
byte ac, bc;
byte acc, bcc;
while ((i < al) && (i < bl)) {
- assert (i + aoffset < a.length) : "i = " + i + ", aoffset = " + aoffset + ", a.length = " + a.length + ", a = " + kelondroNaturalOrder.arrayList(a, aoffset, al);
- assert (i + boffset < b.length) : "i = " + i + ", boffset = " + boffset + ", b.length = " + b.length + ", b = " + kelondroNaturalOrder.arrayList(b, boffset, al);
+ assert (i + aoffset < a.length) : "i = " + i + ", aoffset = " + aoffset + ", a.length = " + a.length + ", a = " + NaturalOrder.arrayList(a, aoffset, al);
+ assert (i + boffset < b.length) : "i = " + i + ", boffset = " + boffset + ", b.length = " + b.length + ", b = " + NaturalOrder.arrayList(b, boffset, al);
ac = a[aoffset + i];
- assert (ac >= 0) && (ac < 128) : "ac = " + ac + ", a = " + kelondroNaturalOrder.arrayList(a, aoffset, al);
+ assert (ac >= 0) && (ac < 128) : "ac = " + ac + ", a = " + NaturalOrder.arrayList(a, aoffset, al);
bc = b[boffset + i];
if ((ac == 0) && (bc == 0)) return 0; // zero-terminated length
- assert (bc >= 0) && (bc < 128) : "bc = " + bc + ", b = " + kelondroNaturalOrder.arrayList(b, boffset, al);
+ assert (bc >= 0) && (bc < 128) : "bc = " + bc + ", b = " + NaturalOrder.arrayList(b, boffset, al);
if (ac == bc) {
// shortcut in case of equality: we don't need to lookup the ahpla value
i++;
continue;
}
acc = ahpla[ac];
- assert (acc >= 0) : "acc = " + acc + ", a = " + kelondroNaturalOrder.arrayList(a, aoffset, al) + "/" + new String(a, aoffset, al) + ", aoffset = 0x" + Integer.toHexString(aoffset) + ", i = " + i + "\n" + kelondroNaturalOrder.table(a, 16, aoffset);
+ assert (acc >= 0) : "acc = " + acc + ", a = " + NaturalOrder.arrayList(a, aoffset, al) + "/" + new String(a, aoffset, al) + ", aoffset = 0x" + Integer.toHexString(aoffset) + ", i = " + i + "\n" + NaturalOrder.table(a, 16, aoffset);
bcc = ahpla[bc];
- assert (bcc >= 0) : "bcc = " + bcc + ", b = " + kelondroNaturalOrder.arrayList(b, boffset, bl) + "/" + new String(b, boffset, bl) + ", boffset = 0x" + Integer.toHexString(boffset) + ", i = " + i + "\n" + kelondroNaturalOrder.table(b, 16, boffset);
+ assert (bcc >= 0) : "bcc = " + bcc + ", b = " + NaturalOrder.arrayList(b, boffset, bl) + "/" + new String(b, boffset, bl) + ", boffset = 0x" + Integer.toHexString(boffset) + ", i = " + i + "\n" + NaturalOrder.table(b, 16, boffset);
if (acc > bcc) return 1;
if (acc < bcc) return -1;
// else the bytes are equal and it may go on yet undecided
@@ -360,7 +360,7 @@ public class kelondroBase64Order extends kelondroAbstractOrder<byte[]> implement
assert bb >= 0;
assert bb < 128;
bcc = ahpla[bb];
- assert (bcc >= 0) : "bcc = " + bcc + ", b = " + kelondroNaturalOrder.arrayList(b, boffset, bl) + "/" + new String(b, boffset, bl) + ", boffset = 0x" + Integer.toHexString(boffset) + ", i = " + i + "\n" + kelondroNaturalOrder.table(b, 16, boffset);
+ assert (bcc >= 0) : "bcc = " + bcc + ", b = " + NaturalOrder.arrayList(b, boffset, bl) + "/" + new String(b, boffset, bl) + ", boffset = 0x" + Integer.toHexString(boffset) + ", i = " + i + "\n" + NaturalOrder.table(b, 16, boffset);
if (acc > bcc) return 1;
if (acc < bcc) return -1;
// else the bytes are equal and it may go on yet undecided
@@ -389,7 +389,7 @@ public class kelondroBase64Order extends kelondroAbstractOrder<byte[]> implement
public static void main(final String[] s) {
// java -classpath classes de.anomic.kelondro.kelondroBase64Order
- final kelondroBase64Order b64 = new kelondroBase64Order(true, true);
+ final Base64Order b64 = new Base64Order(true, true);
if (s.length == 0) {
System.out.println("usage: -[ec|dc|es|ds|clcn] <arg>");
System.exit(0);
@@ -412,11 +412,11 @@ public class kelondroBase64Order extends kelondroAbstractOrder<byte[]> implement
}
if (s[0].equals("-cl")) {
// return the cardinal of a given string as long value with the enhanced encoder
- System.out.println(kelondroBase64Order.enhancedCoder.cardinal(s[1].getBytes()));
+ System.out.println(Base64Order.enhancedCoder.cardinal(s[1].getBytes()));
}
if (s[0].equals("-cn")) {
// return the cardinal of a given string as normalized float 0 .. 1 with the enhanced encoder
- System.out.println(((double) kelondroBase64Order.enhancedCoder.cardinal(s[1].getBytes())) / ((double) Long.MAX_VALUE));
+ System.out.println(((double) Base64Order.enhancedCoder.cardinal(s[1].getBytes())) / ((double) Long.MAX_VALUE));
}
}
}
diff --git a/source/de/anomic/kelondro/kelondroBitfield.java b/source/de/anomic/kelondro/coding/Bitfield.java
similarity index 83%
rename from source/de/anomic/kelondro/kelondroBitfield.java
rename to source/de/anomic/kelondro/coding/Bitfield.java
index 7f491e97a..3467ba3fa 100644
--- a/source/de/anomic/kelondro/kelondroBitfield.java
+++ b/source/de/anomic/kelondro/coding/Bitfield.java
@@ -22,30 +22,31 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.kelondro;
+package de.anomic.kelondro.coding;
-public class kelondroBitfield implements Cloneable {
+
+public class Bitfield implements Cloneable {
// the bitfield implements a binary array. Such arrays may be exported in a base64-String
private byte[] bb;
- public kelondroBitfield() {
+ public Bitfield() {
this(0);
}
- public kelondroBitfield(final byte[] b) {
+ public Bitfield(final byte[] b) {
if (b == null) this.bb = new byte[0]; else this.bb = b;
}
- public kelondroBitfield(final int bytelength) {
+ public Bitfield(final int bytelength) {
this.bb= new byte[bytelength];
for (int i = 0 ; i < bytelength; i++) bb[i] = 0;
}
- public kelondroBitfield(final int bytelength, final String exported) {
+ public Bitfield(final int bytelength, final String exported) {
// imports a b64-encoded bitfield
- final byte[] b = kelondroBase64Order.enhancedCoder.decode(exported, "de.anomic.kelondro.kelondroBitfield.kelondroBitfield(...)");
+ final byte[] b = Base64Order.enhancedCoder.decode(exported, "de.anomic.kelondro.kelondroBitfield.kelondroBitfield(...)");
if (b.length == bytelength) {
bb = b;
} else {
@@ -55,8 +56,8 @@ public class kelondroBitfield implements Cloneable {
}
}
- public kelondroBitfield clone() {
- final kelondroBitfield theClone = new kelondroBitfield(new byte[this.bb.length]);
+ public Bitfield clone() {
+ final Bitfield theClone = new Bitfield(new byte[this.bb.length]);
System.arraycopy(this.bb, 0, theClone.bb, 0, this.bb.length);
return theClone;
}
@@ -90,7 +91,7 @@ public class kelondroBitfield implements Cloneable {
}
public String exportB64() {
- return kelondroBase64Order.enhancedCoder.encode(bb);
+ return Base64Order.enhancedCoder.encode(bb);
}
public byte[] bytes() {
@@ -103,18 +104,18 @@ public class kelondroBitfield implements Cloneable {
return new String(sb);
}
- public boolean equals(final kelondroBitfield x) {
+ public boolean equals(final Bitfield x) {
if (x.bb.length != bb.length) return false;
for (int i = 0; i < bb.length; i++) if (bb[i] != x.bb[i]) return false;
return true;
}
- public void and(final kelondroBitfield x) {
+ public void and(final Bitfield x) {
final int c = Math.min(x.length(), this.length());
for (int i = 0; i < c; i++) set(i, this.get(i) && x.get(i));
}
- public void or(final kelondroBitfield x) {
+ public void or(final Bitfield x) {
final int c = Math.min(x.length(), this.length());
for (int i = 0; i < c; i++) set(i, this.get(i) || x.get(i));
if (x.length() > c) {
@@ -122,7 +123,7 @@ public class kelondroBitfield implements Cloneable {
}
}
- public void xor(final kelondroBitfield x) {
+ public void xor(final Bitfield x) {
final int c = Math.min(x.length(), this.length());
for (int i = 0; i < c; i++) set(i, this.get(i) != x.get(i));
if (x.length() > c) {
@@ -130,13 +131,13 @@ public class kelondroBitfield implements Cloneable {
}
}
- public boolean anyOf(final kelondroBitfield x) {
+ public boolean anyOf(final Bitfield x) {
final int c = Math.min(x.length(), this.length());
for (int i = 0; i < c; i++) if ((x.get(i)) && (this.get(i))) return true;
return false;
}
- public boolean allOf(final kelondroBitfield x) {
+ public boolean allOf(final Bitfield x) {
final int c = Math.min(x.length(), this.length());
for (int i = 0; i < c; i++) if ((x.get(i)) && (!(this.get(i)))) return false;
if (x.length() > c) {
@@ -146,7 +147,7 @@ public class kelondroBitfield implements Cloneable {
}
public static void main(final String[] args) {
- kelondroBitfield test = new kelondroBitfield(4);
+ Bitfield test = new Bitfield(4);
final int l = test.length();
System.out.println("available: " + l);
System.out.println("bevore: " + test.toString());
@@ -157,7 +158,7 @@ public class kelondroBitfield implements Cloneable {
}
for (int i = l/2; i < l; i++) {
System.out.println(test.exportB64());
- test = new kelondroBitfield(4, test.exportB64());
+ test = new Bitfield(4, test.exportB64());
test.set(i, true);
System.out.println(i + ":" + test.toString());
}
diff --git a/source/de/anomic/kelondro/kelondroByteOrder.java b/source/de/anomic/kelondro/coding/ByteOrder.java
similarity index 86%
rename from source/de/anomic/kelondro/kelondroByteOrder.java
rename to source/de/anomic/kelondro/coding/ByteOrder.java
index 5906e8936..e425b9e56 100644
--- a/source/de/anomic/kelondro/kelondroByteOrder.java
+++ b/source/de/anomic/kelondro/coding/ByteOrder.java
@@ -25,11 +25,12 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.kelondro;
+package de.anomic.kelondro.coding;
import java.util.Comparator;
-public interface kelondroByteOrder extends kelondroOrder<byte[]> {
+
+public interface ByteOrder extends kelondroOrder<byte[]> {
public boolean wellformed(byte[] a, int start, int len);
@@ -37,13 +38,13 @@ public interface kelondroByteOrder extends kelondroOrder<byte[]> {
public final static class StringOrder implements Comparator<String> {
- public kelondroByteOrder baseOrder;
- public StringOrder(final kelondroByteOrder base) {
+ public ByteOrder baseOrder;
+ public StringOrder(final ByteOrder base) {
this.baseOrder = base;
}
public StringOrder(final kelondroOrder<byte[]> base) {
- this.baseOrder = (kelondroByteOrder) base;
+ this.baseOrder = (ByteOrder) base;
}
public final int compare(final String s1, final String s2) {
diff --git a/source/de/anomic/kelondro/kelondroCoding.java b/source/de/anomic/kelondro/coding/Coding.java
similarity index 96%
rename from source/de/anomic/kelondro/kelondroCoding.java
rename to source/de/anomic/kelondro/coding/Coding.java
index fbf269ba1..625df5345 100644
--- a/source/de/anomic/kelondro/kelondroCoding.java
+++ b/source/de/anomic/kelondro/coding/Coding.java
@@ -24,9 +24,9 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.kelondro;
+package de.anomic.kelondro.coding;
-public interface kelondroCoding {
+public interface Coding {
public char encodeByte(byte b);
public byte decodeByte(char b);
diff --git a/source/de/anomic/kelondro/kelondroDate.java b/source/de/anomic/kelondro/coding/DateFormatter.java
similarity index 94%
rename from source/de/anomic/kelondro/kelondroDate.java
rename to source/de/anomic/kelondro/coding/DateFormatter.java
index 08870308b..2444d67ed 100644
--- a/source/de/anomic/kelondro/kelondroDate.java
+++ b/source/de/anomic/kelondro/coding/DateFormatter.java
@@ -22,7 +22,7 @@
// this class is needed to replace the slow java built-in date method by a faster version
-package de.anomic.kelondro;
+package de.anomic.kelondro.coding;
import java.text.DateFormat;
import java.text.ParseException;
@@ -34,7 +34,7 @@ import java.util.NoSuchElementException;
import java.util.StringTokenizer;
import java.util.TimeZone;
-public final class kelondroDate {
+public final class DateFormatter {
/** minimal date format without time information (fixed width: 8) */
public static final String PATTERN_SHORT_DAY = "yyyyMMdd";
@@ -94,8 +94,8 @@ public final class kelondroDate {
// the year value starting with 1970
CAL_GMT.setTimeInMillis(0);
- for (int i = 0; i < kelondroDate.FORMATS_HTTP.length; i++) {
- final SimpleDateFormat f = kelondroDate.FORMATS_HTTP[i];
+ for (int i = 0; i < DateFormatter.FORMATS_HTTP.length; i++) {
+ final SimpleDateFormat f = DateFormatter.FORMATS_HTTP[i];
f.setTimeZone(TZ_GMT);
f.set2DigitYearStart(CAL_GMT.getTime());
}
@@ -351,7 +351,7 @@ public final class kelondroDate {
if (remoteTimeString == null || remoteTimeString.length() == 0) { return new Date(); }
if (remoteUTCOffset == null || remoteUTCOffset.length() == 0) { return new Date(); }
try {
- return new Date(parse(FORMAT_SHORT_SECOND, remoteTimeString).getTime() - kelondroDate.UTCDiff() + kelondroDate.UTCDiff(remoteUTCOffset));
+ return new Date(parse(FORMAT_SHORT_SECOND, remoteTimeString).getTime() - DateFormatter.UTCDiff() + DateFormatter.UTCDiff(remoteUTCOffset));
} catch (final java.text.ParseException e) {
//serverLog.logFinest("parseUniversalDate", e.getMessage() + ", remoteTimeString=[" + remoteTimeString + "]");
return new Date();
@@ -511,11 +511,11 @@ public final class kelondroDate {
return System.currentTimeMillis() - UTCDiff();
}
- public kelondroDate() {
+ public DateFormatter() {
this(System.currentTimeMillis());
}
- public kelondroDate(final long utime) {
+ public DateFormatter(final long utime) {
// set the time as the difference, measured in milliseconds,
// between the current time and midnight, January 1, 1970 UTC/GMT
this.utime = utime;
@@ -545,7 +545,7 @@ public final class kelondroDate {
this.dow = (int) (((utime / dayMillis) + 3) % 7);
}
- public kelondroDate(final String datestring) throws java.text.ParseException {
+ public DateFormatter(final String datestring) throws java.text.ParseException {
// parse a date string; othervise throw a java.text.ParseException
if ((datestring.length() == 14) || (datestring.length() == 17)) {
// parse a ShortString
@@ -634,18 +634,18 @@ public final class kelondroDate {
public static void main(final String[] args) {
//System.out.println("kelondroDate is (" + new kelondroDate().toString() + ")");
System.out.println("offset is " + (UTCDiff()/1000/60/60) + " hours, javaDate is " + new Date() + ", correctedDate is " + new Date(correctedUTCTime()));
- System.out.println("serverDate : " + new kelondroDate().toShortString(false));
+ System.out.println("serverDate : " + new DateFormatter().toShortString(false));
System.out.println(" javaDate : " + formatShortSecond());
- System.out.println("serverDate : " + new kelondroDate().toString());
+ System.out.println("serverDate : " + new DateFormatter().toString());
System.out.println(" JavaDate : " + DateFormat.getDateInstance().format(new Date()));
- System.out.println("serverDate0: " + new kelondroDate(0).toShortString(false));
+ System.out.println("serverDate0: " + new DateFormatter(0).toShortString(false));
System.out.println(" JavaDate0: " + format(FORMAT_SHORT_SECOND, new Date(0)));
- System.out.println("serverDate0: " + new kelondroDate(0).toString());
+ System.out.println("serverDate0: " + new DateFormatter(0).toString());
System.out.println(" JavaDate0: " + DateFormat.getDateInstance().format(new Date(0)));
// parse test
try {
- System.out.println("serverDate re-parse short: " + new kelondroDate(new kelondroDate().toShortString(false)).toShortString(true));
- System.out.println("serverDate re-parse long : " + new kelondroDate(new kelondroDate().toShortString(true)).toShortString(true));
+ System.out.println("serverDate re-parse short: " + new DateFormatter(new DateFormatter().toShortString(false)).toShortString(true));
+ System.out.println("serverDate re-parse long : " + new DateFormatter(new DateFormatter().toShortString(true)).toShortString(true));
} catch (final java.text.ParseException e) {
System.out.println("Parse Exception: " + e.getMessage() + ", pos " + e.getErrorOffset());
}
@@ -655,7 +655,7 @@ public final class kelondroDate {
final String[] testresult = new String[10000];
start = System.currentTimeMillis();
- for (int i = 0; i < cycles; i++) testresult[i] = new kelondroDate().toShortString(false);
+ for (int i = 0; i < cycles; i++) testresult[i] = new DateFormatter().toShortString(false);
System.out.println("time for " + cycles + " calls to serverDate:" + (System.currentTimeMillis() - start) + " milliseconds");
start = System.currentTimeMillis();
diff --git a/source/de/anomic/kelondro/kelondroDigest.java b/source/de/anomic/kelondro/coding/Digest.java
similarity index 97%
rename from source/de/anomic/kelondro/kelondroDigest.java
rename to source/de/anomic/kelondro/coding/Digest.java
index 30307b0e9..ae0d96442 100644
--- a/source/de/anomic/kelondro/kelondroDigest.java
+++ b/source/de/anomic/kelondro/coding/Digest.java
@@ -24,7 +24,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.kelondro;
+package de.anomic.kelondro.coding;
import java.io.ByteArrayInputStream;
import java.io.File;
@@ -44,7 +44,8 @@ import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingQueue;
-public class kelondroDigest {
+
+public class Digest {
public static String encodeHex(final long in, final int length) {
String s = Long.toHexString(in);
@@ -232,7 +233,7 @@ public class kelondroDigest {
public static String fastFingerprintB64(final File file, boolean includeDate) {
try {
- return kelondroBase64Order.enhancedCoder.encode(fastFingerprintRaw(file, includeDate));
+ return Base64Order.enhancedCoder.encode(fastFingerprintRaw(file, includeDate));
} catch (IOException e) {
return null;
}
@@ -274,8 +275,8 @@ public class kelondroDigest {
raf.seek(fl - mb);
raf.readFully(a, 0, mb - 1);
digest.update(a, 0, mb);
- digest.update(kelondroNaturalOrder.encodeLong(fl, 8), 0, 8);
- if (includeDate) digest.update(kelondroNaturalOrder.encodeLong(file.lastModified(), 8), 0, 8);
+ digest.update(NaturalOrder.encodeLong(fl, 8), 0, 8);
+ if (includeDate) digest.update(NaturalOrder.encodeLong(file.lastModified(), 8), 0, 8);
return digest.digest();
}
diff --git a/source/de/anomic/kelondro/kelondroMicroDate.java b/source/de/anomic/kelondro/coding/MicroDate.java
old mode 100755
new mode 100644
similarity index 91%
rename from source/de/anomic/kelondro/kelondroMicroDate.java
rename to source/de/anomic/kelondro/coding/MicroDate.java
index 8e40b4442..16b645c22
--- a/source/de/anomic/kelondro/kelondroMicroDate.java
+++ b/source/de/anomic/kelondro/coding/MicroDate.java
@@ -24,11 +24,12 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.kelondro;
+package de.anomic.kelondro.coding;
import java.util.Date;
-public class kelondroMicroDate {
+
+public class MicroDate {
private static final long hour = 3600000L; // milliseconds of a hour
private static final long day = 86400000L; // milliseconds of a day
@@ -47,7 +48,7 @@ public class kelondroMicroDate {
}
public static String microDateHoursStr(final long time) {
- return kelondroBase64Order.enhancedCoder.encodeLong(microDateHoursInt(time), 3);
+ return Base64Order.enhancedCoder.encodeLong(microDateHoursInt(time), 3);
}
public static int microDateHoursInt(final long time) {
@@ -55,7 +56,7 @@ public class kelondroMicroDate {
}
public static int microDateHoursAge(final String mdhs) {
- return microDateHoursInt(System.currentTimeMillis()) - (int) kelondroBase64Order.enhancedCoder.decodeLong(mdhs);
+ return microDateHoursInt(System.currentTimeMillis()) - (int) Base64Order.enhancedCoder.decodeLong(mdhs);
}
public static long reverseMicroDateDays(final long microDateDays) {
diff --git a/source/de/anomic/kelondro/kelondroNaturalOrder.java b/source/de/anomic/kelondro/coding/NaturalOrder.java
similarity index 87%
rename from source/de/anomic/kelondro/kelondroNaturalOrder.java
rename to source/de/anomic/kelondro/coding/NaturalOrder.java
index ed6c86d41..9db6a578d 100644
--- a/source/de/anomic/kelondro/kelondroNaturalOrder.java
+++ b/source/de/anomic/kelondro/coding/NaturalOrder.java
@@ -24,15 +24,15 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.kelondro;
+package de.anomic.kelondro.coding;
import java.util.Comparator;
-public final class kelondroNaturalOrder extends kelondroAbstractOrder<byte[]> implements kelondroByteOrder, Comparator<byte[]>, Cloneable {
+public final class NaturalOrder extends AbstractOrder<byte[]> implements ByteOrder, Comparator<byte[]>, Cloneable {
- public static final kelondroByteOrder naturalOrder = new kelondroNaturalOrder(true);
- public static final Comparator<String> naturalComparator = new kelondroByteOrder.StringOrder(naturalOrder);
- public kelondroNaturalOrder(final boolean ascending) {
+ public static final ByteOrder naturalOrder = new NaturalOrder(true);
+ public static final Comparator<String> naturalComparator = new ByteOrder.StringOrder(naturalOrder);
+ public NaturalOrder(final boolean ascending) {
this.asc = ascending;
this.zero = null;
}
@@ -46,22 +46,22 @@ public final class kelondroNaturalOrder extends kelondroAbstractOrder<byte[]> im
}
public final kelondroOrder<byte[]> clone() {
- final kelondroNaturalOrder o = new kelondroNaturalOrder(this.asc);
+ final NaturalOrder o = new NaturalOrder(this.asc);
o.rotate(this.zero);
return o;
}
- public static kelondroByteOrder orderBySignature(final String signature) {
- kelondroByteOrder oo = null;
- if (oo == null) oo = kelondroNaturalOrder.bySignature(signature);
- if (oo == null) oo = kelondroBase64Order.bySignature(signature);
- if (oo == null) oo = new kelondroNaturalOrder(true);
+ public static ByteOrder orderBySignature(final String signature) {
+ ByteOrder oo = null;
+ if (oo == null) oo = NaturalOrder.bySignature(signature);
+ if (oo == null) oo = Base64Order.bySignature(signature);
+ if (oo == null) oo = new NaturalOrder(true);
return oo;
}
- public final static kelondroByteOrder bySignature(final String signature) {
- if (signature.equals("nd")) return new kelondroNaturalOrder(false);
- if (signature.equals("nu")) return new kelondroNaturalOrder(true);
+ public final static ByteOrder bySignature(final String signature) {
+ if (signature.equals("nd")) return new NaturalOrder(false);
+ if (signature.equals("nu")) return new NaturalOrder(true);
return null;
}
@@ -205,7 +205,7 @@ public final class kelondroNaturalOrder extends kelondroAbstractOrder<byte[]> im
final byte[] t = new byte[12];
for (int i = 0; i < 12; i++) t[i] = (byte) 255;
t[0] = (byte) 127;
- final kelondroOrder<byte[]> o = new kelondroNaturalOrder(true);
+ final kelondroOrder<byte[]> o = new NaturalOrder(true);
System.out.println(o.partition(t, 16));
}
diff --git a/source/de/anomic/kelondro/kelondroOrder.java b/source/de/anomic/kelondro/coding/kelondroOrder.java
similarity index 98%
rename from source/de/anomic/kelondro/kelondroOrder.java
rename to source/de/anomic/kelondro/coding/kelondroOrder.java
index 34945c21f..9dda655ae 100644
--- a/source/de/anomic/kelondro/kelondroOrder.java
+++ b/source/de/anomic/kelondro/coding/kelondroOrder.java
@@ -24,7 +24,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.kelondro;
+package de.anomic.kelondro.coding;
import java.util.Comparator;
diff --git a/source/de/anomic/kelondro/kelondroArray.java b/source/de/anomic/kelondro/index/Array.java
similarity index 77%
rename from source/de/anomic/kelondro/kelondroArray.java
rename to source/de/anomic/kelondro/index/Array.java
index e9abb923b..b9c4135cb 100644
--- a/source/de/anomic/kelondro/kelondroArray.java
+++ b/source/de/anomic/kelondro/index/Array.java
@@ -22,21 +22,22 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.kelondro;
+package de.anomic.kelondro.index;
import java.io.IOException;
-public interface kelondroArray {
+
+public interface Array {
public int size();
- public kelondroRow row();
+ public Row row();
- public void set(int index, kelondroRow.Entry rowentry) throws IOException;
+ public void set(int index, Row.Entry rowentry) throws IOException;
- public kelondroRow.Entry get(int index) throws IOException;
+ public Row.Entry get(int index) throws IOException;
- public int add(kelondroRow.Entry rowinstance) throws IOException;
+ public int add(Row.Entry rowinstance) throws IOException;
public void remove(int index) throws IOException;
diff --git a/source/de/anomic/kelondro/kelondroBinSearch.java b/source/de/anomic/kelondro/index/BinSearch.java
similarity index 89%
rename from source/de/anomic/kelondro/kelondroBinSearch.java
rename to source/de/anomic/kelondro/index/BinSearch.java
index 229aa8b1c..8e8e64d9e 100644
--- a/source/de/anomic/kelondro/kelondroBinSearch.java
+++ b/source/de/anomic/kelondro/index/BinSearch.java
@@ -24,17 +24,20 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.kelondro;
+package de.anomic.kelondro.index;
+import de.anomic.kelondro.coding.ByteOrder;
+import de.anomic.kelondro.coding.NaturalOrder;
-public class kelondroBinSearch {
+
+public class BinSearch {
private final byte[] chunks;
private final int chunksize;
private final int count;
- private final kelondroByteOrder objectOrder = new kelondroNaturalOrder(true);
+ private final ByteOrder objectOrder = new NaturalOrder(true);
- public kelondroBinSearch(final byte[] chunks, final int chunksize) {
+ public BinSearch(final byte[] chunks, final int chunksize) {
this.chunks = chunks;
this.chunksize = chunksize;
this.count = chunks.length / chunksize;
@@ -70,7 +73,7 @@ public class kelondroBinSearch {
public static void main(final String[] args) {
final String s = "4CEvsI8FRczRBo_ApRCkwfEbFLn1pIFXg39QGMgj5RHM6HpIMJq67QX3M5iQYr_LyI_5aGDaa_bYbRgJ9XnQjpmq6QkOoGWAoEaihRqhV3kItLFHjRtqauUR";
- final kelondroBinSearch bs = new kelondroBinSearch(s.getBytes(), 6);
+ final BinSearch bs = new BinSearch(s.getBytes(), 6);
for (int i = 0; i + 6 <= s.length(); i = i + 6) {
System.out.println(s.substring(i, i + 6) + ":" + ((bs.contains(s.substring(i, i + 6).getBytes())) ? "drin" : "draussen"));
}
diff --git a/source/de/anomic/kelondro/kelondroBytesIntMap.java b/source/de/anomic/kelondro/index/BytesIntMap.java
similarity index 77%
rename from source/de/anomic/kelondro/kelondroBytesIntMap.java
rename to source/de/anomic/kelondro/index/BytesIntMap.java
index ae1308175..09e5462b8 100644
--- a/source/de/anomic/kelondro/kelondroBytesIntMap.java
+++ b/source/de/anomic/kelondro/index/BytesIntMap.java
@@ -22,7 +22,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.kelondro;
+package de.anomic.kelondro.index;
import java.io.IOException;
import java.util.ArrayList;
@@ -34,17 +34,20 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
-public class kelondroBytesIntMap {
+import de.anomic.kelondro.kelondroCloneableIterator;
+import de.anomic.kelondro.coding.ByteOrder;
+
+public class BytesIntMap {
- private final kelondroRow rowdef;
- private kelondroIndex index;
+ private final Row rowdef;
+ private ObjectIndex index;
- public kelondroBytesIntMap(final int keylength, final kelondroByteOrder objectOrder, final int space) {
- this.rowdef = new kelondroRow(new kelondroColumn[]{new kelondroColumn("key", kelondroColumn.celltype_binary, kelondroColumn.encoder_bytes, keylength, "key"), new kelondroColumn("int c-4 {b256}")}, objectOrder, 0);
- this.index = new kelondroRAMIndex(rowdef, space);
+ public BytesIntMap(final int keylength, final ByteOrder objectOrder, final int space) {
+ this.rowdef = new Row(new Column[]{new Column("key", Column.celltype_binary, Column.encoder_bytes, keylength, "key"), new Column("int c-4 {b256}")}, objectOrder, 0);
+ this.index = new RAMIndex(rowdef, space);
}
- public kelondroRow row() {
+ public Row row() {
return index.row();
}
@@ -59,7 +62,7 @@ public class kelondroBytesIntMap {
public synchronized int geti(final byte[] key) throws IOException {
assert (key != null);
- final kelondroRow.Entry indexentry = index.get(key);
+ final Row.Entry indexentry = index.get(key);
if (indexentry == null) return -1;
return (int) indexentry.getColLong(1);
}
@@ -67,10 +70,10 @@ public class kelondroBytesIntMap {
public synchronized int puti(final byte[] key, final int i) throws IOException {
assert i >= 0 : "i = " + i;
assert (key != null);
- final kelondroRow.Entry newentry = index.row().newEntry();
+ final Row.Entry newentry = index.row().newEntry();
newentry.setCol(0, key);
newentry.setCol(1, i);
- final kelondroRow.Entry oldentry = index.put(newentry);
+ final Row.Entry oldentry = index.put(newentry);
if (oldentry == null) return -1;
return (int) oldentry.getColLong(1);
}
@@ -78,7 +81,7 @@ public class kelondroBytesIntMap {
public synchronized void addi(final byte[] key, final int i) throws IOException {
assert i >= 0 : "i = " + i;
assert (key != null);
- final kelondroRow.Entry newentry = this.rowdef.newEntry();
+ final Row.Entry newentry = this.rowdef.newEntry();
newentry.setCol(0, key);
newentry.setCol(1, i);
index.addUnique(newentry);
@@ -89,10 +92,10 @@ public class kelondroBytesIntMap {
Integer[] is;
int c, i;
final int initialSize = this.size();
- for (final kelondroRowCollection delset: index.removeDoubles()) {
+ for (final RowCollection delset: index.removeDoubles()) {
is = new Integer[delset.size()];
c = 0;
- for (kelondroRow.Entry e : delset) {
+ for (Row.Entry e : delset) {
i = (int) e.getColLong(1);
assert i < initialSize : "i = " + i + ", initialSize = " + initialSize;
is[c++] = Integer.valueOf(i);
@@ -104,13 +107,13 @@ public class kelondroBytesIntMap {
public synchronized int removei(final byte[] key) throws IOException {
assert (key != null);
- final kelondroRow.Entry indexentry = index.remove(key);
+ final Row.Entry indexentry = index.remove(key);
if (indexentry == null) return -1;
return (int) indexentry.getColLong(1);
}
public synchronized int removeonei() throws IOException {
- final kelondroRow.Entry indexentry = index.removeOne();
+ final Row.Entry indexentry = index.removeOne();
if (indexentry == null) return -1;
return (int) indexentry.getColLong(1);
}
@@ -123,7 +126,7 @@ public class kelondroBytesIntMap {
return index.keys(up, firstKey);
}
- public synchronized kelondroCloneableIterator<kelondroRow.Entry> rows(final boolean up, final byte[] firstKey) throws IOException {
+ public synchronized kelondroCloneableIterator<Row.Entry> rows(final boolean up, final byte[] firstKey) throws IOException {
return index.rows(up, firstKey);
}
@@ -151,29 +154,29 @@ public class kelondroBytesIntMap {
* @param bufferSize
* @return
*/
- public static initDataConsumer asynchronusInitializer(final int keylength, final kelondroByteOrder objectOrder, final int space, int bufferSize) {
- initDataConsumer initializer = new initDataConsumer(new kelondroBytesIntMap(keylength, objectOrder, space), bufferSize);
+ public static initDataConsumer asynchronusInitializer(final int keylength, final ByteOrder objectOrder, final int space, int bufferSize) {
+ initDataConsumer initializer = new initDataConsumer(new BytesIntMap(keylength, objectOrder, space), bufferSize);
ExecutorService service = Executors.newSingleThreadExecutor();
initializer.setResult(service.submit(initializer));
service.shutdown();
return initializer;
}
- public static class initDataConsumer implements Callable<kelondroBytesIntMap> {
+ public static class initDataConsumer implements Callable<BytesIntMap> {
private BlockingQueue<entry> cache;
private final entry poison = new entry(new byte[0], 0);
- private kelondroBytesIntMap map;
- private Future<kelondroBytesIntMap> result;
+ private BytesIntMap map;
+ private Future<BytesIntMap> result;
private boolean sortAtEnd;
- public initDataConsumer(kelondroBytesIntMap map, int bufferCount) {
+ public initDataConsumer(BytesIntMap map, int bufferCount) {
this.map = map;
cache = new ArrayBlockingQueue<entry>(bufferCount);
sortAtEnd = false;
}
- protected void setResult(Future<kelondroBytesIntMap> result) {
+ protected void setResult(Future<BytesIntMap> result) {
this.result = result;
}
@@ -211,11 +214,11 @@ public class kelondroBytesIntMap {
* @throws InterruptedException
* @throws ExecutionException
*/
- public kelondroBytesIntMap result() throws InterruptedException, ExecutionException {
+ public BytesIntMap result() throws InterruptedException, ExecutionException {
return this.result.get();
}
- public kelondroBytesIntMap call() throws IOException {
+ public BytesIntMap call() throws IOException {
try {
entry c;
while ((c = cache.take()) != poison) {
@@ -224,8 +227,8 @@ public class kelondroBytesIntMap {
} catch (InterruptedException e) {
e.printStackTrace();
}
- if (sortAtEnd && map.index instanceof kelondroRAMIndex) {
- ((kelondroRAMIndex) map.index).finishInitialization();
+ if (sortAtEnd && map.index instanceof RAMIndex) {
+ ((RAMIndex) map.index).finishInitialization();
}
return map;
}
diff --git a/source/de/anomic/kelondro/kelondroBytesLongMap.java b/source/de/anomic/kelondro/index/BytesLongMap.java
similarity index 79%
rename from source/de/anomic/kelondro/kelondroBytesLongMap.java
rename to source/de/anomic/kelondro/index/BytesLongMap.java
index 5bb8f0de2..3b47706ce 100644
--- a/source/de/anomic/kelondro/kelondroBytesLongMap.java
+++ b/source/de/anomic/kelondro/index/BytesLongMap.java
@@ -22,7 +22,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.kelondro;
+package de.anomic.kelondro.index;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
@@ -42,10 +42,13 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
-public class kelondroBytesLongMap {
+import de.anomic.kelondro.kelondroCloneableIterator;
+import de.anomic.kelondro.coding.ByteOrder;
+
+public class BytesLongMap {
- private final kelondroRow rowdef;
- private kelondroRAMIndex index;
+ private final Row rowdef;
+ private RAMIndex index;
/**
* initialize a BytesLongMap
@@ -55,9 +58,9 @@ public class kelondroBytesLongMap {
* @param objectOrder
* @param space
*/
- public kelondroBytesLongMap(final int keylength, final kelondroByteOrder objectOrder, final int space) {
- this.rowdef = new kelondroRow(new kelondroColumn[]{new kelondroColumn("key", kelondroColumn.celltype_binary, kelondroColumn.encoder_bytes, keylength, "key"), new kelondroColumn("long c-8 {b256}")}, objectOrder, 0);
- this.index = new kelondroRAMIndex(rowdef, space);
+ public BytesLongMap(final int keylength, final ByteOrder objectOrder, final int space) {
+ this.rowdef = new Row(new Column[]{new Column("key", Column.celltype_binary, Column.encoder_bytes, keylength, "key"), new Column("long c-8 {b256}")}, objectOrder, 0);
+ this.index = new RAMIndex(rowdef, space);
}
/**
@@ -67,7 +70,7 @@ public class kelondroBytesLongMap {
* @param file
* @throws IOException
*/
- public kelondroBytesLongMap(final int keylength, final kelondroByteOrder objectOrder, final File file) throws IOException {
+ public BytesLongMap(final int keylength, final ByteOrder objectOrder, final File file) throws IOException {
this(keylength, objectOrder, (int) (file.length() / (keylength + 8)));
// read the index dump and fill the index
InputStream is = new BufferedInputStream(new FileInputStream(file), 1024 * 1024);
@@ -92,7 +95,7 @@ public class kelondroBytesLongMap {
// we must use an iterator from the combined index, because we need the entries sorted
// otherwise we could just write the byte[] from the in kelondroRowSet which would make
// everything much faster, but this is not an option here.
- Iterator<kelondroRow.Entry> i = this.index.rows(true, null);
+ Iterator<Row.Entry> i = this.index.rows(true, null);
OutputStream os = new BufferedOutputStream(new FileOutputStream(file), 1024 * 1024);
int c = 0;
while (i.hasNext()) {
@@ -104,7 +107,7 @@ public class kelondroBytesLongMap {
return c;
}
- public kelondroRow row() {
+ public Row row() {
return index.row();
}
@@ -114,7 +117,7 @@ public class kelondroBytesLongMap {
public synchronized long getl(final byte[] key) throws IOException {
assert (key != null);
- final kelondroRow.Entry indexentry = index.get(key);
+ final Row.Entry indexentry = index.get(key);
if (indexentry == null) return -1;
return indexentry.getColLong(1);
}
@@ -122,10 +125,10 @@ public class kelondroBytesLongMap {
public synchronized long putl(final byte[] key, final long l) throws IOException {
assert l >= 0 : "l = " + l;
assert (key != null);
- final kelondroRow.Entry newentry = index.row().newEntry();
+ final Row.Entry newentry = index.row().newEntry();
newentry.setCol(0, key);
newentry.setCol(1, l);
- final kelondroRow.Entry oldentry = index.put(newentry);
+ final Row.Entry oldentry = index.put(newentry);
if (oldentry == null) return -1;
return oldentry.getColLong(1);
}
@@ -133,21 +136,21 @@ public class kelondroBytesLongMap {
public synchronized void addl(final byte[] key, final long l) throws IOException {
assert l >= 0 : "l = " + l;
assert (key != null);
- final kelondroRow.Entry newentry = this.rowdef.newEntry();
+ final Row.Entry newentry = this.rowdef.newEntry();
newentry.setCol(0, key);
newentry.setCol(1, l);
index.addUnique(newentry);
}
public synchronized ArrayList<Long[]> removeDoubles() throws IOException {
- final ArrayList<kelondroRowCollection> indexreport = index.removeDoubles();
+ final ArrayList<RowCollection> indexreport = index.removeDoubles();
final ArrayList<Long[]> report = new ArrayList<Long[]>();
Long[] is;
int c;
- for (final kelondroRowCollection rowset: indexreport) {
+ for (final RowCollection rowset: indexreport) {
is = new Long[rowset.size()];
c = 0;
- for (kelondroRow.Entry e: rowset) {
+ for (Row.Entry e: rowset) {
is[c++] = Long.valueOf(e.getColLong(1));
}
report.add(is);
@@ -157,13 +160,13 @@ public class kelondroBytesLongMap {
public synchronized long removel(final byte[] key) throws IOException {
assert (key != null);
- final kelondroRow.Entry indexentry = index.remove(key);
+ final Row.Entry indexentry = index.remove(key);
if (indexentry == null) return -1;
return indexentry.getColLong(1);
}
public synchronized long removeonel() throws IOException {
- final kelondroRow.Entry indexentry = index.removeOne();
+ final Row.Entry indexentry = index.removeOne();
if (indexentry == null) return -1;
return indexentry.getColLong(1);
}
@@ -176,7 +179,7 @@ public class kelondroBytesLongMap {
return index.keys(up, firstKey);
}
- public synchronized kelondroCloneableIterator<kelondroRow.Entry> rows(final boolean up, final byte[] firstKey) throws IOException {
+ public synchronized kelondroCloneableIterator<Row.Entry> rows(final boolean up, final byte[] firstKey) throws IOException {
return index.rows(up, firstKey);
}
@@ -195,8 +198,8 @@ public class kelondroBytesLongMap {
* @param bufferSize
* @return
*/
- public static initDataConsumer asynchronusInitializer(final int keylength, final kelondroByteOrder objectOrder, final int space, int bufferSize) {
- initDataConsumer initializer = new initDataConsumer(new kelondroBytesLongMap(keylength, objectOrder, space), bufferSize);
+ public static initDataConsumer asynchronusInitializer(final int keylength, final ByteOrder objectOrder, final int space, int bufferSize) {
+ initDataConsumer initializer = new initDataConsumer(new BytesLongMap(keylength, objectOrder, space), bufferSize);
ExecutorService service = Executors.newSingleThreadExecutor();
initializer.setResult(service.submit(initializer));
service.shutdown();
@@ -212,19 +215,19 @@ public class kelondroBytesLongMap {
}
}
- public static class initDataConsumer implements Callable<kelondroBytesLongMap> {
+ public static class initDataConsumer implements Callable<BytesLongMap> {
private BlockingQueue<entry> cache;
private final entry poison = new entry(new byte[0], 0);
- private kelondroBytesLongMap map;
- private Future<kelondroBytesLongMap> result;
+ private BytesLongMap map;
+ private Future<BytesLongMap> result;
- public initDataConsumer(kelondroBytesLongMap map, int bufferCount) {
+ public initDataConsumer(BytesLongMap map, int bufferCount) {
this.map = map;
cache = new ArrayBlockingQueue<entry>(bufferCount);
}
- protected void setResult(Future<kelondroBytesLongMap> result) {
+ protected void setResult(Future<BytesLongMap> result) {
this.result = result;
}
@@ -261,11 +264,11 @@ public class kelondroBytesLongMap {
* @throws InterruptedException
* @throws ExecutionException
*/
- public kelondroBytesLongMap result() throws InterruptedException, ExecutionException {
+ public BytesLongMap result() throws InterruptedException, ExecutionException {
return this.result.get();
}
- public kelondroBytesLongMap call() throws IOException {
+ public BytesLongMap call() throws IOException {
try {
entry c;
while ((c = cache.take()) != poison) {
diff --git a/source/de/anomic/kelondro/kelondroColumn.java b/source/de/anomic/kelondro/index/Column.java
similarity index 97%
rename from source/de/anomic/kelondro/kelondroColumn.java
rename to source/de/anomic/kelondro/index/Column.java
index f01b67fe7..f504be3f1 100644
--- a/source/de/anomic/kelondro/kelondroColumn.java
+++ b/source/de/anomic/kelondro/index/Column.java
@@ -25,9 +25,11 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.kelondro;
+package de.anomic.kelondro.index;
-public class kelondroColumn {
+import de.anomic.kelondro.kelondroException;
+
+public class Column {
public static final int celltype_undefined = 0;
public static final int celltype_boolean = 1;
@@ -44,7 +46,7 @@ public class kelondroColumn {
public int celltype, cellwidth, encoder;
public String nickname, description;
- public kelondroColumn(final String nickname, final int celltype, final int encoder, final int cellwidth, final String description) {
+ public Column(final String nickname, final int celltype, final int encoder, final int cellwidth, final String description) {
this.celltype = celltype;
this.cellwidth = cellwidth;
this.encoder = encoder;
@@ -52,7 +54,7 @@ public class kelondroColumn {
this.description = description;
}
- public kelondroColumn(String celldef) {
+ public Column(String celldef) {
// define column with column syntax
// example: <UDate-3>
@@ -265,9 +267,9 @@ public class kelondroColumn {
return true;
if (obj == null)
return false;
- if (!(obj instanceof kelondroColumn))
+ if (!(obj instanceof Column))
return false;
- kelondroColumn other = (kelondroColumn) obj;
+ Column other = (Column) obj;
if (celltype != other.celltype)
return false;
if (cellwidth != other.cellwidth)
diff --git a/source/de/anomic/kelondro/kelondroIndex.java b/source/de/anomic/kelondro/index/ObjectIndex.java
similarity index 64%
rename from source/de/anomic/kelondro/kelondroIndex.java
rename to source/de/anomic/kelondro/index/ObjectIndex.java
index 6d93d5bde..b22502883 100644
--- a/source/de/anomic/kelondro/kelondroIndex.java
+++ b/source/de/anomic/kelondro/index/ObjectIndex.java
@@ -29,30 +29,32 @@
kelondroTree and kelondroHashtable
*/
-package de.anomic.kelondro;
+package de.anomic.kelondro.index;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
-public interface kelondroIndex {
+import de.anomic.kelondro.kelondroCloneableIterator;
+
+public interface ObjectIndex {
public String filename(); // returns a unique identified for this index; can be a real or artificial file name
public int size();
- public kelondroRow row();
+ public Row row();
public boolean has(byte[] key); // use this only if there is no get in case that has returns true
- 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<kelondroRow.Entry> rows) throws IOException; // for R/W head path optimization
- public void addUnique(kelondroRow.Entry row) throws IOException; // no double-check
- public void addUniqueMultiple(List<kelondroRow.Entry> rows) throws IOException; // no double-check
- public ArrayList<kelondroRowCollection> removeDoubles() throws IOException; // removes all elements that are double (to be used after all addUnique)
- public kelondroRow.Entry remove(byte[] key) throws IOException;
- public kelondroRow.Entry removeOne() throws IOException;
+ public Row.Entry get(byte[] key) throws IOException;
+ public Row.Entry put(Row.Entry row) throws IOException;
+ public Row.Entry put(Row.Entry row, Date entryDate) throws IOException;
+ public void putMultiple(List<Row.Entry> rows) throws IOException; // for R/W head path optimization
+ public void addUnique(Row.Entry row) throws IOException; // no double-check
+ public void addUniqueMultiple(List<Row.Entry> rows) throws IOException; // no double-check
+ public ArrayList<RowCollection> removeDoubles() throws IOException; // removes all elements that are double (to be used after all addUnique)
+ public Row.Entry remove(byte[] key) throws IOException;
+ public Row.Entry removeOne() 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 row
+ public kelondroCloneableIterator<Row.Entry> rows(boolean up, byte[] firstKey) throws IOException; // iterates the whole row
public void deleteOnExit();
public void clear() throws IOException;
public void close();
diff --git a/source/de/anomic/kelondro/kelondroRAMIndex.java b/source/de/anomic/kelondro/index/RAMIndex.java
similarity index 79%
rename from source/de/anomic/kelondro/kelondroRAMIndex.java
rename to source/de/anomic/kelondro/index/RAMIndex.java
index df560b660..68914fee3 100644
--- a/source/de/anomic/kelondro/kelondroRAMIndex.java
+++ b/source/de/anomic/kelondro/index/RAMIndex.java
@@ -22,24 +22,26 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.kelondro;
+package de.anomic.kelondro.index;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
-import de.anomic.kelondro.kelondroRow.Entry;
+import de.anomic.kelondro.kelondroCloneableIterator;
+import de.anomic.kelondro.kelondroMergeIterator;
+import de.anomic.kelondro.index.Row.Entry;
-public class kelondroRAMIndex implements kelondroIndex {
+public class RAMIndex implements ObjectIndex {
- private final kelondroRow rowdef;
- private kelondroRowSet index0, index1;
- private final kelondroRow.EntryComparator entryComparator;
+ private final Row rowdef;
+ private RowSet index0, index1;
+ private final Row.EntryComparator entryComparator;
- public kelondroRAMIndex(final kelondroRow rowdef, final int initialspace) {
+ public RAMIndex(final Row rowdef, final int initialspace) {
this.rowdef = rowdef;
- this.entryComparator = new kelondroRow.EntryComparator(rowdef.objectOrder);
+ this.entryComparator = new Row.EntryComparator(rowdef.objectOrder);
reset(initialspace);
}
@@ -49,11 +51,11 @@ public class kelondroRAMIndex implements kelondroIndex {
public void reset(final int initialspace) {
this.index0 = null; // first flush RAM to make room
- this.index0 = new kelondroRowSet(rowdef, initialspace);
+ this.index0 = new RowSet(rowdef, initialspace);
this.index1 = null; // to show that this is the initialization phase
}
- public kelondroRow row() {
+ public Row row() {
return index0.row();
}
@@ -62,15 +64,15 @@ public class kelondroRAMIndex implements kelondroIndex {
// finish initialization phase
index0.sort();
index0.uniq();
- index1 = new kelondroRowSet(rowdef, 0);
+ index1 = new RowSet(rowdef, 0);
}
}
- public synchronized kelondroRow.Entry get(final byte[] key) {
+ public synchronized Row.Entry get(final byte[] key) {
assert (key != null);
finishInitialization();
assert index0.isSorted();
- final kelondroRow.Entry indexentry = index0.get(key);
+ final Row.Entry indexentry = index0.get(key);
if (indexentry != null) return indexentry;
return index1.get(key);
}
@@ -83,12 +85,12 @@ public class kelondroRAMIndex implements kelondroIndex {
return index1.has(key);
}
- public synchronized kelondroRow.Entry put(final kelondroRow.Entry entry) {
+ public synchronized Row.Entry put(final Row.Entry entry) {
assert (entry != null);
finishInitialization();
// if the new entry is within the initialization part, just overwrite it
assert index0.isSorted();
- final kelondroRow.Entry indexentry = index0.remove(entry.getPrimaryKeyBytes()); // keeps ordering
+ final Row.Entry indexentry = index0.remove(entry.getPrimaryKeyBytes()); // keeps ordering
if (indexentry != null) {
index1.put(entry);
return indexentry;
@@ -108,7 +110,7 @@ public class kelondroRAMIndex implements kelondroIndex {
}
}
- public synchronized void addUnique(final kelondroRow.Entry entry) {
+ public synchronized void addUnique(final Row.Entry entry) {
assert (entry != null);
if (index1 == null) {
// we are in the initialization phase
@@ -124,27 +126,27 @@ public class kelondroRAMIndex implements kelondroIndex {
while (i.hasNext()) addUnique(i.next());
}
- public synchronized ArrayList<kelondroRowCollection> removeDoubles() {
+ public synchronized ArrayList<RowCollection> removeDoubles() {
// finish initialization phase explicitely
- if (index1 == null) index1 = new kelondroRowSet(rowdef, 0);
+ if (index1 == null) index1 = new RowSet(rowdef, 0);
return index0.removeDoubles();
}
- public synchronized kelondroRow.Entry remove(final byte[] key) {
+ public synchronized Row.Entry remove(final byte[] key) {
finishInitialization();
// if the new entry is within the initialization part, just delete it
- final kelondroRow.Entry indexentry = index0.remove(key);
+ final Row.Entry indexentry = index0.remove(key);
if (indexentry != null) {
assert index0.get(key) == null; // check if remove worked
return indexentry;
}
// else remove it from the index1
- final kelondroRow.Entry removed = index1.remove(key);
+ final Row.Entry removed = index1.remove(key);
assert index1.get(key) == null : "removed " + ((removed == null) ? " is null" : " is not null") + ", and index entry still exists"; // check if remove worked
return removed;
}
- public synchronized kelondroRow.Entry removeOne() {
+ public synchronized Row.Entry removeOne() {
if ((index1 != null) && (index1.size() != 0)) {
return index1.removeOne();
}
@@ -171,7 +173,7 @@ public class kelondroRAMIndex implements kelondroIndex {
// finish initialization phase
index0.sort();
index0.uniq();
- index1 = new kelondroRowSet(rowdef, 0);
+ index1 = new RowSet(rowdef, 0);
return index0.keys(up, firstKey);
}
assert (index1 != null);
@@ -191,13 +193,13 @@ public class kelondroRAMIndex implements kelondroIndex {
true);
}
- public synchronized kelondroCloneableIterator<kelondroRow.Entry> rows(final boolean up, final byte[] firstKey) {
+ public synchronized kelondroCloneableIterator<Row.Entry> rows(final boolean up, final byte[] firstKey) {
// returns the row-iterator of the underlying kelondroIndex
if (index1 == null) {
// finish initialization phase
index0.sort();
index0.uniq();
- index1 = new kelondroRowSet(rowdef, 0);
+ index1 = new RowSet(rowdef, 0);
return index0.rows(up, firstKey);
}
assert (index1 != null);
@@ -209,7 +211,7 @@ public class kelondroRAMIndex implements kelondroIndex {
// sort index1 to enable working of the merge iterator
index1.sort();
//assert consistencyAnalysis0() : "consistency problem: " + consistencyAnalysis();
- return new kelondroMergeIterator<kelondroRow.Entry>(
+ return new kelondroMergeIterator<Row.Entry>(
index0.rows(up, firstKey),
index1.rows(up, firstKey),
entryComparator,
diff --git a/source/de/anomic/kelondro/kelondroRow.java b/source/de/anomic/kelondro/index/Row.java
similarity index 89%
rename from source/de/anomic/kelondro/kelondroRow.java
rename to source/de/anomic/kelondro/index/Row.java
index 7e4e0250a..592a65716 100644
--- a/source/de/anomic/kelondro/kelondroRow.java
+++ b/source/de/anomic/kelondro/index/Row.java
@@ -25,7 +25,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.kelondro;
+package de.anomic.kelondro.index;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
@@ -34,18 +34,26 @@ import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
+import de.anomic.kelondro.kelondroException;
+import de.anomic.kelondro.coding.AbstractOrder;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.Bitfield;
+import de.anomic.kelondro.coding.ByteOrder;
+import de.anomic.kelondro.coding.NaturalOrder;
+import de.anomic.kelondro.coding.kelondroOrder;
+import de.anomic.kelondro.tools.ByteBuffer;
import de.anomic.server.logging.serverLog;
-public final class kelondroRow {
+public final class Row {
- protected kelondroColumn[] row;
- protected int[] colstart;
- protected kelondroByteOrder objectOrder;
+ protected Column[] row;
+ public int[] colstart;
+ public ByteOrder 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(final kelondroColumn[] row, final kelondroByteOrder objectOrder, final int primaryKey) {
+ public Row(final Column[] row, final ByteOrder objectOrder, final int primaryKey) {
assert objectOrder != null;
this.objectOrder = objectOrder;
this.row = row;
@@ -60,7 +68,7 @@ public final class kelondroRow {
this.primaryKeyLength = (primaryKey < 0) ? this.objectsize : row[primaryKeyIndex].cellwidth;
}
- public kelondroRow(String structure, final kelondroByteOrder objectOrder, final int primaryKey) {
+ public Row(String structure, final ByteOrder objectOrder, final int primaryKey) {
assert (objectOrder != null);
this.objectOrder = objectOrder;
// define row with row syntax
@@ -74,15 +82,15 @@ public final class kelondroRow {
// parse property part definition:
int p = structure.indexOf('|');
if (p < 0) p = structure.length();
- final ArrayList<kelondroColumn> l = new ArrayList<kelondroColumn>();
+ final ArrayList<Column> l = new ArrayList<Column>();
final String attr = structure.substring(0, p);
final StringTokenizer st = new StringTokenizer(attr, ",");
while (st.hasMoreTokens()) {
- l.add(new kelondroColumn(st.nextToken()));
+ l.add(new Column(st.nextToken()));
}
// define columns
- this.row = new kelondroColumn[l.size()];
+ this.row = new Column[l.size()];
this.colstart = new int[row.length];
this.objectsize = 0;
for (int i = 0; i < l.size(); i++) {
@@ -94,14 +102,14 @@ public final class kelondroRow {
this.primaryKeyLength = (primaryKey < 0) ? this.objectsize : row[primaryKeyIndex].cellwidth;
}
- public final void setOrdering(final kelondroByteOrder objectOrder, final int primaryKey) {
+ public final void setOrdering(final ByteOrder objectOrder, final int primaryKey) {
assert (objectOrder != null);
this.objectOrder = objectOrder;
this.primaryKeyIndex = primaryKey;
this.primaryKeyLength = (primaryKey < 0) ? this.objectsize : row[primaryKeyIndex].cellwidth;
}
- public final kelondroByteOrder getOrdering() {
+ public final ByteOrder getOrdering() {
return this.objectOrder;
}
@@ -119,7 +127,7 @@ public final class kelondroRow {
return this.objectsize;
}
*/
- public final kelondroColumn column(final int col) {
+ public final Column column(final int col) {
return row[col];
}
@@ -151,7 +159,7 @@ public final class kelondroRow {
if (rowinstance == null) return null;
//assert (rowinstance[0] != 0);
if (!(this.objectOrder.wellformed(rowinstance, 0, row[0].cellwidth))) {
- serverLog.logWarning("kelondroRow", "row not well-formed: rowinstance[0] = " + new String(rowinstance, 0, row[0].cellwidth) + " / " + kelondroNaturalOrder.arrayList(rowinstance, 0, row[0].cellwidth));
+ serverLog.logWarning("kelondroRow", "row not well-formed: rowinstance[0] = " + new String(rowinstance, 0, row[0].cellwidth) + " / " + NaturalOrder.arrayList(rowinstance, 0, row[0].cellwidth));
return null;
}
return new Entry(rowinstance, false);
@@ -193,10 +201,10 @@ public final class kelondroRow {
return new EntryIndex(rowinstance, index);
}
- public static class EntryComparator extends kelondroAbstractOrder<Entry> implements kelondroOrder<Entry>, Comparator<Entry>, Cloneable {
+ public static class EntryComparator extends AbstractOrder<Entry> implements kelondroOrder<Entry>, Comparator<Entry>, Cloneable {
- kelondroByteOrder base;
- public EntryComparator(final kelondroByteOrder baseOrder) {
+ ByteOrder base;
+ public EntryComparator(final ByteOrder baseOrder) {
this.base = baseOrder;
}
@@ -289,14 +297,14 @@ public final class kelondroRow {
if (p + 1 == elts[i].length())
setCol(nick, null);
else {
- if ((decimalCardinal) && (row[i].celltype == kelondroColumn.celltype_cardinal)) {
+ if ((decimalCardinal) && (row[i].celltype == Column.celltype_cardinal)) {
try {
setCol(nick, Long.parseLong(elts[i].substring(p + 1).trim()));
} catch (final NumberFormatException e) {
serverLog.logSevere("kelondroRow", "NumberFormatException for celltype_cardinal; row = " + i + ", celltype = " + row[i].celltype + ", encoder = " + row[i].encoder + ", value = '" + elts[i].substring(p + 1).trim() + "'");
setCol(nick, 0);
}
- } else if ((decimalCardinal) && (row[i].celltype == kelondroColumn.celltype_binary)) {
+ } else if ((decimalCardinal) && (row[i].celltype == Column.celltype_binary)) {
assert row[i].cellwidth == 1;
try {
setCol(nick, new byte[]{(byte) Integer.parseInt(elts[i].substring(p + 1).trim())});
@@ -304,8 +312,8 @@ public final class kelondroRow {
serverLog.logSevere("kelondroRow", "NumberFormatException for celltype_binary; row = " + i + ", celltype = " + row[i].celltype + ", encoder = " + row[i].encoder + ", value = '" + elts[i].substring(p + 1).trim() + "'");
setCol(nick, new byte[]{0});
}
- } else if ((decimalCardinal) && (row[i].celltype == kelondroColumn.celltype_bitfield)) {
- setCol(nick, (new kelondroBitfield(row[i].cellwidth, elts[i].substring(p + 1).trim())).bytes());
+ } else if ((decimalCardinal) && (row[i].celltype == Column.celltype_bitfield)) {
+ setCol(nick, (new Bitfield(row[i].cellwidth, elts[i].substring(p + 1).trim())).bytes());
} else {
setCol(nick, elts[i].substring(p + 1).trim().getBytes());
}
@@ -377,7 +385,7 @@ public final class kelondroRow {
if (nickref == null) genNickRef();
final Object[] ref = nickref.get(nickname);
if (ref == null) return;
- final kelondroColumn col = (kelondroColumn) ref[0];
+ final Column col = (Column) ref[0];
setCol(col.encoder, ((Integer) ref[1]).intValue(), col.cellwidth, cell);
}
@@ -435,7 +443,7 @@ public final class kelondroRow {
if (nickref == null) genNickRef();
final Object[] ref = nickref.get(nickname);
if (ref == null) return;
- final kelondroColumn col = (kelondroColumn) ref[0];
+ final Column col = (Column) ref[0];
setCol(col.encoder, offset + ((Integer) ref[1]).intValue(), col.cellwidth, cell);
}
@@ -446,15 +454,15 @@ public final class kelondroRow {
private final void setCol(final int encoder, final int offset, final int length, final long cell) {
switch (encoder) {
- case kelondroColumn.encoder_none:
+ case Column.encoder_none:
throw new kelondroException("ROW", "setColLong has celltype none, no encoder given");
- case kelondroColumn.encoder_b64e:
- kelondroBase64Order.enhancedCoder.encodeLong(cell, rowinstance, offset, length);
+ case Column.encoder_b64e:
+ Base64Order.enhancedCoder.encodeLong(cell, rowinstance, offset, length);
break;
- case kelondroColumn.encoder_b256:
- kelondroNaturalOrder.encodeLong(cell, rowinstance, offset, length);
+ case Column.encoder_b256:
+ NaturalOrder.encodeLong(cell, rowinstance, offset, length);
break;
- case kelondroColumn.encoder_bytes:
+ case Column.encoder_bytes:
throw new kelondroException("ROW", "setColLong of celltype bytes not applicable");
}
}
@@ -463,7 +471,7 @@ public final class kelondroRow {
if (nickref == null) genNickRef();
final Object[] ref = nickref.get(nickname);
if (ref == null) return dflt;
- final kelondroColumn col = (kelondroColumn) ref[0];
+ final Column col = (Column) ref[0];
final byte[] cell = new byte[col.cellwidth];
System.arraycopy(rowinstance, offset + ((Integer) ref[1]).intValue(), cell, 0, cell.length);
return cell;
@@ -473,7 +481,7 @@ public final class kelondroRow {
if (nickref == null) genNickRef();
final Object[] ref = nickref.get(nickname);
if (ref == null) return dflt;
- final kelondroColumn col = (kelondroColumn) ref[0];
+ final Column col = (Column) ref[0];
return getColString(col.encoder, ((Integer) ref[1]).intValue(), col.cellwidth, encoding);
}
@@ -499,7 +507,7 @@ public final class kelondroRow {
if (nickref == null) genNickRef();
final Object[] ref = nickref.get(nickname);
if (ref == null) return dflt;
- final kelondroColumn col = (kelondroColumn) ref[0];
+ final Column col = (Column) ref[0];
final int clstrt = ((Integer) ref[1]).intValue();
return getColLong(col.encoder, clstrt, col.cellwidth);
}
@@ -511,9 +519,9 @@ public final class kelondroRow {
protected final long getColLong(final int encoder, final int clstrt, final int length) {
switch (encoder) {
- case kelondroColumn.encoder_none:
+ case Column.encoder_none:
throw new kelondroException("ROW", "getColLong has celltype none, no encoder given");
- case kelondroColumn.encoder_b64e:
+ case Column.encoder_b64e:
// start - fix for badly stored parameters
if ((length >= 3) && (rowinstance[offset + clstrt] == '[') && (rowinstance[offset + clstrt + 1] == 'B') && (rowinstance[offset + clstrt + 2] == '@')) return 0;
if ((length == 2) && (rowinstance[offset + clstrt] == '[') && (rowinstance[offset + clstrt + 1] == 'B')) return 0;
@@ -522,10 +530,10 @@ public final class kelondroRow {
for (int i = 0; i < length; i++) if (rowinstance[offset + clstrt + i] != '_') {maxvalue = false; break;}
if (maxvalue) return 0;
// stop - fix for badly stored parameters
- return kelondroBase64Order.enhancedCoder.decodeLong(rowinstance, offset + clstrt, length);
- case kelondroColumn.encoder_b256:
- return kelondroNaturalOrder.decodeLong(rowinstance, offset + clstrt, length);
- case kelondroColumn.encoder_bytes:
+ return Base64Order.enhancedCoder.decodeLong(rowinstance, offset + clstrt, length);
+ case Column.encoder_b256:
+ return NaturalOrder.decodeLong(rowinstance, offset + clstrt, length);
+ case Column.encoder_bytes:
throw new kelondroException("ROW", "getColLong of celltype bytes not applicable");
}
throw new kelondroException("ROW", "getColLong did not find appropriate encoding");
@@ -571,16 +579,16 @@ public final class kelondroRow {
}
public final String toPropertyForm(final boolean includeBraces, final boolean decimalCardinal, final boolean longname) {
- final kelondroByteBuffer bb = new kelondroByteBuffer();
+ final ByteBuffer bb = new ByteBuffer();
if (includeBraces) bb.append('{');
for (int i = 0; i < row.length; i++) {
bb.append((longname) ? row[i].description : row[i].nickname);
bb.append('=');
- if ((decimalCardinal) && (row[i].celltype == kelondroColumn.celltype_cardinal)) {
+ if ((decimalCardinal) && (row[i].celltype == Column.celltype_cardinal)) {
bb.append(Long.toString(getColLong(i)));
- } else if ((decimalCardinal) && (row[i].celltype == kelondroColumn.celltype_bitfield)) {
- bb.append((new kelondroBitfield(getColBytes(i))).exportB64());
- } else if ((decimalCardinal) && (row[i].celltype == kelondroColumn.celltype_binary)) {
+ } else if ((decimalCardinal) && (row[i].celltype == Column.celltype_bitfield)) {
+ bb.append((new Bitfield(getColBytes(i))).exportB64());
+ } else if ((decimalCardinal) && (row[i].celltype == Column.celltype_binary)) {
assert row[i].cellwidth == 1;
bb.append(Integer.toString((0xff & getColByte(i))));
} else {
@@ -627,20 +635,20 @@ public final class kelondroRow {
return x;
}
- public final boolean subsumes(final kelondroRow otherRow) {
+ public final boolean subsumes(final Row otherRow) {
// returns true, if this row has at least all columns as the other row
// and possibly some more
if (this.objectsize < otherRow.objectsize) return false;
for (int i = 0; i < otherRow.row.length; i++) {
if ((this.row[i].cellwidth == otherRow.row[i].cellwidth) &&
- (this.row[i].celltype == kelondroColumn.celltype_bitfield) &&
- (otherRow.row[i].celltype == kelondroColumn.celltype_binary)) continue;
+ (this.row[i].celltype == Column.celltype_bitfield) &&
+ (otherRow.row[i].celltype == Column.celltype_binary)) continue;
if (!(this.row[i].equals(otherRow.row[i]))) return false;
}
return true;
}
- public final boolean equals(final kelondroRow otherRow) {
+ public final boolean equals(final Row otherRow) {
if (this.objectsize != otherRow.objectsize) return false;
if (this.columns() != otherRow.columns()) return false;
for (int i = 0; i < otherRow.row.length; i++) {
diff --git a/source/de/anomic/kelondro/kelondroRowCollection.java b/source/de/anomic/kelondro/index/RowCollection.java
similarity index 89%
rename from source/de/anomic/kelondro/kelondroRowCollection.java
rename to source/de/anomic/kelondro/index/RowCollection.java
index 0cb5f5764..7174d774b 100644
--- a/source/de/anomic/kelondro/kelondroRowCollection.java
+++ b/source/de/anomic/kelondro/index/RowCollection.java
@@ -22,7 +22,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.kelondro;
+package de.anomic.kelondro.index;
import java.io.File;
import java.io.IOException;
@@ -37,13 +37,18 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
+import de.anomic.kelondro.kelondroException;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.ByteOrder;
+import de.anomic.kelondro.coding.NaturalOrder;
+import de.anomic.kelondro.tools.MemoryControl;
import de.anomic.server.NamePrefixThreadFactory;
import de.anomic.server.serverFileUtils;
import de.anomic.server.serverProcessor;
import de.anomic.server.logging.serverLog;
import de.anomic.yacy.yacySeedDB;
-public class kelondroRowCollection implements Iterable<kelondroRow.Entry> {
+public class RowCollection implements Iterable<Row.Entry> {
public static final double growfactor = 1.4;
private static final int isortlimit = 20;
@@ -55,7 +60,7 @@ public class kelondroRowCollection implements Iterable<kelondroRow.Entry> {
protected byte[] chunkcache;
protected int chunkcount;
protected long lastTimeRead, lastTimeWrote;
- protected kelondroRow rowdef;
+ public Row rowdef;
protected int sortBound;
private static final int exp_chunkcount = 0;
@@ -65,7 +70,7 @@ public class kelondroRowCollection implements Iterable<kelondroRow.Entry> {
private static final int exp_order_bound = 4;
private static final int exp_collection = 5;
- public kelondroRowCollection(final kelondroRowCollection rc) {
+ public RowCollection(final RowCollection rc) {
this.rowdef = rc.rowdef;
this.chunkcache = rc.chunkcache;
this.chunkcount = rc.chunkcount;
@@ -74,7 +79,7 @@ public class kelondroRowCollection implements Iterable<kelondroRow.Entry> {
this.lastTimeWrote = rc.lastTimeWrote;
}
- public kelondroRowCollection(final kelondroRow rowdef, final int objectCount) {
+ public RowCollection(final Row rowdef, final int objectCount) {
this.rowdef = rowdef;
this.chunkcache = new byte[objectCount * rowdef.objectsize];
this.chunkcount = 0;
@@ -83,7 +88,7 @@ public class kelondroRowCollection implements Iterable<kelondroRow.Entry> {
this.lastTimeWrote = System.currentTimeMillis();
}
- public kelondroRowCollection(final kelondroRow rowdef, final int objectCount, final byte[] cache, final int sortBound) {
+ public RowCollection(final Row rowdef, final int objectCount, final byte[] cache, final int sortBound) {
this.rowdef = rowdef;
this.chunkcache = cache;
this.chunkcount = objectCount;
@@ -92,9 +97,9 @@ public class kelondroRowCollection implements Iterable<kelondroRow.Entry> {
this.lastTimeWrote = System.currentTimeMillis();
}
- public kelondroRowCollection(final kelondroRow rowdef, final kelondroRow.Entry exportedCollectionRowEnvironment) {
+ public RowCollection(final Row rowdef, final Row.Entry exportedCollectionRowEnvironment) {
final int chunkcachelength = exportedCollectionRowEnvironment.cellwidth(1) - exportOverheadSize;
- final kelondroRow.Entry exportedCollection = exportRow(chunkcachelength).newEntry(exportedCollectionRowEnvironment, 1);
+ final Row.Entry exportedCollection = exportRow(chunkcachelength).newEntry(exportedCollectionRowEnvironment, 1);
this.rowdef = rowdef;
this.chunkcount = (int) exportedCollection.getColLong(exp_chunkcount);
@@ -105,12 +110,12 @@ public class kelondroRowCollection implements Iterable<kelondroRow.Entry> {
this.lastTimeRead = (exportedCollection.getColLong(exp_last_read) + 10957) * day;
this.lastTimeWrote = (exportedCollection.getColLong(exp_last_wrote) + 10957) * day;
final String sortOrderKey = exportedCollection.getColString(exp_order_type, null);
- kelondroByteOrder oldOrder = null;
+ ByteOrder oldOrder = null;
if ((sortOrderKey == null) || (sortOrderKey.equals("__"))) {
oldOrder = null;
} else {
- oldOrder = kelondroNaturalOrder.bySignature(sortOrderKey);
- if (oldOrder == null) oldOrder = kelondroBase64Order.bySignature(sortOrderKey);
+ oldOrder = NaturalOrder.bySignature(sortOrderKey);
+ if (oldOrder == null) oldOrder = Base64Order.bySignature(sortOrderKey);
}
if ((rowdef.objectOrder != null) && (oldOrder != null) && (!(rowdef.objectOrder.signature().equals(oldOrder.signature()))))
throw new kelondroException("old collection order does not match with new order; objectOrder.signature = " + rowdef.objectOrder.signature() + ", oldOrder.signature = " + oldOrder.signature());
@@ -128,10 +133,10 @@ public class kelondroRowCollection implements Iterable<kelondroRow.Entry> {
this.sortBound = 0;
}
- private static final kelondroRow exportMeasureRow = exportRow(0 /* no relevance */);
+ private static final Row exportMeasureRow = exportRow(0 /* no relevance */);
- protected static final int sizeOfExportedCollectionRows(final kelondroRow.Entry exportedCollectionRowEnvironment, final int columnInEnvironment) {
- final kelondroRow.Entry exportedCollectionEntry = exportMeasureRow.newEntry(exportedCollectionRowEnvironment, columnInEnvironment);
+ public static final int sizeOfExportedCollectionRows(final Row.Entry exportedCollectionRowEnvironment, final int columnInEnvironment) {
+ final Row.Entry exportedCollectionEntry = exportMeasureRow.newEntry(exportedCollectionRowEnvironment, columnInEnvironment);
final int chunkcount = (int) exportedCollectionEntry.getColLong(exp_chunkcount);
return chunkcount;
}
@@ -142,16 +147,16 @@ public class kelondroRowCollection implements Iterable<kelondroRow.Entry> {
return (int) (time / day) - 10957;
}
- private static kelondroRow exportRow(final int chunkcachelength) {
+ private static Row exportRow(final int chunkcachelength) {
// find out the size of this collection
- return new kelondroRow(
+ return new Row(
"int size-4 {b256}," +
"short lastread-2 {b256}," + // as daysSince2000
"short lastwrote-2 {b256}," + // as daysSince2000
"byte[] orderkey-2," +
"int orderbound-4 {b256}," +
"byte[] collection-" + chunkcachelength,
- kelondroNaturalOrder.naturalOrder, 0
+ NaturalOrder.naturalOrder, 0
);
}
@@ -161,8 +166,8 @@ public class kelondroRowCollection implements Iterable<kelondroRow.Entry> {
// returns null if the collection is empty
trim(false);
assert this.size() * this.rowdef.objectsize == this.chunkcache.length : "this.size() = " + this.size() + ", objectsize = " + this.rowdef.objectsize + ", chunkcache.length = " + this.chunkcache.length;
- final kelondroRow row = exportRow(chunkcache.length);
- final kelondroRow.Entry entry = row.newEntry();
+ final Row row = exportRow(chunkcache.length);
+ final Row.Entry entry = row.newEntry();
assert (sortBound <= chunkcount) : "sortBound = " + sortBound + ", chunkcount = " + chunkcount;
assert (this.chunkcount <= chunkcache.length / rowdef.objectsize) : "chunkcount = " + this.chunkcount + ", chunkcache.length = " + chunkcache.length + ", rowdef.objectsize = " + rowdef.objectsize;
entry.setCol(exp_chunkcount, this.chunkcount);
@@ -178,7 +183,7 @@ public class kelondroRowCollection implements Iterable<kelondroRow.Entry> {
serverFileUtils.copy(exportCollection(), file);
}
- public kelondroRow row() {
+ public Row row() {
return this.rowdef;
}
@@ -201,7 +206,7 @@ public class kelondroRowCollection implements Iterable<kelondroRow.Entry> {
if (needed >= chunkcache.length)
return; // in case that the growfactor causes that the cache would
// grow instead of shrink, simply ignore the growfactor
- if (kelondroMemory.available() + 1000 < needed)
+ if (MemoryControl.available() + 1000 < needed)
return; // if the swap buffer is not available, we must give up.
// This is not critical. Otherwise we provoke a serious
// problem with OOM
@@ -232,13 +237,13 @@ public class kelondroRowCollection implements Iterable<kelondroRow.Entry> {
return b;
}
- public synchronized final kelondroRow.Entry get(final int index, final boolean clone) {
+ public synchronized final Row.Entry get(final int index, final boolean clone) {
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 (chunkcache != null && index * rowdef.objectsize < chunkcache.length);
assert sortBound <= chunkcount : "sortBound = " + sortBound + ", chunkcount = " + chunkcount;
if ((chunkcache == null) || (rowdef == null)) return null; // case may appear during shutdown
- kelondroRow.Entry entry;
+ Row.Entry entry;
final int addr = index * rowdef.objectsize;
synchronized (this) {
if (index >= chunkcount) return null;
@@ -249,7 +254,7 @@ public class kelondroRowCollection implements Iterable<kelondroRow.Entry> {
return entry;
}
- public synchronized final void set(final int index, final kelondroRow.Entry a) {
+ public synchronized final void set(final int index, final Row.Entry a) {
assert (index >= 0) : "set: access with index " + index + " is below zero";
ensureSize(index + 1);
boolean sameKey = match(a.bytes(), 0, a.cellwidth(0), index);
@@ -260,7 +265,7 @@ public class kelondroRowCollection implements Iterable<kelondroRow.Entry> {
this.lastTimeWrote = System.currentTimeMillis();
}
- public final void insertUnique(final int index, final kelondroRow.Entry a) {
+ public final void insertUnique(final int index, final Row.Entry a) {
assert (a != null);
if (index < chunkcount) {
@@ -273,14 +278,14 @@ public class kelondroRowCollection implements Iterable<kelondroRow.Entry> {
set(index, a);
}
- public synchronized void addUnique(final kelondroRow.Entry row) {
+ public synchronized void addUnique(final Row.Entry row) {
final byte[] r = row.bytes();
addUnique(r, 0, r.length);
}
- public synchronized void addUniqueMultiple(final List<kelondroRow.Entry> rows) {
+ public synchronized void addUniqueMultiple(final List<Row.Entry> rows) {
assert this.sortBound == 0 : "sortBound = " + this.sortBound + ", chunkcount = " + this.chunkcount;
- final Iterator<kelondroRow.Entry> i = rows.iterator();
+ final Iterator<Row.Entry> i = rows.iterator();
while (i.hasNext()) addUnique(i.next());
}
@@ -292,7 +297,7 @@ public class kelondroRowCollection implements Iterable<kelondroRow.Entry> {
private final void addUnique(final byte[] a, final int astart, final int alength) {
assert (a != null);
assert (astart >= 0) && (astart < a.length) : " astart = " + astart;
- assert (!(serverLog.allZero(a, astart, alength))) : "a = " + kelondroNaturalOrder.arrayList(a, astart, alength);
+ assert (!(serverLog.allZero(a, astart, alength))) : "a = " + NaturalOrder.arrayList(a, astart, alength);
assert (alength > 0);
assert (astart + alength <= a.length);
assert alength == rowdef.objectsize : "alength =" + alength + ", rowdef.objectsize = " + rowdef.objectsize;
@@ -316,7 +321,7 @@ public class kelondroRowCollection implements Iterable<kelondroRow.Entry> {
protected final void addSorted(final byte[] a, final int astart, final int alength) {
assert (a != null);
assert (astart >= 0) && (astart < a.length) : " astart = " + astart;
- assert (!(serverLog.allZero(a, astart, alength))) : "a = " + kelondroNaturalOrder.arrayList(a, astart, alength);
+ assert (!(serverLog.allZero(a, astart, alength))) : "a = " + NaturalOrder.arrayList(a, astart, alength);
assert (alength > 0);
assert (astart + alength <= a.length);
assert alength == rowdef.objectsize : "alength =" + alength + ", rowdef.objectsize = " + rowdef.objectsize;
@@ -328,7 +333,7 @@ public class kelondroRowCollection implements Iterable<kelondroRow.Entry> {
this.lastTimeWrote = System.currentTimeMillis();
}
- public synchronized final void addAllUnique(final kelondroRowCollection c) {
+ public synchronized final void addAllUnique(final RowCollection c) {
if (c == null) return;
assert(rowdef.objectsize == c.rowdef.objectsize);
ensureSize(chunkcount + c.size());
@@ -346,7 +351,7 @@ public class kelondroRowCollection implements Iterable<kelondroRow.Entry> {
* @param p element at this position will be removed
* @param keepOrder keep the order of remaining entries
*/
- protected synchronized final void removeRow(final int p, final boolean keepOrder) {
+ public synchronized final void removeRow(final int p, final boolean keepOrder) {
assert p >= 0 : "p = " + p;
assert p < chunkcount : "p = " + p + ", chunkcount = " + chunkcount;
assert chunkcount > 0 : "chunkcount = " + chunkcount;
@@ -379,9 +384,9 @@ public class kelondroRowCollection implements Iterable<kelondroRow.Entry> {
* removes the last entry from the collection
* @return
*/
- public synchronized kelondroRow.Entry removeOne() {
+ public synchronized Row.Entry removeOne() {
if (chunkcount == 0) return null;
- final kelondroRow.Entry r = get(chunkcount - 1, true);
+ final Row.Entry r = get(chunkcount - 1, true);
if (chunkcount == sortBound) sortBound--;
chunkcount--;
this.lastTimeWrote = System.currentTimeMillis();
@@ -442,7 +447,7 @@ public class kelondroRowCollection implements Iterable<kelondroRow.Entry> {
/**
* return an iterator for the row entries in this object
*/
- public Iterator<kelondroRow.Entry> iterator() {
+ public Iterator<Row.Entry> iterator() {
// iterates kelondroRow.Entry - type entries
return new rowIterator();
}
@@ -452,7 +457,7 @@ public class kelondroRowCollection implements Iterable<kelondroRow.Entry> {
* It supports remove() and keeps the order of the underlying
* collection during removes.
*/
- public class rowIterator implements Iterator<kelondroRow.Entry> {
+ public class rowIterator implements Iterator<Row.Entry> {
private int p;
@@ -464,7 +469,7 @@ public class kelondroRowCollection implements Iterable<kelondroRow.Entry> {
return p < chunkcount;
}
- public kelondroRow.Entry next() {
+ public Row.Entry next() {
return get(p++, true);
}
@@ -478,8 +483,8 @@ public class kelondroRowCollection implements Iterable<kelondroRow.Entry> {
public synchronized void select(final Set<String> keys) {
// removes all entries but the ones given by urlselection
if ((keys == null) || (keys.isEmpty())) return;
- final Iterator<kelondroRow.Entry> i = iterator();
- kelondroRow.Entry row;
+ final Iterator<Row.Entry> i = iterator();
+ Row.Entry row;
while (i.hasNext()) {
row = i.next();
if (!(keys.contains(row.getColString(0, null)))) i.remove();
@@ -564,10 +569,10 @@ public class kelondroRowCollection implements Iterable<kelondroRow.Entry> {
}
public static class qsortthread implements Callable<Object> {
- kelondroRowCollection rc;
+ RowCollection rc;
int L, R, S;
- public qsortthread(final kelondroRowCollection rc, final int L, final int R, final int S) {
+ public qsortthread(final RowCollection rc, final int L, final int R, final int S) {
this.rc = rc;
this.L = L;
this.R = R;
@@ -594,10 +599,10 @@ public class kelondroRowCollection implements Iterable<kelondroRow.Entry> {
}
public static class partitionthread implements Callable<Integer> {
- kelondroRowCollection rc;
+ RowCollection rc;
int L, R, S;
- public partitionthread(final kelondroRowCollection rc, final int L, final int R, final int S) {
+ public partitionthread(final RowCollection rc, final int L, final int R, final int S) {
this.rc = rc;
this.L = L;
this.R = R;
@@ -625,7 +630,7 @@ public class kelondroRowCollection implements Iterable<kelondroRow.Entry> {
int pivot = pivot(L, R, S, swapspace);
int oldpivot = -1;
byte[] compiledPivot = null;
- if (this.rowdef.objectOrder instanceof kelondroBase64Order) {
+ if (this.rowdef.objectOrder instanceof Base64Order) {
while (p <= q) {
// wenn pivot < S: pivot befindet sich in sortierter Sequenz von L bis S - 1
// d.h. alle Werte von L bis pivot sind kleiner als das pivot
@@ -787,18 +792,18 @@ public class kelondroRowCollection implements Iterable<kelondroRow.Entry> {
}
}
- public synchronized ArrayList<kelondroRowCollection> removeDoubles() {
+ public synchronized ArrayList<RowCollection> removeDoubles() {
assert (this.rowdef.objectOrder != null);
// removes double-occurrences of chunks
// in contrast to uniq() this removes also the remaining, non-double entry that had a double-occurrence to the others
// all removed chunks are returned in an array
this.sort();
- final ArrayList<kelondroRowCollection> report = new ArrayList<kelondroRowCollection>();
+ final ArrayList<RowCollection> report = new ArrayList<RowCollection>();
if (chunkcount < 2) return report;
int i = chunkcount - 2;
int d = 0;
boolean u = true;
- kelondroRowCollection collection = new kelondroRowCollection(this.rowdef, 2);
+ RowCollection collection = new RowCollection(this.rowdef, 2);
try {
while (i >= 0) {
if (compare(i, i + 1) == 0) {
@@ -814,7 +819,7 @@ public class kelondroRowCollection implements Iterable<kelondroRow.Entry> {
if (i + 1 < chunkcount - 1) u = false;
collection.trim(false);
report.add(collection);
- collection = new kelondroRowSet(this.rowdef, 2);
+ collection = new RowSet(this.rowdef, 2);
}
i--;
}
@@ -844,7 +849,7 @@ public class kelondroRowCollection implements Iterable<kelondroRow.Entry> {
public synchronized String toString() {
final StringBuilder s = new StringBuilder();
- final Iterator<kelondroRow.Entry> i = iterator();
+ final Iterator<Row.Entry> i = iterator();
if (i.hasNext()) s.append(i.next().toString());
while (i.hasNext()) s.append(", " + (i.next()).toString());
return new String(s);
@@ -873,29 +878,29 @@ public class kelondroRowCollection implements Iterable<kelondroRow.Entry> {
protected final byte[] compilePivot(final int i) {
assert (i >= 0) && (i < chunkcount) : "i = " + i + ", chunkcount = " + chunkcount;
assert (this.rowdef.objectOrder != null);
- assert (this.rowdef.objectOrder instanceof kelondroBase64Order);
+ assert (this.rowdef.objectOrder instanceof Base64Order);
assert (this.rowdef.primaryKeyIndex == 0) : "this.sortColumn = " + this.rowdef.primaryKeyIndex;
final int colstart = (this.rowdef.primaryKeyIndex <= 0) ? 0 : this.rowdef.colstart[this.rowdef.primaryKeyIndex];
//assert (!bugappearance(chunkcache, i * this.rowdef.objectsize + colstart, this.rowdef.primaryKeyLength));
- return ((kelondroBase64Order) this.rowdef.objectOrder).compilePivot(chunkcache, i * this.rowdef.objectsize + colstart, this.rowdef.primaryKeyLength);
+ return ((Base64Order) this.rowdef.objectOrder).compilePivot(chunkcache, i * this.rowdef.objectsize + colstart, this.rowdef.primaryKeyLength);
}
protected final byte[] compilePivot(final byte[] a, final int astart, final int alength) {
assert (this.rowdef.objectOrder != null);
- assert (this.rowdef.objectOrder instanceof kelondroBase64Order);
+ assert (this.rowdef.objectOrder instanceof Base64Order);
assert (this.rowdef.primaryKeyIndex == 0) : "this.sortColumn = " + this.rowdef.primaryKeyIndex;
- return ((kelondroBase64Order) this.rowdef.objectOrder).compilePivot(a, astart, alength);
+ return ((Base64Order) this.rowdef.objectOrder).compilePivot(a, astart, alength);
}
protected final int comparePivot(final byte[] compiledPivot, final int j) {
assert (chunkcount * this.rowdef.objectsize <= chunkcache.length) : "chunkcount = " + chunkcount + ", objsize = " + this.rowdef.objectsize + ", chunkcache.length = " + chunkcache.length;
assert (j >= 0) && (j < chunkcount) : "j = " + j + ", chunkcount = " + chunkcount;
assert (this.rowdef.objectOrder != null);
- assert (this.rowdef.objectOrder instanceof kelondroBase64Order);
+ assert (this.rowdef.objectOrder instanceof Base64Order);
assert (this.rowdef.primaryKeyIndex == 0) : "this.sortColumn = " + this.rowdef.primaryKeyIndex;
final int colstart = (this.rowdef.primaryKeyIndex <= 0) ? 0 : this.rowdef.colstart[this.rowdef.primaryKeyIndex];
//assert (!bugappearance(chunkcache, j * this.rowdef.objectsize + colstart, this.rowdef.primaryKeyLength));
- final int c = ((kelondroBase64Order) this.rowdef.objectOrder).comparePivot(
+ final int c = ((Base64Order) this.rowdef.objectOrder).comparePivot(
compiledPivot,
chunkcache,
j * this.rowdef.objectsize + colstart,
@@ -930,29 +935,29 @@ public class kelondroRowCollection implements Iterable<kelondroRow.Entry> {
private static Random random = null;
private static String randomHash() {
return
- kelondroBase64Order.enhancedCoder.encodeLong(random.nextLong(), 4) +
- kelondroBase64Order.enhancedCoder.encodeLong(random.nextLong(), 4) +
- kelondroBase64Order.enhancedCoder.encodeLong(random.nextLong(), 4);
+ Base64Order.enhancedCoder.encodeLong(random.nextLong(), 4) +
+ Base64Order.enhancedCoder.encodeLong(random.nextLong(), 4) +
+ Base64Order.enhancedCoder.encodeLong(random.nextLong(), 4);
}
public static void test(final int testsize) {
- final kelondroRow r = new kelondroRow(new kelondroColumn[]{
- new kelondroColumn("hash", kelondroColumn.celltype_string, kelondroColumn.encoder_bytes, yacySeedDB.commonHashLength, "hash")},
- kelondroBase64Order.enhancedCoder, 0);
+ final Row r = new Row(new Column[]{
+ new Column("hash", Column.celltype_string, Column.encoder_bytes, yacySeedDB.commonHashLength, "hash")},
+ Base64Order.enhancedCoder, 0);
- kelondroRowCollection a = new kelondroRowCollection(r, testsize);
+ RowCollection a = new RowCollection(r, testsize);
a.add("AAAAAAAAAAAA".getBytes());
a.add("BBBBBBBBBBBB".getBytes());
a.add("BBBBBBBBBBBB".getBytes());
a.add("BBBBBBBBBBBB".getBytes());
a.add("CCCCCCCCCCCC".getBytes());
- final ArrayList<kelondroRowCollection> del = a.removeDoubles();
+ final ArrayList<RowCollection> del = a.removeDoubles();
System.out.println(del + "rows double");
- final Iterator<kelondroRow.Entry> j = a.iterator();
+ final Iterator<Row.Entry> j = a.iterator();
while (j.hasNext()) System.out.println(new String(j.next().bytes()));
System.out.println("kelondroRowCollection test with size = " + testsize);
- a = new kelondroRowCollection(r, testsize);
+ a = new RowCollection(r, testsize);
long t0 = System.nanoTime();
random = new Random(0);
for (int i = 0; i < testsize; i++) a.add(randomHash().getBytes());
@@ -963,7 +968,7 @@ public class kelondroRowCollection implements Iterable<kelondroRow.Entry> {
long t1 = System.nanoTime();
System.out.println("create a : " + (t1 - t0) + " nanoseconds, " + d(testsize, (t1 - t0)) + " entries/nanoseconds; a.size() = " + a.size());
- final kelondroRowCollection c = new kelondroRowCollection(r, testsize);
+ final RowCollection c = new RowCollection(r, testsize);
random = new Random(0);
t0 = System.nanoTime();
for (int i = 0; i < testsize; i++) {
@@ -971,7 +976,7 @@ public class kelondroRowCollection implements Iterable<kelondroRow.Entry> {
}
t1 = System.nanoTime();
System.out.println("create c : " + (t1 - t0) + " nanoseconds, " + d(testsize, (t1 - t0)) + " entries/nanoseconds");
- final kelondroRowCollection d = new kelondroRowCollection(r, testsize);
+ final RowCollection d = new RowCollection(r, testsize);
for (int i = 0; i < testsize; i++) {
d.add(c.get(i, false).getColBytes(0));
}
@@ -992,7 +997,7 @@ public class kelondroRowCollection implements Iterable<kelondroRow.Entry> {
final long t6 = System.nanoTime();
System.out.println("uniq d : " + (t6 - t5) + " nanoseconds, " + d(testsize, (t6 - t5)) + " entries/nanoseconds");
random = new Random(0);
- final kelondroRowSet e = new kelondroRowSet(r, testsize);
+ final RowSet e = new RowSet(r, testsize);
for (int i = 0; i < testsize; i++) {
e.put(r.newEntry(randomHash().getBytes()));
}
diff --git a/source/de/anomic/kelondro/kelondroRowSet.java b/source/de/anomic/kelondro/index/RowSet.java
similarity index 83%
rename from source/de/anomic/kelondro/kelondroRowSet.java
rename to source/de/anomic/kelondro/index/RowSet.java
index 56b187c77..004567a77 100644
--- a/source/de/anomic/kelondro/kelondroRowSet.java
+++ b/source/de/anomic/kelondro/index/RowSet.java
@@ -22,7 +22,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.kelondro;
+package de.anomic.kelondro.index;
import java.io.DataInput;
import java.io.IOException;
@@ -31,20 +31,25 @@ import java.util.Iterator;
import java.util.List;
import java.util.Random;
-public class kelondroRowSet extends kelondroRowCollection implements kelondroIndex, Iterable<kelondroRow.Entry> {
+import de.anomic.kelondro.kelondroCloneableIterator;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.ByteOrder;
+import de.anomic.kelondro.coding.NaturalOrder;
+
+public class RowSet extends RowCollection implements ObjectIndex, Iterable<Row.Entry> {
private static final int collectionReSortLimit = 400;
- public kelondroRowSet(final kelondroRowSet rs) {
+ public RowSet(final RowSet rs) {
super(rs);
}
- public kelondroRowSet(final kelondroRow rowdef, final int objectCount, final byte[] cache, final int sortBound) {
+ public RowSet(final Row rowdef, final int objectCount, final byte[] cache, final int sortBound) {
super(rowdef, objectCount, cache, sortBound);
assert rowdef.objectOrder != null;
}
- public kelondroRowSet(final kelondroRow rowdef, final int objectCount) {
+ public RowSet(final Row rowdef, final int objectCount) {
super(rowdef, objectCount);
assert rowdef.objectOrder != null;
}
@@ -55,12 +60,12 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd
* @param exportedCollectionRowEnvironment
* @param columnInEnvironment
*/
- public kelondroRowSet(final kelondroRow rowdef, final kelondroRow.Entry exportedCollectionRowEnvironment) {
+ public RowSet(final Row rowdef, final Row.Entry exportedCollectionRowEnvironment) {
super(rowdef, exportedCollectionRowEnvironment);
assert rowdef.objectOrder != null;
}
- public void setOrdering(final kelondroByteOrder newOrder, final int newColumn) {
+ public void setOrdering(final ByteOrder newOrder, final int newColumn) {
assert newOrder != null;
if ((rowdef.objectOrder == null) ||
(!(rowdef.objectOrder.signature().equals(newOrder.signature()))) ||
@@ -70,7 +75,7 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd
}
}
- public static kelondroRowSet importRowSet(final DataInput is, final kelondroRow rowdef) throws IOException {
+ public static RowSet importRowSet(final DataInput is, final Row rowdef) throws IOException {
final byte[] byte6 = new byte[6];
final int size = is.readInt();
is.readFully(byte6);
@@ -80,16 +85,16 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd
final int orderbound = is.readInt();
final byte[] chunkcache = new byte[size * rowdef.objectsize];
is.readFully(chunkcache);
- return new kelondroRowSet(rowdef, size, chunkcache, orderbound);
+ return new RowSet(rowdef, size, chunkcache, orderbound);
}
- public static kelondroRowSet importRowSet(byte[] b, final kelondroRow rowdef) {
- final int size = (int) kelondroNaturalOrder.decodeLong(b, 0, 4);
- final int orderbound = (int) kelondroNaturalOrder.decodeLong(b, 10, 4);
+ public static RowSet importRowSet(byte[] b, final Row rowdef) {
+ final int size = (int) NaturalOrder.decodeLong(b, 0, 4);
+ final int orderbound = (int) NaturalOrder.decodeLong(b, 10, 4);
final byte[] chunkcache = new byte[size * rowdef.objectsize];
assert b.length - exportOverheadSize == size * rowdef.objectsize;
System.arraycopy(b, 14, chunkcache, 0, chunkcache.length);
- return new kelondroRowSet(rowdef, size, chunkcache, orderbound);
+ return new RowSet(rowdef, size, chunkcache, orderbound);
}
public void reset() {
@@ -101,30 +106,30 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd
return index >= 0;
}
- public synchronized kelondroRow.Entry get(final byte[] key) {
+ public synchronized Row.Entry get(final byte[] key) {
return get(key, 0, key.length);
}
- private kelondroRow.Entry get(final byte[] key, final int astart, final int alength) {
+ private Row.Entry get(final byte[] key, final int astart, final int alength) {
final int index = find(key, astart, alength);
- final kelondroRow.Entry entry = (index >= 0) ? get(index, true) : null;
+ final Row.Entry entry = (index >= 0) ? get(index, true) : null;
return entry;
}
- public synchronized void putMultiple(final List<kelondroRow.Entry> rows) {
- final Iterator<kelondroRow.Entry> i = rows.iterator();
+ public synchronized void putMultiple(final List<Row.Entry> rows) {
+ final Iterator<Row.Entry> i = rows.iterator();
while (i.hasNext()) put(i.next());
}
- public kelondroRow.Entry put(final kelondroRow.Entry row, final Date entryDate) {
+ public Row.Entry put(final Row.Entry row, final Date entryDate) {
return put(row);
}
- public synchronized kelondroRow.Entry put(final kelondroRow.Entry entry) {
+ public synchronized Row.Entry put(final Row.Entry entry) {
assert (entry != null);
assert (entry.getPrimaryKeyBytes() != null);
int index = -1;
- kelondroRow.Entry oldentry = null;
+ Row.Entry oldentry = null;
// when reaching a specific amount of un-sorted entries, re-sort all
if ((this.chunkcount - this.sortBound) > collectionReSortLimit) {
sort();
@@ -141,13 +146,13 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd
return oldentry;
}
- private synchronized kelondroRow.Entry remove(final byte[] a, final int start, final int length) {
+ private synchronized Row.Entry remove(final byte[] a, final int start, final int length) {
final int index = find(a, start, length);
if (index < 0) return null;
- final kelondroRow.Entry entry = super.get(index, true);
+ final Row.Entry entry = super.get(index, true);
super.removeRow(index, true); // keep order of collection!
int findagainindex = 0;
- assert (findagainindex = find(a, start, length)) < 0 : "remove: chunk found again at index position (after remove) " + findagainindex + ", index(before) = " + index + ", inset=" + kelondroNaturalOrder.arrayList(super.chunkcache, super.rowdef.objectsize * findagainindex, length) + ", searchkey=" + kelondroNaturalOrder.arrayList(a, start, length); // check if the remove worked
+ assert (findagainindex = find(a, start, length)) < 0 : "remove: chunk found again at index position (after remove) " + findagainindex + ", index(before) = " + index + ", inset=" + NaturalOrder.arrayList(super.chunkcache, super.rowdef.objectsize * findagainindex, length) + ", searchkey=" + NaturalOrder.arrayList(a, start, length); // check if the remove worked
return entry;
}
@@ -156,7 +161,7 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd
* if the entry was found, return the entry, but delete the entry from the set
* if the entry was not found, return null.
*/
- public kelondroRow.Entry remove(final byte[] a) {
+ public Row.Entry remove(final byte[] a) {
return remove(a, 0, a.length);
}
@@ -169,7 +174,7 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd
sort();
}
- if ((this.rowdef.objectOrder != null) && (this.rowdef.objectOrder instanceof kelondroBase64Order) && (this.sortBound > 4000)) {
+ if ((this.rowdef.objectOrder != null) && (this.rowdef.objectOrder instanceof Base64Order) && (this.sortBound > 4000)) {
// first try to find in sorted area
assert this.rowdef.objectOrder.wellformed(a, astart, alength) : "not wellformed: " + new String(a, astart, alength);
final byte[] compiledPivot = compilePivot(a, astart, alength);
@@ -206,7 +211,7 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd
private int iterativeSearchCompiledPivot(final byte[] compiledPivot, final int leftBorder, final int rightBound) {
// returns the chunknumber
assert (rowdef.objectOrder != null);
- assert (rowdef.objectOrder instanceof kelondroBase64Order);
+ assert (rowdef.objectOrder instanceof Base64Order);
for (int i = leftBorder; i < rightBound; i++) {
if (comparePivot(compiledPivot, i) == 0) return i;
}
@@ -234,7 +239,7 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd
// returns the exact position of the key if the key exists,
// or -1 if the key does not exist
assert (rowdef.objectOrder != null);
- assert (rowdef.objectOrder instanceof kelondroBase64Order);
+ assert (rowdef.objectOrder instanceof Base64Order);
int l = 0;
int rbound = this.sortBound;
int p = 0;
@@ -321,17 +326,17 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd
}
}
- public synchronized Iterator<kelondroRow.Entry> iterator() {
+ public synchronized Iterator<Row.Entry> iterator() {
// iterates kelondroRow.Entry - type entries
sort();
return super.iterator();
}
- public synchronized kelondroCloneableIterator<kelondroRow.Entry> rows(final boolean up, final byte[] firstKey) {
+ public synchronized kelondroCloneableIterator<Row.Entry> rows(final boolean up, final byte[] firstKey) {
return new rowIterator(up, firstKey);
}
- public class rowIterator implements kelondroCloneableIterator<kelondroRow.Entry> {
+ public class rowIterator implements kelondroCloneableIterator<Row.Entry> {
private final boolean up;
private final byte[] first;
@@ -366,8 +371,8 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd
}
}
- public kelondroRow.Entry next() {
- final kelondroRow.Entry entry = get(p, true);
+ public Row.Entry next() {
+ final Row.Entry entry = get(p, true);
if (up) p++; else p--;
return entry;
}
@@ -385,7 +390,7 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd
* @param c
* @return
*/
- public kelondroRowSet merge(kelondroRowSet c) {
+ public RowSet merge(RowSet c) {
/*
if (this.isSorted() && this.size() >= c.size()) {
return mergeInsert(this, c);
@@ -412,9 +417,9 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd
* @param c
* @return
*/
- protected static kelondroRowSet mergeEnum(kelondroRowCollection c0, kelondroRowCollection c1) {
+ protected static RowSet mergeEnum(RowCollection c0, RowCollection c1) {
assert c0.rowdef == c1.rowdef;
- kelondroRowSet r = new kelondroRowSet(c0.rowdef, c0.size() + c1.size());
+ RowSet r = new RowSet(c0.rowdef, c0.size() + c1.size());
c0.sort();
c1.sort();
int c0i = 0, c1i = 0;
@@ -476,16 +481,16 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd
*/
final String[] test = { "eins", "zwei", "drei", "vier", "fuenf", "sechs", "sieben", "acht", "neun", "zehn" };
- final kelondroRowSet d = new kelondroRowSet(new kelondroRow("byte[] key-10, Cardinal x-4 {b256}", kelondroNaturalOrder.naturalOrder, 0), 0);
- d.setOrdering(kelondroNaturalOrder.naturalOrder, 0);
+ final RowSet d = new RowSet(new Row("byte[] key-10, Cardinal x-4 {b256}", NaturalOrder.naturalOrder, 0), 0);
+ d.setOrdering(NaturalOrder.naturalOrder, 0);
for (int ii = 0; ii < test.length; ii++) d.add(test[ii].getBytes());
for (int ii = 0; ii < test.length; ii++) d.add(test[ii].getBytes());
d.sort();
d.remove("fuenf".getBytes(), 0, 5);
- final Iterator<kelondroRow.Entry> ii = d.iterator();
+ final Iterator<Row.Entry> ii = d.iterator();
String s;
System.out.print("INPUT-ITERATOR: ");
- kelondroRow.Entry entry;
+ Row.Entry entry;
while (ii.hasNext()) {
entry = ii.next();
s = new String(entry.getColBytes(0)).trim();
@@ -564,7 +569,7 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd
// remove test
final long start = System.currentTimeMillis();
- final kelondroRowSet c = new kelondroRowSet(new kelondroRow("byte[] a-12, byte[] b-12", kelondroBase64Order.enhancedCoder, 0), 0);
+ final RowSet c = new RowSet(new Row("byte[] a-12, byte[] b-12", Base64Order.enhancedCoder, 0), 0);
byte[] key;
final int testsize = 5000;
final byte[][] delkeys = new byte[testsize / 5][];
@@ -599,8 +604,8 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd
public static byte[] randomHash(final long r0, final long r1) {
// a long can have 64 bit, but a 12-byte hash can have 6 * 12 = 72 bits
// so we construct a generic Hash using two long values
- return (kelondroBase64Order.enhancedCoder.encodeLong(Math.abs(r0), 11).substring(5) +
- kelondroBase64Order.enhancedCoder.encodeLong(Math.abs(r1), 11).substring(5)).getBytes();
+ return (Base64Order.enhancedCoder.encodeLong(Math.abs(r0), 11).substring(5) +
+ Base64Order.enhancedCoder.encodeLong(Math.abs(r1), 11).substring(5)).getBytes();
}
public static byte[] randomHash(final Random r) {
return randomHash(r.nextLong(), r.nextLong());
diff --git a/source/de/anomic/kelondro/kelondroAbstractIOChunks.java b/source/de/anomic/kelondro/io/AbstractIOChunks.java
similarity index 97%
rename from source/de/anomic/kelondro/kelondroAbstractIOChunks.java
rename to source/de/anomic/kelondro/io/AbstractIOChunks.java
index 72f47db6d..a4415ae51 100644
--- a/source/de/anomic/kelondro/kelondroAbstractIOChunks.java
+++ b/source/de/anomic/kelondro/io/AbstractIOChunks.java
@@ -20,11 +20,12 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.kelondro;
+package de.anomic.kelondro.io;
import java.io.IOException;
-public abstract class kelondroAbstractIOChunks implements kelondroIOChunks {
+
+public abstract class AbstractIOChunks implements IOChunksInterface {
// logging support
protected String name = null;
diff --git a/source/de/anomic/kelondro/kelondroAbstractRA.java b/source/de/anomic/kelondro/io/AbstractRandomAccess.java
similarity index 92%
rename from source/de/anomic/kelondro/kelondroAbstractRA.java
rename to source/de/anomic/kelondro/io/AbstractRandomAccess.java
index 4d3d5bba5..4d4f86c56 100644
--- a/source/de/anomic/kelondro/kelondroAbstractRA.java
+++ b/source/de/anomic/kelondro/io/AbstractRandomAccess.java
@@ -5,9 +5,9 @@
// first published on http://www.anomic.de
// Frankfurt, Germany, 2004
//
-// $LastChangedDate$
-// $LastChangedRevision$
-// $LastChangedBy$
+// $LastChangedDate: 2009-01-30 15:48:11 +0100 (Fr, 30 Jan 2009) $
+// $LastChangedRevision: 5539 $
+// $LastChangedBy: orbiter $
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -23,7 +23,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.kelondro;
+package de.anomic.kelondro.io;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
@@ -34,7 +34,9 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
-abstract class kelondroAbstractRA implements kelondroRA {
+import de.anomic.kelondro.tools.ByteBuffer;
+
+public abstract class AbstractRandomAccess implements RandomAccessInterface {
// logging support
protected String name = null;
@@ -143,7 +145,7 @@ abstract class kelondroAbstractRA implements kelondroRA {
this.seek(0);
final Iterator<Map.Entry<String, String>> iter = map.entrySet().iterator();
Map.Entry<String, String> entry;
- final kelondroByteBuffer bb = new kelondroByteBuffer(map.size() * 40);
+ final ByteBuffer bb = new ByteBuffer(map.size() * 40);
bb.append("# ").append(comment).append("\r\n");
while (iter.hasNext()) {
entry = iter.next();
diff --git a/source/de/anomic/kelondro/kelondroBufferedIOChunks.java b/source/de/anomic/kelondro/io/BufferedIOChunks.java
similarity index 93%
rename from source/de/anomic/kelondro/kelondroBufferedIOChunks.java
rename to source/de/anomic/kelondro/io/BufferedIOChunks.java
index a1511b585..985344a52 100644
--- a/source/de/anomic/kelondro/kelondroBufferedIOChunks.java
+++ b/source/de/anomic/kelondro/io/BufferedIOChunks.java
@@ -23,19 +23,20 @@
// this is a WRITE-buffer!
// the buffer MUST be flushed before closing of the underlying kelondroRA
-package de.anomic.kelondro;
+package de.anomic.kelondro.io;
import java.io.IOException;
-public final class kelondroBufferedIOChunks extends kelondroAbstractIOChunks implements kelondroIOChunks {
- protected kelondroRA ra;
+public final class BufferedIOChunks extends AbstractIOChunks implements IOChunksInterface {
+
+ protected RandomAccessInterface ra;
private int bufferSize;
private final long commitTimeout;
private final byte[] buffer;
private long lastCommit = 0;
- public kelondroBufferedIOChunks(final kelondroRA ra, final String name, final int buffersize, final long commitTimeout) {
+ public BufferedIOChunks(final RandomAccessInterface ra, final String name, final int buffersize, final long commitTimeout) {
this.name = name;
this.ra = ra;
this.bufferSize = 0;
@@ -44,7 +45,7 @@ public final class kelondroBufferedIOChunks extends kelondroAbstractIOChunks imp
this.lastCommit = System.currentTimeMillis();
}
- public kelondroRA getRA() {
+ public RandomAccessInterface getRA() {
return this.ra;
}
diff --git a/source/de/anomic/kelondro/kelondroBufferedRA.java b/source/de/anomic/kelondro/io/BufferedRandomAccess.java
similarity index 83%
rename from source/de/anomic/kelondro/kelondroBufferedRA.java
rename to source/de/anomic/kelondro/io/BufferedRandomAccess.java
index ec6e9627b..93d12bf2a 100644
--- a/source/de/anomic/kelondro/kelondroBufferedRA.java
+++ b/source/de/anomic/kelondro/io/BufferedRandomAccess.java
@@ -20,26 +20,28 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.kelondro;
+package de.anomic.kelondro.io;
import java.io.IOException;
-public class kelondroBufferedRA extends kelondroAbstractRA implements kelondroRA {
+import de.anomic.kelondro.tools.ByteBuffer;
- private kelondroByteBuffer sbb;
+public class BufferedRandomAccess extends AbstractRandomAccess implements RandomAccessInterface {
+
+ private ByteBuffer sbb;
private long pos;
- public kelondroBufferedRA() {
- sbb = new kelondroByteBuffer();
+ public BufferedRandomAccess() {
+ sbb = new ByteBuffer();
pos = 0;
}
- public kelondroBufferedRA(final kelondroByteBuffer bb) {
+ public BufferedRandomAccess(final ByteBuffer bb) {
sbb = bb;
pos = 0;
}
- public kelondroByteBuffer getBuffer() {
+ public ByteBuffer getBuffer() {
return this.sbb;
}
diff --git a/source/de/anomic/kelondro/kelondroCachedFileRA.java b/source/de/anomic/kelondro/io/CachedRandomAccess.java
similarity index 93%
rename from source/de/anomic/kelondro/kelondroCachedFileRA.java
rename to source/de/anomic/kelondro/io/CachedRandomAccess.java
index 8f9c6c8dd..c55e72a7f 100644
--- a/source/de/anomic/kelondro/kelondroCachedFileRA.java
+++ b/source/de/anomic/kelondro/io/CachedRandomAccess.java
@@ -20,21 +20,22 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.kelondro;
+package de.anomic.kelondro.io;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
-public final class kelondroCachedFileRA extends kelondroAbstractRA implements kelondroRA {
+
+public final class CachedRandomAccess extends AbstractRandomAccess implements RandomAccessInterface {
private RandomAccessFile RAFile;
private byte[] cache;
private long cachestart;
private int cachelen;
- public kelondroCachedFileRA(final File file) throws IOException, FileNotFoundException {
+ public CachedRandomAccess(final File file) throws IOException, FileNotFoundException {
this.name = file.getName();
this.file = file;
RAFile = new RandomAccessFile(file, "rw");
diff --git a/source/de/anomic/kelondro/kelondroChannelRA.java b/source/de/anomic/kelondro/io/ChannelRandomAccess.java
similarity index 91%
rename from source/de/anomic/kelondro/kelondroChannelRA.java
rename to source/de/anomic/kelondro/io/ChannelRandomAccess.java
index 374bac9cf..b27332996 100644
--- a/source/de/anomic/kelondro/kelondroChannelRA.java
+++ b/source/de/anomic/kelondro/io/ChannelRandomAccess.java
@@ -20,7 +20,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.kelondro;
+package de.anomic.kelondro.io;
import java.io.File;
import java.io.FileNotFoundException;
@@ -29,12 +29,13 @@ import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
-public final class kelondroChannelRA extends kelondroAbstractRA implements kelondroRA {
+
+public final class ChannelRandomAccess extends AbstractRandomAccess implements RandomAccessInterface {
private FileChannel channel;
private RandomAccessFile raf;
- public kelondroChannelRA(final File file) throws IOException, FileNotFoundException {
+ public ChannelRandomAccess(final File file) throws IOException, FileNotFoundException {
this.name = file.getName();
this.file = file;
this.raf = new RandomAccessFile(file, "rw");
diff --git a/source/de/anomic/kelondro/kelondroFileRA.java b/source/de/anomic/kelondro/io/FileRandomAccess.java
similarity index 88%
rename from source/de/anomic/kelondro/kelondroFileRA.java
rename to source/de/anomic/kelondro/io/FileRandomAccess.java
index f3f826d11..d25a53655 100644
--- a/source/de/anomic/kelondro/kelondroFileRA.java
+++ b/source/de/anomic/kelondro/io/FileRandomAccess.java
@@ -20,7 +20,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.kelondro;
+package de.anomic.kelondro.io;
import java.io.File;
import java.io.FileNotFoundException;
@@ -28,11 +28,12 @@ import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.Map;
-public final class kelondroFileRA extends kelondroAbstractRA implements kelondroRA {
+
+public final class FileRandomAccess extends AbstractRandomAccess implements RandomAccessInterface {
private RandomAccessFile RAFile;
- public kelondroFileRA(final File file) throws IOException, FileNotFoundException {
+ public FileRandomAccess(final File file) throws IOException, FileNotFoundException {
this.name = file.getName();
this.file = file;
RAFile = new RandomAccessFile(file, "rw");
@@ -78,9 +79,9 @@ public final class kelondroFileRA extends kelondroAbstractRA implements kelondro
public static void writeMap(final File f, final Map<String, String> map, final String comment) throws IOException {
final File fp = f.getParentFile();
if (fp != null) fp.mkdirs();
- kelondroRA kra = null;
+ RandomAccessInterface kra = null;
try {
- kra = new kelondroCachedFileRA(f);
+ kra = new CachedRandomAccess(f);
kra.writeMap(map, comment);
kra.close();
} finally {
@@ -89,9 +90,9 @@ public final class kelondroFileRA extends kelondroAbstractRA implements kelondro
}
public static Map<String, String> readMap(final File f) throws IOException {
- kelondroRA kra = null;
+ RandomAccessInterface kra = null;
try {
- kra = new kelondroCachedFileRA(f);
+ kra = new CachedRandomAccess(f);
final Map<String, String> map = kra.readMap();
kra.close();
return map;
diff --git a/source/de/anomic/kelondro/kelondroIOChunks.java b/source/de/anomic/kelondro/io/IOChunksInterface.java
similarity index 94%
rename from source/de/anomic/kelondro/kelondroIOChunks.java
rename to source/de/anomic/kelondro/io/IOChunksInterface.java
index 00d472028..4af232cee 100644
--- a/source/de/anomic/kelondro/kelondroIOChunks.java
+++ b/source/de/anomic/kelondro/io/IOChunksInterface.java
@@ -20,17 +20,18 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.kelondro;
+package de.anomic.kelondro.io;
import java.io.IOException;
-public interface kelondroIOChunks {
+
+public interface IOChunksInterface {
// logging support
public String name();
// reference handling
- public kelondroRA getRA();
+ public RandomAccessInterface getRA();
// pseudo-native methods:
public long length() throws IOException;
diff --git a/source/de/anomic/kelondro/kelondroRAIOChunks.java b/source/de/anomic/kelondro/io/RandomAccessIOChunks.java
similarity index 87%
rename from source/de/anomic/kelondro/kelondroRAIOChunks.java
rename to source/de/anomic/kelondro/io/RandomAccessIOChunks.java
index 44c51681f..668cf061f 100644
--- a/source/de/anomic/kelondro/kelondroRAIOChunks.java
+++ b/source/de/anomic/kelondro/io/RandomAccessIOChunks.java
@@ -20,20 +20,21 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.kelondro;
+package de.anomic.kelondro.io;
import java.io.IOException;
-public final class kelondroRAIOChunks extends kelondroAbstractIOChunks implements kelondroIOChunks {
- protected kelondroRA ra;
+public final class RandomAccessIOChunks extends AbstractIOChunks implements IOChunksInterface {
+
+ protected RandomAccessInterface ra;
- public kelondroRAIOChunks(final kelondroRA ra, final String name) {
+ public RandomAccessIOChunks(final RandomAccessInterface ra, final String name) {
this.name = name;
this.ra = ra;
}
- public kelondroRA getRA() {
+ public RandomAccessInterface getRA() {
return this.ra;
}
diff --git a/source/de/anomic/kelondro/kelondroRA.java b/source/de/anomic/kelondro/io/RandomAccessInterface.java
similarity index 94%
rename from source/de/anomic/kelondro/kelondroRA.java
rename to source/de/anomic/kelondro/io/RandomAccessInterface.java
index c35f53231..2aae66c5e 100644
--- a/source/de/anomic/kelondro/kelondroRA.java
+++ b/source/de/anomic/kelondro/io/RandomAccessInterface.java
@@ -28,14 +28,14 @@
ony file - random-access, we need an abstract interface.
*/
-package de.anomic.kelondro;
+package de.anomic.kelondro.io;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
-public interface kelondroRA {
+public interface RandomAccessInterface {
// logging support
public String name();
diff --git a/source/de/anomic/kelondro/kelondroRecords.java b/source/de/anomic/kelondro/io/RandomAccessRecords.java
similarity index 90%
rename from source/de/anomic/kelondro/kelondroRecords.java
rename to source/de/anomic/kelondro/io/RandomAccessRecords.java
index e53a97094..26ae4ac98 100644
--- a/source/de/anomic/kelondro/kelondroRecords.java
+++ b/source/de/anomic/kelondro/io/RandomAccessRecords.java
@@ -24,11 +24,14 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.kelondro;
+package de.anomic.kelondro.io;
import java.io.IOException;
-public interface kelondroRecords {
+import de.anomic.kelondro.kelondroHandle;
+import de.anomic.kelondro.kelondroNode;
+
+public interface RandomAccessRecords {
// this is now implemented by kelondroTray
// the newNode method is used to define a enumeration in kelondroTray, but is still there abstract
diff --git a/source/de/anomic/kelondro/kelondroBufferedEcoFS.java b/source/de/anomic/kelondro/io/kelondroBufferedEcoFS.java
similarity index 99%
rename from source/de/anomic/kelondro/kelondroBufferedEcoFS.java
rename to source/de/anomic/kelondro/io/kelondroBufferedEcoFS.java
index 5f27f49e4..963296bc5 100644
--- a/source/de/anomic/kelondro/kelondroBufferedEcoFS.java
+++ b/source/de/anomic/kelondro/io/kelondroBufferedEcoFS.java
@@ -22,7 +22,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.kelondro;
+package de.anomic.kelondro.io;
import java.io.File;
import java.io.IOException;
@@ -30,6 +30,7 @@ import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;
+
/**
* The kelondroBufferedEcoFS extends the IO reduction to EcoFS by providing a
* write buffer to elements that are INSIDE the filed entries of the file
diff --git a/source/de/anomic/kelondro/kelondroEcoFS.java b/source/de/anomic/kelondro/io/kelondroEcoFS.java
similarity index 98%
rename from source/de/anomic/kelondro/kelondroEcoFS.java
rename to source/de/anomic/kelondro/io/kelondroEcoFS.java
index 0421cd974..61dbdbaa9 100644
--- a/source/de/anomic/kelondro/kelondroEcoFS.java
+++ b/source/de/anomic/kelondro/io/kelondroEcoFS.java
@@ -22,7 +22,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.kelondro;
+package de.anomic.kelondro.io;
import java.io.File;
import java.io.FileNotFoundException;
@@ -30,6 +30,8 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.RandomAccessFile;
+import de.anomic.kelondro.tools.MemoryControl;
+
/**
* The EcoFS is a flat file with records of fixed length. The file does not contain
* any meta information and the first record starts right at file position 0
@@ -101,9 +103,9 @@ public class kelondroEcoFS {
// initialize cache and buffer
int cachesize = Math.max(1, (maxReadCache / recordsize)) * recordsize;
int buffersize = Math.max(1, (maxWriteBuffer / recordsize)) * recordsize;
- if (!kelondroMemory.request(cachesize + buffersize + 1024 * 1024 * 20, true)) {
+ if (!MemoryControl.request(cachesize + buffersize + 1024 * 1024 * 20, true)) {
// not enough memory there, take less
- long lessmem = Math.min(Math.min(maxReadCache, maxWriteBuffer) / 8, kelondroMemory.available() - (1024 * 1024 * 6) / 6);
+ long lessmem = Math.min(Math.min(maxReadCache, maxWriteBuffer) / 8, MemoryControl.available() - (1024 * 1024 * 6) / 6);
//System.out.println("newmem vorher: cachesize = " + cachesize + ", buffersize = " + buffersize + ", available = " + serverMemory.available() + ", lessmem = " + lessmem);
cachesize = Math.max(1, (int) (lessmem / recordsize)) * recordsize;
buffersize = Math.max(1, (int) (lessmem / recordsize)) * recordsize;
diff --git a/source/de/anomic/kelondro/kelondroAbstractRecords.java b/source/de/anomic/kelondro/kelondroAbstractRecords.java
index d88175d33..f555ec54b 100644
--- a/source/de/anomic/kelondro/kelondroAbstractRecords.java
+++ b/source/de/anomic/kelondro/kelondroAbstractRecords.java
@@ -39,10 +39,21 @@ import java.util.TreeSet;
import java.util.logging.Level;
import java.util.logging.Logger;
-import de.anomic.kelondro.kelondroRow.EntryIndex;
+import de.anomic.kelondro.coding.ByteOrder;
+import de.anomic.kelondro.coding.NaturalOrder;
+import de.anomic.kelondro.index.Column;
+import de.anomic.kelondro.index.Row;
+import de.anomic.kelondro.index.Row.EntryIndex;
+import de.anomic.kelondro.io.BufferedIOChunks;
+import de.anomic.kelondro.io.ChannelRandomAccess;
+import de.anomic.kelondro.io.FileRandomAccess;
+import de.anomic.kelondro.io.IOChunksInterface;
+import de.anomic.kelondro.io.RandomAccessInterface;
+import de.anomic.kelondro.io.RandomAccessIOChunks;
+import de.anomic.kelondro.io.RandomAccessRecords;
import de.anomic.server.logging.serverLog;
-public abstract class kelondroAbstractRecords implements kelondroRecords {
+public abstract class kelondroAbstractRecords implements RandomAccessRecords {
private static final boolean useChannel = false;
@@ -72,7 +83,7 @@ public abstract class kelondroAbstractRecords implements kelondroRecords {
// values that are only present at run-time
protected String filename; // the database's file name
- protected kelondroIOChunks entryFile; // the database file
+ protected IOChunksInterface entryFile; // the database file
protected int overhead; // OHBYTEC + 4 * OHHANDLEC = size of additional control bytes
protected int headchunksize;// overheadsize + key element column size
protected int tailchunksize;// sum(all: COLWIDTHS) minus the size of the key element colum
@@ -88,7 +99,7 @@ public abstract class kelondroAbstractRecords implements kelondroRecords {
protected usageControl USAGE; // counter for used and re-use records and pointer to free-list
protected short OHBYTEC; // number of extra bytes in each node
protected short OHHANDLEC; // number of handles in each node
- protected kelondroRow ROW; // array with widths of columns
+ protected Row ROW; // array with widths of columns
private kelondroHandle HANDLES[]; // array with handles
private byte[] TXTPROPS[]; // array with text properties
private int TXTPROPW; // size of a single TXTPROPS element
@@ -344,8 +355,8 @@ public abstract class kelondroAbstractRecords implements kelondroRecords {
public static int staticsize(final File file) {
if (!(file.exists())) return 0;
try {
- final kelondroRA ra = (useChannel) ? new kelondroChannelRA(new File(file.getCanonicalPath())) : new kelondroFileRA(new File(file.getCanonicalPath()));
- final kelondroIOChunks entryFile = new kelondroRAIOChunks(ra, ra.name());
+ final RandomAccessInterface ra = (useChannel) ? new ChannelRandomAccess(new File(file.getCanonicalPath())) : new FileRandomAccess(new File(file.getCanonicalPath()));
+ final IOChunksInterface entryFile = new RandomAccessIOChunks(ra, ra.name());
final int used = entryFile.readInt(POS_USEDC); // works only if consistency with file size is given
entryFile.close();
@@ -360,7 +371,7 @@ public abstract class kelondroAbstractRecords implements kelondroRecords {
public kelondroAbstractRecords(final File file, final boolean useNodeCache,
final short ohbytec, final short ohhandlec,
- final kelondroRow rowdef, final int FHandles, final int txtProps, final int txtPropWidth) throws IOException {
+ final Row rowdef, final int FHandles, final int txtProps, final int txtPropWidth) throws IOException {
// opens an existing file or creates a new file
// file: the file that shall be created
// oha : overhead size array of four bytes: oha[0]=# of bytes, oha[1]=# of shorts, oha[2]=# of ints, oha[3]=# of longs,
@@ -377,7 +388,7 @@ public abstract class kelondroAbstractRecords implements kelondroRecords {
if (file.exists()) {
// opens an existing tree
this.filename = file.getCanonicalPath();
- kelondroRA raf = (useChannel) ? new kelondroChannelRA(new File(this.filename)) : new kelondroFileRA(new File(this.filename));
+ RandomAccessInterface raf = (useChannel) ? new ChannelRandomAccess(new File(this.filename)) : new FileRandomAccess(new File(this.filename));
//kelondroRA raf = new kelondroBufferedRA(new kelondroFileRA(this.filename), 1024, 100);
//kelondroRA raf = new kelondroCachedRA(new kelondroFileRA(this.filename), 5000000, 1000);
//kelondroRA raf = new kelondroNIOFileRA(this.filename, (file.length() < 4000000), 10000);
@@ -385,14 +396,14 @@ public abstract class kelondroAbstractRecords implements kelondroRecords {
initExistingFile(raf, useNodeCache);
} else {
this.filename = file.getCanonicalPath();
- final kelondroRA raf = (useChannel) ? new kelondroChannelRA(new File(this.filename)) : new kelondroFileRA(new File(this.filename));
+ final RandomAccessInterface raf = (useChannel) ? new ChannelRandomAccess(new File(this.filename)) : new FileRandomAccess(new File(this.filename));
// kelondroRA raf = new kelondroBufferedRA(new kelondroFileRA(this.filename), 1024, 100);
// kelondroRA raf = new kelondroNIOFileRA(this.filename, false, 10000);
initNewFile(raf, FHandles, txtProps);
}
assignRowdef(rowdef);
if (fileExisted) {
- final kelondroByteOrder oldOrder = readOrderType();
+ final ByteOrder oldOrder = readOrderType();
if ((oldOrder != null) && (!(oldOrder.equals(rowdef.objectOrder)))) {
writeOrderType(); // write new order type
//throw new IOException("wrong object order upon initialization. new order is " + rowdef.objectOrder.toString() + ", old order was " + oldOrder.toString());
@@ -403,9 +414,9 @@ public abstract class kelondroAbstractRecords implements kelondroRecords {
}
}
- public kelondroAbstractRecords(final kelondroRA ra, final String filename, final boolean useCache,
+ public kelondroAbstractRecords(final RandomAccessInterface ra, final String filename, final boolean useCache,
final short ohbytec, final short ohhandlec,
- final kelondroRow rowdef, final int FHandles, final int txtProps, final int txtPropWidth,
+ final Row rowdef, final int FHandles, final int txtProps, final int txtPropWidth,
final boolean exitOnFail) {
// this always creates a new file
this.fileExisted = false;
@@ -426,19 +437,19 @@ public abstract class kelondroAbstractRecords implements kelondroRecords {
}
public void clear() throws IOException {
- kelondroRA ra = this.entryFile.getRA();
+ RandomAccessInterface ra = this.entryFile.getRA();
final File f = ra.file();
assert f != null;
this.entryFile.close();
f.delete();
- ra = (useChannel) ? new kelondroChannelRA(f) : new kelondroFileRA(f);
+ ra = (useChannel) ? new ChannelRandomAccess(f) : new FileRandomAccess(f);
initNewFile(ra, this.HANDLES.length, this.TXTPROPS.length);
}
- private void initNewFile(final kelondroRA ra, final int FHandles, final int txtProps) throws IOException {
+ private void initNewFile(final RandomAccessInterface ra, final int FHandles, final int txtProps) throws IOException {
// create new Chunked IO
- this.entryFile = new kelondroRAIOChunks(ra, ra.name());
+ this.entryFile = new RandomAccessIOChunks(ra, ra.name());
// store dynamic run-time data
this.overhead = this.OHBYTEC + 4 * this.OHHANDLEC;
@@ -532,20 +543,20 @@ public abstract class kelondroAbstractRecords implements kelondroRecords {
this.theLogger.fine("KELONDRO DEBUG " + this.filename + ": " + message);
}
- public kelondroAbstractRecords(final kelondroRA ra, final String filename, final boolean useNodeCache) throws IOException{
+ public kelondroAbstractRecords(final RandomAccessInterface ra, final String filename, final boolean useNodeCache) throws IOException{
this.fileExisted = false;
this.filename = filename;
initExistingFile(ra, useNodeCache);
readOrderType();
}
- private void initExistingFile(final kelondroRA ra, boolean useBuffer) throws IOException {
+ private void initExistingFile(final RandomAccessInterface ra, boolean useBuffer) throws IOException {
// read from Chunked IO
//useBuffer = false;
if (useBuffer) {
- this.entryFile = new kelondroBufferedIOChunks(ra, ra.name(), 1024*1024, 30000 + random.nextLong() % 30000);
+ this.entryFile = new BufferedIOChunks(ra, ra.name(), 1024*1024, 30000 + random.nextLong() % 30000);
} else {
- this.entryFile = new kelondroRAIOChunks(ra, ra.name());
+ this.entryFile = new RandomAccessIOChunks(ra, ra.name());
}
// read dynamic variables that are back-ups of stored values in file;
@@ -554,7 +565,7 @@ public abstract class kelondroAbstractRecords implements kelondroRecords {
this.OHBYTEC = entryFile.readShort(POS_OHBYTEC);
this.OHHANDLEC = entryFile.readShort(POS_OHHANDLEC);
- final kelondroColumn[] COLDEFS = new kelondroColumn[entryFile.readShort(POS_COLUMNS)];
+ final Column[] COLDEFS = new Column[entryFile.readShort(POS_COLUMNS)];
this.HANDLES = new kelondroHandle[entryFile.readInt(POS_INTPROPC)];
this.TXTPROPS = new byte[entryFile.readInt(POS_TXTPROPC)][];
this.TXTPROPW = entryFile.readInt(POS_TXTPROPW);
@@ -569,7 +580,7 @@ public abstract class kelondroAbstractRecords implements kelondroRecords {
// read configuration arrays
for (int i = 0; i < COLDEFS.length; i++) {
- COLDEFS[i] = new kelondroColumn("col-" + i, kelondroColumn.celltype_binary, kelondroColumn.encoder_bytes, entryFile.readInt(POS_COLWIDTHS + 4 * i), "");
+ COLDEFS[i] = new Column("col-" + i, Column.celltype_binary, Column.encoder_bytes, entryFile.readInt(POS_COLWIDTHS + 4 * i), "");
}
for (int i = 0; i < HANDLES.length; i++) {
HANDLES[i] = new kelondroHandle(entryFile.readInt(POS_HANDLES + 4 * i));
@@ -578,7 +589,7 @@ public abstract class kelondroAbstractRecords implements kelondroRecords {
TXTPROPS[i] = new byte[TXTPROPW];
entryFile.readFully(POS_TXTPROPS + TXTPROPW * i, TXTPROPS[i], 0, TXTPROPS[i].length);
}
- this.ROW = new kelondroRow(COLDEFS, readOrderType(), 0);
+ this.ROW = new Row(COLDEFS, readOrderType(), 0);
// assign remaining values that are only present at run-time
this.overhead = OHBYTEC + 4 * OHHANDLEC;
@@ -596,11 +607,11 @@ public abstract class kelondroAbstractRecords implements kelondroRecords {
} catch (final IOException e) {}
}
- private kelondroByteOrder readOrderType() {
+ private ByteOrder readOrderType() {
try {
final byte[] d = getDescription();
final String s = new String(d).substring(0, 2);
- return kelondroNaturalOrder.orderBySignature(s);
+ return NaturalOrder.orderBySignature(s);
} catch (final IOException e) {
return null;
}
@@ -628,16 +639,16 @@ public abstract class kelondroAbstractRecords implements kelondroRecords {
USAGE.dispose(handle);
}
- protected void printChunk(final kelondroRow.Entry chunk) {
+ protected void printChunk(final Row.Entry chunk) {
for (int j = 0; j < chunk.columns(); j++)
System.out.print(new String(chunk.getColBytes(j)) + ", ");
}
- public final kelondroRow row() {
+ public final Row row() {
return this.ROW;
}
- private final void assignRowdef(final kelondroRow rowdef) {
+ private final void assignRowdef(final Row rowdef) {
// overwrites a given rowdef
// the new rowdef must be compatible
/*
diff --git a/source/de/anomic/kelondro/kelondroAttrSeq.java b/source/de/anomic/kelondro/kelondroAttrSeq.java
index f6f30a089..a23073df5 100644
--- a/source/de/anomic/kelondro/kelondroAttrSeq.java
+++ b/source/de/anomic/kelondro/kelondroAttrSeq.java
@@ -43,6 +43,11 @@ import java.util.TreeSet;
import java.util.logging.Logger;
import java.util.zip.GZIPInputStream;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.index.Column;
+import de.anomic.kelondro.index.Row;
+import de.anomic.kelondro.index.RowCollection;
+import de.anomic.kelondro.tools.MemoryControl;
import de.anomic.server.serverFileUtils;
public class kelondroAttrSeq {
@@ -241,7 +246,7 @@ public class kelondroAttrSeq {
protected int[] prop_len = null, prop_pos = null;
protected String[] seq_names = null;
protected int[] seq_len = null, seq_pos = null;
- protected kelondroRow seqrow;
+ protected Row seqrow;
// example:
//# Structure=<pivot-12>,'=',<UDate-3>,<VDate-3>,<LCount-2>,<GCount-2>,<ICount-2>,<DCount-2>,<TLength-3>,<WACount-3>,<WUCount-3>,<Flags-1>,'|',*<Anchor-12>
@@ -253,19 +258,19 @@ public class kelondroAttrSeq {
if (p < 0) return;
final String pivot = structure.substring(0, p);
structure = structure.substring(p + 5);
- kelondroColumn a = new kelondroColumn(pivot);
+ Column a = new Column(pivot);
pivot_name = a.nickname;
pivot_len = a.cellwidth;
// parse property part definition:
p = structure.indexOf(",'|'");
if (p < 0) return;
- ArrayList<kelondroColumn> l = new ArrayList<kelondroColumn>();
+ ArrayList<Column> l = new ArrayList<Column>();
final String attr = structure.substring(0, p);
String seqs = structure.substring(p + 5);
StringTokenizer st = new StringTokenizer(attr, ",");
while (st.hasMoreTokens()) {
- a = new kelondroColumn(st.nextToken());
+ a = new Column(st.nextToken());
l.add(a);
}
prop_names = new String[l.size()];
@@ -282,10 +287,10 @@ public class kelondroAttrSeq {
// parse sequence definition:
if (seqs.startsWith("*")) seqs = seqs.substring(1);
- l = new ArrayList<kelondroColumn>();
+ l = new ArrayList<Column>();
st = new StringTokenizer(seqs, ",");
while (st.hasMoreTokens()) {
- a = new kelondroColumn(st.nextToken());
+ a = new Column(st.nextToken());
l.add(a);
}
seq_names = new String[l.size()];
@@ -313,7 +318,7 @@ public class kelondroAttrSeq {
rowdef.append('-');
rowdef.append(seq_len[i]);
}
- seqrow = new kelondroRow(new String(rowdef), null, 0);
+ seqrow = new Row(new String(rowdef), null, 0);
}
public String toString() {
@@ -350,7 +355,7 @@ public class kelondroAttrSeq {
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], Long.valueOf(kelondroBase64Order.enhancedCoder.decodeLong(attrseq.substring(structure.prop_pos[i], structure.prop_pos[i] + structure.prop_len[i]))));
+ attrs.put(structure.prop_names[i], Long.valueOf(Base64Order.enhancedCoder.decodeLong(attrseq.substring(structure.prop_pos[i], structure.prop_pos[i] + structure.prop_len[i]))));
}
int p = attrseq.indexOf('|') + 1;
@@ -385,8 +390,8 @@ public class kelondroAttrSeq {
return seq;
}
- public kelondroRowCollection getSeqCollection() {
- final kelondroRowCollection collection = new kelondroRowCollection(structure.seqrow, seq.size());
+ public RowCollection getSeqCollection() {
+ final RowCollection collection = new RowCollection(structure.seqrow, seq.size());
final Iterator<String> i = seq.iterator();
while (i.hasNext()) {
collection.addUnique(structure.seqrow.newEntry(i.next().getBytes()));
@@ -408,7 +413,7 @@ public class kelondroAttrSeq {
Long val;
for (int i = 0; i < structure.prop_names.length; i++) {
val = attrs.get(structure.prop_names[i]);
- sb.append(kelondroBase64Order.enhancedCoder.encodeLongSmart((val == null) ? 0 : val.longValue(), structure.prop_len[i]));
+ sb.append(Base64Order.enhancedCoder.encodeLongSmart((val == null) ? 0 : val.longValue(), structure.prop_len[i]));
}
sb.append('|');
final Iterator<String> q = seq.iterator();
@@ -430,7 +435,7 @@ public class kelondroAttrSeq {
private static boolean shortmemstate = false;
private static boolean shortmem() {
if ((cc % 300) == 0) {
- shortmemstate = (kelondroMemory.available() < 20000000L);
+ shortmemstate = (MemoryControl.available() < 20000000L);
}
return shortmemstate;
}
diff --git a/source/de/anomic/kelondro/kelondroBLOB.java b/source/de/anomic/kelondro/kelondroBLOB.java
index ebbdf4fbb..4ed724af4 100644
--- a/source/de/anomic/kelondro/kelondroBLOB.java
+++ b/source/de/anomic/kelondro/kelondroBLOB.java
@@ -28,6 +28,8 @@ package de.anomic.kelondro;
import java.io.IOException;
+import de.anomic.kelondro.coding.ByteOrder;
+
public interface kelondroBLOB {
/**
@@ -46,7 +48,7 @@ public interface kelondroBLOB {
* return the underlying odering
* @return
*/
- public kelondroByteOrder ordering();
+ public ByteOrder ordering();
/**
* clears the content of the database
diff --git a/source/de/anomic/kelondro/kelondroBLOBArray.java b/source/de/anomic/kelondro/kelondroBLOBArray.java
index 41c9ffdd9..6758a0d96 100755
--- a/source/de/anomic/kelondro/kelondroBLOBArray.java
+++ b/source/de/anomic/kelondro/kelondroBLOBArray.java
@@ -36,6 +36,10 @@ import java.util.List;
import java.util.TreeMap;
import java.util.concurrent.CopyOnWriteArrayList;
+import de.anomic.kelondro.coding.ByteOrder;
+import de.anomic.kelondro.coding.DateFormatter;
+import de.anomic.kelondro.coding.NaturalOrder;
+
public class kelondroBLOBArray implements kelondroBLOB {
/*
@@ -55,7 +59,7 @@ public class kelondroBLOBArray implements kelondroBLOB {
public static final long oneGigabyte = 1024 * 1024 * 1024;
private int keylength;
- private kelondroByteOrder ordering;
+ private ByteOrder ordering;
private File heapLocation;
private long fileAgeLimit;
private long fileSizeLimit;
@@ -69,7 +73,7 @@ public class kelondroBLOBArray implements kelondroBLOB {
final File heapLocation,
final String blobSalt,
final int keylength,
- final kelondroByteOrder ordering,
+ final ByteOrder ordering,
final int buffersize) throws IOException {
this.keylength = keylength;
this.blobSalt = blobSalt;
@@ -99,7 +103,7 @@ public class kelondroBLOBArray implements kelondroBLOB {
for (int i = 0; i < files.length; i++) {
if (files[i].length() >= 19 && files[i].endsWith(".blob")) {
try {
- d = kelondroDate.parseShortSecond(files[i].substring(0, 14));
+ d = DateFormatter.parseShortSecond(files[i].substring(0, 14));
time = d.getTime();
if (time > maxtime) maxtime = time;
} catch (ParseException e) {continue;}
@@ -108,7 +112,7 @@ public class kelondroBLOBArray implements kelondroBLOB {
for (int i = 0; i < files.length; i++) {
if (files[i].length() >= 19 && files[i].endsWith(".blob")) {
try {
- d = kelondroDate.parseShortSecond(files[i].substring(0, 14));
+ d = DateFormatter.parseShortSecond(files[i].substring(0, 14));
f = new File(heapLocation, files[i]);
time = d.getTime();
oneBlob = (time == maxtime && buffersize > 0) ? new kelondroBLOBHeap(f, keylength, ordering, buffersize) : new kelondroBLOBHeapModifier(f, keylength, ordering);
@@ -133,7 +137,7 @@ public class kelondroBLOBArray implements kelondroBLOB {
public void mountBLOB(File location) throws IOException {
Date d;
try {
- d = kelondroDate.parseShortSecond(location.getName().substring(0, 14));
+ d = DateFormatter.parseShortSecond(location.getName().substring(0, 14));
} catch (ParseException e) {
throw new IOException("date parse problem with file " + location.toString() + ": " + e.getMessage());
}
@@ -176,7 +180,7 @@ public class kelondroBLOBArray implements kelondroBLOB {
* @return
*/
public File newBLOB(Date creation) {
- return new File(heapLocation, kelondroDate.formatShortSecond(creation) + "." + blobSalt + ".blob");
+ return new File(heapLocation, DateFormatter.formatShortSecond(creation) + "." + blobSalt + ".blob");
}
public String name() {
@@ -223,7 +227,7 @@ public class kelondroBLOBArray implements kelondroBLOB {
return s;
}
- public kelondroByteOrder ordering() {
+ public ByteOrder ordering() {
return this.ordering;
}
@@ -422,7 +426,7 @@ public class kelondroBLOBArray implements kelondroBLOB {
final File f = new File("/Users/admin/blobarraytest");
try {
//f.delete();
- final kelondroBLOBArray heap = new kelondroBLOBArray(f, "test", 12, kelondroNaturalOrder.naturalOrder, 512 * 1024);
+ final kelondroBLOBArray heap = new kelondroBLOBArray(f, "test", 12, NaturalOrder.naturalOrder, 512 * 1024);
heap.put("aaaaaaaaaaaa".getBytes(), "eins zwei drei".getBytes());
heap.put("aaaaaaaaaaab".getBytes(), "vier fuenf sechs".getBytes());
heap.put("aaaaaaaaaaac".getBytes(), "sieben acht neun".getBytes());
diff --git a/source/de/anomic/kelondro/kelondroBLOBCompressor.java b/source/de/anomic/kelondro/kelondroBLOBCompressor.java
index 140a0aec8..c3395607b 100644
--- a/source/de/anomic/kelondro/kelondroBLOBCompressor.java
+++ b/source/de/anomic/kelondro/kelondroBLOBCompressor.java
@@ -37,6 +37,9 @@ import java.util.Map;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
+import de.anomic.kelondro.coding.ByteOrder;
+import de.anomic.kelondro.tools.ByteArray;
+
public class kelondroBLOBCompressor extends Thread implements kelondroBLOB {
static byte[] gzipMagic = {(byte) 'z', (byte) '|'}; // magic for gzip-encoded content
@@ -69,7 +72,7 @@ public class kelondroBLOBCompressor extends Thread implements kelondroBLOB {
this.bufferlength = 0;
}
- public kelondroByteOrder ordering() {
+ public ByteOrder ordering() {
return this.backend.ordering();
}
@@ -121,7 +124,7 @@ public class kelondroBLOBCompressor extends Thread implements kelondroBLOB {
private byte[] decompress(byte[] b) {
// use a magic in the head of the bytes to identify compression type
if (b == null) return null;
- if (kelondroByteArray.equals(b, gzipMagic)) {
+ if (ByteArray.equals(b, gzipMagic)) {
//System.out.print("\\"); // DEBUG
cdr--;
ByteArrayInputStream bais = new ByteArrayInputStream(b);
@@ -145,7 +148,7 @@ public class kelondroBLOBCompressor extends Thread implements kelondroBLOB {
e.printStackTrace();
return null;
}
- } else if (kelondroByteArray.equals(b, plainMagic)) {
+ } else if (ByteArray.equals(b, plainMagic)) {
System.out.print("-"); // DEBUG
byte[] r = new byte[b.length - 2];
System.arraycopy(b, 2, r, 0, b.length - 2);
diff --git a/source/de/anomic/kelondro/kelondroBLOBHeap.java b/source/de/anomic/kelondro/kelondroBLOBHeap.java
index 4a4ac604c..e5f0f116a 100755
--- a/source/de/anomic/kelondro/kelondroBLOBHeap.java
+++ b/source/de/anomic/kelondro/kelondroBLOBHeap.java
@@ -32,6 +32,10 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+import de.anomic.kelondro.coding.ByteOrder;
+import de.anomic.kelondro.coding.NaturalOrder;
+import de.anomic.kelondro.io.AbstractRandomAccess;
+
public final class kelondroBLOBHeap extends kelondroBLOBHeapModifier implements kelondroBLOB {
private HashMap<String, byte[]> buffer; // a write buffer to limit IO to the file; attention: Maps cannot use byte[] as key
@@ -71,7 +75,7 @@ public final class kelondroBLOBHeap extends kelondroBLOBHeapModifier implements
public kelondroBLOBHeap(
final File heapFile,
final int keylength,
- final kelondroByteOrder ordering,
+ final ByteOrder ordering,
int buffermax) throws IOException {
super(heapFile, keylength, ordering);
this.buffermax = buffermax;
@@ -163,7 +167,7 @@ public final class kelondroBLOBHeap extends kelondroBLOBHeapModifier implements
key = entry.getKey().getBytes();
blob = entry.getValue();
index.putl(key, posFile);
- b = kelondroAbstractRA.int2array(key.length + blob.length);
+ b = AbstractRandomAccess.int2array(key.length + blob.length);
assert b.length == 4;
System.arraycopy(b, 0, ba, posBuffer, 4);
System.arraycopy(key, 0, ba, posBuffer + 4, key.length);
@@ -402,7 +406,7 @@ public final class kelondroBLOBHeap extends kelondroBLOBHeapModifier implements
final File f = new File("/Users/admin/blobtest.heap");
try {
//f.delete();
- final kelondroBLOBHeap heap = new kelondroBLOBHeap(f, 12, kelondroNaturalOrder.naturalOrder, 1024 * 512);
+ final kelondroBLOBHeap heap = new kelondroBLOBHeap(f, 12, NaturalOrder.naturalOrder, 1024 * 512);
heap.put("aaaaaaaaaaaa".getBytes(), "eins zwei drei".getBytes());
heap.put("aaaaaaaaaaab".getBytes(), "vier fuenf sechs".getBytes());
heap.put("aaaaaaaaaaac".getBytes(), "sieben acht neun".getBytes());
@@ -435,7 +439,7 @@ public final class kelondroBLOBHeap extends kelondroBLOBHeapModifier implements
final File f = new File("/Users/admin/blobtest.heap");
try {
//f.delete();
- final kelondroMap heap = new kelondroMap(new kelondroBLOBHeap(f, 12, kelondroNaturalOrder.naturalOrder, 1024 * 512), 500);
+ final kelondroMap heap = new kelondroMap(new kelondroBLOBHeap(f, 12, NaturalOrder.naturalOrder, 1024 * 512), 500);
heap.put("aaaaaaaaaaaa", map("aaaaaaaaaaaa", "eins zwei drei"));
heap.put("aaaaaaaaaaab", map("aaaaaaaaaaab", "vier fuenf sechs"));
heap.put("aaaaaaaaaaac", map("aaaaaaaaaaac", "sieben acht neun"));
diff --git a/source/de/anomic/kelondro/kelondroBLOBHeapModifier.java b/source/de/anomic/kelondro/kelondroBLOBHeapModifier.java
index a6b8738f6..c770378b8 100644
--- a/source/de/anomic/kelondro/kelondroBLOBHeapModifier.java
+++ b/source/de/anomic/kelondro/kelondroBLOBHeapModifier.java
@@ -30,6 +30,9 @@ import java.util.Iterator;
import java.util.Map;
import java.util.SortedMap;
+import de.anomic.kelondro.coding.ByteOrder;
+import de.anomic.kelondro.io.CachedRandomAccess;
+import de.anomic.kelondro.tools.MemoryControl;
import de.anomic.server.logging.serverLog;
public class kelondroBLOBHeapModifier extends kelondroBLOBHeapReader implements kelondroBLOB {
@@ -46,7 +49,7 @@ public class kelondroBLOBHeapModifier extends kelondroBLOBHeapReader implements
* @param ordering
* @throws IOException
*/
- public kelondroBLOBHeapModifier(final File heapFile, final int keylength, final kelondroByteOrder ordering) throws IOException {
+ public kelondroBLOBHeapModifier(final File heapFile, final int keylength, final ByteOrder ordering) throws IOException {
super(heapFile, keylength, ordering);
mergeFreeEntries();
}
@@ -93,7 +96,7 @@ public class kelondroBLOBHeapModifier extends kelondroBLOBHeapReader implements
e.printStackTrace();
}
this.heapFile.delete();
- this.file = new kelondroCachedFileRA(heapFile);
+ this.file = new CachedRandomAccess(heapFile);
}
/**
@@ -284,8 +287,8 @@ public class kelondroBLOBHeapModifier extends kelondroBLOBHeapReader implements
// access the file and read the container
file.seek(pos);
final int len = file.readInt() - index.row().primaryKeyLength;
- if (kelondroMemory.available() < len) {
- if (!kelondroMemory.request(len, true)) return 0; // not enough memory available for this blob
+ if (MemoryControl.available() < len) {
+ if (!MemoryControl.request(len, true)) return 0; // not enough memory available for this blob
}
// read the key
diff --git a/source/de/anomic/kelondro/kelondroBLOBHeapReader.java b/source/de/anomic/kelondro/kelondroBLOBHeapReader.java
index de41ad8de..cf4f99383 100644
--- a/source/de/anomic/kelondro/kelondroBLOBHeapReader.java
+++ b/source/de/anomic/kelondro/kelondroBLOBHeapReader.java
@@ -34,27 +34,31 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ExecutionException;
+import de.anomic.kelondro.coding.ByteOrder;
+import de.anomic.kelondro.index.BytesLongMap;
+import de.anomic.kelondro.io.CachedRandomAccess;
+import de.anomic.kelondro.tools.MemoryControl;
import de.anomic.server.logging.serverLog;
public class kelondroBLOBHeapReader {
protected int keylength; // the length of the primary key
- protected kelondroBytesLongMap index; // key/seek relation for used records
+ protected BytesLongMap index; // key/seek relation for used records
protected kelondroBLOBGap free; // set of {seek, size} pairs denoting space and position of free records
protected final File heapFile; // the file of the heap
- protected final kelondroByteOrder ordering; // the ordering on keys
- protected kelondroCachedFileRA file; // a random access to the file
+ protected final ByteOrder ordering; // the ordering on keys
+ protected CachedRandomAccess file; // a random access to the file
public kelondroBLOBHeapReader(
final File heapFile,
final int keylength,
- final kelondroByteOrder ordering) throws IOException {
+ final ByteOrder ordering) throws IOException {
this.ordering = ordering;
this.heapFile = heapFile;
this.keylength = keylength;
this.index = null; // will be created as result of initialization process
this.free = null; // will be initialized later depending on existing idx/gap file
- this.file = new kelondroCachedFileRA(heapFile);
+ this.file = new CachedRandomAccess(heapFile);
// read or initialize the index
if (initIndexReadDump(heapFile)) {
@@ -100,7 +104,7 @@ public class kelondroBLOBHeapReader {
// there is an index and a gap file:
// read the index file:
try {
- this.index = new kelondroBytesLongMap(this.keylength, this.ordering, fif);
+ this.index = new BytesLongMap(this.keylength, this.ordering, fif);
} catch (IOException e) {
e.printStackTrace();
return false;
@@ -126,7 +130,7 @@ public class kelondroBLOBHeapReader {
// this initializes the this.index object by reading positions from the heap file
this.free = new kelondroBLOBGap();
- kelondroBytesLongMap.initDataConsumer indexready = kelondroBytesLongMap.asynchronusInitializer(keylength, this.ordering, 0, Math.max(10, (int) (Runtime.getRuntime().freeMemory() / (10 * 1024 * 1024))));
+ BytesLongMap.initDataConsumer indexready = BytesLongMap.asynchronusInitializer(keylength, this.ordering, 0, Math.max(10, (int) (Runtime.getRuntime().freeMemory() / (10 * 1024 * 1024))));
byte[] key = new byte[keylength];
int reclen;
long seek = 0;
@@ -211,7 +215,7 @@ public class kelondroBLOBHeapReader {
}
}
- public kelondroByteOrder ordering() {
+ public ByteOrder ordering() {
return this.ordering;
}
@@ -231,8 +235,8 @@ public class kelondroBLOBHeapReader {
// access the file and read the container
file.seek(pos);
final int len = file.readInt() - index.row().primaryKeyLength;
- if (kelondroMemory.available() < len) {
- if (!kelondroMemory.request(len, true)) return null; // not enough memory available for this blob
+ if (MemoryControl.available() < len) {
+ if (!MemoryControl.request(len, true)) return null; // not enough memory available for this blob
}
// read the key
diff --git a/source/de/anomic/kelondro/kelondroBLOBHeapWriter.java b/source/de/anomic/kelondro/kelondroBLOBHeapWriter.java
index b791ec7bb..6f57aae94 100644
--- a/source/de/anomic/kelondro/kelondroBLOBHeapWriter.java
+++ b/source/de/anomic/kelondro/kelondroBLOBHeapWriter.java
@@ -30,12 +30,15 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
+import de.anomic.kelondro.coding.ByteOrder;
+import de.anomic.kelondro.coding.Digest;
+import de.anomic.kelondro.index.BytesLongMap;
import de.anomic.server.logging.serverLog;
public final class kelondroBLOBHeapWriter {
private int keylength; // the length of the primary key
- private kelondroBytesLongMap index; // key/seek relation for used records
+ private BytesLongMap index; // key/seek relation for used records
private final File heapFile; // the file of the heap
private DataOutputStream os; // the output stream where the BLOB is written
private long seek; // the current write position
@@ -65,10 +68,10 @@ public final class kelondroBLOBHeapWriter {
* @param ordering
* @throws IOException
*/
- public kelondroBLOBHeapWriter(final File heapFile, final int keylength, final kelondroByteOrder ordering) throws IOException {
+ public kelondroBLOBHeapWriter(final File heapFile, final int keylength, final ByteOrder ordering) throws IOException {
this.heapFile = heapFile;
this.keylength = keylength;
- this.index = new kelondroBytesLongMap(keylength, ordering, 10);
+ this.index = new BytesLongMap(keylength, ordering, 10);
this.os = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(heapFile), 1024 * 1024));
this.seek = 0;
}
@@ -103,7 +106,7 @@ public final class kelondroBLOBHeapWriter {
}
protected static String fingerprintFileHash(File f) {
- return kelondroDigest.fastFingerprintB64(f, false).substring(0, 12);
+ return Digest.fastFingerprintB64(f, false).substring(0, 12);
}
public static void deleteAllFingerprints(File f) {
diff --git a/source/de/anomic/kelondro/kelondroBLOBTree.java b/source/de/anomic/kelondro/kelondroBLOBTree.java
index 85fbd5fbd..d5fff0c3e 100644
--- a/source/de/anomic/kelondro/kelondroBLOBTree.java
+++ b/source/de/anomic/kelondro/kelondroBLOBTree.java
@@ -41,6 +41,13 @@ import java.io.File;
import java.io.IOException;
import java.util.Iterator;
+import de.anomic.kelondro.coding.ByteOrder;
+import de.anomic.kelondro.coding.NaturalOrder;
+import de.anomic.kelondro.index.Row;
+import de.anomic.kelondro.index.ObjectIndex;
+import de.anomic.kelondro.io.AbstractRandomAccess;
+import de.anomic.kelondro.io.RandomAccessInterface;
+
public class kelondroBLOBTree implements kelondroBLOB {
private static final int counterlen = 8;
@@ -50,9 +57,9 @@ public class kelondroBLOBTree implements kelondroBLOB {
private final int reclen;
//private int segmentCount;
private final char fillChar;
- private final kelondroIndex index;
+ private final ObjectIndex index;
private kelondroObjectBuffer buffer;
- private final kelondroRow rowdef;
+ private final Row rowdef;
private File file;
/**
@@ -60,11 +67,11 @@ public class kelondroBLOBTree implements kelondroBLOB {
*/
@Deprecated
public kelondroBLOBTree(final File file, final boolean useNodeCache, final boolean useObjectCache, final int key,
- final int nodesize, final char fillChar, final kelondroByteOrder objectOrder, final boolean usetree, final boolean writebuffer, final boolean resetOnFail) {
+ final int nodesize, final char fillChar, final ByteOrder objectOrder, final boolean usetree, final boolean writebuffer, final boolean resetOnFail) {
// creates or opens a dynamic tree
- rowdef = new kelondroRow("byte[] key-" + (key + counterlen) + ", byte[] node-" + nodesize, objectOrder, 0);
+ rowdef = new Row("byte[] key-" + (key + counterlen) + ", byte[] node-" + nodesize, objectOrder, 0);
this.file = file;
- kelondroIndex fbi;
+ ObjectIndex fbi;
if (usetree) {
try {
fbi = new kelondroTree(file, useNodeCache, 0, rowdef, 1, 8);
@@ -94,7 +101,7 @@ public class kelondroBLOBTree implements kelondroBLOB {
fbi = new kelondroEcoTable(file, rowdef, kelondroEcoTable.tailCacheUsageAuto, EcoFSBufferSize, 0);
}
}
- this.index = ((useObjectCache) && (!(fbi instanceof kelondroEcoTable))) ? (kelondroIndex) new kelondroCache(fbi) : fbi;
+ this.index = ((useObjectCache) && (!(fbi instanceof kelondroEcoTable))) ? (ObjectIndex) new kelondroCache(fbi) : fbi;
this.keylen = key;
this.reclen = nodesize;
this.fillChar = fillChar;
@@ -147,7 +154,7 @@ public class kelondroBLOBTree implements kelondroBLOB {
return this.keylen;
}
- public kelondroByteOrder ordering() {
+ public ByteOrder ordering() {
return this.rowdef.objectOrder;
}
@@ -177,10 +184,10 @@ public class kelondroBLOBTree implements kelondroBLOB {
public class keyIterator implements kelondroCloneableIterator<byte[]> {
// the iterator iterates all keys
- kelondroCloneableIterator<kelondroRow.Entry> ri;
+ kelondroCloneableIterator<Row.Entry> ri;
String nextKey;
- public keyIterator(final kelondroCloneableIterator<kelondroRow.Entry> iter) {
+ public keyIterator(final kelondroCloneableIterator<Row.Entry> iter) {
ri = iter;
nextKey = n();
}
@@ -208,7 +215,7 @@ public class kelondroBLOBTree implements kelondroBLOB {
String k;
String v;
int c;
- kelondroRow.Entry nt;
+ Row.Entry nt;
while (ri.hasNext()) {
nt = ri.next();
if (nt == null) return null;
@@ -247,7 +254,7 @@ public class kelondroBLOBTree implements kelondroBLOB {
if (buffered != null) return buffered;
// read from db
- final kelondroRow.Entry result = index.get(key);
+ final Row.Entry result = index.get(key);
if (result == null) return null;
// return result
@@ -273,7 +280,7 @@ public class kelondroBLOBTree implements kelondroBLOB {
}
public synchronized byte[] get(final byte[] key) throws IOException {
- final kelondroRA ra = getRA(new String(key));
+ final RandomAccessInterface ra = getRA(new String(key));
if (ra == null) return null;
return ra.readFully();
}
@@ -400,13 +407,13 @@ public class kelondroBLOBTree implements kelondroBLOB {
}
}
- public synchronized kelondroRA getRA(final String filekey) {
+ public synchronized RandomAccessInterface getRA(final String filekey) {
// this returns always a RARecord, even if no existed bevore
//return new kelondroBufferedRA(new RARecord(filekey), 512, 0);
return new RARecord(filekey);
}
- public class RARecord extends kelondroAbstractRA implements kelondroRA {
+ public class RARecord extends AbstractRandomAccess implements RandomAccessInterface {
int seekpos = 0;
int compLength = -1;
@@ -478,7 +485,7 @@ public class kelondroBLOBTree implements kelondroBLOB {
if (args.length == 1) {
// open a db and list keys
try {
- final kelondroBLOB kd = new kelondroBLOBTree(new File(args[0]), true, true, 4 ,100, '_', kelondroNaturalOrder.naturalOrder, true, false, false);
+ final kelondroBLOB kd = new kelondroBLOBTree(new File(args[0]), true, true, 4 ,100, '_', NaturalOrder.naturalOrder, true, false, false);
System.out.println(kd.size() + " elements in DB");
final Iterator<byte[]> i = kd.keys(true, false);
while (i.hasNext())
diff --git a/source/de/anomic/kelondro/kelondroCache.java b/source/de/anomic/kelondro/kelondroCache.java
index 247930133..4f4798905 100644
--- a/source/de/anomic/kelondro/kelondroCache.java
+++ b/source/de/anomic/kelondro/kelondroCache.java
@@ -36,9 +36,15 @@ import java.util.List;
import java.util.Map;
import java.util.TreeMap;
-import de.anomic.kelondro.kelondroRow.Entry;
+import de.anomic.kelondro.index.Column;
+import de.anomic.kelondro.index.Row;
+import de.anomic.kelondro.index.RowCollection;
+import de.anomic.kelondro.index.RowSet;
+import de.anomic.kelondro.index.ObjectIndex;
+import de.anomic.kelondro.index.Row.Entry;
+import de.anomic.kelondro.tools.MemoryControl;
-public class kelondroCache implements kelondroIndex {
+public class kelondroCache implements ObjectIndex {
// this is a combined read cache and write buffer
// we maintain four tables:
@@ -54,23 +60,23 @@ public class kelondroCache implements kelondroIndex {
private static long memStartShrink = 8 * 1024 * 1024; // a limit for the node cache to start with shrinking if less than this memory amount is available
// class objects
- private kelondroRowSet readHitCache;
- private kelondroRowSet readMissCache;
- private final kelondroIndex index;
- private kelondroRow keyrow;
+ private RowSet readHitCache;
+ private RowSet readMissCache;
+ private final ObjectIndex index;
+ private Row keyrow;
private int readHit, readMiss, writeUnique, writeDouble, cacheDelete, cacheFlush;
private int hasnotHit, hasnotMiss, hasnotUnique, hasnotDouble, hasnotDelete;
- public kelondroCache(final kelondroIndex backupIndex) {
+ public kelondroCache(final ObjectIndex backupIndex) {
this.index = backupIndex;
init();
objectTracker.put(backupIndex.filename(), this);
}
private void init() {
- this.keyrow = new kelondroRow(new kelondroColumn[]{index.row().column(index.row().primaryKeyIndex)}, index.row().objectOrder, 0);
- this.readHitCache = new kelondroRowSet(index.row(), 0);
- this.readMissCache = new kelondroRowSet(this.keyrow, 0);
+ this.keyrow = new Row(new Column[]{index.row().column(index.row().primaryKeyIndex)}, index.row().objectOrder, 0);
+ this.readHitCache = new RowSet(index.row(), 0);
+ this.readMissCache = new RowSet(this.keyrow, 0);
this.readHit = 0;
this.readMiss = 0;
this.writeUnique = 0;
@@ -123,7 +129,7 @@ public class kelondroCache implements kelondroIndex {
final 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)));
+ map.put("objectHitMem", (readHitCache == null) ? "0" : Integer.toString((int) (readHitCache.rowdef.objectsize * readHitCache.size() * RowCollection.growfactor)));
map.put("objectHitCacheReadHit", Integer.toString(readHit));
map.put("objectHitCacheReadMiss", Integer.toString(readMiss));
map.put("objectHitCacheWriteUnique", Integer.toString(writeUnique));
@@ -133,7 +139,7 @@ public class kelondroCache implements kelondroIndex {
map.put("objectMissChunkSize", (readMissCache == null) ? "0" : Integer.toString(readMissCache.rowdef.objectsize));
map.put("objectMissCacheCount", (readMissCache == null) ? "0" : Integer.toString(readMissCache.size()));
- map.put("objectMissMem", (readMissCache == null) ? "0" : Integer.toString((int) (readMissCache.rowdef.objectsize * readMissCache.size() * kelondroRowCollection.growfactor)));
+ map.put("objectMissMem", (readMissCache == null) ? "0" : Integer.toString((int) (readMissCache.rowdef.objectsize * readMissCache.size() * RowCollection.growfactor)));
map.put("objectMissCacheReadHit", Integer.toString(hasnotHit));
map.put("objectMissCacheReadMiss", Integer.toString(hasnotMiss));
map.put("objectMissCacheWriteUnique", Integer.toString(hasnotUnique));
@@ -146,7 +152,7 @@ public class kelondroCache implements kelondroIndex {
}
private int cacheGrowStatus() {
- return kelondroCachedRecords.cacheGrowStatus(kelondroMemory.available(), memStopGrow, memStartShrink);
+ return kelondroCachedRecords.cacheGrowStatus(MemoryControl.available(), memStopGrow, memStartShrink);
}
private boolean checkMissSpace() {
@@ -238,14 +244,14 @@ public class kelondroCache implements kelondroIndex {
// learn from result
if (entry == null) {
if ((checkMissSpace()) && (readMissCache != null)) {
- final kelondroRow.Entry dummy = readMissCache.put(readMissCache.row().newEntry(key));
+ final Row.Entry dummy = readMissCache.put(readMissCache.row().newEntry(key));
if (dummy == null) this.hasnotUnique++; else this.hasnotDouble++;
}
return null;
}
if ((checkHitSpace()) && (readHitCache != null)) {
- final kelondroRow.Entry dummy = readHitCache.put(entry);
+ final Row.Entry dummy = readHitCache.put(entry);
if (dummy == null) this.writeUnique++; else this.writeDouble++;
}
return entry;
@@ -276,7 +282,7 @@ public class kelondroCache implements kelondroIndex {
// the entry does not exist before
index.put(row); // write to backend
if (readHitCache != null) {
- final kelondroRow.Entry dummy = readHitCache.put(row); // learn that entry
+ final Row.Entry dummy = readHitCache.put(row); // learn that entry
if (dummy == null) this.writeUnique++; else this.writeDouble++;
}
return null;
@@ -292,7 +298,7 @@ public class kelondroCache implements kelondroIndex {
// write directly to backend index
index.put(row);
// learn from situation
- final kelondroRow.Entry dummy = readHitCache.put(row); // overwrite old entry
+ final Row.Entry dummy = readHitCache.put(row); // overwrite old entry
if (dummy == null) this.writeUnique++; else this.writeDouble++;
return entry;
}
@@ -301,7 +307,7 @@ public class kelondroCache implements kelondroIndex {
// the worst case: we must write to the back-end directly
entry = index.put(row);
if (readHitCache != null) {
- final kelondroRow.Entry dummy = readHitCache.put(row); // learn that entry
+ final Row.Entry dummy = readHitCache.put(row); // learn that entry
if (dummy == null) this.writeUnique++; else this.writeDouble++;
}
return entry;
@@ -328,7 +334,7 @@ public class kelondroCache implements kelondroIndex {
// the entry does not exist before
index.addUnique(row); // write to backend
if (readHitCache != null) {
- final kelondroRow.Entry dummy = readHitCache.put(row); // learn that entry
+ final Row.Entry dummy = readHitCache.put(row); // learn that entry
if (dummy == null) this.writeUnique++; else this.writeDouble++;
}
return;
@@ -337,7 +343,7 @@ public class kelondroCache implements kelondroIndex {
// the worst case: we must write to the back-end directly
index.addUnique(row);
if (readHitCache != null) {
- final kelondroRow.Entry dummy = readHitCache.put(row); // learn that entry
+ final Row.Entry dummy = readHitCache.put(row); // learn that entry
if (dummy == null) this.writeUnique++; else this.writeDouble++;
}
}
@@ -363,7 +369,7 @@ public class kelondroCache implements kelondroIndex {
// the worst case: we must write to the backend directly
index.addUnique(row);
if (readHitCache != null) {
- final kelondroRow.Entry dummy = readHitCache.put(row); // learn that entry
+ final Row.Entry dummy = readHitCache.put(row); // learn that entry
if (dummy == null) this.writeUnique++; else this.writeDouble++;
}
}
@@ -373,7 +379,7 @@ public class kelondroCache implements kelondroIndex {
while (i.hasNext()) addUnique(i.next());
}
- public synchronized ArrayList<kelondroRowCollection> removeDoubles() throws IOException {
+ public synchronized ArrayList<RowCollection> removeDoubles() throws IOException {
return index.removeDoubles();
// todo: remove reported entries from the cache!!!
}
@@ -384,7 +390,7 @@ public class kelondroCache implements kelondroIndex {
// add entry to miss-cache
if (readMissCache != null) {
// set the miss cache; if there was already an entry we know that the return value must be null
- final kelondroRow.Entry dummy = readMissCache.put(readMissCache.row().newEntry(key));
+ final Row.Entry dummy = readMissCache.put(readMissCache.row().newEntry(key));
if (dummy == null) {
this.hasnotUnique++;
} else {
@@ -415,17 +421,17 @@ public class kelondroCache implements kelondroIndex {
if (entry == null) return null;
final byte[] key = entry.getPrimaryKeyBytes();
if (readMissCache != null) {
- final kelondroRow.Entry dummy = readMissCache.put(readMissCache.row().newEntry(key));
+ final Row.Entry dummy = readMissCache.put(readMissCache.row().newEntry(key));
if (dummy == null) this.hasnotUnique++; else this.hasnotDouble++;
}
if (readHitCache != null) {
- final kelondroRow.Entry dummy = readHitCache.remove(key);
+ final Row.Entry dummy = readHitCache.remove(key);
if (dummy != null) this.cacheDelete++;
}
return entry;
}
- public synchronized kelondroRow row() {
+ public synchronized Row row() {
return index.row();
}
@@ -433,7 +439,7 @@ public class kelondroCache implements kelondroIndex {
return index.keys(up, firstKey);
}
- public synchronized kelondroCloneableIterator<kelondroRow.Entry> rows(final boolean up, final byte[] firstKey) throws IOException {
+ public synchronized kelondroCloneableIterator<Row.Entry> rows(final boolean up, final byte[] firstKey) throws IOException {
return index.rows(up, firstKey);
}
diff --git a/source/de/anomic/kelondro/kelondroCachedRecords.java b/source/de/anomic/kelondro/kelondroCachedRecords.java
index d457a4bd9..043644538 100644
--- a/source/de/anomic/kelondro/kelondroCachedRecords.java
+++ b/source/de/anomic/kelondro/kelondroCachedRecords.java
@@ -33,7 +33,12 @@ import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;
-public class kelondroCachedRecords extends kelondroAbstractRecords implements kelondroRecords {
+import de.anomic.kelondro.index.Row;
+import de.anomic.kelondro.io.RandomAccessInterface;
+import de.anomic.kelondro.io.RandomAccessRecords;
+import de.anomic.kelondro.tools.MemoryControl;
+
+public class kelondroCachedRecords extends kelondroAbstractRecords implements RandomAccessRecords {
// memory calculation
private static final int element_in_cache = 4; // for kelondroCollectionObjectMap: 4; for HashMap: 52
@@ -56,16 +61,16 @@ public class kelondroCachedRecords extends kelondroAbstractRecords implements ke
public kelondroCachedRecords(
final File file, final boolean useNodeCache, final long preloadTime,
final short ohbytec, final short ohhandlec,
- final kelondroRow rowdef, final int FHandles, final int txtProps, final int txtPropWidth) throws IOException {
+ final Row rowdef, final int FHandles, final int txtProps, final int txtPropWidth) throws IOException {
super(file, useNodeCache, ohbytec, ohhandlec, rowdef, FHandles, txtProps, txtPropWidth);
initCache(useNodeCache, preloadTime);
if (useNodeCache) recordTracker.put(this.filename, this);
}
public kelondroCachedRecords(
- final kelondroRA ra, final String filename, final boolean useNodeCache, final long preloadTime,
+ final RandomAccessInterface ra, final String filename, final boolean useNodeCache, final long preloadTime,
final short ohbytec, final short ohhandlec,
- final kelondroRow rowdef, final int FHandles, final int txtProps, final int txtPropWidth,
+ final Row rowdef, final int FHandles, final int txtProps, final int txtPropWidth,
final boolean exitOnFail) {
super(ra, filename, useNodeCache, ohbytec, ohhandlec, rowdef, FHandles, txtProps, txtPropWidth, exitOnFail);
initCache(useNodeCache, preloadTime);
@@ -73,7 +78,7 @@ public class kelondroCachedRecords extends kelondroAbstractRecords implements ke
}
public kelondroCachedRecords(
- final kelondroRA ra, final String filename, final boolean useNodeCache, final long preloadTime) throws IOException{
+ final RandomAccessInterface ra, final String filename, final boolean useNodeCache, final long preloadTime) throws IOException{
super(ra, filename, useNodeCache);
initCache(useNodeCache, preloadTime);
if (useNodeCache) recordTracker.put(this.filename, this);
@@ -114,7 +119,7 @@ public class kelondroCachedRecords extends kelondroAbstractRecords implements ke
}
int cacheGrowStatus() {
- final long available = kelondroMemory.available();
+ final long available = MemoryControl.available();
if ((cacheHeaders != null) && (available < cacheHeaders.memoryNeededForGrow())) return 0;
return cacheGrowStatus(available, memStopGrow, memStartShrink);
}
@@ -126,10 +131,10 @@ public class kelondroCachedRecords extends kelondroAbstractRecords implements ke
// 2: cache is allowed to grow and must not shrink
if (available > stopGrow) return 2;
if (available > startShrink) {
- kelondroMemory.gc(30000, "kelendroCacheRecords.cacheGrowStatus(...) 1"); // thq
+ MemoryControl.gc(30000, "kelendroCacheRecords.cacheGrowStatus(...) 1"); // thq
return 1;
}
- kelondroMemory.gc(3000, "kelendroCacheRecords.cacheGrowStatus(...) 0"); // thq
+ MemoryControl.gc(3000, "kelendroCacheRecords.cacheGrowStatus(...) 0"); // thq
return 0;
}
@@ -205,8 +210,8 @@ public class kelondroCachedRecords extends kelondroAbstractRecords implements ke
} else {
System.out.println("### cache report: " + cacheHeaders.size() + " entries");
- final Iterator<kelondroRow.Entry> i = cacheHeaders.rows();
- kelondroRow.Entry entry;
+ final Iterator<Row.Entry> i = cacheHeaders.rows();
+ Row.Entry entry;
while (i.hasNext()) {
entry = i.next();
@@ -578,7 +583,7 @@ public class kelondroCachedRecords extends kelondroAbstractRecords implements ke
h = getOHHandle(i);
if (h == null) s = s + ":hNULL"; else s = s + ":h" + h.toString();
}
- final kelondroRow.Entry content = row().newEntry(getValueRow());
+ final Row.Entry content = row().newEntry(getValueRow());
for (int i = 0; i < row().columns(); i++) s = s + ":" + ((content.empty(i)) ? "NULL" : content.getColString(i, "UTF-8").trim());
} catch (final IOException e) {
s = s + ":***LOAD ERROR***:" + e.getMessage();
diff --git a/source/de/anomic/kelondro/kelondroCollectionIndex.java b/source/de/anomic/kelondro/kelondroCollectionIndex.java
index 8e4932166..fdd0e1a72 100644
--- a/source/de/anomic/kelondro/kelondroCollectionIndex.java
+++ b/source/de/anomic/kelondro/kelondroCollectionIndex.java
@@ -41,7 +41,16 @@ import java.util.Set;
import java.util.TimeZone;
import de.anomic.index.indexContainer;
-import de.anomic.kelondro.kelondroRow.EntryIndex;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.ByteOrder;
+import de.anomic.kelondro.coding.Digest;
+import de.anomic.kelondro.coding.NaturalOrder;
+import de.anomic.kelondro.index.Row;
+import de.anomic.kelondro.index.RowCollection;
+import de.anomic.kelondro.index.RowSet;
+import de.anomic.kelondro.index.ObjectIndex;
+import de.anomic.kelondro.index.Row.EntryIndex;
+import de.anomic.kelondro.tools.MemoryControl;
import de.anomic.server.serverFileUtils;
import de.anomic.server.logging.serverLog;
import de.anomic.yacy.yacyURL;
@@ -53,14 +62,14 @@ public class kelondroCollectionIndex {
private static final int EcoFSBufferSize = 1000;
private static final int errorLimit = 500; // if the index exceeds this number of errors, it is re-built next time the application starts
- private kelondroIndex index;
+ private ObjectIndex index;
private final int keylength;
private final File path;
private final String filenameStub;
private final File commonsPath;
private final int loadfactor;
private Map<String, kelondroFixedWidthArray> arrays; // Map of (partitionNumber"-"chunksize)/kelondroFixedWidthArray - Objects
- private final kelondroRow payloadrow; // definition of the payload (chunks inside the collections)
+ private final Row payloadrow; // definition of the payload (chunks inside the collections)
private final int maxPartitions; // this is the maxmimum number of array files
private int indexErrors; // counter for exceptions when index returned wrong value
@@ -73,8 +82,8 @@ public class kelondroCollectionIndex {
private static final int idx_col_lastread = 6; // a time stamp, update time in days since 1.1.2000
private static final int idx_col_lastwrote = 7; // a time stamp, update time in days since 1.1.2000
- private static kelondroRow indexRow(final int keylength, final kelondroByteOrder payloadOrder) {
- return new kelondroRow(
+ private static Row indexRow(final int keylength, final ByteOrder payloadOrder) {
+ return new Row(
"byte[] key-" + keylength + "," +
"int chunksize-4 {b256}," +
"int chunkcount-4 {b256}," +
@@ -87,7 +96,7 @@ public class kelondroCollectionIndex {
);
}
- public kelondroRow payloadRow() {
+ public Row payloadRow() {
return this.payloadrow;
}
@@ -104,8 +113,8 @@ public class kelondroCollectionIndex {
return new File(path, filenameStub + "." + lf + "." + cs + "." + pn + "." + sn + ".kca"); // kelondro collection array
}
- public kelondroCollectionIndex(final File path, final String filenameStub, final int keyLength, final kelondroByteOrder indexOrder,
- final int loadfactor, final int maxpartitions, final kelondroRow rowdef, boolean useCommons) throws IOException {
+ public kelondroCollectionIndex(final File path, final String filenameStub, final int keyLength, final ByteOrder indexOrder,
+ final int loadfactor, final int maxpartitions, final Row rowdef, boolean useCommons) throws IOException {
// the buffersize is number of bytes that are only used if the kelondroFlexTable is backed up with a kelondroTree
indexErrors = 0;
this.path = path;
@@ -152,12 +161,12 @@ public class kelondroCollectionIndex {
continue;
}
}
- serverLog.logFine("STARTUP", "STARTED INITIALIZATION OF NEW COLLECTION INDEX WITH " + initialSpace + " ENTRIES. THIS WILL TAKE SOME TIME. " + (kelondroMemory.available() / 1024 / 1024) + "MB AVAILABLE.");
- final kelondroRow indexRowdef = indexRow(keyLength, indexOrder);
+ serverLog.logFine("STARTUP", "STARTED INITIALIZATION OF NEW COLLECTION INDEX WITH " + initialSpace + " ENTRIES. THIS WILL TAKE SOME TIME. " + (MemoryControl.available() / 1024 / 1024) + "MB AVAILABLE.");
+ final Row indexRowdef = indexRow(keyLength, indexOrder);
final long necessaryRAM4fullTable = minimumRAM4Eco + (indexRowdef.objectsize + 4) * initialSpace * 3 / 2;
// initialize (new generation) index table from file
- index = new kelondroEcoTable(f, indexRowdef, (kelondroMemory.request(necessaryRAM4fullTable, false)) ? kelondroEcoTable.tailCacheUsageAuto : kelondroEcoTable.tailCacheDenyUsage, EcoFSBufferSize, initialSpace);
+ index = new kelondroEcoTable(f, indexRowdef, (MemoryControl.request(necessaryRAM4fullTable, false)) ? kelondroEcoTable.tailCacheUsageAuto : kelondroEcoTable.tailCacheDenyUsage, EcoFSBufferSize, initialSpace);
// open array files
this.arrays = new HashMap<String, kelondroFixedWidthArray>(); // all entries will be dynamically created with getArray()
@@ -177,13 +186,13 @@ public class kelondroCollectionIndex {
this.index.deleteOnExit();
}
- private void openAllArrayFiles(final boolean indexGeneration, final kelondroByteOrder indexOrder) throws IOException {
+ private void openAllArrayFiles(final boolean indexGeneration, final ByteOrder indexOrder) throws IOException {
final String[] list = this.path.list();
kelondroFixedWidthArray array;
- final kelondroRow irow = indexRow(keylength, indexOrder);
- final int t = kelondroRowCollection.daysSince2000(System.currentTimeMillis());
+ final Row irow = indexRow(keylength, indexOrder);
+ final int t = RowCollection.daysSince2000(System.currentTimeMillis());
for (int i = 0; i < list.length; i++) if (list[i].endsWith(".kca")) {
// open array
@@ -204,8 +213,8 @@ public class kelondroCollectionIndex {
if ((index != null) && (indexGeneration)) {
// loop over all elements in array and create index entry for each row
- kelondroRow.EntryIndex aentry;
- kelondroRow.Entry ientry;
+ Row.EntryIndex aentry;
+ Row.Entry ientry;
final Iterator<EntryIndex> ei = array.contentRows(-1);
byte[] key;
final long start = System.currentTimeMillis();
@@ -219,7 +228,7 @@ public class kelondroCollectionIndex {
ientry = irow.newEntry();
ientry.setCol(idx_col_key, key);
ientry.setCol(idx_col_chunksize, chunksize);
- ientry.setCol(idx_col_chunkcount, kelondroRowCollection.sizeOfExportedCollectionRows(aentry, 1));
+ ientry.setCol(idx_col_chunkcount, RowCollection.sizeOfExportedCollectionRows(aentry, 1));
ientry.setCol(idx_col_clusteridx, (byte) partitionNumber);
ientry.setCol(idx_col_flags, (byte) 0);
ientry.setCol(idx_col_indexpos, aentry.index());
@@ -238,13 +247,13 @@ public class kelondroCollectionIndex {
}
// care for double entries
int partition, maxpartition;
- kelondroRow.Entry maxentry;
+ Row.Entry maxentry;
int doublecount = 0;
- for (final kelondroRowCollection doubleset: index.removeDoubles()) {
+ for (final RowCollection doubleset: index.removeDoubles()) {
// for each entry in doubleset choose one which we want to keep
maxentry = null;
maxpartition = -1;
- for (kelondroRow.Entry entry: doubleset) {
+ for (Row.Entry entry: doubleset) {
partition = (int) entry.getColLong(idx_col_clusteridx);
if (partition > maxpartition) {
maxpartition = partition;
@@ -260,19 +269,19 @@ public class kelondroCollectionIndex {
if (doublecount > 0) serverLog.logWarning("STARTUP", "found " + doublecount + " RWI entries with references to several collections. All have been fixed (zombies still exists).");
}
- private kelondroIndex openIndexFile(final File path, final String filenameStub, final kelondroByteOrder indexOrder,
- final int loadfactor, final kelondroRow rowdef, final int initialSpace) throws IOException {
+ private ObjectIndex openIndexFile(final File path, final String filenameStub, final ByteOrder indexOrder,
+ final int loadfactor, final Row rowdef, final int initialSpace) throws IOException {
// open/create index table
final File f = new File(path, filenameStub + ".index");
- final kelondroRow indexRowdef = indexRow(keylength, indexOrder);
- kelondroIndex theindex;
+ final Row indexRowdef = indexRow(keylength, indexOrder);
+ ObjectIndex theindex;
if (f.isDirectory()) {
kelondroFlexTable.delete(path, filenameStub + ".index");
}
// open a ecotable
final long records = f.length() / indexRowdef.objectsize;
final long necessaryRAM4fullTable = minimumRAM4Eco + (indexRowdef.objectsize + 4) * records * 3 / 2;
- final boolean fullCache = kelondroMemory.request(necessaryRAM4fullTable, false);
+ final boolean fullCache = MemoryControl.request(necessaryRAM4fullTable, false);
if (fullCache) {
theindex = new kelondroEcoTable(f, indexRowdef, kelondroEcoTable.tailCacheUsageAuto, EcoFSBufferSize, initialSpace);
//if (!((kelondroEcoTable) theindex).usesFullCopy()) theindex = new kelondroCache(theindex);
@@ -283,12 +292,12 @@ public class kelondroCollectionIndex {
return theindex;
}
- private kelondroFixedWidthArray openArrayFile(final int partitionNumber, final int serialNumber, final kelondroByteOrder indexOrder, final boolean create) throws IOException {
+ private kelondroFixedWidthArray openArrayFile(final int partitionNumber, final int serialNumber, final ByteOrder indexOrder, final boolean create) throws IOException {
final File f = arrayFile(path, filenameStub, loadfactor, payloadrow.objectsize, partitionNumber, serialNumber);
final int load = arrayCapacity(partitionNumber);
- final kelondroRow rowdef = new kelondroRow(
+ final Row rowdef = new Row(
"byte[] key-" + keylength + "," +
- "byte[] collection-" + (kelondroRowCollection.exportOverheadSize + load * this.payloadrow.objectsize),
+ "byte[] collection-" + (RowCollection.exportOverheadSize + load * this.payloadrow.objectsize),
indexOrder,
0
);
@@ -298,7 +307,7 @@ public class kelondroCollectionIndex {
return a;
}
- private kelondroFixedWidthArray getArray(final int partitionNumber, final int serialNumber, final kelondroByteOrder indexOrder, final int chunksize) {
+ private kelondroFixedWidthArray getArray(final int partitionNumber, final int serialNumber, final ByteOrder indexOrder, final int chunksize) {
final String accessKey = partitionNumber + "-" + chunksize;
kelondroFixedWidthArray array = arrays.get(accessKey);
if (array != null) return array;
@@ -341,7 +350,7 @@ public class kelondroCollectionIndex {
// this is computed by the size of the biggest used collection
// this must be multiplied with the payload size
// and doubled for necessary memory transformation during sort operation
- return (int) (arrayCapacity(arrays.size() - 1) * this.payloadrow.objectsize * kelondroRowCollection.growfactor);
+ return (int) (arrayCapacity(arrays.size() - 1) * this.payloadrow.objectsize * RowCollection.growfactor);
}
private void array_remove(
@@ -355,15 +364,15 @@ public class kelondroCollectionIndex {
array.remove(oldRownumber);
}
- private kelondroRow.Entry array_new(
- final byte[] key, final kelondroRowCollection collection) throws IOException {
+ private Row.Entry array_new(
+ final byte[] key, final RowCollection collection) throws IOException {
// the collection is new
final int partitionNumber = arrayIndex(collection.size());
- final kelondroRow.Entry indexrow = index.row().newEntry();
+ final Row.Entry indexrow = index.row().newEntry();
final kelondroFixedWidthArray array = getArray(partitionNumber, serialNumber, index.row().objectOrder, this.payloadrow.objectsize);
// define row
- final kelondroRow.Entry arrayEntry = array.row().newEntry();
+ final Row.Entry arrayEntry = array.row().newEntry();
arrayEntry.setCol(0, key);
arrayEntry.setCol(1, collection.exportCollection());
@@ -378,8 +387,8 @@ public class kelondroCollectionIndex {
indexrow.setCol(idx_col_clusteridx, (byte) partitionNumber);
indexrow.setCol(idx_col_flags, (byte) 0);
indexrow.setCol(idx_col_indexpos, newRowNumber);
- indexrow.setCol(idx_col_lastread, kelondroRowCollection.daysSince2000(System.currentTimeMillis()));
- indexrow.setCol(idx_col_lastwrote, kelondroRowCollection.daysSince2000(System.currentTimeMillis()));
+ indexrow.setCol(idx_col_lastread, RowCollection.daysSince2000(System.currentTimeMillis()));
+ indexrow.setCol(idx_col_lastwrote, RowCollection.daysSince2000(System.currentTimeMillis()));
// after calling this method there must be an index.addUnique(indexrow);
return indexrow;
@@ -391,14 +400,14 @@ public class kelondroCollectionIndex {
}
private void array_add(
- final byte[] key, final kelondroRowCollection collection, final kelondroRow.Entry indexrow,
+ final byte[] key, final RowCollection collection, final Row.Entry indexrow,
final int partitionNumber, final int serialNumber, final int chunkSize) throws IOException {
// write a new entry in the other array
final kelondroFixedWidthArray array = getArray(partitionNumber, serialNumber, index.row().objectOrder, chunkSize);
// define new row
- final kelondroRow.Entry arrayEntry = array.row().newEntry();
+ final Row.Entry arrayEntry = array.row().newEntry();
arrayEntry.setCol(0, key);
arrayEntry.setCol(1, collection.exportCollection());
@@ -409,13 +418,13 @@ public class kelondroCollectionIndex {
indexrow.setCol(idx_col_chunkcount, collection.size());
indexrow.setCol(idx_col_clusteridx, (byte) partitionNumber);
indexrow.setCol(idx_col_indexpos, rowNumber);
- indexrow.setCol(idx_col_lastwrote, kelondroRowCollection.daysSince2000(System.currentTimeMillis()));
+ indexrow.setCol(idx_col_lastwrote, RowCollection.daysSince2000(System.currentTimeMillis()));
// after calling this method there must be a index.put(indexrow);
}
private void array_replace(
- final byte[] key, final kelondroRowCollection collection, final kelondroRow.Entry indexrow,
+ final byte[] key, final RowCollection collection, final Row.Entry indexrow,
final int partitionNumber, final int serialNumber, final int chunkSize,
final int rowNumber) throws IOException {
// we don't need a new slot, just write collection into the old one
@@ -424,7 +433,7 @@ public class kelondroCollectionIndex {
final kelondroFixedWidthArray array = getArray(partitionNumber, serialNumber, index.row().objectOrder, chunkSize);
// define new row
- final kelondroRow.Entry arrayEntry = array.row().newEntry();
+ final Row.Entry arrayEntry = array.row().newEntry();
arrayEntry.setCol(0, key);
arrayEntry.setCol(1, collection.exportCollection());
@@ -435,18 +444,18 @@ public class kelondroCollectionIndex {
final int collectionsize = collection.size(); // extra variable for easier debugging
indexrow.setCol(idx_col_chunkcount, collectionsize);
indexrow.setCol(idx_col_clusteridx, (byte) partitionNumber);
- indexrow.setCol(idx_col_lastwrote, kelondroRowCollection.daysSince2000(System.currentTimeMillis()));
+ indexrow.setCol(idx_col_lastwrote, RowCollection.daysSince2000(System.currentTimeMillis()));
// after calling this method there must be a index.put(indexrow);
}
- public synchronized void put(final byte[] key, final kelondroRowCollection collection) throws IOException, kelondroOutOfLimitsException {
+ public synchronized void put(final byte[] key, final RowCollection collection) throws IOException, kelondroOutOfLimitsException {
assert (key != null);
assert (collection != null);
assert (collection.size() != 0);
// first find an old entry, if one exists
- kelondroRow.Entry indexrow = index.get(key);
+ Row.Entry indexrow = index.get(key);
if (indexrow == null) {
// create new row and index entry
@@ -495,14 +504,14 @@ public class kelondroCollectionIndex {
final byte[] key = container.getWordHash().getBytes();
// first find an old entry, if one exists
- kelondroRow.Entry indexrow = index.get(key);
+ Row.Entry indexrow = index.get(key);
if (indexrow == null) {
indexrow = array_new(key, container); // modifies indexrow
if (indexrow != null) index.addUnique(indexrow); // write modified indexrow
} else {
// merge with the old collection
// attention! this modifies the indexrow entry which must be written with index.put(indexrow) afterwards!
- kelondroRowSet collection = container;
+ RowSet collection = container;
// read old information
final int oldchunksize = (int) indexrow.getColLong(idx_col_chunksize); // needed only for migration
@@ -514,7 +523,7 @@ public class kelondroCollectionIndex {
// load the old collection and join it
try {
- kelondroRowSet krc = getwithparams(indexrow, oldchunksize, oldchunkcount, oldPartitionNumber, oldrownumber, oldSerialNumber, false);
+ RowSet krc = getwithparams(indexrow, oldchunksize, oldchunkcount, oldPartitionNumber, oldrownumber, oldSerialNumber, false);
//System.out.println("***DEBUG kelondroCollectionIndex.merge before merge*** krc.size = " + krc.size() + ", krc.sortbound = " + krc.sortBound + ", collection.size = " + collection.size() + ", collection.sortbound = " + collection.sortBound);
collection = collection.merge(krc);
//System.out.println("***DEBUG kelondroCollectionIndex.merge after merge*** collection.size = " + collection.size() + ", collection.sortbound = " + collection.sortBound);
@@ -561,7 +570,7 @@ public class kelondroCollectionIndex {
}
}
- private void shrinkCollection(final byte[] key, final kelondroRowCollection collection, final int targetSize) {
+ private void shrinkCollection(final byte[] key, final RowCollection collection, final int targetSize) {
// removes entries from collection
// the removed entries are stored in a 'commons' dump file
@@ -569,11 +578,11 @@ public class kelondroCollectionIndex {
// check if the collection is already small enough
final int oldsize = collection.size();
if (oldsize <= targetSize) return;
- final kelondroRowSet newcommon = new kelondroRowSet(collection.rowdef, 0);
+ final RowSet newcommon = new RowSet(collection.rowdef, 0);
// delete some entries, which are bad rated
- Iterator<kelondroRow.Entry> i = collection.iterator();
- kelondroRow.Entry entry;
+ Iterator<Row.Entry> i = collection.iterator();
+ Row.Entry entry;
byte[] ref;
while (i.hasNext()) {
entry = i.next();
@@ -608,7 +617,7 @@ public class kelondroCollectionIndex {
newcommon.sort();
final SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
- final String filename = kelondroDigest.encodeHex(kelondroBase64Order.enhancedCoder.decode(new String(key), "de.anomic.kelondro.kelondroCollectionIndex.shrinkCollection(...)")) + "_" + formatter.format(new Date()) + ".collection";
+ final String filename = Digest.encodeHex(Base64Order.enhancedCoder.decode(new String(key), "de.anomic.kelondro.kelondroCollectionIndex.shrinkCollection(...)")) + "_" + formatter.format(new Date()) + ".collection";
final File storagePath = new File(commonsPath, filename.substring(0, 2)); // make a subpath
storagePath.mkdirs();
final File file = new File(storagePath, filename);
@@ -627,7 +636,7 @@ public class kelondroCollectionIndex {
if ((removekeys == null) || (removekeys.size() == 0)) return 0;
// first find an old entry, if one exists
- final kelondroRow.Entry indexrow = index.get(key);
+ final Row.Entry indexrow = index.get(key);
if (indexrow == null) return 0;
@@ -642,7 +651,7 @@ public class kelondroCollectionIndex {
int removed = 0;
assert (removekeys != null);
// load the old collection and remove keys
- kelondroRowSet oldcollection = null;
+ RowSet oldcollection = null;
try {
oldcollection = getwithparams(indexrow, oldchunksize, oldchunkcount, oldPartitionNumber, oldrownumber, serialNumber, false);
} catch (kelondroException e) {
@@ -696,25 +705,25 @@ public class kelondroCollectionIndex {
return index.has(key);
}
- public synchronized kelondroRowSet get(final byte[] key) throws IOException {
+ public synchronized RowSet get(final byte[] key) throws IOException {
// find an entry, if one exists
- final kelondroRow.Entry indexrow = index.get(key);
+ final Row.Entry indexrow = index.get(key);
if (indexrow == null) return null;
- final kelondroRowSet col = getdelete(indexrow, false);
+ final RowSet col = getdelete(indexrow, false);
assert (col != null);
return col;
}
- public synchronized kelondroRowSet delete(final byte[] key) throws IOException {
+ public synchronized RowSet delete(final byte[] key) throws IOException {
// find an entry, if one exists
- final kelondroRow.Entry indexrow = index.remove(key);
+ final Row.Entry indexrow = index.remove(key);
if (indexrow == null) return null;
- final kelondroRowSet removedCollection = getdelete(indexrow, true);
+ final RowSet removedCollection = getdelete(indexrow, true);
assert (removedCollection != null);
return removedCollection;
}
- protected kelondroRowSet getdelete(final kelondroRow.Entry indexrow, final boolean remove) throws IOException {
+ protected RowSet getdelete(final Row.Entry indexrow, final boolean remove) throws IOException {
// call this only within a synchronized(index) environment
// read values
@@ -728,16 +737,16 @@ public class kelondroCollectionIndex {
return getwithparams(indexrow, chunksize, chunkcount, partitionnumber, rownumber, serialnumber, remove);
}
- private synchronized kelondroRowSet getwithparams(final kelondroRow.Entry indexrow, final int chunksize, final int chunkcount, final int clusteridx, final int rownumber, final int serialnumber, final boolean remove) throws IOException {
+ private synchronized RowSet getwithparams(final Row.Entry indexrow, final int chunksize, final int chunkcount, final int clusteridx, final int rownumber, final int serialnumber, final boolean remove) throws IOException {
// open array entry
final kelondroFixedWidthArray array = getArray(clusteridx, serialnumber, index.row().objectOrder, chunksize);
- final kelondroRow.Entry arrayrow = array.get(rownumber);
+ final Row.Entry arrayrow = array.get(rownumber);
if (arrayrow == null) {
// the index appears to be corrupted
this.indexErrors++;
if (this.indexErrors == errorLimit) deleteIndexOnExit(); // delete index on exit for rebuild
serverLog.logWarning("kelondroCollectionIndex", "array " + arrayFile(this.path, this.filenameStub, this.loadfactor, chunksize, clusteridx, serialnumber).toString() + " does not contain expected row (error #" + indexErrors + ")");
- return new kelondroRowSet(this.payloadrow, 0);
+ return new RowSet(this.payloadrow, 0);
}
// read the row and define a collection
@@ -750,23 +759,23 @@ public class kelondroCollectionIndex {
this.indexErrors++;
if (this.indexErrors == errorLimit) deleteIndexOnExit(); // delete index on exit for rebuild
serverLog.logSevere("kelondroCollectionIndex." + array.filename, "lost a RowCollection because of a bad arraykey (error #" + indexErrors + ")");
- return new kelondroRowSet(this.payloadrow, 0);
+ return new RowSet(this.payloadrow, 0);
}
- final kelondroRowSet collection = new kelondroRowSet(this.payloadrow, arrayrow); // FIXME: this does not yet work with different rowdef in case of several rowdef.objectsize()
+ final RowSet collection = new RowSet(this.payloadrow, arrayrow); // FIXME: this does not yet work with different rowdef in case of several rowdef.objectsize()
if ((!(index.row().objectOrder.wellformed(indexkey))) || (index.row().objectOrder.compare(arraykey, indexkey) != 0)) {
// check if we got the right row; this row is wrong. Fix it:
index.remove(indexkey); // the wrong row cannot be fixed
// store the row number in the index; this may be a double-entry, but better than nothing
- final kelondroRow.Entry indexEntry = index.row().newEntry();
+ final Row.Entry indexEntry = index.row().newEntry();
indexEntry.setCol(idx_col_key, arrayrow.getColBytes(0));
indexEntry.setCol(idx_col_chunksize, this.payloadrow.objectsize);
indexEntry.setCol(idx_col_chunkcount, collection.size());
indexEntry.setCol(idx_col_clusteridx, (byte) clusteridx);
indexEntry.setCol(idx_col_flags, (byte) 0);
indexEntry.setCol(idx_col_indexpos, rownumber);
- indexEntry.setCol(idx_col_lastread, kelondroRowCollection.daysSince2000(System.currentTimeMillis()));
- indexEntry.setCol(idx_col_lastwrote, kelondroRowCollection.daysSince2000(System.currentTimeMillis()));
+ indexEntry.setCol(idx_col_lastread, RowCollection.daysSince2000(System.currentTimeMillis()));
+ indexEntry.setCol(idx_col_lastwrote, RowCollection.daysSince2000(System.currentTimeMillis()));
index.put(indexEntry);
this.indexErrors++;
if (this.indexErrors == errorLimit) deleteIndexOnExit(); // delete index on exit for rebuild
@@ -797,12 +806,12 @@ public class kelondroCollectionIndex {
public class keycollectionIterator implements Iterator<Object[]> {
- Iterator<kelondroRow.Entry> indexRowIterator;
+ Iterator<Row.Entry> indexRowIterator;
public keycollectionIterator(final byte[] startKey, final byte[] secondKey, final boolean rot) throws IOException {
// iterator of {byte[], kelondroRowSet} Objects
- final kelondroCloneableIterator<kelondroRow.Entry> i = index.rows(true, startKey);
- indexRowIterator = (rot) ? new kelondroRotateIterator<kelondroRow.Entry>(i, secondKey, index.size()) : i;
+ final kelondroCloneableIterator<Row.Entry> i = index.rows(true, startKey);
+ indexRowIterator = (rot) ? new kelondroRotateIterator<Row.Entry>(i, secondKey, index.size()) : i;
}
public boolean hasNext() {
@@ -810,7 +819,7 @@ public class kelondroCollectionIndex {
}
public Object[] next() {
- final kelondroRow.Entry indexrow = indexRowIterator.next();
+ final Row.Entry indexrow = indexRowIterator.next();
assert (indexrow != null);
if (indexrow == null) return null;
try {
@@ -836,7 +845,7 @@ public class kelondroCollectionIndex {
public static void main(final String[] args) {
// define payload structure
- final kelondroRow rowdef = new kelondroRow("byte[] a-10, byte[] b-80", kelondroNaturalOrder.naturalOrder, 0);
+ final Row rowdef = new Row("byte[] a-10, byte[] b-80", NaturalOrder.naturalOrder, 0);
final File path = new File(args[0]);
final String filenameStub = args[1];
@@ -844,16 +853,16 @@ public class kelondroCollectionIndex {
// initialize collection index
final kelondroCollectionIndex collectionIndex = new kelondroCollectionIndex(
path, filenameStub, 9 /*keyLength*/,
- kelondroNaturalOrder.naturalOrder,
+ NaturalOrder.naturalOrder,
4 /*loadfactor*/, 7, rowdef, false);
// fill index with values
- kelondroRowSet collection = new kelondroRowSet(rowdef, 0);
+ RowSet collection = new RowSet(rowdef, 0);
collection.addUnique(rowdef.newEntry(new byte[][]{"abc".getBytes(), "efg".getBytes()}));
collectionIndex.put("erstes".getBytes(), collection);
for (int i = 1; i <= 170; i++) {
- collection = new kelondroRowSet(rowdef, 0);
+ collection = new RowSet(rowdef, 0);
for (int j = 0; j < i; j++) {
collection.addUnique(rowdef.newEntry(new byte[][]{("abc" + j).getBytes(), "xxx".getBytes()}));
}
@@ -863,7 +872,7 @@ public class kelondroCollectionIndex {
// extend collections with more values
for (int i = 0; i <= 170; i++) {
- collection = new kelondroRowSet(rowdef, 0);
+ collection = new RowSet(rowdef, 0);
for (int j = 0; j < i; j++) {
collection.addUnique(rowdef.newEntry(new byte[][]{("def" + j).getBytes(), "xxx".getBytes()}));
}
@@ -872,7 +881,7 @@ public class kelondroCollectionIndex {
// printout of index
collectionIndex.close();
- final kelondroEcoTable index = new kelondroEcoTable(new File(path, filenameStub + ".index"), kelondroCollectionIndex.indexRow(9, kelondroNaturalOrder.naturalOrder), kelondroEcoTable.tailCacheUsageAuto, 0, 0);
+ final kelondroEcoTable index = new kelondroEcoTable(new File(path, filenameStub + ".index"), kelondroCollectionIndex.indexRow(9, NaturalOrder.naturalOrder), kelondroEcoTable.tailCacheUsageAuto, 0, 0);
index.print();
index.close();
} catch (final IOException e) {
diff --git a/source/de/anomic/kelondro/kelondroEcoTable.java b/source/de/anomic/kelondro/kelondroEcoTable.java
index 5c0d7ee8e..1ef0ccf7b 100644
--- a/source/de/anomic/kelondro/kelondroEcoTable.java
+++ b/source/de/anomic/kelondro/kelondroEcoTable.java
@@ -38,7 +38,17 @@ import java.util.Map;
import java.util.TreeMap;
import java.util.TreeSet;
-import de.anomic.kelondro.kelondroRow.Entry;
+import de.anomic.kelondro.coding.NaturalOrder;
+import de.anomic.kelondro.index.BytesIntMap;
+import de.anomic.kelondro.index.Column;
+import de.anomic.kelondro.index.Row;
+import de.anomic.kelondro.index.RowCollection;
+import de.anomic.kelondro.index.RowSet;
+import de.anomic.kelondro.index.ObjectIndex;
+import de.anomic.kelondro.index.Row.Entry;
+import de.anomic.kelondro.io.kelondroBufferedEcoFS;
+import de.anomic.kelondro.io.kelondroEcoFS;
+import de.anomic.kelondro.tools.MemoryControl;
import de.anomic.server.logging.serverLog;
/*
@@ -51,7 +61,7 @@ import de.anomic.server.logging.serverLog;
* The content cache can also be deleted during run-time, if the available RAM gets too low.
*/
-public class kelondroEcoTable implements kelondroIndex {
+public class kelondroEcoTable implements ObjectIndex {
// static tracker objects
private static TreeMap<String, kelondroEcoTable> tableTracker = new TreeMap<String, kelondroEcoTable>();
@@ -62,26 +72,26 @@ public class kelondroEcoTable implements kelondroIndex {
public static final long maxarraylength = 134217727L; // that may be the maxmimum size of array length in some JVMs
private static final long minmemremaining = 20 * 1024 * 1024; // if less than this memory is remaininig, the memory copy of a table is abandoned
- kelondroRowSet table;
- kelondroBytesIntMap index;
+ RowSet table;
+ BytesIntMap index;
kelondroBufferedEcoFS file;
- kelondroRow rowdef;
+ Row rowdef;
int fail;
- kelondroRow taildef;
+ Row taildef;
private final int buffersize;
- public kelondroEcoTable(final File tablefile, final kelondroRow rowdef, final int useTailCache, final int buffersize, final int initialSpace) {
+ public kelondroEcoTable(final File tablefile, final Row rowdef, final int useTailCache, final int buffersize, final int initialSpace) {
this.rowdef = rowdef;
this.buffersize = buffersize;
//this.fail = 0;
assert rowdef.primaryKeyIndex == 0;
// define the taildef, a row like the rowdef but without the first column
- final kelondroColumn[] cols = new kelondroColumn[rowdef.columns() - 1];
+ final Column[] cols = new Column[rowdef.columns() - 1];
for (int i = 0; i < cols.length; i++) {
cols[i] = rowdef.column(i + 1);
}
- this.taildef = new kelondroRow(cols, kelondroNaturalOrder.naturalOrder, -1);
+ this.taildef = new Row(cols, NaturalOrder.naturalOrder, -1);
// initialize table file
if (!tablefile.exists()) {
@@ -105,19 +115,19 @@ public class kelondroEcoTable implements kelondroIndex {
final long neededRAM4table = (records) * ((rowdef.objectsize) + 4L) * 3L;
table = ((neededRAM4table < maxarraylength) &&
((useTailCache == tailCacheForceUsage) ||
- ((useTailCache == tailCacheUsageAuto) && (kelondroMemory.free() > neededRAM4table + 200 * 1024 * 1024)))) ?
- new kelondroRowSet(taildef, records) : null;
- serverLog.logInfo("ECOTABLE", "initialization of " + tablefile + ": available RAM: " + (kelondroMemory.available() / 1024 / 1024) + "MB, allocating space for " + records + " entries");
+ ((useTailCache == tailCacheUsageAuto) && (MemoryControl.free() > neededRAM4table + 200 * 1024 * 1024)))) ?
+ new RowSet(taildef, records) : null;
+ serverLog.logInfo("ECOTABLE", "initialization of " + tablefile + ": available RAM: " + (MemoryControl.available() / 1024 / 1024) + "MB, allocating space for " + records + " entries");
final long neededRAM4index = 2 * 1024 * 1024 + records * (rowdef.primaryKeyLength + 4) * 3 / 2;
- if (!kelondroMemory.request(neededRAM4index, false)) {
+ if (!MemoryControl.request(neededRAM4index, false)) {
// despite calculations seemed to show that there is enough memory for the table AND the index
// there is now not enough memory left for the index. So delete the table again to free the memory
// for the index
- serverLog.logSevere("ECOTABLE", tablefile + ": not enough RAM (" + (kelondroMemory.available() / 1024 / 1024) + "MB) left for index, deleting allocated table space to enable index space allocation (needed: " + (neededRAM4index / 1024 / 1024) + "MB)");
+ serverLog.logSevere("ECOTABLE", tablefile + ": not enough RAM (" + (MemoryControl.available() / 1024 / 1024) + "MB) left for index, deleting allocated table space to enable index space allocation (needed: " + (neededRAM4index / 1024 / 1024) + "MB)");
table = null; System.gc();
- serverLog.logSevere("ECOTABLE", tablefile + ": RAM after releasing the table: " + (kelondroMemory.available() / 1024 / 1024) + "MB");
+ serverLog.logSevere("ECOTABLE", tablefile + ": RAM after releasing the table: " + (MemoryControl.available() / 1024 / 1024) + "MB");
}
- index = new kelondroBytesIntMap(rowdef.primaryKeyLength, rowdef.objectOrder, records);
+ index = new BytesIntMap(rowdef.primaryKeyLength, rowdef.objectOrder, records);
serverLog.logInfo("ECOTABLE", tablefile + ": EcoTable " + tablefile.toString() + " has table copy " + ((table == null) ? "DISABLED" : "ENABLED"));
// read all elements from the file into the copy table
@@ -207,7 +217,7 @@ public class kelondroEcoTable implements kelondroIndex {
private boolean abandonTable() {
// check if not enough memory is there to maintain a memory copy of the table
- return kelondroMemory.available() < minmemremaining;
+ return MemoryControl.available() < minmemremaining;
}
public static long tableSize(final File tablefile, final int recordsize) {
@@ -234,9 +244,9 @@ public class kelondroEcoTable implements kelondroIndex {
final HashMap<String, String> map = new HashMap<String, String>();
map.put("tableSize", Integer.toString(index.size()));
map.put("tableKeyChunkSize", Integer.toString(index.row().objectsize));
- map.put("tableKeyMem", Integer.toString((int) (index.row().objectsize * index.size() * kelondroRowCollection.growfactor)));
+ map.put("tableKeyMem", Integer.toString((int) (index.row().objectsize * index.size() * RowCollection.growfactor)));
map.put("tableValueChunkSize", (table == null) ? "0" : Integer.toString(table.row().objectsize));
- map.put("tableValueMem", (table == null) ? "0" : Integer.toString((int) (table.row().objectsize * table.size() * kelondroRowCollection.growfactor)));
+ map.put("tableValueMem", (table == null) ? "0" : Integer.toString((int) (table.row().objectsize * table.size() * RowCollection.growfactor)));
return map;
}
@@ -244,8 +254,8 @@ public class kelondroEcoTable implements kelondroIndex {
return this.table != null;
}
- public static int staticRAMIndexNeed(final File f, final kelondroRow rowdef) {
- return (int) ((rowdef.primaryKeyLength + 4) * tableSize(f, rowdef.objectsize) * kelondroRowCollection.growfactor);
+ public static int staticRAMIndexNeed(final File f, final Row rowdef) {
+ return (int) ((rowdef.primaryKeyLength + 4) * tableSize(f, rowdef.objectsize) * RowCollection.growfactor);
}
public synchronized void addUnique(final Entry row) throws IOException {
@@ -276,19 +286,19 @@ public class kelondroEcoTable implements kelondroIndex {
* this process calls the underlying removeDoubles() method from the table index
* and
*/
- public synchronized ArrayList<kelondroRowCollection> removeDoubles() throws IOException {
+ public synchronized ArrayList<RowCollection> removeDoubles() throws IOException {
assert file.size() == index.size() + fail : "file.size() = " + file.size() + ", index.size() = " + index.size();
- final ArrayList<kelondroRowCollection> report = new ArrayList<kelondroRowCollection>();
- kelondroRowSet rows;
+ final ArrayList<RowCollection> report = new ArrayList<RowCollection>();
+ RowSet rows;
final TreeSet<Integer> d = new TreeSet<Integer>();
final byte[] b = new byte[rowdef.objectsize];
Integer L;
- kelondroRow.Entry inconsistentEntry;
+ Row.Entry inconsistentEntry;
// iterate over all entries that have inconsistent index references
for (final Integer[] is: index.removeDoubles()) {
// 'is' is the set of all indexes, that have the same reference
// we collect that entries now here
- rows = new kelondroRowSet(this.rowdef, is.length);
+ rows = new RowSet(this.rowdef, is.length);
for (int j = 0; j < is.length; j++) {
L = is[j];
assert L.intValue() < file.size() : "L.intValue() = " + L.intValue() + ", file.size = " + file.size(); // prevent ooBounds Exception
@@ -338,7 +348,7 @@ public class kelondroEcoTable implements kelondroIndex {
file.get(i, b, 0);
} else {
// construct the row using the copy in RAM
- final kelondroRow.Entry v = table.get(i, false);
+ final Row.Entry v = table.get(i, false);
assert v != null;
if (v == null) return null;
assert key.length == rowdef.primaryKeyLength;
@@ -385,7 +395,7 @@ public class kelondroEcoTable implements kelondroIndex {
file.put(i, row.bytes(), 0);
} else {
// read old value
- final kelondroRow.Entry v = table.get(i, false);
+ final Row.Entry v = table.get(i, false);
assert v != null;
System.arraycopy(row.getPrimaryKeyBytes(), 0, b, 0, rowdef.primaryKeyLength);
System.arraycopy(v.bytes(), 0, b, rowdef.primaryKeyLength, rowdef.objectsize - rowdef.primaryKeyLength);
@@ -433,12 +443,12 @@ public class kelondroEcoTable implements kelondroIndex {
file.cleanLast();
} else {
// switch values
- final kelondroRow.Entry te = table.removeOne();
+ final Row.Entry te = table.removeOne();
table.set(i, te);
file.cleanLast(p, 0);
file.put(i, p, 0);
- final kelondroRow.Entry lr = rowdef.newEntry(p);
+ final Row.Entry lr = rowdef.newEntry(p);
index.puti(lr.getPrimaryKeyBytes(), i);
}
}
@@ -476,7 +486,7 @@ public class kelondroEcoTable implements kelondroIndex {
assert (file.size() == index.size() + fail);
} else {
// get result value from the table copy, so we don't need to read it from the file
- final kelondroRow.Entry v = table.get(i, false);
+ final Row.Entry v = table.get(i, false);
System.arraycopy(key, 0, b, 0, key.length);
System.arraycopy(v.bytes(), 0, b, rowdef.primaryKeyLength, taildef.objectsize);
@@ -491,12 +501,12 @@ public class kelondroEcoTable implements kelondroIndex {
ix = index.removei(key);
assert ix == i;
- final kelondroRow.Entry te = table.removeOne();
+ final Row.Entry te = table.removeOne();
table.set(i, te);
file.cleanLast(p, 0);
file.put(i, p, 0);
- final kelondroRow.Entry lr = rowdef.newEntry(p);
+ final Row.Entry lr = rowdef.newEntry(p);
index.puti(lr.getPrimaryKeyBytes(), i);
}
assert (file.size() == index.size() + fail);
@@ -513,7 +523,7 @@ public class kelondroEcoTable implements kelondroIndex {
assert ((table == null) || (table.size() == index.size()));
final byte[] le = new byte[rowdef.objectsize];
file.cleanLast(le, 0);
- final kelondroRow.Entry lr = rowdef.newEntry(le);
+ final Row.Entry lr = rowdef.newEntry(le);
final int i = index.removei(lr.getPrimaryKeyBytes());
assert i >= 0;
if (table != null) table.removeOne();
@@ -546,11 +556,11 @@ public class kelondroEcoTable implements kelondroIndex {
}
// initialize index and copy table
- table = (table == null) ? null : new kelondroRowSet(taildef, 1);
- index = new kelondroBytesIntMap(rowdef.primaryKeyLength, rowdef.objectOrder, 1);
+ table = (table == null) ? null : new RowSet(taildef, 1);
+ index = new BytesIntMap(rowdef.primaryKeyLength, rowdef.objectOrder, 1);
}
- public kelondroRow row() {
+ public Row row() {
return this.rowdef;
}
@@ -611,7 +621,7 @@ public class kelondroEcoTable implements kelondroIndex {
}
} else {
// compose from table and key
- final kelondroRow.Entry v = table.get(this.c, false);
+ final Row.Entry v = table.get(this.c, false);
assert v != null;
if (v == null) return null;
System.arraycopy(k, 0, b, 0, rowdef.primaryKeyLength);
@@ -626,12 +636,12 @@ public class kelondroEcoTable implements kelondroIndex {
}
- public static kelondroIndex testTable(final File f, final String testentities, final int testcase) throws IOException {
+ public static ObjectIndex testTable(final File f, final String testentities, final int testcase) throws IOException {
if (f.exists()) f.delete();
- final kelondroRow rowdef = new kelondroRow("byte[] a-4, byte[] b-4", kelondroNaturalOrder.naturalOrder, 0);
- final kelondroIndex tt = new kelondroEcoTable(f, rowdef, testcase, 100, 0);
+ final Row rowdef = new Row("byte[] a-4, byte[] b-4", NaturalOrder.naturalOrder, 0);
+ final ObjectIndex tt = new kelondroEcoTable(f, rowdef, testcase, 100, 0);
byte[] b;
- final kelondroRow.Entry row = rowdef.newEntry();
+ final Row.Entry row = rowdef.newEntry();
for (int i = 0; i < testentities.length(); i++) {
b = kelondroTree.testWord(testentities.charAt(i));
row.setCol(0, b);
@@ -645,7 +655,7 @@ public class kelondroEcoTable implements kelondroIndex {
System.out.println("starting big test with " + elements + " elements:");
final long start = System.currentTimeMillis();
final String[] s = kelondroTree.permutations(elements);
- kelondroIndex tt;
+ ObjectIndex tt;
try {
for (int i = 0; i < s.length; i++) {
System.out.println("*** probing tree " + i + " for permutation " + s[i]);
diff --git a/source/de/anomic/kelondro/kelondroFixedWidthArray.java b/source/de/anomic/kelondro/kelondroFixedWidthArray.java
index 15d06b3bf..c0526b76b 100644
--- a/source/de/anomic/kelondro/kelondroFixedWidthArray.java
+++ b/source/de/anomic/kelondro/kelondroFixedWidthArray.java
@@ -33,13 +33,18 @@ import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;
-public class kelondroFixedWidthArray extends kelondroFullRecords implements kelondroArray {
+import de.anomic.kelondro.coding.NaturalOrder;
+import de.anomic.kelondro.index.Array;
+import de.anomic.kelondro.index.Row;
+import de.anomic.kelondro.io.RandomAccessInterface;
+
+public class kelondroFixedWidthArray extends kelondroFullRecords implements Array {
// define the Over-Head-Array
private static short thisOHBytes = 0; // our record definition does not need extra bytes
private static short thisOHHandles = 0; // and no handles
- public kelondroFixedWidthArray(final File file, final kelondroRow rowdef, final int intprops) throws IOException {
+ public kelondroFixedWidthArray(final File file, final Row rowdef, final int intprops) throws IOException {
// this creates a new array
//super(file, true, -1, thisOHBytes, thisOHHandles, rowdef, intprops, rowdef.columns() /* txtProps */, 80 /* txtPropWidth */);
super(file, thisOHBytes, thisOHHandles, rowdef, intprops, rowdef.columns() /* txtProps */, 80 /* txtPropWidth */);
@@ -54,7 +59,7 @@ public class kelondroFixedWidthArray extends kelondroFullRecords implements kelo
}
}
- public kelondroFixedWidthArray(final kelondroRA ra, final String filename, final kelondroRow rowdef, final int intprops) throws IOException {
+ public kelondroFixedWidthArray(final RandomAccessInterface ra, final String filename, final Row rowdef, final int intprops) throws IOException {
// this creates a new array
//super(ra, filename, true, -1, thisOHBytes, thisOHHandles, rowdef, intprops, rowdef.columns() /* txtProps */, 80 /* txtPropWidth */, false);
super(ra, filename, thisOHBytes, thisOHHandles, rowdef, intprops, rowdef.columns() /* txtProps */, 80 /* txtPropWidth */, false);
@@ -67,7 +72,7 @@ public class kelondroFixedWidthArray extends kelondroFullRecords implements kelo
}
}
- public static kelondroFixedWidthArray open(final File file, final kelondroRow rowdef, final int intprops) {
+ public static kelondroFixedWidthArray open(final File file, final Row rowdef, final int intprops) {
try {
return new kelondroFixedWidthArray(file, rowdef, intprops);
} catch (final IOException e) {
@@ -83,7 +88,7 @@ public class kelondroFixedWidthArray extends kelondroFullRecords implements kelo
}
}
- public synchronized void set(final int index, final kelondroRow.Entry rowentry) throws IOException {
+ public synchronized void set(final int index, final Row.Entry rowentry) throws IOException {
// this writes a row without reading the row from the file system first
// create a node at position index with rowentry
@@ -94,9 +99,9 @@ public class kelondroFixedWidthArray extends kelondroFullRecords implements kelo
// the OHbytes and OHhandles are zero.
}
- public synchronized void setMultiple(final TreeMap<Integer, kelondroRow.Entry> rows) throws IOException {
- final Iterator<Map.Entry<Integer, kelondroRow.Entry>> i = rows.entrySet().iterator();
- Map.Entry<Integer, kelondroRow.Entry> entry;
+ public synchronized void setMultiple(final TreeMap<Integer, Row.Entry> rows) throws IOException {
+ final Iterator<Map.Entry<Integer, Row.Entry>> i = rows.entrySet().iterator();
+ Map.Entry<Integer, Row.Entry> entry;
int k;
while (i.hasNext()) {
entry = i.next();
@@ -105,14 +110,14 @@ public class kelondroFixedWidthArray extends kelondroFullRecords implements kelo
}
}
- public synchronized kelondroRow.Entry getIfValid(final int index) throws IOException {
+ public synchronized Row.Entry getIfValid(final int index) throws IOException {
final byte[] b = (new EcoNode(new kelondroHandle(index))).getValueRow();
if (b[0] == 0) return null;
if ((b[0] == -128) && (b[1] == 0)) return null;
return row().newEntry(b);
}
- public synchronized kelondroRow.Entry get(final int index) throws IOException {
+ public synchronized Row.Entry get(final int index) throws IOException {
return row().newEntry(new EcoNode(new kelondroHandle(index)).getValueRow());
}
@@ -126,7 +131,7 @@ public class kelondroFixedWidthArray extends kelondroFullRecords implements kelo
return getHandle(index).hashCode();
}
- public synchronized int add(final kelondroRow.Entry rowentry) throws IOException {
+ public synchronized int add(final Row.Entry rowentry) throws IOException {
// adds a new rowentry, but re-uses a previously as-deleted marked entry
final kelondroNode n = new EcoNode(rowentry.bytes());
n.commit();
@@ -150,7 +155,7 @@ public class kelondroFixedWidthArray extends kelondroFullRecords implements kelo
public void print() throws IOException {
System.out.println("PRINTOUT of table, length=" + size());
- kelondroRow.Entry row;
+ Row.Entry row;
for (int i = 0; i < (super.free() + super.size()); i++) {
System.out.print("row " + i + ": ");
row = get(i);
@@ -163,7 +168,7 @@ public class kelondroFixedWidthArray extends kelondroFullRecords implements kelo
public static void main(final String[] args) {
//File f = new File("d:\\\\mc\\privat\\fixtest.db");
final File f = new File("/Users/admin/fixtest.db");
- final kelondroRow rowdef = new kelondroRow("byte[] a-12, byte[] b-4", kelondroNaturalOrder.naturalOrder, 0);
+ final Row rowdef = new Row("byte[] a-12, byte[] b-4", NaturalOrder.naturalOrder, 0);
try {
System.out.println("erster Test");
f.delete();
diff --git a/source/de/anomic/kelondro/kelondroFlexTable.java b/source/de/anomic/kelondro/kelondroFlexTable.java
index 7842d7d72..4c1fce142 100644
--- a/source/de/anomic/kelondro/kelondroFlexTable.java
+++ b/source/de/anomic/kelondro/kelondroFlexTable.java
@@ -35,22 +35,29 @@ import java.util.Map;
import java.util.TreeMap;
import java.util.TreeSet;
+import de.anomic.kelondro.coding.NaturalOrder;
+import de.anomic.kelondro.index.BytesIntMap;
+import de.anomic.kelondro.index.Row;
+import de.anomic.kelondro.index.RowCollection;
+import de.anomic.kelondro.index.RowSet;
+import de.anomic.kelondro.index.ObjectIndex;
+import de.anomic.kelondro.tools.MemoryControl;
import de.anomic.server.logging.serverLog;
-public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondroIndex {
+public class kelondroFlexTable extends kelondroFlexWidthArray implements ObjectIndex {
// static tracker objects
private static TreeMap<String, kelondroFlexTable> tableTracker = new TreeMap<String, kelondroFlexTable>();
// class objects
- protected kelondroBytesIntMap index;
+ protected BytesIntMap index;
private boolean RAMIndex;
/**
* Deprecated Class. Please use kelondroEcoTable instead
*/
@Deprecated
- public kelondroFlexTable(final File path, final String tablename, final kelondroRow rowdef, int minimumSpace, final boolean resetOnFail) {
+ public kelondroFlexTable(final File path, final String tablename, final Row rowdef, int minimumSpace, final boolean resetOnFail) {
// the buffersize applies to a possible load of the ram-index
// the minimumSpace is a initial allocation space for the index; names the number of index slots
// if the ram is not sufficient, a tree file is generated
@@ -64,7 +71,7 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr
}
minimumSpace = Math.max(minimumSpace, super.size());
try {
- final long neededRAM = 10 * 1024 * 104 + (long) ((super.row().column(0).cellwidth + 4) * minimumSpace * kelondroRowCollection.growfactor);
+ final long neededRAM = 10 * 1024 * 104 + (long) ((super.row().column(0).cellwidth + 4) * minimumSpace * RowCollection.growfactor);
final File newpath = new File(path, tablename);
final File indexfile = new File(newpath, "col.000.index");
@@ -83,7 +90,7 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr
}
// fill the index
- System.out.print("*** Loading RAM index for " + size() + " entries from " + newpath + "; available RAM = " + (kelondroMemory.available() >> 20) + " MB, allocating " + (neededRAM >> 20) + " MB for index.");
+ System.out.print("*** Loading RAM index for " + size() + " entries from " + newpath + "; available RAM = " + (MemoryControl.available() >> 20) + " MB, allocating " + (neededRAM >> 20) + " MB for index.");
index = initializeRamIndex(minimumSpace);
System.out.println(" -done-");
@@ -103,7 +110,7 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr
} catch (final IOException e) {
if (resetOnFail) {
RAMIndex = true;
- index = new kelondroBytesIntMap(super.row().column(0).cellwidth, super.rowdef.objectOrder, 0);
+ index = new BytesIntMap(super.row().column(0).cellwidth, super.rowdef.objectOrder, 0);
} else {
throw new kelondroException(e.getMessage());
}
@@ -113,15 +120,15 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr
public void clear() throws IOException {
super.reset();
RAMIndex = true;
- index = new kelondroBytesIntMap(super.row().column(0).cellwidth, super.rowdef.objectOrder, 0);
+ index = new BytesIntMap(super.row().column(0).cellwidth, super.rowdef.objectOrder, 0);
}
public static int staticSize(final File path, final String tablename) {
return kelondroFlexWidthArray.staticsize(path, tablename);
}
- public static int staticRAMIndexNeed(final File path, final String tablename, final kelondroRow rowdef) {
- return (int) ((rowdef.column(0).cellwidth + 4) * staticSize(path, tablename) * kelondroRowCollection.growfactor);
+ public static int staticRAMIndexNeed(final File path, final String tablename, final Row rowdef) {
+ return (int) ((rowdef.column(0).cellwidth + 4) * staticSize(path, tablename) * RowCollection.growfactor);
}
public boolean hasRAMIndex() {
@@ -136,10 +143,10 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr
return index.has(key);
}
- private kelondroBytesIntMap initializeRamIndex(final int initialSpace) {
+ private BytesIntMap initializeRamIndex(final int initialSpace) {
final int space = Math.max(super.col[0].size(), initialSpace) + 1;
if (space < 0) throw new kelondroException("wrong space: " + space);
- final kelondroBytesIntMap ri = new kelondroBytesIntMap(super.row().column(0).cellwidth, super.rowdef.objectOrder, space);
+ final BytesIntMap ri = new BytesIntMap(super.row().column(0).cellwidth, super.rowdef.objectOrder, space);
final Iterator<kelondroNode> content = super.col[0].contentNodes(-1);
kelondroNode node;
int i;
@@ -166,7 +173,7 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr
return ri;
}
- public synchronized kelondroRow.Entry get(final byte[] key) throws IOException {
+ public synchronized Row.Entry get(final byte[] key) throws IOException {
if (index == null) return null; // case may happen during shutdown
final int pos = index.geti(key);
assert this.size() == index.size() : "content.size() = " + this.size() + ", index.size() = " + index.size();
@@ -183,21 +190,21 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr
// assume that the column for the primary key is 0,
// and the column 0 is stored in a file only for that column
// then we don't need to lookup from that file, because we already know the value (it's the key)
- final kelondroRow.Entry result = super.getOmitCol0(pos, key);
+ final Row.Entry result = super.getOmitCol0(pos, key);
assert result != null;
return result;
//}
}
- public synchronized void putMultiple(final List<kelondroRow.Entry> rows) throws IOException {
+ public synchronized void putMultiple(final List<Row.Entry> rows) throws IOException {
// put a list of entries in a ordered way.
// this should save R/W head positioning time
- final Iterator<kelondroRow.Entry> i = rows.iterator();
- kelondroRow.Entry row;
+ final Iterator<Row.Entry> i = rows.iterator();
+ Row.Entry row;
int pos;
byte[] key;
- final TreeMap<Integer, kelondroRow.Entry> old_rows_ordered = new TreeMap<Integer, kelondroRow.Entry>();
- final ArrayList<kelondroRow.Entry> new_rows_sequential = new ArrayList<kelondroRow.Entry>();
+ final TreeMap<Integer, Row.Entry> old_rows_ordered = new TreeMap<Integer, Row.Entry>();
+ final ArrayList<Row.Entry> new_rows_sequential = new ArrayList<Row.Entry>();
assert this.size() == index.size() : "content.size() = " + this.size() + ", index.size() = " + index.size();
while (i.hasNext()) {
row = i.next();
@@ -217,12 +224,12 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr
assert this.size() == index.size() : "content.size() = " + this.size() + ", index.size() = " + index.size();
}
- public synchronized kelondroRow.Entry put(final kelondroRow.Entry row, final Date entryDate) throws IOException {
+ public synchronized Row.Entry put(final Row.Entry row, final Date entryDate) throws IOException {
assert this.size() == index.size() : "content.size() = " + this.size() + ", index.size() = " + index.size();
return put(row);
}
- public synchronized kelondroRow.Entry put(final kelondroRow.Entry row) throws IOException {
+ public synchronized Row.Entry put(final Row.Entry row) throws IOException {
assert (row != null);
assert (!(serverLog.allZero(row.getColBytes(0))));
assert row.objectsize() <= this.rowdef.objectsize;
@@ -236,7 +243,7 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr
return null;
}
//System.out.println("row.key=" + serverLog.arrayList(row.bytes(), 0, row.objectsize()));
- final kelondroRow.Entry oldentry = super.get(pos);
+ final Row.Entry oldentry = super.get(pos);
assert this.size() == index.size() : "content.size() = " + this.size() + ", index.size() = " + index.size();
if (oldentry == null) {
serverLog.logSevere("kelondroFlexTable", "put(): index failure; the index pointed to a cell which is empty. content.size() = " + this.size() + ", index.size() = " + index.size());
@@ -250,19 +257,19 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr
return null;
}
assert oldentry != null : "overwrite of empty position " + pos + ", index management must have failed before";
- assert rowdef.objectOrder.compare(oldentry.getPrimaryKeyBytes(), key) == 0 : "key and row does not match; key = " + kelondroNaturalOrder.arrayList(key, 0, key.length) + " row.key = " + kelondroNaturalOrder.arrayList(oldentry.getPrimaryKeyBytes(), 0, rowdef.primaryKeyLength);
+ assert rowdef.objectOrder.compare(oldentry.getPrimaryKeyBytes(), key) == 0 : "key and row does not match; key = " + NaturalOrder.arrayList(key, 0, key.length) + " row.key = " + NaturalOrder.arrayList(oldentry.getPrimaryKeyBytes(), 0, rowdef.primaryKeyLength);
super.set(pos, row);
assert this.size() == index.size() : "content.size() = " + this.size() + ", index.size() = " + index.size();
return oldentry;
}
- public synchronized void addUnique(final kelondroRow.Entry row) throws IOException {
+ public synchronized void addUnique(final Row.Entry row) throws IOException {
assert row.objectsize() == this.rowdef.objectsize;
assert this.size() == index.size() : "content.size() = " + this.size() + ", index.size() = " + index.size();
index.addi(row.getColBytes(0), super.add(row));
}
- public synchronized void addUniqueMultiple(final List<kelondroRow.Entry> rows) throws IOException {
+ public synchronized void addUniqueMultiple(final List<Row.Entry> rows) throws IOException {
// add a list of entries in a ordered way.
// this should save R/W head positioning time
final TreeMap<Integer, byte[]> indexed_result = super.addMultiple(rows);
@@ -277,12 +284,12 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr
assert this.size() == index.size() : "content.size() = " + this.size() + ", index.size() = " + index.size();
}
- public synchronized ArrayList<kelondroRowCollection> removeDoubles() throws IOException {
- final ArrayList<kelondroRowCollection> report = new ArrayList<kelondroRowCollection>();
- kelondroRowSet rows;
+ public synchronized ArrayList<RowCollection> removeDoubles() throws IOException {
+ final ArrayList<RowCollection> report = new ArrayList<RowCollection>();
+ RowSet rows;
final TreeSet<Integer> d = new TreeSet<Integer>();
for (final Integer[] is: index.removeDoubles()) {
- rows = new kelondroRowSet(this.rowdef, is.length);
+ rows = new RowSet(this.rowdef, is.length);
for (int j = 0; j < is.length; j++) {
d.add(is[j]);
rows.addUnique(this.get(is[j].intValue()));
@@ -299,7 +306,7 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr
return report;
}
- public synchronized kelondroRow.Entry remove(final byte[] key) throws IOException {
+ public synchronized Row.Entry remove(final byte[] key) throws IOException {
// the underlying data structure is a file, where the order cannot be maintained. Gaps are filled with new values.
final int i = index.removei(key);
assert (index.geti(key) < 0); // must be deleted
@@ -307,7 +314,7 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr
assert this.size() == index.size() : "content.size() = " + this.size() + ", index.size() = " + index.size();
return null;
}
- final kelondroRow.Entry r = super.getOmitCol0(i, key);
+ final Row.Entry r = super.getOmitCol0(i, key);
if (r == null) {
serverLog.logSevere("kelondroFlexTable", "remove(): index failure; the index pointed to a cell which is empty. content.size() = " + this.size() + ", index.size() = " + ((index == null) ? 0 : index.size()));
// patch bug ***** FIND CAUSE! (see also: put)
@@ -315,17 +322,17 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr
return null;
}
assert r != null : "r == null"; // should be avoided with path above
- assert rowdef.objectOrder.compare(r.getPrimaryKeyBytes(), key) == 0 : "key and row does not match; key = " + kelondroNaturalOrder.arrayList(key, 0, key.length) + " row.key = " + kelondroNaturalOrder.arrayList(r.getPrimaryKeyBytes(), 0, rowdef.primaryKeyLength);
+ assert rowdef.objectOrder.compare(r.getPrimaryKeyBytes(), key) == 0 : "key and row does not match; key = " + NaturalOrder.arrayList(key, 0, key.length) + " row.key = " + NaturalOrder.arrayList(r.getPrimaryKeyBytes(), 0, rowdef.primaryKeyLength);
super.remove(i);
- assert super.get(i) == null : "i = " + i + ", get(i) = " + kelondroNaturalOrder.arrayList(super.get(i).bytes(), 0, 12);
+ assert super.get(i) == null : "i = " + i + ", get(i) = " + NaturalOrder.arrayList(super.get(i).bytes(), 0, 12);
assert this.size() == index.size() : "content.size() = " + this.size() + ", index.size() = " + index.size();
return r;
}
- public synchronized kelondroRow.Entry removeOne() throws IOException {
+ public synchronized Row.Entry removeOne() throws IOException {
final int i = index.removeonei();
if (i < 0) return null;
- kelondroRow.Entry r;
+ Row.Entry r;
r = super.get(i);
super.remove(i);
assert this.size() == index.size() : "content.size() = " + this.size() + ", index.size() = " + index.size();
@@ -336,15 +343,15 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr
return index.keys(up, firstKey);
}
- public synchronized kelondroCloneableIterator<kelondroRow.Entry> rows(final boolean up, final byte[] firstKey) throws IOException {
+ public synchronized kelondroCloneableIterator<Row.Entry> rows(final boolean up, final byte[] firstKey) throws IOException {
if (index == null) return new rowIterator(up, firstKey);
assert this.size() == index.size() : "content.size() = " + this.size() + ", index.size() = " + index.size();
return new rowIterator(up, firstKey);
}
- public class rowIterator implements kelondroCloneableIterator<kelondroRow.Entry> {
+ public class rowIterator implements kelondroCloneableIterator<Row.Entry> {
- kelondroCloneableIterator<kelondroRow.Entry> indexIterator;
+ kelondroCloneableIterator<Row.Entry> indexIterator;
boolean up;
public rowIterator(final boolean up, final byte[] firstKey) throws IOException {
@@ -364,8 +371,8 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr
return indexIterator.hasNext();
}
- public kelondroRow.Entry next() {
- kelondroRow.Entry idxEntry = null;
+ public Row.Entry next() {
+ Row.Entry idxEntry = null;
while ((indexIterator.hasNext()) && (idxEntry == null)) {
idxEntry = indexIterator.next();
}
@@ -406,7 +413,7 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr
final HashMap<String, String> map = new HashMap<String, String>();
map.put("tableIndexChunkSize", (!RAMIndex) ? "0" : Integer.toString(index.row().objectsize));
map.put("tableIndexCount", (!RAMIndex) ? "0" : Integer.toString(index.size()));
- map.put("tableIndexMem", (!RAMIndex) ? "0" : Integer.toString((int) (index.row().objectsize * index.size() * kelondroRowCollection.growfactor)));
+ map.put("tableIndexMem", (!RAMIndex) ? "0" : Integer.toString((int) (index.row().objectsize * index.size() * RowCollection.growfactor)));
return map;
}
@@ -426,10 +433,10 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr
// open a file, add one entry and exit
final File f = new File(args[0]);
final String name = args[1];
- final kelondroRow row = new kelondroRow("Cardinal key-4 {b256}, byte[] x-64", kelondroNaturalOrder.naturalOrder, 0);
+ final Row row = new Row("Cardinal key-4 {b256}, byte[] x-64", NaturalOrder.naturalOrder, 0);
try {
final kelondroFlexTable t = new kelondroFlexTable(f, name, row, 0, true);
- final kelondroRow.Entry entry = row.newEntry();
+ final Row.Entry entry = row.newEntry();
entry.setCol(0, System.currentTimeMillis());
entry.setCol(1, "dummy".getBytes());
t.put(entry);
diff --git a/source/de/anomic/kelondro/kelondroFlexWidthArray.java b/source/de/anomic/kelondro/kelondroFlexWidthArray.java
index ac4176d96..74cdcd665 100644
--- a/source/de/anomic/kelondro/kelondroFlexWidthArray.java
+++ b/source/de/anomic/kelondro/kelondroFlexWidthArray.java
@@ -33,18 +33,22 @@ import java.util.List;
import java.util.Map;
import java.util.TreeMap;
+import de.anomic.kelondro.coding.NaturalOrder;
+import de.anomic.kelondro.index.Array;
+import de.anomic.kelondro.index.Column;
+import de.anomic.kelondro.index.Row;
import de.anomic.server.serverFileUtils;
import de.anomic.server.logging.serverLog;
-public class kelondroFlexWidthArray implements kelondroArray {
+public class kelondroFlexWidthArray implements Array {
protected kelondroFixedWidthArray[] col;
- protected kelondroRow rowdef;
+ protected Row rowdef;
protected File path;
protected String tablename;
protected String filename;
- public kelondroFlexWidthArray(final File path, final String tablename, final kelondroRow rowdef, final boolean resetOnFail) {
+ public kelondroFlexWidthArray(final File path, final String tablename, final Row rowdef, final boolean resetOnFail) {
this.path = path;
this.rowdef = rowdef;
this.tablename = tablename;
@@ -105,7 +109,7 @@ public class kelondroFlexWidthArray implements kelondroArray {
if (propfile.exists()) {
props = serverFileUtils.loadHashMap(propfile);
final String stored_rowdef = props.get("rowdef");
- if ((stored_rowdef != null) && (!(rowdef.subsumes(new kelondroRow(stored_rowdef, rowdef.objectOrder, 0))))) {
+ if ((stored_rowdef != null) && (!(rowdef.subsumes(new Row(stored_rowdef, rowdef.objectOrder, 0))))) {
System.out.println("FATAL ERROR: stored rowdef '" + stored_rowdef + "' does not match with new rowdef '" +
rowdef + "' for flex table '" + path + "', table " + tablename);
System.exit(-1);
@@ -121,9 +125,9 @@ public class kelondroFlexWidthArray implements kelondroArray {
final int colstart = Integer.parseInt(files[i].substring(4, 7));
final int colend = (files[i].charAt(7) == '-') ? Integer.parseInt(files[i].substring(8, 11)) : colstart;
- final kelondroColumn columns[] = new kelondroColumn[colend - colstart + 1];
+ final Column columns[] = new Column[colend - colstart + 1];
for (int j = colstart; j <= colend; j++) columns[j-colstart] = rowdef.column(j);
- col[colstart] = new kelondroFixedWidthArray(new File(tabledir, files[i]), new kelondroRow(columns, (colstart == 0) ? rowdef.objectOrder : kelondroNaturalOrder.naturalOrder, 0), 16);
+ col[colstart] = new kelondroFixedWidthArray(new File(tabledir, files[i]), new Row(columns, (colstart == 0) ? rowdef.objectOrder : NaturalOrder.naturalOrder, 0), 16);
for (int j = colstart; j <= colend; j++) check = check.substring(0, j) + "X" + check.substring(j + 1);
}
}
@@ -137,12 +141,12 @@ public class kelondroFlexWidthArray implements kelondroArray {
q--;
}
// create new array file
- final kelondroColumn[] columns = new kelondroColumn[q - p + 1];
+ final Column[] columns = new Column[q - p + 1];
for (int j = p; j <= q; j++) {
columns[j - p] = rowdef.column(j);
check = check.substring(0, j) + "X" + check.substring(j + 1);
}
- col[p] = new kelondroFixedWidthArray(new File(tabledir, colfilename(p, q)), new kelondroRow(columns, (p == 0) ? rowdef.objectOrder : kelondroNaturalOrder.naturalOrder, 0), 16);
+ col[p] = new kelondroFixedWidthArray(new File(tabledir, colfilename(p, q)), new Row(columns, (p == 0) ? rowdef.objectOrder : NaturalOrder.naturalOrder, 0), 16);
}
}
@@ -209,7 +213,7 @@ public class kelondroFlexWidthArray implements kelondroArray {
}
- public kelondroRow row() {
+ public Row row() {
return rowdef;
}
@@ -218,11 +222,11 @@ public class kelondroFlexWidthArray implements kelondroArray {
return col[0].size();
}
- public synchronized void setMultiple(final TreeMap<Integer, kelondroRow.Entry> entries) throws IOException {
+ public synchronized void setMultiple(final TreeMap<Integer, Row.Entry> entries) throws IOException {
// a R/W head path-optimized option to write a set of entries
- Iterator<Map.Entry<Integer, kelondroRow.Entry>> i;
- Map.Entry<Integer, kelondroRow.Entry> entry;
- kelondroRow.Entry rowentry, e;
+ Iterator<Map.Entry<Integer, Row.Entry>> i;
+ Map.Entry<Integer, Row.Entry> entry;
+ Row.Entry rowentry, e;
int c = 0, index;
// go across each file
while (c < rowdef.columns()) {
@@ -240,10 +244,10 @@ public class kelondroFlexWidthArray implements kelondroArray {
}
}
- public synchronized void set(final int index, final kelondroRow.Entry rowentry) throws IOException {
+ public synchronized void set(final int index, final Row.Entry rowentry) throws IOException {
assert rowentry.objectsize() == this.rowdef.objectsize;
int c = 0;
- kelondroRow.Entry e;
+ Row.Entry e;
final byte[] reb = rowentry.bytes();
while (c < rowdef.columns()) {
e = col[c].row().newEntry(reb, rowdef.colstart[c], false);
@@ -252,7 +256,7 @@ public class kelondroFlexWidthArray implements kelondroArray {
}
}
- public synchronized int add(final kelondroRow.Entry rowentry) throws IOException {
+ public synchronized int add(final Row.Entry rowentry) throws IOException {
assert rowentry.objectsize() == this.rowdef.objectsize;
int index = -1;
final byte[] reb = rowentry.bytes();
@@ -267,23 +271,23 @@ public class kelondroFlexWidthArray implements kelondroArray {
}
@SuppressWarnings("unchecked")
- protected synchronized TreeMap<Integer, byte[]> addMultiple(final List<kelondroRow.Entry> rows) throws IOException {
+ protected synchronized TreeMap<Integer, byte[]> addMultiple(final List<Row.Entry> rows) throws IOException {
// result is a Integer/byte[] relation
// of newly added rows (index, key)
final TreeMap<Integer, byte[]> indexref = new TreeMap<Integer, byte[]>();
- Iterator<kelondroRow.Entry> i;
- kelondroRow.Entry rowentry;
+ Iterator<Row.Entry> i;
+ Row.Entry rowentry;
// prepare storage for other columns
- final TreeMap<Integer, kelondroRow.Entry>[] colm = new TreeMap[col.length];
+ final TreeMap<Integer, Row.Entry>[] colm = new TreeMap[col.length];
for (int j = 0; j < col.length; j++) {
- if (col[j] == null) colm[j] = null; else colm[j] = new TreeMap<Integer, kelondroRow.Entry>();
+ if (col[j] == null) colm[j] = null; else colm[j] = new TreeMap<Integer, Row.Entry>();
}
i = rows.iterator();
while (i.hasNext()) {
rowentry = i.next();
assert rowentry.objectsize() == this.rowdef.objectsize;
- kelondroRow.Entry e;
+ Row.Entry e;
int index = -1;
final byte[] reb = rowentry.bytes();
e = col[0].row().newEntry(reb, 0, false);
@@ -306,11 +310,11 @@ public class kelondroFlexWidthArray implements kelondroArray {
return indexref;
}
- public synchronized kelondroRow.Entry get(final int index) throws IOException {
- kelondroRow.Entry e = col[0].getIfValid(index);
+ public synchronized Row.Entry get(final int index) throws IOException {
+ Row.Entry e = col[0].getIfValid(index);
//assert e != null;
if (e == null) return null; // probably a deleted entry
- final kelondroRow.Entry p = rowdef.newEntry();
+ final Row.Entry p = rowdef.newEntry();
p.setCol(0, e.getColBytes(0));
int r = col[0].row().columns();
while (r < rowdef.columns()) {
@@ -323,10 +327,10 @@ public class kelondroFlexWidthArray implements kelondroArray {
return p;
}
- public synchronized kelondroRow.Entry getOmitCol0(final int index, final byte[] col0) throws IOException {
+ public synchronized Row.Entry getOmitCol0(final int index, final byte[] col0) throws IOException {
assert col[0].row().columns() == 1;
- final kelondroRow.Entry p = rowdef.newEntry();
- kelondroRow.Entry e;
+ final Row.Entry p = rowdef.newEntry();
+ Row.Entry e;
p.setCol(0, col0);
int r = 1;
while (r < rowdef.columns()) {
@@ -355,7 +359,7 @@ public class kelondroFlexWidthArray implements kelondroArray {
public void print() throws IOException {
System.out.println("PRINTOUT of table, length=" + size());
- kelondroRow.Entry row;
+ Row.Entry row;
for (int i = 0; i < (col[0].free() + col[0].size()); i++) {
System.out.print("row " + i + ": ");
row = get(i);
@@ -369,7 +373,7 @@ public class kelondroFlexWidthArray implements kelondroArray {
public static void main(final String[] args) {
//File f = new File("d:\\\\mc\\privat\\fixtest.db");
final File f = new File("/Users/admin/");
- final kelondroRow rowdef = new kelondroRow("byte[] a-12, byte[] b-4", kelondroNaturalOrder.naturalOrder, 0);
+ final Row rowdef = new Row("byte[] a-12, byte[] b-4", NaturalOrder.naturalOrder, 0);
final String testname = "flextest";
try {
System.out.println("erster Test");
diff --git a/source/de/anomic/kelondro/kelondroFullRecords.java b/source/de/anomic/kelondro/kelondroFullRecords.java
index c0a79016a..e5fe077f8 100644
--- a/source/de/anomic/kelondro/kelondroFullRecords.java
+++ b/source/de/anomic/kelondro/kelondroFullRecords.java
@@ -31,6 +31,9 @@ import java.io.IOException;
import java.util.Iterator;
import java.util.TreeMap;
+import de.anomic.kelondro.index.Row;
+import de.anomic.kelondro.io.RandomAccessInterface;
+
public class kelondroFullRecords extends kelondroAbstractRecords {
// static supervision objects: recognize and coordinate all activities
@@ -39,22 +42,22 @@ public class kelondroFullRecords extends kelondroAbstractRecords {
public kelondroFullRecords(
final File file,
final short ohbytec, final short ohhandlec,
- final kelondroRow rowdef, final int FHandles, final int txtProps, final int txtPropWidth) throws IOException {
+ final Row rowdef, final int FHandles, final int txtProps, final int txtPropWidth) throws IOException {
super(file, true, ohbytec, ohhandlec, rowdef, FHandles, txtProps, txtPropWidth);
recordTracker.put(this.filename, this);
}
public kelondroFullRecords(
- final kelondroRA ra, final String filename,
+ final RandomAccessInterface ra, final String filename,
final short ohbytec, final short ohhandlec,
- final kelondroRow rowdef, final int FHandles, final int txtProps, final int txtPropWidth,
+ final Row rowdef, final int FHandles, final int txtProps, final int txtPropWidth,
final boolean exitOnFail) {
super(ra, filename, true, ohbytec, ohhandlec, rowdef, FHandles, txtProps, txtPropWidth, exitOnFail);
recordTracker.put(this.filename, this);
}
public kelondroFullRecords(
- final kelondroRA ra, final String filename) throws IOException{
+ final RandomAccessInterface ra, final String filename) throws IOException{
super(ra, filename, true);
recordTracker.put(this.filename, this);
}
diff --git a/source/de/anomic/kelondro/kelondroHashtable.java b/source/de/anomic/kelondro/kelondroHashtable.java
index d0f57339c..8c2512d0d 100644
--- a/source/de/anomic/kelondro/kelondroHashtable.java
+++ b/source/de/anomic/kelondro/kelondroHashtable.java
@@ -113,17 +113,22 @@ package de.anomic.kelondro;
import java.io.File;
import java.io.IOException;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.index.Column;
+import de.anomic.kelondro.index.Row;
+import de.anomic.kelondro.tools.SetTools;
+
public class kelondroHashtable {
private final kelondroFixedWidthArray hashArray;
protected int offset;
protected int maxk;
private int maxrehash;
- private kelondroRow.Entry dummyRow;
+ private Row.Entry dummyRow;
- private static final byte[] dummyKey = kelondroBase64Order.enhancedCoder.encodeLong(0, 5).getBytes();
+ private static final byte[] dummyKey = Base64Order.enhancedCoder.encodeLong(0, 5).getBytes();
- public kelondroHashtable(final File file, final kelondroRow rowdef, final int offset, final int maxsize, final int maxrehash) throws IOException {
+ public kelondroHashtable(final File file, final Row rowdef, final int offset, final int maxsize, final int maxrehash) throws IOException {
// this creates a new hashtable
// the key element is not part of the columns array
// this is unlike the kelondroTree, where the key is part of a row
@@ -141,8 +146,8 @@ public class kelondroHashtable {
this.maxrehash = hashArray.geti(2);
} else {
this.offset = offset;
- this.maxk = kelondroMSetTools.log2a(maxsize); // equal to |log2(maxsize)| + 1
- if (this.maxk >= kelondroMSetTools.log2a(maxsize + power2(offset + 1) + 1) - 1) this.maxk--;
+ this.maxk = SetTools.log2a(maxsize); // equal to |log2(maxsize)| + 1
+ if (this.maxk >= SetTools.log2a(maxsize + power2(offset + 1) + 1) - 1) this.maxk--;
this.maxrehash = maxrehash;
dummyRow = this.hashArray.row().newEntry();
dummyRow.setCol(0, dummyKey);
@@ -153,11 +158,11 @@ public class kelondroHashtable {
}
}
- private kelondroRow extCol(final kelondroRow rowdef) {
- final kelondroColumn[] newCol = new kelondroColumn[rowdef.columns() + 1];
- newCol[0] = new kelondroColumn("Cardinal key-4 {b256}");
+ private Row extCol(final Row rowdef) {
+ final Column[] newCol = new Column[rowdef.columns() + 1];
+ newCol[0] = new Column("Cardinal key-4 {b256}");
for (int i = 0; i < rowdef.columns(); i++) newCol[i + 1] = rowdef.column(i);
- return new kelondroRow(newCol, rowdef.objectOrder, rowdef.primaryKeyIndex);
+ return new Row(newCol, rowdef.objectOrder, rowdef.primaryKeyIndex);
}
public static int power2(int x) {
@@ -175,24 +180,24 @@ public class kelondroHashtable {
return result;
}
- public synchronized kelondroRow.Entry put(final int key, final kelondroRow.Entry rowentry) throws IOException {
+ public synchronized Row.Entry put(final int key, final Row.Entry rowentry) throws IOException {
final Hash hash = new Hash(key);
// find row
final Object[] search = search(hash);
- kelondroRow.Entry oldhkrow;
+ Row.Entry oldhkrow;
final int rowNumber = ((Integer) search[0]).intValue();
if (search[1] == null) {
oldhkrow = null;
} else {
- oldhkrow = (kelondroRow.Entry) search[1];
+ oldhkrow = (Row.Entry) search[1];
}
// make space
while (rowNumber >= hashArray.size()) hashArray.set(hashArray.size(), dummyRow);
// write row
- final kelondroRow.Entry newhkrow = hashArray.row().newEntry();
+ final Row.Entry newhkrow = hashArray.row().newEntry();
newhkrow.setCol(0, hash.key());
newhkrow.setCol(1, rowentry.bytes());
hashArray.set(rowNumber, newhkrow);
@@ -200,7 +205,7 @@ public class kelondroHashtable {
}
private Object[] search(final Hash hash) throws IOException {
- kelondroRow.Entry hkrow;
+ Row.Entry hkrow;
int rowKey;
int rowNumber;
do {
diff --git a/source/de/anomic/kelondro/kelondroIntBytesMap.java b/source/de/anomic/kelondro/kelondroIntBytesMap.java
index ff0b48c11..9d1c9cc5d 100644
--- a/source/de/anomic/kelondro/kelondroIntBytesMap.java
+++ b/source/de/anomic/kelondro/kelondroIntBytesMap.java
@@ -29,6 +29,10 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.Random;
+import de.anomic.kelondro.coding.NaturalOrder;
+import de.anomic.kelondro.index.Row;
+import de.anomic.kelondro.index.RowSet;
+
public class kelondroIntBytesMap {
// we use two indexes: one for initialization, and one for data aquired during runtime
@@ -38,14 +42,14 @@ public class kelondroIntBytesMap {
// to index0 with addb, and a runtime-phase where data can only be written
// to index1 with putb.
- private final kelondroRow rowdef;
- private final kelondroRowSet index0;
- private kelondroRowSet index1;
+ private final Row rowdef;
+ private final RowSet index0;
+ private RowSet index1;
//private final kelondroOrder<kelondroRow.Entry> entryOrder;
public kelondroIntBytesMap(final int payloadSize, final int initSize) {
- this.rowdef = new kelondroRow("Cardinal key-4 {b256}, byte[] payload-" + payloadSize, kelondroNaturalOrder.naturalOrder, 0);
- this.index0 = new kelondroRowSet(rowdef, initSize);
+ this.rowdef = new Row("Cardinal key-4 {b256}, byte[] payload-" + payloadSize, NaturalOrder.naturalOrder, 0);
+ this.index0 = new RowSet(rowdef, initSize);
this.index1 = null;
//this.entryOrder = new kelondroRow.EntryComparator(rowdef.objectOrder);
}
@@ -56,25 +60,25 @@ public class kelondroIntBytesMap {
return index1.memoryNeededForGrow();
}
- public kelondroRow row() {
+ public Row row() {
return index0.row();
}
public byte[] getb(final int ii) {
assert ii >= 0 : "i = " + ii;
- final byte[] key = kelondroNaturalOrder.encodeLong(ii, 4);
+ final byte[] key = NaturalOrder.encodeLong(ii, 4);
if (index0 != null) {
if (index1 == null) {
// finish initialization phase
index0.sort();
index0.uniq();
- index1 = new kelondroRowSet(rowdef, 0);
+ index1 = new RowSet(rowdef, 0);
}
- final kelondroRow.Entry indexentry = index0.get(key);
+ final Row.Entry indexentry = index0.get(key);
if (indexentry != null) return indexentry.getColBytes(1);
}
assert (index1 != null);
- final kelondroRow.Entry indexentry = index1.get(key);
+ final Row.Entry indexentry = index1.get(key);
if (indexentry == null) return null;
return indexentry.getColBytes(1);
}
@@ -82,15 +86,15 @@ public class kelondroIntBytesMap {
public byte[] putb(final int ii, final byte[] value) {
assert ii >= 0 : "i = " + ii;
assert value != null;
- final byte[] key = kelondroNaturalOrder.encodeLong(ii, 4);
+ final byte[] key = NaturalOrder.encodeLong(ii, 4);
if (index0 != null) {
if (index1 == null) {
// finish initialization phase
index0.sort();
index0.uniq();
- index1 = new kelondroRowSet(rowdef, 0);
+ index1 = new RowSet(rowdef, 0);
}
- final kelondroRow.Entry indexentry = index0.get(key);
+ final Row.Entry indexentry = index0.get(key);
if (indexentry != null) {
final byte[] oldv = indexentry.getColBytes(1);
indexentry.setCol(0, key);
@@ -103,10 +107,10 @@ public class kelondroIntBytesMap {
// at this point index1 cannot be null
assert (index1 != null);
- final kelondroRow.Entry newentry = rowdef.newEntry();
+ final Row.Entry newentry = rowdef.newEntry();
newentry.setCol(0, ii);
newentry.setCol(1, value);
- final kelondroRow.Entry oldentry = index1.put(newentry);
+ final Row.Entry oldentry = index1.put(newentry);
if (oldentry == null) return null;
return oldentry.getColBytes(1);
}
@@ -115,7 +119,7 @@ public class kelondroIntBytesMap {
assert index1 == null; // valid only in init-phase
assert ii >= 0 : "i = " + ii;
assert value != null;
- final kelondroRow.Entry newentry = index0.row().newEntry();
+ final Row.Entry newentry = index0.row().newEntry();
newentry.setCol(0, ii);
newentry.setCol(1, value);
index0.addUnique(newentry);
@@ -124,15 +128,15 @@ public class kelondroIntBytesMap {
public byte[] removeb(final int ii) {
assert ii >= 0 : "i = " + ii;
- final byte[] key = kelondroNaturalOrder.encodeLong(ii, 4);
+ final byte[] key = NaturalOrder.encodeLong(ii, 4);
if (index0 != null) {
if (index1 == null) {
// finish initialization phase
index0.sort();
index0.uniq();
- index1 = new kelondroRowSet(rowdef, 0);
+ index1 = new RowSet(rowdef, 0);
}
- final kelondroRow.Entry indexentry = index0.remove(key);
+ final Row.Entry indexentry = index0.remove(key);
if (indexentry != null) {
return indexentry.getColBytes(1);
}
@@ -141,21 +145,21 @@ public class kelondroIntBytesMap {
// at this point index1 cannot be null
assert (index1 != null);
if (index1.size() == 0) return null;
- final kelondroRow.Entry indexentry = index1.remove(key);
+ final Row.Entry indexentry = index1.remove(key);
if (indexentry == null) return null;
return indexentry.getColBytes(1);
}
public byte[] removeoneb() {
if ((index1 != null) && (index1.size() != 0)) {
- final kelondroRow.Entry indexentry = index1.removeOne();
+ final Row.Entry indexentry = index1.removeOne();
assert (indexentry != null);
if (indexentry == null) return null;
//assert consistencyAnalysis0() : "consistency problem: " + consistencyAnalysis();
return indexentry.getColBytes(1);
}
if ((index0 != null) && (index0.size() != 0)) {
- final kelondroRow.Entry indexentry = index0.removeOne();
+ final Row.Entry indexentry = index0.removeOne();
assert (indexentry != null);
if (indexentry == null) return null;
//assert consistencyAnalysis0() : "consistency problem: " + consistencyAnalysis();
@@ -178,13 +182,13 @@ public class kelondroIntBytesMap {
return index0.size() + index1.size();
}
- public Iterator<kelondroRow.Entry> rows() {
+ public Iterator<Row.Entry> rows() {
if (index0 != null) {
if (index1 == null) {
// finish initialization phase
index0.sort();
index0.uniq();
- index1 = new kelondroRowSet(rowdef, 0);
+ index1 = new RowSet(rowdef, 0);
}
return index0.rows(true, null);
} else {
diff --git a/source/de/anomic/kelondro/kelondroMap.java b/source/de/anomic/kelondro/kelondroMap.java
index da00649ef..d056670de 100644
--- a/source/de/anomic/kelondro/kelondroMap.java
+++ b/source/de/anomic/kelondro/kelondroMap.java
@@ -36,11 +36,15 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+import de.anomic.kelondro.coding.DateFormatter;
+import de.anomic.kelondro.coding.NaturalOrder;
+import de.anomic.kelondro.tools.ScoreCluster;
+
public class kelondroMap {
private final kelondroBLOB blob;
- private kelondroMScoreCluster<String> cacheScore;
+ private ScoreCluster<String> cacheScore;
private HashMap<String, Map<String, String>> cache;
private final long startup;
private final int cachesize;
@@ -48,7 +52,7 @@ public class kelondroMap {
public kelondroMap(final kelondroBLOB blob, final int cachesize) {
this.blob = blob;
this.cache = new HashMap<String, Map<String, String>>();
- this.cacheScore = new kelondroMScoreCluster<String>();
+ this.cacheScore = new ScoreCluster<String>();
this.startup = System.currentTimeMillis();
this.cachesize = cachesize;
@@ -91,7 +95,7 @@ public class kelondroMap {
public void clear() throws IOException {
this.blob.clear();
this.cache = new HashMap<String, Map<String, String>>();
- this.cacheScore = new kelondroMScoreCluster<String>();
+ this.cacheScore = new ScoreCluster<String>();
}
private static String map2string(final Map<String, String> map, final String comment) {
@@ -139,7 +143,7 @@ public class kelondroMap {
while (key.length() < blob.keylength()) key += "_";
// write entry
- blob.put(key.getBytes(), map2string(newMap, "W" + kelondroDate.formatShortSecond() + " ").getBytes());
+ blob.put(key.getBytes(), map2string(newMap, "W" + DateFormatter.formatShortSecond() + " ").getBytes());
// check for space in cache
checkCacheSpace();
@@ -335,7 +339,7 @@ public class kelondroMap {
if (f.exists()) f.delete();
try {
// make a blob
- kelondroBLOB blob = new kelondroBLOBHeap(f, 12, kelondroNaturalOrder.naturalOrder, 1024 * 1024);
+ kelondroBLOB blob = new kelondroBLOBHeap(f, 12, NaturalOrder.naturalOrder, 1024 * 1024);
// make map
kelondroMap map = new kelondroMap(blob, 1024);
// put some values into the map
diff --git a/source/de/anomic/kelondro/kelondroMapDataMining.java b/source/de/anomic/kelondro/kelondroMapDataMining.java
index bb51f554d..3abaee7cd 100644
--- a/source/de/anomic/kelondro/kelondroMapDataMining.java
+++ b/source/de/anomic/kelondro/kelondroMapDataMining.java
@@ -34,10 +34,12 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+import de.anomic.kelondro.tools.ScoreCluster;
+
public class kelondroMapDataMining extends kelondroMap {
private final String[] sortfields, longaccfields, doubleaccfields;
- private HashMap<String, kelondroMScoreCluster<String>> sortClusterMap; // a String-kelondroMScoreCluster - relation
+ private HashMap<String, ScoreCluster<String>> sortClusterMap; // a String-kelondroMScoreCluster - relation
private HashMap<String, Object> accMap; // to store accumulations of specific fields
@SuppressWarnings("unchecked")
@@ -49,12 +51,12 @@ public class kelondroMapDataMining extends kelondroMap {
this.longaccfields = longaccfields;
this.doubleaccfields = doubleaccfields;
- kelondroMScoreCluster<String>[] cluster = null;
+ ScoreCluster<String>[] cluster = null;
if (sortfields == null) sortClusterMap = null; else {
- sortClusterMap = new HashMap<String, kelondroMScoreCluster<String>>();
- cluster = new kelondroMScoreCluster[sortfields.length];
+ sortClusterMap = new HashMap<String, ScoreCluster<String>>();
+ cluster = new ScoreCluster[sortfields.length];
for (int i = 0; i < sortfields.length; i++) {
- cluster[i] = new kelondroMScoreCluster<String>();
+ cluster[i] = new ScoreCluster<String>();
}
}
@@ -93,7 +95,7 @@ public class kelondroMapDataMining extends kelondroMap {
if (sortfields != null && cluster != null) for (int i = 0; i < sortfields.length; i++) {
cell = map.get(sortfields[i]);
- if (cell != null) cluster[i].setScore(mapname, kelondroMScoreCluster.object2score(cell));
+ if (cell != null) cluster[i].setScore(mapname, ScoreCluster.object2score(cell));
}
if (longaccfields != null && longaccumulator != null) for (int i = 0; i < longaccfields.length; i++) {
@@ -141,9 +143,9 @@ public class kelondroMapDataMining extends kelondroMap {
public synchronized void clear() throws IOException {
super.clear();
if (sortfields == null) sortClusterMap = null; else {
- sortClusterMap = new HashMap<String, kelondroMScoreCluster<String>>();
+ sortClusterMap = new HashMap<String, ScoreCluster<String>>();
for (int i = 0; i < sortfields.length; i++) {
- sortClusterMap.put(sortfields[i], new kelondroMScoreCluster<String>());
+ sortClusterMap.put(sortfields[i], new ScoreCluster<String>());
}
}
@@ -225,12 +227,12 @@ public class kelondroMapDataMining extends kelondroMap {
private void updateSortCluster(final String key, final Map<String, String> map) {
Object cell;
- kelondroMScoreCluster<String> cluster;
+ ScoreCluster<String> cluster;
for (int i = 0; i < sortfields.length; i++) {
cell = map.get(sortfields[i]);
if (cell != null) {
cluster = sortClusterMap.get(sortfields[i]);
- cluster.setScore(key, kelondroMScoreCluster.object2score(cell));
+ cluster.setScore(key, ScoreCluster.object2score(cell));
sortClusterMap.put(sortfields[i], cluster);
}
}
@@ -256,7 +258,7 @@ public class kelondroMapDataMining extends kelondroMap {
private void deleteSortCluster(final String key) {
if (key == null) return;
- kelondroMScoreCluster<String> cluster;
+ ScoreCluster<String> cluster;
for (int i = 0; i < sortfields.length; i++) {
cluster = sortClusterMap.get(sortfields[i]);
cluster.deleteScore(key);
@@ -267,7 +269,7 @@ public class kelondroMapDataMining extends kelondroMap {
public synchronized Iterator<byte[]> keys(final boolean up, /* sorted by */ final String field) {
// sorted iteration using the sortClusters
if (sortClusterMap == null) return null;
- final kelondroMScoreCluster<String> cluster = sortClusterMap.get(field);
+ final ScoreCluster<String> cluster = sortClusterMap.get(field);
if (cluster == null) return null; // sort field does not exist
//System.out.println("DEBUG: cluster for field " + field + ": " + cluster.toString());
return new string2bytearrayIterator(cluster.scores(up));
diff --git a/source/de/anomic/kelondro/kelondroMergeIterator.java b/source/de/anomic/kelondro/kelondroMergeIterator.java
index 90b0464ed..6137ae503 100644
--- a/source/de/anomic/kelondro/kelondroMergeIterator.java
+++ b/source/de/anomic/kelondro/kelondroMergeIterator.java
@@ -29,6 +29,8 @@ import java.util.Comparator;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
+import de.anomic.kelondro.coding.kelondroOrder;
+
public class kelondroMergeIterator<E> implements kelondroCloneableIterator<E> {
private Comparator<E> comp;
diff --git a/source/de/anomic/kelondro/kelondroObjectBuffer.java b/source/de/anomic/kelondro/kelondroObjectBuffer.java
index 0fe1156c8..4593281fe 100644
--- a/source/de/anomic/kelondro/kelondroObjectBuffer.java
+++ b/source/de/anomic/kelondro/kelondroObjectBuffer.java
@@ -56,6 +56,8 @@
package de.anomic.kelondro;
+import de.anomic.kelondro.coding.NaturalOrder;
+
public class kelondroObjectBuffer {
// this is a buffer for a single (only one) key/value object
@@ -108,7 +110,7 @@ public class kelondroObjectBuffer {
public void put(final byte[] key, final Object value) {
if ((key == null) || (value == null)) return;
synchronized(this) {
- if (kelondroNaturalOrder.equal(this.key, key)){
+ if (NaturalOrder.equal(this.key, key)){
this.writeDouble++;
} else {
this.writeUnique++;
@@ -121,7 +123,7 @@ public class kelondroObjectBuffer {
public void put(final String key, final Object value) {
if ((key == null) || (value == null)) return;
synchronized(this) {
- if (kelondroNaturalOrder.equal(this.key, key.getBytes())){
+ if (NaturalOrder.equal(this.key, key.getBytes())){
this.writeDouble++;
} else {
this.writeUnique++;
@@ -134,7 +136,7 @@ public class kelondroObjectBuffer {
public Object get(final byte[] key) {
if (key == null) return null;
synchronized(this) {
- if (kelondroNaturalOrder.equal(this.key, key)){
+ if (NaturalOrder.equal(this.key, key)){
this.readHit++;
return this.value;
} else {
@@ -147,7 +149,7 @@ public class kelondroObjectBuffer {
public Object get(final String key) {
if (key == null) return null;
synchronized(this) {
- if (kelondroNaturalOrder.equal(this.key, key.getBytes())){
+ if (NaturalOrder.equal(this.key, key.getBytes())){
this.readHit++;
return this.value;
} else {
@@ -160,7 +162,7 @@ public class kelondroObjectBuffer {
public void remove(final byte[] key) {
if (key == null) return;
synchronized(this) {
- if (kelondroNaturalOrder.equal(this.key, key)){
+ if (NaturalOrder.equal(this.key, key)){
this.key = null;
this.value = null;
}
@@ -170,7 +172,7 @@ public class kelondroObjectBuffer {
public void remove(final String key) {
if (key == null) return;
synchronized(this) {
- if (kelondroNaturalOrder.equal(this.key, key.getBytes())){
+ if (NaturalOrder.equal(this.key, key.getBytes())){
this.key = null;
this.value = null;
}
diff --git a/source/de/anomic/kelondro/kelondroRelations.java b/source/de/anomic/kelondro/kelondroRelations.java
index 1ddf7ca40..96cd79c33 100755
--- a/source/de/anomic/kelondro/kelondroRelations.java
+++ b/source/de/anomic/kelondro/kelondroRelations.java
@@ -30,16 +30,20 @@ import java.io.File;
import java.io.IOException;
import java.util.HashMap;
+import de.anomic.kelondro.coding.NaturalOrder;
+import de.anomic.kelondro.index.Row;
+import de.anomic.kelondro.index.ObjectIndex;
+
public class kelondroRelations {
private final File baseDir;
- private HashMap<String, kelondroIndex> relations;
+ private HashMap<String, ObjectIndex> relations;
public kelondroRelations(final File location) {
this.baseDir = location;
}
- private static kelondroRow rowdef(String filename) {
+ private static Row rowdef(String filename) {
int p = filename.lastIndexOf('.');
if (p >= 0) filename = filename.substring(0, p);
p = filename.lastIndexOf('-');
@@ -52,13 +56,13 @@ public class kelondroRelations {
return rowdef(keysize, payloadsize);
}
- private static kelondroRow rowdef(final int keysize, final int payloadsize) {
- return new kelondroRow(
+ private static Row rowdef(final int keysize, final int payloadsize) {
+ return new Row(
"byte[] key-" + keysize + ", " +
"long time-8" + keysize + ", " +
"int ttl-4" + keysize + ", " +
"byte[] node-" + payloadsize,
- kelondroNaturalOrder.naturalOrder, 0);
+ NaturalOrder.naturalOrder, 0);
}
private static String filename(final String tablename, final int keysize, final int payloadsize) {
@@ -67,7 +71,7 @@ public class kelondroRelations {
public void declareRelation(final String name, final int keysize, final int payloadsize) {
// try to get the relation from the relation-cache
- final kelondroIndex relation = relations.get(name);
+ final ObjectIndex relation = relations.get(name);
if (relation != null) return;
// try to find the relation as stored on file
final String[] list = baseDir.list();
@@ -75,29 +79,29 @@ public class kelondroRelations {
for (int i = 0; i < list.length; i++) {
if (list[i].startsWith(name)) {
if (!list[i].equals(targetfilename)) continue;
- final kelondroRow row = rowdef(list[i]);
+ final Row row = rowdef(list[i]);
if (row.primaryKeyLength != keysize || row.column(1).cellwidth != payloadsize) continue; // a wrong table
- final kelondroIndex table = new kelondroEcoTable(new File(baseDir, list[i]), row, kelondroEcoTable.tailCacheUsageAuto, 1024*1024, 0);
+ final ObjectIndex table = new kelondroEcoTable(new File(baseDir, list[i]), row, kelondroEcoTable.tailCacheUsageAuto, 1024*1024, 0);
relations.put(name, table);
return;
}
}
// the relation does not exist, create it
- final kelondroRow row = rowdef(keysize, payloadsize);
- final kelondroIndex table = new kelondroEcoTable(new File(baseDir, targetfilename), row, kelondroEcoTable.tailCacheUsageAuto, 1024*1024, 0);
+ final Row row = rowdef(keysize, payloadsize);
+ final ObjectIndex table = new kelondroEcoTable(new File(baseDir, targetfilename), row, kelondroEcoTable.tailCacheUsageAuto, 1024*1024, 0);
relations.put(name, table);
}
- public kelondroIndex getRelation(final String name) {
+ public ObjectIndex getRelation(final String name) {
// try to get the relation from the relation-cache
- final kelondroIndex relation = relations.get(name);
+ final ObjectIndex relation = relations.get(name);
if (relation != null) return relation;
// try to find the relation as stored on file
final String[] list = baseDir.list();
for (int i = 0; i < list.length; i++) {
if (list[i].startsWith(name)) {
- final kelondroRow row = rowdef(list[i]);
- final kelondroIndex table = new kelondroEcoTable(new File(baseDir, list[i]), row, kelondroEcoTable.tailCacheUsageAuto, 1024*1024, 0);
+ final Row row = rowdef(list[i]);
+ final ObjectIndex table = new kelondroEcoTable(new File(baseDir, list[i]), row, kelondroEcoTable.tailCacheUsageAuto, 1024*1024, 0);
relations.put(name, table);
return table;
}
@@ -113,14 +117,14 @@ public class kelondroRelations {
}
public byte[] putRelation(final String name, final byte[] key, final byte[] value) throws IOException {
- final kelondroIndex table = getRelation(name);
+ final ObjectIndex table = getRelation(name);
if (table == null) return null;
- final kelondroRow.Entry entry = table.row().newEntry();
+ final Row.Entry entry = table.row().newEntry();
entry.setCol(0, key);
entry.setCol(1, System.currentTimeMillis());
entry.setCol(2, 1000000);
entry.setCol(3, value);
- final kelondroRow.Entry oldentry = table.put(entry);
+ final Row.Entry oldentry = table.put(entry);
if (oldentry == null) return null;
return oldentry.getColBytes(3);
}
@@ -132,23 +136,23 @@ public class kelondroRelations {
}
public byte[] getRelation(final String name, final byte[] key) throws IOException {
- final kelondroIndex table = getRelation(name);
+ final ObjectIndex table = getRelation(name);
if (table == null) return null;
- final kelondroRow.Entry entry = table.get(key);
+ final Row.Entry entry = table.get(key);
if (entry == null) return null;
return entry.getColBytes(3);
}
public boolean hasRelation(final String name, final byte[] key) {
- final kelondroIndex table = getRelation(name);
+ final ObjectIndex table = getRelation(name);
if (table == null) return false;
return table.has(key);
}
public byte[] removeRelation(final String name, final byte[] key) throws IOException {
- final kelondroIndex table = getRelation(name);
+ final ObjectIndex table = getRelation(name);
if (table == null) return null;
- final kelondroRow.Entry entry = table.remove(key);
+ final Row.Entry entry = table.remove(key);
if (entry == null) return null;
return entry.getColBytes(3);
}
diff --git a/source/de/anomic/kelondro/kelondroSQLTable.java b/source/de/anomic/kelondro/kelondroSQLTable.java
index 966f9f106..4147c95e3 100644
--- a/source/de/anomic/kelondro/kelondroSQLTable.java
+++ b/source/de/anomic/kelondro/kelondroSQLTable.java
@@ -37,6 +37,12 @@ import java.util.Date;
import java.util.Iterator;
import java.util.List;
+import de.anomic.kelondro.coding.ByteOrder;
+import de.anomic.kelondro.coding.NaturalOrder;
+import de.anomic.kelondro.index.Row;
+import de.anomic.kelondro.index.RowCollection;
+import de.anomic.kelondro.index.ObjectIndex;
+
/*
* Commands to create a database using mysql:
*
@@ -48,7 +54,7 @@ import java.util.List;
* grant ALL on yacy.* to yacy;
*/
-public class kelondroSQLTable implements kelondroIndex {
+public class kelondroSQLTable implements ObjectIndex {
private static final String db_driver_str_mysql = "org.gjt.mm.mysql.Driver";
private static final String db_driver_str_pgsql = "org.postgresql.Driver";
@@ -60,10 +66,10 @@ public class kelondroSQLTable implements kelondroIndex {
private static final String db_pwd_str = "yacy";
private Connection theDBConnection = null;
- private final kelondroByteOrder order = new kelondroNaturalOrder(true);
- private final kelondroRow rowdef;
+ private final ByteOrder order = new NaturalOrder(true);
+ private final Row rowdef;
- public kelondroSQLTable(final String dbType, final kelondroRow rowdef) throws Exception {
+ public kelondroSQLTable(final String dbType, final Row rowdef) throws Exception {
this.rowdef = rowdef;
openDatabaseConnection(dbType);
}
@@ -128,7 +134,7 @@ public class kelondroSQLTable implements kelondroIndex {
}
}
- public kelondroRow row() {
+ public Row row() {
return this.rowdef;
}
@@ -140,11 +146,11 @@ public class kelondroSQLTable implements kelondroIndex {
}
}
- public ArrayList<kelondroRowCollection> removeDoubles() {
- return new ArrayList<kelondroRowCollection>();
+ public ArrayList<RowCollection> removeDoubles() {
+ return new ArrayList<RowCollection>();
}
- public kelondroRow.Entry get(final byte[] key) throws IOException {
+ public Row.Entry get(final byte[] key) throws IOException {
try {
final String sqlQuery = "SELECT value from test where hash = ?";
@@ -161,26 +167,26 @@ public class kelondroSQLTable implements kelondroIndex {
sqlStatement.close();
if (value == null) return null;
- final kelondroRow.Entry entry = this.rowdef.newEntry(value);
+ final Row.Entry entry = this.rowdef.newEntry(value);
return entry;
} catch (final Exception e) {
throw new IOException(e.getMessage());
}
}
- public synchronized void putMultiple(final List<kelondroRow.Entry> rows) throws IOException {
- final Iterator<kelondroRow.Entry> i = rows.iterator();
+ public synchronized void putMultiple(final List<Row.Entry> rows) throws IOException {
+ final Iterator<Row.Entry> i = rows.iterator();
while (i.hasNext()) put(i.next());
}
- public kelondroRow.Entry put(final kelondroRow.Entry row, final Date entryDate) throws IOException {
+ public Row.Entry put(final Row.Entry row, final Date entryDate) throws IOException {
return put(row);
}
- public kelondroRow.Entry put(final kelondroRow.Entry row) throws IOException {
+ public Row.Entry put(final Row.Entry row) throws IOException {
try {
- final kelondroRow.Entry oldEntry = remove(row.getColBytes(0));
+ final Row.Entry oldEntry = remove(row.getColBytes(0));
final String sqlQuery = "INSERT INTO test (" +
"hash, " +
@@ -202,23 +208,23 @@ public class kelondroSQLTable implements kelondroIndex {
}
}
- public synchronized void addUnique(final kelondroRow.Entry row) throws IOException {
+ public synchronized void addUnique(final Row.Entry row) throws IOException {
throw new UnsupportedOperationException();
}
- public synchronized void addUnique(final kelondroRow.Entry row, final Date entryDate) {
+ public synchronized void addUnique(final Row.Entry row, final Date entryDate) {
throw new UnsupportedOperationException();
}
- public synchronized void addUniqueMultiple(final List<kelondroRow.Entry> rows) throws IOException {
+ public synchronized void addUniqueMultiple(final List<Row.Entry> rows) throws IOException {
throw new UnsupportedOperationException();
}
- public kelondroRow.Entry remove(final byte[] key) throws IOException {
+ public Row.Entry remove(final byte[] key) throws IOException {
PreparedStatement sqlStatement = null;
try {
- final kelondroRow.Entry entry = this.get(key);
+ final Row.Entry entry = this.get(key);
if (entry == null) return null;
final String sqlQuery = "DELETE FROM test WHERE hash = ?";
@@ -242,11 +248,11 @@ public class kelondroSQLTable implements kelondroIndex {
}
}
- public kelondroRow.Entry removeOne() {
+ public Row.Entry removeOne() {
return null;
}
- public kelondroCloneableIterator<kelondroRow.Entry> rows(final boolean up, final byte[] startKey) throws IOException {
+ public kelondroCloneableIterator<Row.Entry> rows(final boolean up, final byte[] startKey) throws IOException {
// Objects are of type kelondroRow.Entry
return null;
}
@@ -266,7 +272,7 @@ public class kelondroSQLTable implements kelondroIndex {
return 0;
}
- public kelondroByteOrder order() {
+ public ByteOrder order() {
return this.order;
}
diff --git a/source/de/anomic/kelondro/kelondroSplitTable.java b/source/de/anomic/kelondro/kelondroSplitTable.java
index 0a3f0354a..1aa302e85 100644
--- a/source/de/anomic/kelondro/kelondroSplitTable.java
+++ b/source/de/anomic/kelondro/kelondroSplitTable.java
@@ -46,33 +46,40 @@ import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
+import de.anomic.kelondro.coding.NaturalOrder;
+import de.anomic.kelondro.coding.kelondroOrder;
+import de.anomic.kelondro.index.Column;
+import de.anomic.kelondro.index.RAMIndex;
+import de.anomic.kelondro.index.Row;
+import de.anomic.kelondro.index.RowCollection;
+import de.anomic.kelondro.index.ObjectIndex;
import de.anomic.server.NamePrefixThreadFactory;
import de.anomic.server.serverProcessor;
import de.anomic.server.logging.serverLog;
-public class kelondroSplitTable implements kelondroIndex {
+public class kelondroSplitTable implements ObjectIndex {
// this is a set of kelondro tables
// the set is divided into tables with different entry date
// the table type can be either kelondroFlex or kelondroEco
private static final int EcoFSBufferSize = 20;
- static final kelondroIndex dummyIndex = new kelondroRAMIndex(new kelondroRow(new kelondroColumn[]{new kelondroColumn("key", kelondroColumn.celltype_binary, kelondroColumn.encoder_bytes, 2, "key")}, kelondroNaturalOrder.naturalOrder, 0), 0);
+ static final ObjectIndex dummyIndex = new RAMIndex(new Row(new Column[]{new Column("key", Column.celltype_binary, Column.encoder_bytes, 2, "key")}, NaturalOrder.naturalOrder, 0), 0);
// the thread pool for the keeperOf executor service
private ExecutorService executor;
- private HashMap<String, kelondroIndex> tables; // a map from a date string to a kelondroIndex object
- private final kelondroRow rowdef;
+ private HashMap<String, ObjectIndex> tables; // a map from a date string to a kelondroIndex object
+ private final Row rowdef;
private final File path;
private final String tablename;
- private final kelondroOrder<kelondroRow.Entry> entryOrder;
+ private final kelondroOrder<Row.Entry> entryOrder;
- public kelondroSplitTable(final File path, final String tablename, final kelondroRow rowdef, final boolean resetOnFail) {
+ public kelondroSplitTable(final File path, final String tablename, final Row rowdef, final boolean resetOnFail) {
this.path = path;
this.tablename = tablename;
this.rowdef = rowdef;
- this.entryOrder = new kelondroRow.EntryComparator(rowdef.objectOrder);
+ this.entryOrder = new Row.EntryComparator(rowdef.objectOrder);
init(resetOnFail);
}
@@ -82,7 +89,7 @@ public class kelondroSplitTable implements kelondroIndex {
this.executor = new ThreadPoolExecutor(serverProcessor.useCPU + 1, serverProcessor.useCPU + 1, 10, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new NamePrefixThreadFactory(tablename));
// initialized tables map
- this.tables = new HashMap<String, kelondroIndex>();
+ this.tables = new HashMap<String, ObjectIndex>();
if (!(path.exists())) path.mkdirs();
final String[] tablefile = path.list();
String date;
@@ -113,7 +120,7 @@ public class kelondroSplitTable implements kelondroIndex {
Map.Entry<String, Long> entry;
String maxf;
long maxram;
- kelondroIndex table;
+ ObjectIndex table;
while (t.size() > 0) {
// find maximum table
maxram = 0;
@@ -179,7 +186,7 @@ public class kelondroSplitTable implements kelondroIndex {
}
public int size() {
- final Iterator<kelondroIndex> i = tables.values().iterator();
+ final Iterator<ObjectIndex> i = tables.values().iterator();
int s = 0;
while (i.hasNext()) s += i.next().size();
return s;
@@ -187,13 +194,13 @@ public class kelondroSplitTable implements kelondroIndex {
public int writeBufferSize() {
int s = 0;
- for (final kelondroIndex index : tables.values()) {
+ for (final ObjectIndex index : tables.values()) {
if (index instanceof kelondroCache) s += ((kelondroCache) index).writeBufferSize();
}
return s;
}
- public kelondroRow row() {
+ public Row row() {
return this.rowdef;
}
@@ -201,28 +208,28 @@ public class kelondroSplitTable implements kelondroIndex {
return keeperOf(key) != null;
}
- public synchronized kelondroRow.Entry get(final byte[] key) throws IOException {
- final kelondroIndex keeper = keeperOf(key);
+ public synchronized Row.Entry get(final byte[] key) throws IOException {
+ final ObjectIndex keeper = keeperOf(key);
if (keeper == null) return null;
return keeper.get(key);
}
- public synchronized void putMultiple(final List<kelondroRow.Entry> rows) throws IOException {
+ public synchronized void putMultiple(final List<Row.Entry> rows) throws IOException {
throw new UnsupportedOperationException("not yet implemented");
}
- public synchronized kelondroRow.Entry put(final kelondroRow.Entry row) throws IOException {
+ public synchronized Row.Entry put(final Row.Entry row) throws IOException {
return put(row, null); // entry for current date
}
- public synchronized kelondroRow.Entry put(final kelondroRow.Entry row, Date entryDate) throws IOException {
+ public synchronized Row.Entry put(final Row.Entry row, Date entryDate) throws IOException {
assert row.objectsize() <= this.rowdef.objectsize;
- final kelondroIndex keeper = keeperOf(row.getColBytes(0));
+ final ObjectIndex keeper = keeperOf(row.getColBytes(0));
if (keeper != null) return keeper.put(row);
if ((entryDate == null) || (entryDate.after(new Date()))) entryDate = new Date(); // fix date
final String suffix = dateSuffix(entryDate);
if (suffix == null) return null;
- kelondroIndex table = tables.get(suffix);
+ ObjectIndex table = tables.get(suffix);
if (table == null) {
// open table
final File f = new File(path, tablename + "." + suffix);
@@ -242,20 +249,20 @@ public class kelondroSplitTable implements kelondroIndex {
return null;
}
- public synchronized kelondroIndex keeperOf(final byte[] key) {
+ public synchronized ObjectIndex keeperOf(final byte[] key) {
// because the index is stored only in one table,
// and the index is completely in RAM, a concurrency will create
// not concurrent File accesses
//long start = System.currentTimeMillis();
// start a concurrent query to database tables
- final CompletionService<kelondroIndex> cs = new ExecutorCompletionService<kelondroIndex>(executor);
+ final CompletionService<ObjectIndex> cs = new ExecutorCompletionService<ObjectIndex>(executor);
final int s = tables.size();
int rejected = 0;
- for (final kelondroIndex table : tables.values()) {
+ for (final ObjectIndex table : tables.values()) {
try {
- cs.submit(new Callable<kelondroIndex>() {
- public kelondroIndex call() {
+ cs.submit(new Callable<ObjectIndex>() {
+ public ObjectIndex call() {
if (table.has(key)) return table;
return dummyIndex;
}
@@ -271,8 +278,8 @@ public class kelondroSplitTable implements kelondroIndex {
// read the result
try {
for (int i = 0, n = s - rejected; i < n; i++) {
- final Future<kelondroIndex> f = cs.take();
- final kelondroIndex index = f.get();
+ final Future<ObjectIndex> f = cs.take();
+ final ObjectIndex index = f.get();
if (index != dummyIndex) {
//System.out.println("*DEBUG SplitTable success.time = " + (System.currentTimeMillis() - start) + " ms");
return index;
@@ -289,16 +296,16 @@ public class kelondroSplitTable implements kelondroIndex {
return null;
}
- public synchronized void addUnique(final kelondroRow.Entry row) throws IOException {
+ public synchronized void addUnique(final Row.Entry row) throws IOException {
addUnique(row, null);
}
- public synchronized void addUnique(final kelondroRow.Entry row, Date entryDate) throws IOException {
+ public synchronized void addUnique(final Row.Entry row, Date entryDate) throws IOException {
assert row.objectsize() <= this.rowdef.objectsize;
if ((entryDate == null) || (entryDate.after(new Date()))) entryDate = new Date(); // fix date
final String suffix = dateSuffix(entryDate);
if (suffix == null) return;
- kelondroIndex table = tables.get(suffix);
+ ObjectIndex table = tables.get(suffix);
if (table == null) {
// make new table
table = new kelondroEcoTable(new File(path, tablename + "." + suffix), rowdef, kelondroEcoTable.tailCacheDenyUsage, EcoFSBufferSize, 0);
@@ -307,34 +314,34 @@ public class kelondroSplitTable implements kelondroIndex {
table.addUnique(row);
}
- public synchronized void addUniqueMultiple(final List<kelondroRow.Entry> rows) throws IOException {
- final Iterator<kelondroRow.Entry> i = rows.iterator();
+ public synchronized void addUniqueMultiple(final List<Row.Entry> rows) throws IOException {
+ final Iterator<Row.Entry> i = rows.iterator();
while (i.hasNext()) addUnique(i.next());
}
- public synchronized void addUniqueMultiple(final List<kelondroRow.Entry> rows, final Date entryDate) throws IOException {
- final Iterator<kelondroRow.Entry> i = rows.iterator();
+ public synchronized void addUniqueMultiple(final List<Row.Entry> rows, final Date entryDate) throws IOException {
+ final Iterator<Row.Entry> i = rows.iterator();
while (i.hasNext()) addUnique(i.next(), entryDate);
}
- public ArrayList<kelondroRowCollection> removeDoubles() throws IOException {
- final Iterator<kelondroIndex> i = tables.values().iterator();
- final ArrayList<kelondroRowCollection> report = new ArrayList<kelondroRowCollection>();
+ public ArrayList<RowCollection> removeDoubles() throws IOException {
+ final Iterator<ObjectIndex> i = tables.values().iterator();
+ final ArrayList<RowCollection> report = new ArrayList<RowCollection>();
while (i.hasNext()) {
report.addAll(i.next().removeDoubles());
}
return report;
}
- public synchronized kelondroRow.Entry remove(final byte[] key) throws IOException {
- final kelondroIndex table = keeperOf(key);
+ public synchronized Row.Entry remove(final byte[] key) throws IOException {
+ final ObjectIndex table = keeperOf(key);
if (table == null) return null;
return table.remove(key);
}
- public synchronized kelondroRow.Entry removeOne() throws IOException {
- final Iterator<kelondroIndex> i = tables.values().iterator();
- kelondroIndex table, maxtable = null;
+ public synchronized Row.Entry removeOne() throws IOException {
+ final Iterator<ObjectIndex> i = tables.values().iterator();
+ ObjectIndex table, maxtable = null;
int maxcount = -1;
while (i.hasNext()) {
table = i.next();
@@ -351,16 +358,16 @@ public class kelondroSplitTable implements kelondroIndex {
public synchronized kelondroCloneableIterator<byte[]> keys(final boolean up, final byte[] firstKey) throws IOException {
final List<kelondroCloneableIterator<byte[]>> c = new ArrayList<kelondroCloneableIterator<byte[]>>(tables.size());
- final Iterator<kelondroIndex> i = tables.values().iterator();
+ final Iterator<ObjectIndex> i = tables.values().iterator();
while (i.hasNext()) {
c.add(i.next().keys(up, firstKey));
}
return kelondroMergeIterator.cascade(c, rowdef.objectOrder, kelondroMergeIterator.simpleMerge, up);
}
- public synchronized kelondroCloneableIterator<kelondroRow.Entry> rows(final boolean up, final byte[] firstKey) throws IOException {
- final List<kelondroCloneableIterator<kelondroRow.Entry>> c = new ArrayList<kelondroCloneableIterator<kelondroRow.Entry>>(tables.size());
- final Iterator<kelondroIndex> i = tables.values().iterator();
+ public synchronized kelondroCloneableIterator<Row.Entry> rows(final boolean up, final byte[] firstKey) throws IOException {
+ final List<kelondroCloneableIterator<Row.Entry>> c = new ArrayList<kelondroCloneableIterator<Row.Entry>>(tables.size());
+ final Iterator<ObjectIndex> i = tables.values().iterator();
while (i.hasNext()) {
c.add(i.next().rows(up, firstKey));
}
@@ -395,7 +402,7 @@ public class kelondroSplitTable implements kelondroIndex {
} catch (final InterruptedException e) {
}
this.executor = null;
- final Iterator<kelondroIndex> i = tables.values().iterator();
+ final Iterator<ObjectIndex> i = tables.values().iterator();
while (i.hasNext()) {
i.next().close();
}
@@ -407,7 +414,7 @@ public class kelondroSplitTable implements kelondroIndex {
}
public void deleteOnExit() {
- for (kelondroIndex i: this.tables.values()) i.deleteOnExit();
+ for (ObjectIndex i: this.tables.values()) i.deleteOnExit();
}
}
diff --git a/source/de/anomic/kelondro/kelondroStack.java b/source/de/anomic/kelondro/kelondroStack.java
index 17c576411..8d3813855 100644
--- a/source/de/anomic/kelondro/kelondroStack.java
+++ b/source/de/anomic/kelondro/kelondroStack.java
@@ -34,6 +34,9 @@ import java.io.RandomAccessFile;
import java.util.Iterator;
import java.util.StringTokenizer;
+import de.anomic.kelondro.coding.NaturalOrder;
+import de.anomic.kelondro.index.Row;
+
public final class kelondroStack extends kelondroFullRecords {
// define the Over-Head-Array
@@ -47,7 +50,7 @@ public final class kelondroStack extends kelondroFullRecords {
protected static final int root = 0; // pointer for FHandles-array: pointer to root node
protected static final int toor = 1; // pointer for FHandles-array: pointer to root node
- public kelondroStack(final File file, final kelondroRow rowdef) throws IOException {
+ public kelondroStack(final File file, final Row rowdef) throws IOException {
// this creates a new stack
super(file, thisOHBytes, thisOHHandles, rowdef, thisFHandles, rowdef.columns() /* txtProps */, 80 /* txtPropWidth */);
if (super.fileExisted) {
@@ -58,7 +61,7 @@ public final class kelondroStack extends kelondroFullRecords {
}
}
- public static final kelondroStack open(final File file, final kelondroRow rowdef) {
+ public static final kelondroStack open(final File file, final Row rowdef) {
try {
return new kelondroStack(file, rowdef);
} catch (final IOException e) {
@@ -77,7 +80,7 @@ public final class kelondroStack extends kelondroFullRecords {
public static kelondroStack reset(final kelondroStack stack) {
// memorize settings to this file
final File f = new File(stack.filename);
- final kelondroRow row = stack.row();
+ final Row row = stack.row();
// close and delete the file
try {stack.close();} catch (final Exception e) {}
@@ -87,13 +90,13 @@ public final class kelondroStack extends kelondroFullRecords {
return open(f, row);
}
- public Iterator<kelondroRow.Entry> stackIterator(final boolean up) {
+ public Iterator<Row.Entry> stackIterator(final boolean up) {
// iterates the elements in an ordered way.
// returns kelondroRow.Entry - type Objects
return new stackIterator(up);
}
- public class stackIterator implements Iterator<kelondroRow.Entry> {
+ public class stackIterator implements Iterator<Row.Entry> {
kelondroHandle nextHandle = null;
kelondroHandle lastHandle = null;
boolean up;
@@ -107,7 +110,7 @@ public final class kelondroStack extends kelondroFullRecords {
return (nextHandle != null);
}
- public kelondroRow.Entry next() {
+ public Row.Entry next() {
lastHandle = nextHandle;
try {
nextHandle = new EcoNode(nextHandle).getOHHandle((up) ? right : left);
@@ -131,7 +134,7 @@ public final class kelondroStack extends kelondroFullRecords {
return super.size();
}
- public synchronized void push(final kelondroRow.Entry row) throws IOException {
+ public synchronized void push(final Row.Entry row) throws IOException {
// check if there is already a stack
if (getHandle(toor) == null) {
if (getHandle(root) != null) throw new RuntimeException("push: internal organisation of root and toor");
@@ -159,11 +162,11 @@ public final class kelondroStack extends kelondroFullRecords {
}
}
- public synchronized kelondroRow.Entry pop() throws IOException {
+ public synchronized Row.Entry pop() throws IOException {
// return row ontop of the stack and shrink stack by one
final kelondroNode n = topNode();
if (n == null) return null;
- final kelondroRow.Entry ret = row().newEntry(n.getValueRow());
+ final Row.Entry ret = row().newEntry(n.getValueRow());
// remove node
unlinkNode(n);
@@ -172,18 +175,18 @@ public final class kelondroStack extends kelondroFullRecords {
return ret;
}
- public synchronized kelondroRow.Entry top() throws IOException {
+ public synchronized Row.Entry top() throws IOException {
// return row ontop of the stack
final kelondroNode n = topNode();
if (n == null) return null;
return row().newEntry(n.getValueRow());
}
- public synchronized kelondroRow.Entry pot() throws IOException {
+ public synchronized Row.Entry pot() throws IOException {
// return row on the bottom of the stack and remove record
final kelondroNode n = botNode();
if (n == null) return null;
- final kelondroRow.Entry ret = row().newEntry(n.getValueRow());
+ final Row.Entry ret = row().newEntry(n.getValueRow());
// remove node
unlinkNode(n);
@@ -192,7 +195,7 @@ public final class kelondroStack extends kelondroFullRecords {
return ret;
}
- public synchronized kelondroRow.Entry bot() throws IOException {
+ public synchronized Row.Entry bot() throws IOException {
// return row on the bottom of the stack
final kelondroNode n = botNode();
if (n == null) return null;
@@ -251,7 +254,7 @@ public final class kelondroStack extends kelondroFullRecords {
String s;
StringTokenizer st;
int recs = 0;
- final kelondroRow.Entry buffer = row().newEntry();
+ final Row.Entry buffer = row().newEntry();
int c;
int line = 0;
while ((s = f.readLine()) != null) {
@@ -287,8 +290,8 @@ public final class kelondroStack extends kelondroFullRecords {
public void print() throws IOException {
super.print();
- final Iterator<kelondroRow.Entry> it = stackIterator(true);
- kelondroRow.Entry r;
+ final Iterator<Row.Entry> it = stackIterator(true);
+ Row.Entry r;
while (it.hasNext()) {
r = it.next();
System.out.print(" KEY:'" + r.getColString(0, null) + "'");
@@ -304,7 +307,7 @@ public final class kelondroStack extends kelondroFullRecords {
for (int i = 0; i < args.length; i++) System.out.print(args[i] + " ");
System.out.println("");
byte[] ret = null;
- final kelondroRow lens = new kelondroRow("byte[] key-" + Integer.parseInt(args[1]) + ", byte[] value-" + Integer.parseInt(args[2]), kelondroNaturalOrder.naturalOrder, 0);
+ final Row lens = new Row("byte[] key-" + Integer.parseInt(args[1]) + ", byte[] value-" + Integer.parseInt(args[2]), NaturalOrder.naturalOrder, 0);
try {
if ((args.length > 4) || (args.length < 2)) {
System.err.println("usage: kelondroStack -c|-p|-v|-g|-i|-s [file]|[key [value]] <db-file>");
@@ -317,7 +320,7 @@ public final class kelondroStack extends kelondroFullRecords {
ret = null;
} else if (args[0].equals("-g")) {
fm = new kelondroStack(new File(args[1]), lens);
- final kelondroRow.Entry ret2 = fm.pop();
+ final Row.Entry ret2 = fm.pop();
ret = ((ret2 == null) ? null : ret2.getColBytes(1));
fm.close();
}
@@ -349,7 +352,7 @@ public final class kelondroStack extends kelondroFullRecords {
}
} else if (args[0].equals("-g")) {
final kelondroStack fm = new kelondroStack(new File(args[2]), lens);
- final kelondroRow.Entry ret2 = fm.pop();
+ final Row.Entry ret2 = fm.pop();
ret = ((ret2 == null) ? null : ret2.getColBytes(1));
fm.close();
}
diff --git a/source/de/anomic/kelondro/kelondroTree.java b/source/de/anomic/kelondro/kelondroTree.java
index b87f54e05..b6141265d 100644
--- a/source/de/anomic/kelondro/kelondroTree.java
+++ b/source/de/anomic/kelondro/kelondroTree.java
@@ -45,10 +45,15 @@ import java.util.TreeSet;
import java.util.Vector;
import java.util.logging.Logger;
-import de.anomic.kelondro.kelondroRow.Entry;
+import de.anomic.kelondro.coding.ByteOrder;
+import de.anomic.kelondro.coding.NaturalOrder;
+import de.anomic.kelondro.index.Row;
+import de.anomic.kelondro.index.RowCollection;
+import de.anomic.kelondro.index.ObjectIndex;
+import de.anomic.kelondro.index.Row.Entry;
import de.anomic.server.logging.serverLog;
-public class kelondroTree extends kelondroCachedRecords implements kelondroIndex {
+public class kelondroTree extends kelondroCachedRecords implements ObjectIndex {
// logging (This probably needs someone to initialize the java.util.logging.* facilities);
public static final Logger log = Logger.getLogger("KELONDRO");
@@ -78,12 +83,12 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
* Deprecated Class. Please use kelondroEcoTable instead
*/
@Deprecated
- public kelondroTree(final File file, final boolean useNodeCache, final long preloadTime, final kelondroRow rowdef) throws IOException {
+ public kelondroTree(final File file, final boolean useNodeCache, final long preloadTime, final Row rowdef) throws IOException {
this(file, useNodeCache, preloadTime, rowdef, rowdef.columns() /* txtProps */, 80 /* txtPropWidth */);
}
@Deprecated
- public kelondroTree(final File file, final boolean useNodeCache, final long preloadTime, final kelondroRow rowdef, final int txtProps, final int txtPropsWidth) throws IOException {
+ public kelondroTree(final File file, final boolean useNodeCache, final long preloadTime, final Row rowdef, final int txtProps, final int txtPropsWidth) throws IOException {
// opens an existing tree file or creates a new tree file
super(file, useNodeCache, preloadTime,
thisOHBytes, thisOHHandles, rowdef,
@@ -93,11 +98,11 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
setHandle(root, null); // define the root value
}
super.setLogger(log);
- this.loopDetectionOrder = new kelondroByteOrder.StringOrder(rowdef.objectOrder);
+ this.loopDetectionOrder = new ByteOrder.StringOrder(rowdef.objectOrder);
}
@Deprecated
- public static final kelondroTree open(final File file, final boolean useNodeCache, final long preloadTime, final kelondroRow rowdef, final int txtProps, final int txtPropsWidth) {
+ public static final kelondroTree open(final File file, final boolean useNodeCache, final long preloadTime, final Row rowdef, final int txtProps, final int txtPropsWidth) {
// opens new or existing file; in case that any error occur the file is deleted again and it is tried to create the file again
// if that fails, the method returns null
try {
@@ -143,8 +148,8 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
}
// Returns the value to which this map maps the specified key.
- public kelondroRow.Entry get(final byte[] key) throws IOException {
- kelondroRow.Entry result;
+ public Row.Entry get(final byte[] key) throws IOException {
+ Row.Entry result;
synchronized (writeSearchObj) {
writeSearchObj.process(key);
if (writeSearchObj.found()) {
@@ -156,9 +161,9 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
return result;
}
- public ArrayList<kelondroRowCollection> removeDoubles() {
+ public ArrayList<RowCollection> removeDoubles() {
// this data structure cannot have doubles; return empty array
- return new ArrayList<kelondroRowCollection>();
+ return new ArrayList<RowCollection>();
}
public class Search {
@@ -311,17 +316,17 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
while (i.hasNext()) put(i.next());
}
- public kelondroRow.Entry put(final kelondroRow.Entry row, final Date entryDate) throws IOException {
+ public Row.Entry put(final Row.Entry row, final Date entryDate) throws IOException {
return put(row);
}
- public kelondroRow.Entry put(final kelondroRow.Entry newrow) throws IOException {
+ public Row.Entry put(final Row.Entry newrow) throws IOException {
assert (newrow != null);
assert (newrow.columns() == row().columns());
assert (!(serverLog.allZero(newrow.getPrimaryKeyBytes())));
assert newrow.objectsize() <= super.row().objectsize;
// Associates the specified value with the specified key in this map
- kelondroRow.Entry result = null;
+ Row.Entry result = null;
//writeLock.stay(2000, 1000);
// first try to find the key element in the database
synchronized(writeSearchObj) {
@@ -457,16 +462,16 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
return result;
}
- public synchronized void addUnique(final kelondroRow.Entry row) throws IOException {
+ public synchronized void addUnique(final Row.Entry row) throws IOException {
this.put(row);
}
- public synchronized void addUnique(final kelondroRow.Entry row, final Date entryDate) throws IOException {
+ public synchronized void addUnique(final Row.Entry row, final Date entryDate) throws IOException {
this.put(row, entryDate);
}
- public synchronized void addUniqueMultiple(final List<kelondroRow.Entry> rows) throws IOException {
- final Iterator<kelondroRow.Entry> i = rows.iterator();
+ public synchronized void addUniqueMultiple(final List<Row.Entry> rows) throws IOException {
+ final Iterator<Row.Entry> i = rows.iterator();
while (i.hasNext()) addUnique(i.next());
}
@@ -588,14 +593,14 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
// Associates the specified value with the specified key in this map
public byte[] put(final byte[] key, final byte[] value) throws IOException {
- final kelondroRow.Entry row = row().newEntry(new byte[][]{key, value});
- final kelondroRow.Entry ret = put(row);
+ final Row.Entry row = row().newEntry(new byte[][]{key, value});
+ final Row.Entry ret = put(row);
if (ret == null) return null;
return ret.getColBytes(0);
}
// Removes the mapping for this key from this map if present (optional operation).
- public kelondroRow.Entry remove(final byte[] key) throws IOException {
+ public Row.Entry remove(final byte[] key) throws IOException {
// the order inside the database file cannot be maintained, but iteration over objects will always maintain the object order
// therefore keepOrder should be true, because the effect is always given, while the data structure does not maintain order
// delete from database
@@ -603,7 +608,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
writeSearchObj.process(key);
if (writeSearchObj.found()) {
final CacheNode result = writeSearchObj.getMatcher();
- final kelondroRow.Entry values = row().newEntry(result.getValueRow());
+ final Row.Entry values = row().newEntry(result.getValueRow());
remove(result, writeSearchObj.getParent());
return values;
}
@@ -611,11 +616,11 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
}
}
- public kelondroRow.Entry removeOne() throws IOException {
+ public Row.Entry removeOne() throws IOException {
// removes just any entry and removes that entry
synchronized(writeSearchObj) {
final CacheNode theOne = lastNode();
- final kelondroRow.Entry values = row().newEntry(theOne.getValueRow());
+ final Row.Entry values = row().newEntry(theOne.getValueRow());
remove(theOne, null);
return values;
}
@@ -955,12 +960,12 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
}
}
- public TreeMap<String, kelondroRow.Entry> rowMap(final boolean up, final byte[] firstKey, final boolean including, final int count) throws IOException {
+ public TreeMap<String, Row.Entry> rowMap(final boolean up, final byte[] firstKey, final boolean including, final int count) throws IOException {
// returns an ordered map of keys/row relations; key objects are of type String, value objects are of type byte[][]
- final kelondroByteOrder setOrder = (kelondroByteOrder) row().objectOrder.clone();
+ final ByteOrder setOrder = (ByteOrder) row().objectOrder.clone();
setOrder.direction(up);
setOrder.rotate(firstKey);
- final TreeMap<String, kelondroRow.Entry> rows = new TreeMap<String, kelondroRow.Entry>(this.loopDetectionOrder);
+ final TreeMap<String, Row.Entry> rows = new TreeMap<String, Row.Entry>(this.loopDetectionOrder);
CacheNode n;
String key;
synchronized (this) {
@@ -977,7 +982,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
public TreeSet<String> keySet(final boolean up, final boolean rotating, final byte[] firstKey, final boolean including, final int count) throws IOException {
// returns an ordered set of keys; objects are of type String
- final kelondroByteOrder setOrder = (kelondroByteOrder) row().objectOrder.clone();
+ final ByteOrder setOrder = (ByteOrder) row().objectOrder.clone();
setOrder.direction(up);
setOrder.rotate(firstKey);
final TreeSet<String> set = new TreeSet<String>(this.loopDetectionOrder);
@@ -992,7 +997,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
return set;
}
- public kelondroCloneableIterator<kelondroRow.Entry> rows(final boolean up, final byte[] firstKey) throws IOException {
+ public kelondroCloneableIterator<Row.Entry> rows(final boolean up, final byte[] firstKey) throws IOException {
// iterates the rows of the Nodes
// enumerated objects are of type byte[][]
// iterates the elements in a sorted way.
@@ -1000,14 +1005,14 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
return new rowIterator(up, firstKey, this.size());
}
- public class rowIterator implements kelondroCloneableIterator<kelondroRow.Entry> {
+ public class rowIterator implements kelondroCloneableIterator<Row.Entry> {
int chunkSize;
boolean inc;
long count;
byte[] lastKey;
- TreeMap<String, kelondroRow.Entry> rowBuffer;
- Iterator<Map.Entry<String, kelondroRow.Entry>> bufferIterator;
+ TreeMap<String, Row.Entry> rowBuffer;
+ Iterator<Map.Entry<String, Row.Entry>> bufferIterator;
long guessedCountLimit;
public rowIterator(final boolean up, final byte[] firstKey, final long guessedCountLimit) throws IOException {
@@ -1035,9 +1040,9 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
return ((bufferIterator != null) && (bufferIterator.hasNext()) && (count < size()));
}
- public kelondroRow.Entry next() {
+ public Row.Entry next() {
if (!(bufferIterator.hasNext())) return null;
- final Map.Entry<String, kelondroRow.Entry> entry = bufferIterator.next();
+ final Map.Entry<String, Row.Entry> entry = bufferIterator.next();
lastKey = entry.getKey().getBytes();
// check if this was the last entry in the rowBuffer
@@ -1148,7 +1153,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
String s;
StringTokenizer st;
int recs = 0;
- final kelondroRow.Entry buffer = row().newEntry();
+ final Row.Entry buffer = row().newEntry();
int c;
int line = 0;
while ((s = f.readLine()) != null) {
@@ -1274,7 +1279,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
// test script
final File testFile = new File("test.db");
while (testFile.exists()) testFile.delete();
- final kelondroTree fm = new kelondroTree(testFile, true, 10, new kelondroRow("byte[] a-4, byte[] b-4", kelondroNaturalOrder.naturalOrder, 0));
+ final kelondroTree fm = new kelondroTree(testFile, true, 10, new Row("byte[] a-4, byte[] b-4", NaturalOrder.naturalOrder, 0));
final byte[] dummy = "".getBytes();
fm.put("abc0".getBytes(), dummy); fm.put("bcd0".getBytes(), dummy);
fm.put("def0".getBytes(), dummy); fm.put("bab0".getBytes(), dummy);
@@ -1296,7 +1301,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
ret = null;
}
} else if (args.length == 2) {
- final kelondroTree fm = new kelondroTree(new File(args[1]), true, 10, new kelondroRow("byte[] a-4, byte[] b-4", kelondroNaturalOrder.naturalOrder, 0));
+ final kelondroTree fm = new kelondroTree(new File(args[1]), true, 10, new Row("byte[] a-4, byte[] b-4", NaturalOrder.naturalOrder, 0));
if (args[0].equals("-v")) {
fm.print();
ret = null;
@@ -1304,11 +1309,11 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
fm.close();
} else if (args.length == 3) {
if (args[0].equals("-d")) {
- final kelondroTree fm = new kelondroTree(new File(args[1]), true, 10, new kelondroRow("byte[] a-4, byte[] b-4", kelondroNaturalOrder.naturalOrder, 0));
+ final kelondroTree fm = new kelondroTree(new File(args[1]), true, 10, new Row("byte[] a-4, byte[] b-4", NaturalOrder.naturalOrder, 0));
fm.remove(args[2].getBytes());
fm.close();
} else if (args[0].equals("-i")) {
- final kelondroTree fm = new kelondroTree(new File(args[1]), true, 10, new kelondroRow("byte[] a-4, byte[] b-4", kelondroNaturalOrder.naturalOrder, 0));
+ final kelondroTree fm = new kelondroTree(new File(args[1]), true, 10, new Row("byte[] a-4, byte[] b-4", NaturalOrder.naturalOrder, 0));
final int i = fm.imp(new File(args[1]),";");
fm.close();
ret = (i + " records imported").getBytes();
@@ -1331,14 +1336,14 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
if (f != null) try {f.close();}catch(final Exception e){}
}
} else if (args[0].equals("-g")) {
- final kelondroTree fm = new kelondroTree(new File(args[1]), true, 10, new kelondroRow("byte[] a-4, byte[] b-4", kelondroNaturalOrder.naturalOrder, 0));
- final kelondroRow.Entry ret2 = fm.get(args[2].getBytes());
+ final kelondroTree fm = new kelondroTree(new File(args[1]), true, 10, new Row("byte[] a-4, byte[] b-4", NaturalOrder.naturalOrder, 0));
+ final Row.Entry ret2 = fm.get(args[2].getBytes());
ret = ((ret2 == null) ? null : ret2.getColBytes(1));
fm.close();
} else if (args[0].equals("-n")) {
- final kelondroTree fm = new kelondroTree(new File(args[1]), true, 10, new kelondroRow("byte[] a-4, byte[] b-4", kelondroNaturalOrder.naturalOrder, 0));
+ final kelondroTree fm = new kelondroTree(new File(args[1]), true, 10, new Row("byte[] a-4, byte[] b-4", NaturalOrder.naturalOrder, 0));
//byte[][] keys = fm.getSequentialKeys(args[2].getBytes(), 500, true);
- final Iterator<kelondroRow.Entry> rowIt = fm.rows(true, (args[2].length() == 0) ? null : args[2].getBytes());
+ final Iterator<Row.Entry> rowIt = fm.rows(true, (args[2].length() == 0) ? null : args[2].getBytes());
final Vector<String> v = new Vector<String>();
while (rowIt.hasNext()) v.add(rowIt.next().getColString(0, null));
ret = v.toString().getBytes();
@@ -1349,11 +1354,11 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
// create <keylen> <valuelen> <filename>
final File f = new File(args[3]);
if (f.exists()) f.delete();
- final kelondroRow lens = new kelondroRow("byte[] key-" + Integer.parseInt(args[1]) + ", byte[] value-" + Integer.parseInt(args[2]), kelondroNaturalOrder.naturalOrder, 0);
+ final Row lens = new Row("byte[] key-" + Integer.parseInt(args[1]) + ", byte[] value-" + Integer.parseInt(args[2]), NaturalOrder.naturalOrder, 0);
final kelondroTree fm = new kelondroTree(f, true, 10, lens);
fm.close();
} else if (args[0].equals("-u")) {
- final kelondroTree fm = new kelondroTree(new File(args[1]), true, 10, new kelondroRow("byte[] a-4, byte[] b-4", kelondroNaturalOrder.naturalOrder, 0));
+ final kelondroTree fm = new kelondroTree(new File(args[1]), true, 10, new Row("byte[] a-4, byte[] b-4", NaturalOrder.naturalOrder, 0));
ret = fm.put(args[1].getBytes(), args[2].getBytes());
fm.close();
}
@@ -1412,7 +1417,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
int steps = 0;
while (true) {
if (testFile.exists()) testFile.delete();
- tt = new kelondroTree(testFile, true, 10, new kelondroRow("byte[] a-4, byte[] b-4", kelondroNaturalOrder.naturalOrder, 0));
+ tt = new kelondroTree(testFile, true, 10, new Row("byte[] a-4, byte[] b-4", NaturalOrder.naturalOrder, 0));
steps = 10 + ((int) System.currentTimeMillis() % 7) * (((int) System.currentTimeMillis() + 17) % 11);
t = s;
d = "";
@@ -1478,7 +1483,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
final File f = new File("test.db");
if (f.exists()) f.delete();
try {
- final kelondroTree tt = new kelondroTree(f, true, 10, new kelondroRow("byte[] a-4, byte[] b-4", kelondroNaturalOrder.naturalOrder, 0));
+ final kelondroTree tt = new kelondroTree(f, true, 10, new Row("byte[] a-4, byte[] b-4", NaturalOrder.naturalOrder, 0));
byte[] b;
b = testWord('B'); tt.put(b, b); //tt.print();
b = testWord('C'); tt.put(b, b); //tt.print();
@@ -1498,7 +1503,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
b = testWord('L'); tt.put(b, b);
final int c = countElements(tt);
System.out.println("elements: " + c);
- final Iterator<kelondroRow.Entry> i = tt.rows(true, testWord('G'));
+ final Iterator<Row.Entry> i = tt.rows(true, testWord('G'));
for (int j = 0; j < c; j++) {
System.out.println("Row " + j + ": " + new String((i.next()).getColBytes(0)));
}
@@ -1543,7 +1548,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
public static kelondroTree testTree(final File f, final String testentities) throws IOException {
if (f.exists()) f.delete();
- final kelondroTree tt = new kelondroTree(f, false, 10, new kelondroRow("byte[] a-4, byte[] b-4", kelondroNaturalOrder.naturalOrder, 0));
+ final kelondroTree tt = new kelondroTree(f, false, 10, new Row("byte[] a-4, byte[] b-4", NaturalOrder.naturalOrder, 0));
byte[] b;
for (int i = 0; i < testentities.length(); i++) {
b = testWord(testentities.charAt(i));
@@ -1605,11 +1610,11 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
}
}
- public static int countElements(final kelondroIndex t) {
+ public static int countElements(final ObjectIndex t) {
int count = 0;
try {
- final Iterator<kelondroRow.Entry> iter = t.rows(true, null);
- kelondroRow.Entry row;
+ final Iterator<Row.Entry> iter = t.rows(true, null);
+ Row.Entry row;
while (iter.hasNext()) {
count++;
row = iter.next();
diff --git a/source/de/anomic/kelondro/kelondroByteArray.java b/source/de/anomic/kelondro/tools/ByteArray.java
similarity index 85%
rename from source/de/anomic/kelondro/kelondroByteArray.java
rename to source/de/anomic/kelondro/tools/ByteArray.java
index ed8a75a33..d18c61b97 100644
--- a/source/de/anomic/kelondro/kelondroByteArray.java
+++ b/source/de/anomic/kelondro/tools/ByteArray.java
@@ -24,41 +24,46 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.kelondro;
+package de.anomic.kelondro.tools;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.ByteOrder;
+import de.anomic.kelondro.coding.NaturalOrder;
+import de.anomic.kelondro.io.RandomAccessInterface;
+
// this class is a experimental replacement of byte[]. It should be used
// if frequent System.arraycopy usage is common for byte[] data types
// when replaced by this class, all copies share the same byte[] but can
// access a different part of the byte array
-public class kelondroByteArray {
+public class ByteArray {
private byte[] buffer;
private int offset;
private int length;
- public kelondroByteArray(final int initLength) {
+ public ByteArray(final int initLength) {
this.buffer = new byte[initLength];
this.length = 0;
this.offset = 0;
}
- public kelondroByteArray(final byte[] bb) {
+ public ByteArray(final byte[] bb) {
this.buffer = bb;
this.length = bb.length;
this.offset = 0;
}
- public kelondroByteArray(final byte[] bb, final int offset, final int length) {
+ public ByteArray(final byte[] bb, final int offset, final int length) {
this.buffer = bb;
this.length = length;
this.offset = offset;
}
- public kelondroByteArray(final kelondroByteArray ba, final int offset, final int length) {
+ public ByteArray(final ByteArray ba, final int offset, final int length) {
this.buffer = ba.buffer;
this.length = length;
this.offset = ba.offset + offset;
@@ -124,11 +129,11 @@ public class kelondroByteArray {
}
public long readLongB64e(final int pos, final int length) {
- return kelondroBase64Order.enhancedCoder.decodeLong(buffer, this.offset + pos, length);
+ return Base64Order.enhancedCoder.decodeLong(buffer, this.offset + pos, length);
}
public long readLongB256(final int pos, final int length) {
- return kelondroNaturalOrder.decodeLong(buffer, this.offset + pos, length);
+ return NaturalOrder.decodeLong(buffer, this.offset + pos, length);
}
public byte[] readBytes(final int from_pos, final int length) {
@@ -149,7 +154,7 @@ public class kelondroByteArray {
}
}
- public void readToRA(final int from_pos, final kelondroRA to_file, final int len) throws IOException {
+ public void readToRA(final int from_pos, final RandomAccessInterface to_file, final int len) throws IOException {
to_file.write(this.buffer, from_pos, len);
}
@@ -161,11 +166,11 @@ public class kelondroByteArray {
System.arraycopy(from_array, from_offset, this.buffer, this.offset + to_position, from_length);
}
- public void write(final int to_position, final kelondroByteArray from_array) {
+ public void write(final int to_position, final ByteArray from_array) {
System.arraycopy(from_array.buffer, from_array.offset, this.buffer, this.offset + to_position, from_array.length);
}
- public void write(final int to_position, final kelondroByteArray from_array, final int from_offset, final int from_length) {
+ public void write(final int to_position, final ByteArray from_array, final int from_offset, final int from_length) {
System.arraycopy(from_array.buffer, from_array.offset + from_offset, this.buffer, this.offset + to_position, from_length);
}
@@ -183,11 +188,11 @@ public class kelondroByteArray {
this.offset = 0;
}
- public int compareTo(final kelondroByteArray b, final kelondroByteOrder order) {
+ public int compareTo(final ByteArray b, final ByteOrder order) {
return order.compare(this.buffer, this.offset, this.length, b.buffer, b.offset, b.length);
}
- public int compareTo(final int aoffset, final int alength, final kelondroByteArray b, final int boffset, final int blength, final kelondroByteOrder order) {
+ public int compareTo(final int aoffset, final int alength, final ByteArray b, final int boffset, final int blength, final ByteOrder order) {
return order.compare(this.buffer, this.offset + aoffset, alength, b.buffer, b.offset + boffset, blength);
}
}
diff --git a/source/de/anomic/kelondro/kelondroByteBuffer.java b/source/de/anomic/kelondro/tools/ByteBuffer.java
similarity index 90%
rename from source/de/anomic/kelondro/kelondroByteBuffer.java
rename to source/de/anomic/kelondro/tools/ByteBuffer.java
index 9378075bd..52b68c7ac 100644
--- a/source/de/anomic/kelondro/kelondroByteBuffer.java
+++ b/source/de/anomic/kelondro/tools/ByteBuffer.java
@@ -19,7 +19,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.kelondro;
+package de.anomic.kelondro.tools;
import java.io.File;
import java.io.FileInputStream;
@@ -29,7 +29,7 @@ import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.util.Properties;
-public final class kelondroByteBuffer extends OutputStream {
+public final class ByteBuffer extends OutputStream {
public static final byte singlequote = (byte) 39;
public static final byte doublequote = (byte) 34;
@@ -40,32 +40,32 @@ public final class kelondroByteBuffer extends OutputStream {
private int length;
- public kelondroByteBuffer() {
+ public ByteBuffer() {
buffer = new byte[10];
length = 0;
offset = 0;
}
- public kelondroByteBuffer(final int initLength) {
+ public ByteBuffer(final int initLength) {
this.buffer = new byte[initLength];
this.length = 0;
this.offset = 0;
}
- public kelondroByteBuffer(final byte[] bb) {
+ public ByteBuffer(final byte[] bb) {
buffer = bb;
length = bb.length;
offset = 0;
}
- public kelondroByteBuffer(final byte[] bb, final int initLength) {
+ public ByteBuffer(final byte[] bb, final int initLength) {
this.buffer = new byte[initLength];
System.arraycopy(bb, 0, buffer, 0, bb.length);
length = bb.length;
offset = 0;
}
- public kelondroByteBuffer(final byte[] bb, final int of, final int le) {
+ public ByteBuffer(final byte[] bb, final int of, final int le) {
if (of * 2 > bb.length) {
buffer = new byte[le];
System.arraycopy(bb, of, buffer, 0, le);
@@ -78,13 +78,13 @@ public final class kelondroByteBuffer extends OutputStream {
}
}
- public kelondroByteBuffer(final kelondroByteBuffer bb) {
+ public ByteBuffer(final ByteBuffer bb) {
buffer = bb.buffer;
length = bb.length;
offset = bb.offset;
}
- public kelondroByteBuffer(final File f) throws IOException {
+ public ByteBuffer(final File f) throws IOException {
// initially fill the byte buffer with the content of a file
if (f.length() > Integer.MAX_VALUE) throw new IOException("file is too large for buffering");
@@ -167,39 +167,39 @@ public final class kelondroByteBuffer extends OutputStream {
if (pos + le > length) length = pos + le;
}
- public kelondroByteBuffer append(final byte b) {
+ public ByteBuffer append(final byte b) {
write(b);
return this;
}
- public kelondroByteBuffer append(final int i) {
+ public ByteBuffer append(final int i) {
write((byte) (i & 0xFF));
return this;
}
- public kelondroByteBuffer append(final byte[] bb) {
+ public ByteBuffer append(final byte[] bb) {
write(bb);
return this;
}
- public kelondroByteBuffer append(final byte[] bb, final int of, final int le) {
+ public ByteBuffer append(final byte[] bb, final int of, final int le) {
write(bb, of, le);
return this;
}
- public kelondroByteBuffer append(final String s) {
+ public ByteBuffer append(final String s) {
return append(s.getBytes());
}
- public kelondroByteBuffer append(final String s, final String charset) throws UnsupportedEncodingException {
+ public ByteBuffer append(final String s, final String charset) throws UnsupportedEncodingException {
return append(s.getBytes(charset));
}
- public kelondroByteBuffer append(final kelondroByteBuffer bb) {
+ public ByteBuffer append(final ByteBuffer bb) {
return append(bb.buffer, bb.offset, bb.length);
}
- public kelondroByteBuffer append(final Object o) {
+ public ByteBuffer append(final Object o) {
if (o instanceof String) return append((String) o);
if (o instanceof byte[]) return append((byte[]) o);
return null;
@@ -286,19 +286,19 @@ public final class kelondroByteBuffer extends OutputStream {
return tmp;
}
- public kelondroByteBuffer trim(final int start) {
+ public ByteBuffer trim(final int start) {
trim(start, this.length - start);
return this;
}
- public kelondroByteBuffer trim(final int start, final int len) {
+ public ByteBuffer trim(final int start, final int len) {
if (start + len > this.length) throw new IndexOutOfBoundsException("trim: start + len > length; this.offset = " + this.offset + ", this.length = " + this.length + ", start = " + start + ", len = " + len);
this.offset = this.offset + start;
this.length = len;
return this;
}
- public kelondroByteBuffer trim() {
+ public ByteBuffer trim() {
int l = 0;
while ((l < length) && (buffer[offset + l] <= 32)) {
l++;
diff --git a/source/de/anomic/kelondro/kelondroMHashMap.java b/source/de/anomic/kelondro/tools/CompressedHashMap.java
similarity index 96%
rename from source/de/anomic/kelondro/kelondroMHashMap.java
rename to source/de/anomic/kelondro/tools/CompressedHashMap.java
index eb331a198..494a15a6f 100644
--- a/source/de/anomic/kelondro/kelondroMHashMap.java
+++ b/source/de/anomic/kelondro/tools/CompressedHashMap.java
@@ -20,11 +20,11 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.kelondro;
+package de.anomic.kelondro.tools;
import java.util.Iterator;
-public class kelondroMHashMap {
+public class CompressedHashMap {
int keylen;
int valuelen;
@@ -32,12 +32,12 @@ public class kelondroMHashMap {
byte[] mem;
private final byte[] emptykey;
- public kelondroMHashMap(final int valuelen) {
+ public CompressedHashMap(final int valuelen) {
// initializes a hash map with integer access key
this(4, valuelen);
}
- public kelondroMHashMap(final int keylen, final int valuelen) {
+ public CompressedHashMap(final int keylen, final int valuelen) {
this.keylen = keylen;
this.valuelen = valuelen;
this.reclen = keylen + valuelen;
@@ -148,7 +148,7 @@ public class kelondroMHashMap {
final int newcapacity = capacity() * 2;
byte[] newmem = new byte[newspace];
final Iterator<entry> i = entries();
- kelondroMHashMap.entry e;
+ CompressedHashMap.entry e;
int mempos;
while (i.hasNext()) {
e = i.next();
@@ -300,10 +300,10 @@ public class kelondroMHashMap {
public static void main(final String[] args) {
final long start = System.currentTimeMillis();
- final kelondroMHashMap map = new kelondroMHashMap(4);
+ final CompressedHashMap map = new CompressedHashMap(4);
for (int i = 0; i < 100; i++) map.put(3333 + i, ("" + (1000 + i)).getBytes());
final Iterator<entry> i = map.entries();
- kelondroMHashMap.entry e;
+ CompressedHashMap.entry e;
System.out.println("Enumeration of elements: count=" + map.size());
int c = 0;
while (i.hasNext()) {
diff --git a/source/de/anomic/kelondro/kelondroMemory.java b/source/de/anomic/kelondro/tools/MemoryControl.java
similarity index 96%
rename from source/de/anomic/kelondro/kelondroMemory.java
rename to source/de/anomic/kelondro/tools/MemoryControl.java
index 2274cb35c..d3a2dbb39 100644
--- a/source/de/anomic/kelondro/kelondroMemory.java
+++ b/source/de/anomic/kelondro/tools/MemoryControl.java
@@ -23,7 +23,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.kelondro;
+package de.anomic.kelondro.tools;
import de.anomic.server.logging.serverLog;
import de.anomic.tools.yFormatter;
@@ -31,7 +31,7 @@ import de.anomic.tools.yFormatter;
/**
* Use this to get information about memory usage or try to free some memory
*/
-public class kelondroMemory {
+public class MemoryControl {
private static final Runtime runtime = Runtime.getRuntime();
private static final serverLog log = new serverLog("MEMORY");
diff --git a/source/de/anomic/kelondro/kelondroMScoreCluster.java b/source/de/anomic/kelondro/tools/ScoreCluster.java
similarity index 95%
rename from source/de/anomic/kelondro/kelondroMScoreCluster.java
rename to source/de/anomic/kelondro/tools/ScoreCluster.java
index b1d664b6e..931d14613 100644
--- a/source/de/anomic/kelondro/kelondroMScoreCluster.java
+++ b/source/de/anomic/kelondro/tools/ScoreCluster.java
@@ -19,7 +19,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.kelondro;
+package de.anomic.kelondro.tools;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -29,14 +29,16 @@ import java.util.Random;
import java.util.SortedMap;
import java.util.TreeMap;
-public final class kelondroMScoreCluster<E> {
+import de.anomic.kelondro.kelondroOutOfLimitsException;
+
+public final class ScoreCluster<E> {
protected final TreeMap<E, Long> refkeyDB; // a mapping from a reference to the cluster key
protected final TreeMap<Long, E> keyrefDB; // a mapping from the cluster key to the reference
private long gcount;
private int encnt;
- public kelondroMScoreCluster() {
+ public ScoreCluster() {
refkeyDB = new TreeMap<E, Long>();
keyrefDB = new TreeMap<Long, E>();
gcount = 0;
@@ -447,7 +449,7 @@ public final class kelondroMScoreCluster<E> {
}
System.out.println("Test for Score: start");
- final kelondroMScoreCluster<String> s = new kelondroMScoreCluster<String>();
+ final ScoreCluster<String> s = new ScoreCluster<String>();
long c = 0;
// create cluster
diff --git a/source/de/anomic/kelondro/kelondroMSetTools.java b/source/de/anomic/kelondro/tools/SetTools.java
similarity index 97%
rename from source/de/anomic/kelondro/kelondroMSetTools.java
rename to source/de/anomic/kelondro/tools/SetTools.java
index 70614c585..ca34c00a6 100644
--- a/source/de/anomic/kelondro/kelondroMSetTools.java
+++ b/source/de/anomic/kelondro/tools/SetTools.java
@@ -19,7 +19,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package de.anomic.kelondro;
+package de.anomic.kelondro.tools;
import java.io.BufferedReader;
import java.io.File;
@@ -36,7 +36,7 @@ import java.util.TreeMap;
import java.util.TreeSet;
import java.util.Map.Entry;
-public class kelondroMSetTools {
+public class SetTools {
//public static Comparator fastStringComparator = fastStringComparator(true);
diff --git a/source/de/anomic/plasma/parser/rss/rssParser.java b/source/de/anomic/plasma/parser/rss/rssParser.java
index 38ec24301..3029680f6 100644
--- a/source/de/anomic/plasma/parser/rss/rssParser.java
+++ b/source/de/anomic/plasma/parser/rss/rssParser.java
@@ -38,7 +38,7 @@ import de.anomic.htmlFilter.htmlFilterAbstractScraper;
import de.anomic.htmlFilter.htmlFilterContentScraper;
import de.anomic.htmlFilter.htmlFilterImageEntry;
import de.anomic.htmlFilter.htmlFilterWriter;
-import de.anomic.kelondro.kelondroByteBuffer;
+import de.anomic.kelondro.tools.ByteBuffer;
import de.anomic.plasma.plasmaParserDocument;
import de.anomic.plasma.parser.AbstractParser;
import de.anomic.plasma.parser.Parser;
@@ -81,7 +81,7 @@ public class rssParser extends AbstractParser implements Parser {
final LinkedList<String> feedSections = new LinkedList<String>();
final HashMap<yacyURL, String> anchors = new HashMap<yacyURL, String>();
final HashMap<String, htmlFilterImageEntry> images = new HashMap<String, htmlFilterImageEntry>();
- final kelondroByteBuffer text = new kelondroByteBuffer();
+ final ByteBuffer text = new ByteBuffer();
final serverCharBuffer authors = new serverCharBuffer();
final RSSFeed feed = new RSSReader(source).getFeed();
diff --git a/source/de/anomic/plasma/parser/tar/tarParser.java b/source/de/anomic/plasma/parser/tar/tarParser.java
index 137547a9e..0419e3df1 100644
--- a/source/de/anomic/plasma/parser/tar/tarParser.java
+++ b/source/de/anomic/plasma/parser/tar/tarParser.java
@@ -41,7 +41,7 @@ import com.ice.tar.TarInputStream;
import de.anomic.htmlFilter.htmlFilterContentScraper;
import de.anomic.htmlFilter.htmlFilterImageEntry;
-import de.anomic.kelondro.kelondroByteBuffer;
+import de.anomic.kelondro.tools.ByteBuffer;
import de.anomic.plasma.plasmaParser;
import de.anomic.plasma.plasmaParserDocument;
import de.anomic.plasma.parser.AbstractParser;
@@ -90,7 +90,7 @@ public class tarParser extends AbstractParser implements Parser {
outputFile = File.createTempFile("zipParser",".tmp");
docText = new BufferedOutputStream(new FileOutputStream(outputFile));
} else {
- docText = new kelondroByteBuffer();
+ docText = new ByteBuffer();
}
// creating a new parser class to parse the unzipped content
@@ -183,7 +183,7 @@ public class tarParser extends AbstractParser implements Parser {
plasmaParserDocument result = null;
- if (docText instanceof kelondroByteBuffer) {
+ if (docText instanceof ByteBuffer) {
result = new plasmaParserDocument(
location,
mimeType,
@@ -194,7 +194,7 @@ public class tarParser extends AbstractParser implements Parser {
"", // TODO: AUTHOR
docSections.toArray(new String[docSections.size()]),
docAbstrct.toString(),
- ((kelondroByteBuffer)docText).getBytes(),
+ ((ByteBuffer)docText).getBytes(),
docAnchors,
docImages);
} else {
diff --git a/source/de/anomic/plasma/parser/vcf/vcfParser.java b/source/de/anomic/plasma/parser/vcf/vcfParser.java
index e36f3e79a..caf6e5600 100644
--- a/source/de/anomic/plasma/parser/vcf/vcfParser.java
+++ b/source/de/anomic/plasma/parser/vcf/vcfParser.java
@@ -37,7 +37,7 @@ import java.util.LinkedList;
import de.anomic.crawler.HTTPLoader;
import de.anomic.http.HttpClient;
import de.anomic.http.httpRequestHeader;
-import de.anomic.kelondro.kelondroBase64Order;
+import de.anomic.kelondro.coding.Base64Order;
import de.anomic.plasma.plasmaParserDocument;
import de.anomic.plasma.parser.AbstractParser;
import de.anomic.plasma.parser.Parser;
@@ -150,7 +150,7 @@ public class vcfParser extends AbstractParser implements Parser {
if (!useLastLine) value += line.trim();
else break;
} while (line.length()!=0);
- value = kelondroBase64Order.standardCoder.decodeString(value, "de.anomic.plasma.parser.vcf.vcfParser.parse(...)");
+ value = Base64Order.standardCoder.decodeString(value, "de.anomic.plasma.parser.vcf.vcfParser.parse(...)");
}
} catch (final Exception ey) {
// Encoding error: This could occure e.g. if the base64 doesn't
diff --git a/source/de/anomic/plasma/parser/zip/zipParser.java b/source/de/anomic/plasma/parser/zip/zipParser.java
index a729cd753..be2466f49 100644
--- a/source/de/anomic/plasma/parser/zip/zipParser.java
+++ b/source/de/anomic/plasma/parser/zip/zipParser.java
@@ -39,7 +39,7 @@ import java.util.zip.ZipInputStream;
import de.anomic.htmlFilter.htmlFilterContentScraper;
import de.anomic.htmlFilter.htmlFilterImageEntry;
-import de.anomic.kelondro.kelondroByteBuffer;
+import de.anomic.kelondro.tools.ByteBuffer;
import de.anomic.plasma.plasmaParser;
import de.anomic.plasma.plasmaParserDocument;
import de.anomic.plasma.parser.AbstractParser;
@@ -88,7 +88,7 @@ public class zipParser extends AbstractParser implements Parser {
outputFile = File.createTempFile("zipParser",".tmp");
docText = new BufferedOutputStream(new FileOutputStream(outputFile));
} else {
- docText = new kelondroByteBuffer();
+ docText = new ByteBuffer();
}
final StringBuilder docKeywords = new StringBuilder();
@@ -167,7 +167,7 @@ public class zipParser extends AbstractParser implements Parser {
plasmaParserDocument result = null;
- if (docText instanceof kelondroByteBuffer) {
+ if (docText instanceof ByteBuffer) {
result = new plasmaParserDocument(
location,
mimeType,
@@ -178,7 +178,7 @@ public class zipParser extends AbstractParser implements Parser {
"", // TODO: AUTHOR
docSections.toArray(new String[docSections.size()]),
docAbstrct.toString(),
- ((kelondroByteBuffer)docText).getBytes(),
+ ((ByteBuffer)docText).getBytes(),
docAnchors,
docImages);
} else {
diff --git a/source/de/anomic/plasma/plasmaCondenser.java b/source/de/anomic/plasma/plasmaCondenser.java
index d2238a65a..11b069842 100644
--- a/source/de/anomic/plasma/plasmaCondenser.java
+++ b/source/de/anomic/plasma/plasmaCondenser.java
@@ -51,8 +51,8 @@ import de.anomic.htmlFilter.htmlFilterImageEntry;
import de.anomic.index.indexPhrase;
import de.anomic.index.indexRWIEntry;
import de.anomic.index.indexWord;
-import de.anomic.kelondro.kelondroBitfield;
-import de.anomic.kelondro.kelondroMSetTools;
+import de.anomic.kelondro.coding.Bitfield;
+import de.anomic.kelondro.tools.SetTools;
import de.anomic.language.identification.Identificator;
import de.anomic.yacy.yacyURL;
@@ -98,7 +98,7 @@ public final class plasmaCondenser {
public int RESULT_DIFF_WORDS = -1;
public int RESULT_NUMB_SENTENCES = -1;
public int RESULT_DIFF_SENTENCES = -1;
- public kelondroBitfield RESULT_FLAGS = new kelondroBitfield(4);
+ public Bitfield RESULT_FLAGS = new Bitfield(4);
Identificator languageIdentificator;
public plasmaCondenser(final plasmaParserDocument document, final boolean indexText, final boolean indexMedia) throws UnsupportedEncodingException {
@@ -107,7 +107,7 @@ public final class plasmaCondenser {
this.wordminsize = 3;
this.wordcut = 2;
this.words = new TreeMap<String, indexWord>();
- this.RESULT_FLAGS = new kelondroBitfield(4);
+ this.RESULT_FLAGS = new Bitfield(4);
// construct flag set for document
if (document.getImages().size() > 0) RESULT_FLAGS.set(flag_cat_hasimage, true);
@@ -216,7 +216,7 @@ public final class plasmaCondenser {
}
}
- private void insertTextToWords(final String text, final int phrase, final int flagpos, final kelondroBitfield flagstemplate, boolean useForLanguageIdentification) {
+ private void insertTextToWords(final String text, final int phrase, final int flagpos, final Bitfield flagstemplate, boolean useForLanguageIdentification) {
String word;
indexWord wprop;
sievedWordsEnum wordenum;
@@ -258,7 +258,7 @@ public final class plasmaCondenser {
// subtracts the given stopwords from the word list
// the word list shrinkes. This returns the number of shrinked words
final int oldsize = words.size();
- words = kelondroMSetTools.excludeConstructive(words, stopwords);
+ words = SetTools.excludeConstructive(words, stopwords);
return oldsize - words.size();
}
diff --git a/source/de/anomic/plasma/plasmaDHTChunk.java b/source/de/anomic/plasma/plasmaDHTChunk.java
index f05bdeb38..ed5c16a37 100644
--- a/source/de/anomic/plasma/plasmaDHTChunk.java
+++ b/source/de/anomic/plasma/plasmaDHTChunk.java
@@ -35,9 +35,9 @@ import de.anomic.index.indexContainer;
import de.anomic.index.indexRWIEntry;
import de.anomic.index.indexRWIRowEntry;
import de.anomic.index.indexURLReference;
-import de.anomic.kelondro.kelondroBase64Order;
-import de.anomic.kelondro.kelondroDigest;
import de.anomic.kelondro.kelondroException;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.Digest;
import de.anomic.server.logging.serverLog;
import de.anomic.yacy.yacyPeerSelection;
import de.anomic.yacy.yacySeed;
@@ -159,7 +159,7 @@ public class plasmaDHTChunk {
public static String selectTransferStart() {
// a random start point. It is dangerous to take a computed start point, because it could cause a flooding at specific target peers, because
// the community of all peers would use the same method for target computation. It is better to just use a random start point.
- return kelondroBase64Order.enhancedCoder.encode(kelondroDigest.encodeMD5Raw(Long.toString(System.currentTimeMillis()))).substring(2, 2 + yacySeedDB.commonHashLength);
+ return Base64Order.enhancedCoder.encode(Digest.encodeMD5Raw(Long.toString(System.currentTimeMillis()))).substring(2, 2 + yacySeedDB.commonHashLength);
}
private int selectTransferContainersResource(final String hash, final boolean ram, final int maxContainerCount, final int maxtime) throws InterruptedException {
@@ -187,7 +187,7 @@ public class plasmaDHTChunk {
((container = indexContainerIterator.next()) != null) &&
(container.size() > 0) &&
((tmpContainers.size() == 0) ||
- (kelondroBase64Order.enhancedComparator.compare(container.getWordHash(), limitHash) < 0)) &&
+ (Base64Order.enhancedComparator.compare(container.getWordHash(), limitHash) < 0)) &&
(System.currentTimeMillis() < timeout)
) {
// check for interruption
diff --git a/source/de/anomic/plasma/plasmaDHTFlush.java b/source/de/anomic/plasma/plasmaDHTFlush.java
index 248890db5..8bb5abcd8 100644
--- a/source/de/anomic/plasma/plasmaDHTFlush.java
+++ b/source/de/anomic/plasma/plasmaDHTFlush.java
@@ -23,8 +23,8 @@
package de.anomic.plasma;
-import de.anomic.kelondro.kelondroBase64Order;
-import de.anomic.kelondro.kelondroDigest;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.Digest;
import de.anomic.server.logging.serverLog;
import de.anomic.yacy.yacySeed;
import de.anomic.yacy.yacySeedDB;
@@ -163,7 +163,7 @@ public class plasmaDHTFlush extends Thread {
if (this.sb.webIndex.size() > 0 && this.delete) {
// if there are still words in the index we try it again now
if((iteration % 10L) == 0) { // seems to be blocked, try another startpoint
- this.startPointHash = kelondroBase64Order.enhancedCoder.encode(kelondroDigest.encodeMD5Raw(Long.toString(System.currentTimeMillis()))).substring(2, 2 + yacySeedDB.commonHashLength);
+ this.startPointHash = Base64Order.enhancedCoder.encode(Digest.encodeMD5Raw(Long.toString(System.currentTimeMillis()))).substring(2, 2 + yacySeedDB.commonHashLength);
} else {
this.startPointHash = "AAAAAAAAAAAA";
}
diff --git a/source/de/anomic/plasma/plasmaDbImporter.java b/source/de/anomic/plasma/plasmaDbImporter.java
index 8c5b0d65e..1ad79270e 100644
--- a/source/de/anomic/plasma/plasmaDbImporter.java
+++ b/source/de/anomic/plasma/plasmaDbImporter.java
@@ -10,7 +10,7 @@ import de.anomic.index.indexContainer;
import de.anomic.index.indexRWIEntry;
import de.anomic.index.indexRWIRowEntry;
import de.anomic.index.indexURLReference;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.DateFormatter;
public class plasmaDbImporter extends AbstractImporter implements Importer {
@@ -187,8 +187,8 @@ public class plasmaDbImporter extends AbstractImporter implements Importer {
"[" + this.wordChunkStartHash + " .. " + this.wordChunkEndHash + "] " +
this.getProcessingStatusPercent() + "%\n" +
"Speed: "+ 500*1000/duration + " word entities/s" +
- " | Elapsed time: " + kelondroDate.formatInterval(getElapsedTime()) +
- " | Estimated time: " + kelondroDate.formatInterval(getEstimatedTime()) + "\n" +
+ " | Elapsed time: " + DateFormatter.formatInterval(getElapsedTime()) +
+ " | Estimated time: " + DateFormatter.formatInterval(getEstimatedTime()) + "\n" +
"Home Words = " + homeWordIndex.size() +
" | Import Words = " + this.importWordIndex.size());
this.wordChunkStart = this.wordChunkEnd;
diff --git a/source/de/anomic/plasma/plasmaHTCache.java b/source/de/anomic/plasma/plasmaHTCache.java
index 7939fd93f..85ebe1fcd 100644
--- a/source/de/anomic/plasma/plasmaHTCache.java
+++ b/source/de/anomic/plasma/plasmaHTCache.java
@@ -47,8 +47,8 @@ import de.anomic.kelondro.kelondroBLOB;
import de.anomic.kelondro.kelondroBLOBArray;
import de.anomic.kelondro.kelondroBLOBCompressor;
import de.anomic.kelondro.kelondroBLOBHeap;
-import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroMap;
+import de.anomic.kelondro.coding.Base64Order;
import de.anomic.server.serverFileUtils;
import de.anomic.server.logging.serverLog;
import de.anomic.yacy.yacySeedDB;
@@ -130,13 +130,13 @@ public final class plasmaHTCache {
final File dbfile = new File(cachePath, RESPONSE_HEADER_DB_NAME);
kelondroBLOB blob = null;
try {
- blob = new kelondroBLOBHeap(dbfile, yacySeedDB.commonHashLength, kelondroBase64Order.enhancedCoder, 1024 * 1024);
+ blob = new kelondroBLOBHeap(dbfile, yacySeedDB.commonHashLength, Base64Order.enhancedCoder, 1024 * 1024);
} catch (final IOException e) {
e.printStackTrace();
}
responseHeaderDB = new kelondroMap(blob, 500);
try {
- fileDBunbuffered = new kelondroBLOBArray(new File(cachePath, FILE_DB_NAME), salt, 12, kelondroBase64Order.enhancedCoder, 1024 * 1024 * 2);
+ fileDBunbuffered = new kelondroBLOBArray(new File(cachePath, FILE_DB_NAME), salt, 12, Base64Order.enhancedCoder, 1024 * 1024 * 2);
fileDBunbuffered.setMaxSize(maxCacheSize);
fileDB = new kelondroBLOBCompressor(fileDBunbuffered, 2 * 1024 * 1024);
} catch (IOException e) {
diff --git a/source/de/anomic/plasma/plasmaRankingCRProcess.java b/source/de/anomic/plasma/plasmaRankingCRProcess.java
index 39d07ec2b..205eec0e0 100644
--- a/source/de/anomic/plasma/plasmaRankingCRProcess.java
+++ b/source/de/anomic/plasma/plasmaRankingCRProcess.java
@@ -31,16 +31,16 @@ import java.io.IOException;
import java.util.Iterator;
import de.anomic.kelondro.kelondroAttrSeq;
-import de.anomic.kelondro.kelondroBase64Order;
-import de.anomic.kelondro.kelondroBitfield;
import de.anomic.kelondro.kelondroCollectionIndex;
import de.anomic.kelondro.kelondroEcoTable;
-import de.anomic.kelondro.kelondroIndex;
-import de.anomic.kelondro.kelondroMicroDate;
-import de.anomic.kelondro.kelondroRow;
-import de.anomic.kelondro.kelondroRowSet;
-import de.anomic.kelondro.kelondroDate;
-import de.anomic.kelondro.kelondroMemory;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.Bitfield;
+import de.anomic.kelondro.coding.DateFormatter;
+import de.anomic.kelondro.coding.MicroDate;
+import de.anomic.kelondro.index.Row;
+import de.anomic.kelondro.index.RowSet;
+import de.anomic.kelondro.index.ObjectIndex;
+import de.anomic.kelondro.tools.MemoryControl;
import de.anomic.server.serverFileUtils;
public class plasmaRankingCRProcess {
@@ -52,18 +52,18 @@ public class plasmaRankingCRProcess {
header.append("# ---"); header.append((char) 13); header.append((char) 10);
*/
- public static final kelondroRow CRG_accrow = new kelondroRow(
+ public static final Row CRG_accrow = new Row(
"byte[] Referee-12," +
"Cardinal UDate-3 {b64e}, Cardinal VDate-3 {b64e}, " +
"Cardinal LCount-2 {b64e}, Cardinal GCount-2 {b64e}, Cardinal ICount-2 {b64e}, Cardinal DCount-2 {b64e}, Cardinal TLength-3 {b64e}, " +
"Cardinal WACount-3 {b64e}, Cardinal WUCount-3 {b64e}, Cardinal Flags-1 {b64e}, " +
"Cardinal FUDate-3 {b64e}, Cardinal FDDate-3 {b64e}, Cardinal LUDate-3 {b64e}, " +
"Cardinal UCount-2 {b64e}, Cardinal PCount-2 {b64e}, Cardinal ACount-2 {b64e}, Cardinal VCount-2 {b64e}, Cardinal Vita-2 {b64e}",
- kelondroBase64Order.enhancedCoder, 0);
- public static final kelondroRow CRG_colrow = new kelondroRow("byte[] Anchor-12", kelondroBase64Order.enhancedCoder, 0);
+ Base64Order.enhancedCoder, 0);
+ public static final Row CRG_colrow = new Row("byte[] Anchor-12", Base64Order.enhancedCoder, 0);
public static final String CRG_accname = "CRG-a-attr";
public static final String CRG_seqname = "CRG-a-coli";
- public static final kelondroRow RCI_coli = new kelondroRow("byte[] RefereeDom-6", kelondroBase64Order.enhancedCoder, 0);
+ public static final Row RCI_coli = new Row("byte[] RefereeDom-6", Base64Order.enhancedCoder, 0);
public static final String RCI_colname = "RCI-a-coli";
private static boolean accumulate_upd(final File f, final kelondroAttrSeq acc) {
@@ -80,11 +80,11 @@ public class plasmaRankingCRProcess {
String key;
kelondroAttrSeq.Entry new_entry, acc_entry;
int FUDate, FDDate, LUDate, UCount, PCount, ACount, VCount, Vita;
- kelondroBitfield acc_flags, new_flags;
+ Bitfield acc_flags, new_flags;
while (el.hasNext()) {
key = el.next();
new_entry = source_cr.getEntry(key);
- new_flags = new kelondroBitfield(kelondroBase64Order.enhancedCoder.encodeLong(new_entry.getAttr("Flags", 0), 1).getBytes());
+ new_flags = new Bitfield(Base64Order.enhancedCoder.encodeLong(new_entry.getAttr("Flags", 0), 1).getBytes());
// enrich information with additional values
if ((acc_entry = acc.getEntry(key)) != null) {
FUDate = (int) acc_entry.getAttr("FUDate", 0);
@@ -105,16 +105,16 @@ public class plasmaRankingCRProcess {
VCount += (new_flags.get(3)) ? 1 : 0;
// 'OR' the flags
- acc_flags = new kelondroBitfield(kelondroBase64Order.enhancedCoder.encodeLong(acc_entry.getAttr("Flags", 0), 1).getBytes());
+ acc_flags = new Bitfield(Base64Order.enhancedCoder.encodeLong(acc_entry.getAttr("Flags", 0), 1).getBytes());
for (int i = 0; i < 6; i++) {
if (new_flags.get(i)) acc_flags.set(i, true);
}
- acc_entry.setAttr("Flags", (int) kelondroBase64Order.enhancedCoder.decodeLong(acc_flags.exportB64()));
+ acc_entry.setAttr("Flags", (int) Base64Order.enhancedCoder.decodeLong(acc_flags.exportB64()));
} else {
// initialize counters and dates
acc_entry = acc.newEntry(key, new_entry.getAttrs(), new_entry.getSeqSet());
- FUDate = kelondroMicroDate.microDateHoursInt(System.currentTimeMillis()); // first update date
- FDDate = kelondroMicroDate.microDateHoursInt(System.currentTimeMillis()); // very difficult to compute; this is only a quick-hack
+ FUDate = MicroDate.microDateHoursInt(System.currentTimeMillis()); // first update date
+ FDDate = MicroDate.microDateHoursInt(System.currentTimeMillis()); // very difficult to compute; this is only a quick-hack
LUDate = (int) new_entry.getAttr("VDate", 0);
UCount = 0;
PCount = (new_flags.get(1)) ? 1 : 0;
@@ -139,7 +139,7 @@ public class plasmaRankingCRProcess {
return true;
}
- private static boolean accumulate_upd(final File f, final kelondroIndex acc, final kelondroCollectionIndex seq) throws IOException {
+ private static boolean accumulate_upd(final File f, final ObjectIndex acc, final kelondroCollectionIndex seq) throws IOException {
// open file
kelondroAttrSeq source_cr = null;
try {
@@ -152,13 +152,13 @@ public class plasmaRankingCRProcess {
final Iterator<String> el = source_cr.keys();
String key;
kelondroAttrSeq.Entry new_entry;
- kelondroRow.Entry acc_entry;
+ Row.Entry acc_entry;
int FUDate, FDDate, LUDate, UCount, PCount, ACount, VCount, Vita;
- kelondroBitfield acc_flags, new_flags;
+ Bitfield acc_flags, new_flags;
while (el.hasNext()) {
key = el.next();
new_entry = source_cr.getEntry(key);
- new_flags = new kelondroBitfield(kelondroBase64Order.enhancedCoder.encodeLong(new_entry.getAttr("Flags", 0), 1).getBytes());
+ new_flags = new Bitfield(Base64Order.enhancedCoder.encodeLong(new_entry.getAttr("Flags", 0), 1).getBytes());
// enrich information with additional values
if ((acc_entry = acc.get(key.getBytes())) != null) {
FUDate = (int) acc_entry.getColLong("FUDate", 0);
@@ -179,11 +179,11 @@ public class plasmaRankingCRProcess {
VCount += (new_flags.get(3)) ? 1 : 0;
// 'OR' the flags
- acc_flags = new kelondroBitfield(kelondroBase64Order.enhancedCoder.encodeLong(acc_entry.getColLong("Flags", 0), 1).getBytes());
+ acc_flags = new Bitfield(Base64Order.enhancedCoder.encodeLong(acc_entry.getColLong("Flags", 0), 1).getBytes());
for (int i = 0; i < 6; i++) {
if (new_flags.get(i)) acc_flags.set(i, true);
}
- acc_entry.setCol("Flags", (int) kelondroBase64Order.enhancedCoder.decodeLong(acc_flags.exportB64()));
+ acc_entry.setCol("Flags", (int) Base64Order.enhancedCoder.decodeLong(acc_flags.exportB64()));
} else {
// initialize counters and dates
acc_entry = acc.row().newEntry();
@@ -192,8 +192,8 @@ public class plasmaRankingCRProcess {
acc_entry.setCol(i, new_entry.getAttr(acc.row().column(i).nickname, 0));
}
seq.put(key.getBytes(), new_entry.getSeqCollection());
- FUDate = kelondroMicroDate.microDateHoursInt(System.currentTimeMillis()); // first update date
- FDDate = kelondroMicroDate.microDateHoursInt(System.currentTimeMillis()); // very difficult to compute; this is only a quick-hack
+ FUDate = MicroDate.microDateHoursInt(System.currentTimeMillis()); // first update date
+ FDDate = MicroDate.microDateHoursInt(System.currentTimeMillis()); // very difficult to compute; this is only a quick-hack
LUDate = (int) new_entry.getAttr("VDate", 0);
UCount = 0;
PCount = (new_flags.get(1)) ? 1 : 0;
@@ -238,12 +238,12 @@ public class plasmaRankingCRProcess {
// open target file
kelondroAttrSeq acc = null;
- kelondroIndex newacc = null;
+ ObjectIndex newacc = null;
kelondroCollectionIndex newseq = null;
if (newdb) {
final File path = to_file.getParentFile(); // path to storage place
newacc = new kelondroEcoTable(new File(path, CRG_accname), CRG_accrow, kelondroEcoTable.tailCacheUsageAuto, 0, 0);
- newseq = new kelondroCollectionIndex(path, CRG_seqname, 12, kelondroBase64Order.enhancedCoder, 2, 9, CRG_colrow, false);
+ newseq = new kelondroCollectionIndex(path, CRG_seqname, 12, Base64Order.enhancedCoder, 2, 9, CRG_colrow, false);
} else {
if (!(to_file.exists())) {
acc = new kelondroAttrSeq("Global Ranking Accumulator File",
@@ -357,7 +357,7 @@ public class plasmaRankingCRProcess {
count++;
if ((count % 1000) == 0) {
l = java.lang.Math.max(1, (System.currentTimeMillis() - start) / 1000);
- System.out.println("processed " + count + " citations, " + (count / l) + " per second, rci.size = " + rci.size() + ", " + ((size - count) / (count / l)) + " seconds remaining; mem = " + kelondroMemory.available());
+ System.out.println("processed " + count + " citations, " + (count / l) + " per second, rci.size = " + rci.size() + ", " + ((size - count) / (count / l)) + " seconds remaining; mem = " + MemoryControl.available());
}
i.remove();
}
@@ -365,15 +365,15 @@ public class plasmaRankingCRProcess {
// finished. write to file
cr = null;
cr_in = null;
- kelondroMemory.gc(1000, "plasmaRankingCRProcess.genrci(...)"); // thq
+ MemoryControl.gc(1000, "plasmaRankingCRProcess.genrci(...)"); // thq
rci.toFile(rci_out);
return count;
}
public static int genrcix(final File cr_path_in, final File rci_path_out) throws IOException {
//kelondroFlexTable acc = new kelondroFlexTable(cr_path_in, CRG_accname, kelondroBase64Order.enhancedCoder, 128 * 1024 * 1024, -1, CRG_accrow, true);
- final kelondroCollectionIndex seq = new kelondroCollectionIndex(cr_path_in, CRG_seqname, 12, kelondroBase64Order.enhancedCoder, 2, 9, CRG_colrow, false);
- final kelondroCollectionIndex rci = new kelondroCollectionIndex(rci_path_out, RCI_colname, 6, kelondroBase64Order.enhancedCoder, 2, 9, RCI_coli, false);
+ final kelondroCollectionIndex seq = new kelondroCollectionIndex(cr_path_in, CRG_seqname, 12, Base64Order.enhancedCoder, 2, 9, CRG_colrow, false);
+ final kelondroCollectionIndex rci = new kelondroCollectionIndex(rci_path_out, RCI_colname, 6, Base64Order.enhancedCoder, 2, 9, RCI_coli, false);
// loop over all referees
int count = 0;
@@ -383,21 +383,21 @@ public class plasmaRankingCRProcess {
final Iterator<Object[]> i = seq.keycollections(null, null, false);
Object[] keycollection;
String referee, refereeDom, anchor, anchorDom;
- kelondroRowSet cr_entry, rci_entry;
+ RowSet cr_entry, rci_entry;
while (i.hasNext()) {
keycollection = i.next();
referee = new String((byte[]) keycollection[0]);
if (referee.length() == 6) refereeDom = referee; else refereeDom = referee.substring(6);
- cr_entry = (kelondroRowSet) keycollection[1];
+ cr_entry = (RowSet) keycollection[1];
// loop over all anchors
- for (kelondroRow.Entry entry: cr_entry) {
+ for (Row.Entry entry: cr_entry) {
anchor = entry.getColString(0, null);
if (anchor.length() == 6) anchorDom = anchor; else anchorDom = anchor.substring(6);
// update domain-specific entry
rci_entry = rci.get(anchorDom.getBytes());
- if (rci_entry == null) rci_entry = new kelondroRowSet(RCI_coli, 0);
+ if (rci_entry == null) rci_entry = new RowSet(RCI_coli, 0);
rci_entry.add(refereeDom.getBytes());
// insert entry
@@ -406,7 +406,7 @@ public class plasmaRankingCRProcess {
count++;
if ((count % 1000) == 0) {
l = java.lang.Math.max(1, (System.currentTimeMillis() - start) / 1000);
- System.out.println("processed " + count + " citations, " + (count / l) + " per second, rci.size = " + rci.size() + ", " + ((size - count) / (count / l) / 60) + " minutes remaining; mem = " + kelondroMemory.free());
+ System.out.println("processed " + count + " citations, " + (count / l) + " per second, rci.size = " + rci.size() + ", " + ((size - count) / (count / l) / 60) + " minutes remaining; mem = " + MemoryControl.free());
}
}
@@ -429,7 +429,7 @@ public class plasmaRankingCRProcess {
final File tmp_dir = new File(root_path, "DATA/RANKING/GLOBAL/016_tmp");
final File err_dir = new File(root_path, "DATA/RANKING/GLOBAL/017_err");
final File acc_dir = new File(root_path, "DATA/RANKING/GLOBAL/018_acc");
- final String filename = "CRG-a-" + new kelondroDate().toShortString(true) + ".cr.gz";
+ final String filename = "CRG-a-" + new DateFormatter().toShortString(true) + ".cr.gz";
final File to_file = new File(root_path, "DATA/RANKING/GLOBAL/020_con0/" + filename);
if (!(ready_dir.exists())) ready_dir.mkdirs();
if (!(tmp_dir.exists())) tmp_dir.mkdirs();
diff --git a/source/de/anomic/plasma/plasmaRankingRCIEvaluation.java b/source/de/anomic/plasma/plasmaRankingRCIEvaluation.java
index 727370ac4..e81c40553 100644
--- a/source/de/anomic/plasma/plasmaRankingRCIEvaluation.java
+++ b/source/de/anomic/plasma/plasmaRankingRCIEvaluation.java
@@ -35,8 +35,8 @@ import java.util.Iterator;
import java.util.TreeSet;
import de.anomic.kelondro.kelondroAttrSeq;
-import de.anomic.kelondro.kelondroBase64Order;
-import de.anomic.kelondro.kelondroDigest;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.Digest;
import de.anomic.server.serverFileUtils;
import de.anomic.yacy.yacyURL;
@@ -137,7 +137,7 @@ public class plasmaRankingRCIEvaluation {
@SuppressWarnings("unchecked")
public static TreeSet<String>[] genRankingTable(final kelondroAttrSeq rci, final int[] partition) {
final TreeSet<String>[] ranked = new TreeSet[partition.length];
- for (int i = 0; i < partition.length; i++) ranked[i] = new TreeSet<String>(kelondroBase64Order.enhancedComparator);
+ for (int i = 0; i < partition.length; i++) ranked[i] = new TreeSet<String>(Base64Order.enhancedComparator);
final Iterator<String> i = rci.keys();
String key;
kelondroAttrSeq.Entry entry;
@@ -169,7 +169,7 @@ public class plasmaRankingRCIEvaluation {
String filename;
if (!(tablePath.exists())) tablePath.mkdirs();
for (int i = 0; i < ranking.length - 1; i++) {
- filename = "YBR-4-" + kelondroDigest.encodeHex(i, 2) + ".idx";
+ filename = "YBR-4-" + Digest.encodeHex(i, 2) + ".idx";
serverFileUtils.saveSet(new File(tablePath, filename), "plain", ranking[i], "");
}
}
diff --git a/source/de/anomic/plasma/plasmaSearchAPI.java b/source/de/anomic/plasma/plasmaSearchAPI.java
index bb1f561c8..62f21f318 100644
--- a/source/de/anomic/plasma/plasmaSearchAPI.java
+++ b/source/de/anomic/plasma/plasmaSearchAPI.java
@@ -36,8 +36,8 @@ import de.anomic.data.listManager;
import de.anomic.index.indexRWIEntry;
import de.anomic.index.indexReferenceBlacklist;
import de.anomic.index.indexURLReference;
-import de.anomic.kelondro.kelondroBitfield;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.Bitfield;
+import de.anomic.kelondro.coding.DateFormatter;
import de.anomic.server.serverObjects;
import de.anomic.yacy.yacyPeerSelection;
import de.anomic.yacy.yacySeed;
@@ -47,12 +47,12 @@ public class plasmaSearchAPI {
// collection of static methods for a search servlet. Exists only to prevent that the same processes are defined more than once.
- public static kelondroBitfield compileFlags(final serverObjects post) {
- final kelondroBitfield b = new kelondroBitfield(4);
+ public static Bitfield compileFlags(final serverObjects post) {
+ final Bitfield b = new Bitfield(4);
if (post.get("allurl", "").equals("on")) return null;
if (post.get("flags") != null) {
if (post.get("flags","").length() == 0) return null;
- return new kelondroBitfield(4, post.get("flags"));
+ return new Bitfield(4, post.get("flags"));
}
if (post.get("description", "").equals("on")) b.set(indexRWIEntry.flag_app_dc_description, true);
if (post.get("title", "").equals("on")) b.set(indexRWIEntry.flag_app_dc_title, true);
@@ -85,7 +85,7 @@ public class plasmaSearchAPI {
prop.put("searchresult_hosts", hc);
}
- public static plasmaSearchRankingProcess genSearchresult(final serverObjects prop, final plasmaSwitchboard sb, final String keyhash, final kelondroBitfield filter) {
+ public static plasmaSearchRankingProcess genSearchresult(final serverObjects prop, final plasmaSwitchboard sb, final String keyhash, final Bitfield filter) {
final plasmaSearchQuery query = new plasmaSearchQuery(keyhash, -1, sb.getRanking(), filter);
final plasmaSearchRankingProcess ranked = new plasmaSearchRankingProcess(sb.webIndex, query, Integer.MAX_VALUE, 1);
ranked.execQuery();
@@ -111,7 +111,7 @@ public class plasmaSearchAPI {
return ranked;
}
- public static void genURLList(final serverObjects prop, final String keyhash, final String keystring, final plasmaSearchRankingProcess ranked, final kelondroBitfield flags, final int maxlines) {
+ public static void genURLList(final serverObjects prop, final String keyhash, final String keystring, final plasmaSearchRankingProcess ranked, final Bitfield flags, final int maxlines) {
// search for a word hash and generate a list of url links
prop.put("genUrlList_keyHash", keyhash);
@@ -147,7 +147,7 @@ public class plasmaSearchAPI {
prop.putNum("genUrlList_urlList_"+i+"_urlExists_ybr", plasmaSearchRankingProcess.ybr(entry.hash()));
prop.putNum("genUrlList_urlList_"+i+"_urlExists_tf", 1000.0 * entry.word().termFrequency());
prop.putNum("genUrlList_urlList_"+i+"_urlExists_authority", (ranked.getOrder() == null) ? -1 : ranked.getOrder().authority(entry.hash()));
- prop.put("genUrlList_urlList_"+i+"_urlExists_date", kelondroDate.formatShortDay(new Date(entry.word().lastModified())));
+ prop.put("genUrlList_urlList_"+i+"_urlExists_date", DateFormatter.formatShortDay(new Date(entry.word().lastModified())));
prop.putNum("genUrlList_urlList_"+i+"_urlExists_wordsintitle", entry.word().wordsintitle());
prop.putNum("genUrlList_urlList_"+i+"_urlExists_wordsintext", entry.word().wordsintext());
prop.putNum("genUrlList_urlList_"+i+"_urlExists_phrasesintext", entry.word().phrasesintext());
diff --git a/source/de/anomic/plasma/plasmaSearchEvent.java b/source/de/anomic/plasma/plasmaSearchEvent.java
index 3c3d4ab70..dfb98d44b 100644
--- a/source/de/anomic/plasma/plasmaSearchEvent.java
+++ b/source/de/anomic/plasma/plasmaSearchEvent.java
@@ -41,10 +41,10 @@ import de.anomic.index.indexContainer;
import de.anomic.index.indexRWIEntry;
import de.anomic.index.indexRWIVarEntry;
import de.anomic.index.indexURLReference;
-import de.anomic.kelondro.kelondroBitfield;
-import de.anomic.kelondro.kelondroMSetTools;
import de.anomic.kelondro.kelondroSortStack;
import de.anomic.kelondro.kelondroSortStore;
+import de.anomic.kelondro.coding.Bitfield;
+import de.anomic.kelondro.tools.SetTools;
import de.anomic.plasma.plasmaSnippetCache.MediaSnippet;
import de.anomic.server.serverProfiling;
import de.anomic.server.logging.serverLog;
@@ -117,10 +117,10 @@ public final class plasmaSearchEvent {
// snippets do not need to match with the complete query hashes,
// only with the query minus the stopwords which had not been used for the search
- final TreeSet<String> filtered = kelondroMSetTools.joinConstructive(query.queryHashes, plasmaSwitchboard.stopwords);
+ final TreeSet<String> filtered = SetTools.joinConstructive(query.queryHashes, plasmaSwitchboard.stopwords);
this.snippetFetchWordHashes = (TreeSet<String>) query.queryHashes.clone();
if ((filtered != null) && (filtered.size() > 0)) {
- kelondroMSetTools.excludeDestructive(this.snippetFetchWordHashes, plasmaSwitchboard.stopwords);
+ SetTools.excludeDestructive(this.snippetFetchWordHashes, plasmaSwitchboard.stopwords);
}
final long start = System.currentTimeMillis();
@@ -708,7 +708,7 @@ public final class plasmaSearchEvent {
System.out.println("DEBUG-INDEXABSTRACT: hash " + (String) entry.getKey() + ": " + ((query.queryHashes.contains((String) entry.getKey())) ? "NEEDED" : "NOT NEEDED") + "; " + ((TreeMap) entry.getValue()).size() + " entries");
}
*/
- final TreeMap<String, String> abstractJoin = (rcAbstracts.size() == query.queryHashes.size()) ? kelondroMSetTools.joinConstructive(rcAbstracts.values(), true) : new TreeMap<String, String>();
+ final TreeMap<String, String> abstractJoin = (rcAbstracts.size() == query.queryHashes.size()) ? SetTools.joinConstructive(rcAbstracts.values(), true) : new TreeMap<String, String>();
if (abstractJoin.size() != 0) {
//System.out.println("DEBUG-INDEXABSTRACT: index abstracts delivered " + abstractJoin.size() + " additional results for secondary search");
// generate query for secondary search
@@ -856,7 +856,7 @@ public final class plasmaSearchEvent {
public yacyURL url() {
return urlcomps.url();
}
- public kelondroBitfield flags() {
+ public Bitfield flags() {
return urlentry.flags();
}
public String urlstring() {
diff --git a/source/de/anomic/plasma/plasmaSearchImages.java b/source/de/anomic/plasma/plasmaSearchImages.java
index af8638804..35a94a736 100644
--- a/source/de/anomic/plasma/plasmaSearchImages.java
+++ b/source/de/anomic/plasma/plasmaSearchImages.java
@@ -30,7 +30,7 @@ import java.util.Iterator;
import de.anomic.htmlFilter.htmlFilterContentScraper;
import de.anomic.htmlFilter.htmlFilterImageEntry;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.DateFormatter;
import de.anomic.plasma.parser.ParserException;
import de.anomic.server.logging.serverLog;
import de.anomic.yacy.yacyURL;
@@ -75,7 +75,7 @@ public final class plasmaSearchImages {
while (i.hasNext()) {
try {
nexturlstring = i.next().toNormalform(true, true);
- addAll(new plasmaSearchImages(kelondroDate.remainingTime(start, maxTime, 10), new yacyURL(nexturlstring, null), depth - 1, indexing));
+ addAll(new plasmaSearchImages(DateFormatter.remainingTime(start, maxTime, 10), new yacyURL(nexturlstring, null), depth - 1, indexing));
} catch (final MalformedURLException e1) {
e1.printStackTrace();
}
diff --git a/source/de/anomic/plasma/plasmaSearchQuery.java b/source/de/anomic/plasma/plasmaSearchQuery.java
index 98b097d81..006e34edb 100644
--- a/source/de/anomic/plasma/plasmaSearchQuery.java
+++ b/source/de/anomic/plasma/plasmaSearchQuery.java
@@ -29,10 +29,10 @@ import java.util.TreeSet;
import de.anomic.htmlFilter.htmlFilterAbstractScraper;
import de.anomic.htmlFilter.htmlFilterCharacterCoding;
import de.anomic.index.indexWord;
-import de.anomic.kelondro.kelondroBase64Order;
-import de.anomic.kelondro.kelondroBitfield;
-import de.anomic.kelondro.kelondroMSetTools;
-import de.anomic.kelondro.kelondroNaturalOrder;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.Bitfield;
+import de.anomic.kelondro.coding.NaturalOrder;
+import de.anomic.kelondro.tools.SetTools;
import de.anomic.yacy.yacySeed;
import de.anomic.yacy.yacySeedDB;
import de.anomic.yacy.yacyURL;
@@ -52,8 +52,8 @@ public final class plasmaSearchQuery {
public static final int CONTENTDOM_VIDEO = 3;
public static final int CONTENTDOM_APP = 4;
- public static final kelondroBitfield empty_constraint = new kelondroBitfield(4, "AAAAAA");
- public static final kelondroBitfield catchall_constraint = new kelondroBitfield(4, "______");
+ public static final Bitfield empty_constraint = new Bitfield(4, "AAAAAA");
+ public static final Bitfield catchall_constraint = new Bitfield(4, "______");
public String queryString;
public TreeSet<String> fullqueryHashes, queryHashes, excludeHashes;
@@ -66,7 +66,7 @@ public final class plasmaSearchQuery {
public int zonecode;
public int domMaxTargets;
public int maxDistance;
- public kelondroBitfield constraint;
+ public Bitfield constraint;
public boolean allofconstraint;
public boolean onlineSnippetFetch;
public plasmaSearchRankingProfile ranking;
@@ -81,8 +81,8 @@ public final class plasmaSearchQuery {
public plasmaSearchQuery(final String queryString,
final int lines,
final plasmaSearchRankingProfile ranking,
- final kelondroBitfield constraint) {
- if ((queryString.length() == 12) && (kelondroBase64Order.enhancedCoder.wellformed(queryString.getBytes()))) {
+ final Bitfield constraint) {
+ if ((queryString.length() == 12) && (Base64Order.enhancedCoder.wellformed(queryString.getBytes()))) {
this.queryString = null;
this.queryHashes = new TreeSet<String>();
this.excludeHashes = new TreeSet<String>();
@@ -124,7 +124,7 @@ public final class plasmaSearchQuery {
final boolean onlineSnippetFetch,
final int lines, final int offset, final String urlMask,
final int domType, final String domGroupName, final int domMaxTargets,
- final kelondroBitfield constraint, final boolean allofconstraint,
+ final Bitfield constraint, final boolean allofconstraint,
final int domainzone,
final String host,
final boolean specialRights) {
@@ -194,8 +194,8 @@ public final class plasmaSearchQuery {
}
public static TreeSet<String> hashes2Set(final String query) {
- if (query == null) return new TreeSet<String>(kelondroBase64Order.enhancedComparator);
- final TreeSet<String> keyhashes = new TreeSet<String>(kelondroBase64Order.enhancedComparator);
+ if (query == null) return new TreeSet<String>(Base64Order.enhancedComparator);
+ final TreeSet<String> keyhashes = new TreeSet<String>(Base64Order.enhancedComparator);
for (int i = 0; i < (query.length() / yacySeedDB.commonHashLength); i++) {
keyhashes.add(query.substring(i * yacySeedDB.commonHashLength, (i + 1) * yacySeedDB.commonHashLength));
}
@@ -231,7 +231,7 @@ public final class plasmaSearchQuery {
// 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
final TreeSet<String> wordhashes = indexWord.words2hashes(plasmaCondenser.getWords(text).keySet());
- return kelondroMSetTools.anymatch(wordhashes, keyhashes);
+ return SetTools.anymatch(wordhashes, keyhashes);
}
private static String seps = "'.,/&_"; static {seps += '"';}
@@ -239,7 +239,7 @@ public final class plasmaSearchQuery {
@SuppressWarnings("unchecked")
public static TreeSet<String>[] cleanQuery(String querystring) {
// returns three sets: a query set, a exclude set and a full query set
- if ((querystring == null) || (querystring.length() == 0)) return new TreeSet[]{new TreeSet<String>(kelondroNaturalOrder.naturalComparator), new TreeSet<String>(kelondroNaturalOrder.naturalComparator)};
+ if ((querystring == null) || (querystring.length() == 0)) return new TreeSet[]{new TreeSet<String>(NaturalOrder.naturalComparator), new TreeSet<String>(NaturalOrder.naturalComparator)};
// convert Umlaute
querystring = htmlFilterAbstractScraper.stripAll(querystring).toLowerCase().trim();
@@ -251,9 +251,9 @@ public final class plasmaSearchQuery {
String s;
int l;
// the string is clean now, but we must generate a set out of it
- final TreeSet<String> query = new TreeSet<String>(kelondroNaturalOrder.naturalComparator);
- final TreeSet<String> exclude = new TreeSet<String>(kelondroNaturalOrder.naturalComparator);
- final TreeSet<String> fullquery = new TreeSet<String>(kelondroNaturalOrder.naturalComparator);
+ final TreeSet<String> query = new TreeSet<String>(NaturalOrder.naturalComparator);
+ final TreeSet<String> exclude = new TreeSet<String>(NaturalOrder.naturalComparator);
+ final TreeSet<String> fullquery = new TreeSet<String>(NaturalOrder.naturalComparator);
final String[] a = querystring.split(" ");
for (int i = 0; i < a.length; i++) {
if (a[i].startsWith("-")) {
@@ -289,7 +289,7 @@ public final class plasmaSearchQuery {
// filter out words that appear in this set
// this is applied to the queryHashes
final TreeSet<String> blues = indexWord.words2hashes(blueList);
- kelondroMSetTools.excludeDestructive(queryHashes, blues);
+ SetTools.excludeDestructive(queryHashes, blues);
}
public String id(final boolean anonymized) {
diff --git a/source/de/anomic/plasma/plasmaSearchRankingProcess.java b/source/de/anomic/plasma/plasmaSearchRankingProcess.java
index ca882ad0f..ab135d428 100644
--- a/source/de/anomic/plasma/plasmaSearchRankingProcess.java
+++ b/source/de/anomic/plasma/plasmaSearchRankingProcess.java
@@ -43,17 +43,17 @@ import de.anomic.index.indexRWIEntryOrder;
import de.anomic.index.indexRWIVarEntry;
import de.anomic.index.indexURLReference;
import de.anomic.index.indexWord;
-import de.anomic.kelondro.kelondroBinSearch;
-import de.anomic.kelondro.kelondroDigest;
-import de.anomic.kelondro.kelondroMScoreCluster;
import de.anomic.kelondro.kelondroSortStack;
+import de.anomic.kelondro.coding.Digest;
+import de.anomic.kelondro.index.BinSearch;
+import de.anomic.kelondro.tools.ScoreCluster;
import de.anomic.server.serverFileUtils;
import de.anomic.server.serverProfiling;
import de.anomic.yacy.yacyURL;
public final class plasmaSearchRankingProcess {
- public static kelondroBinSearch[] ybrTables = null; // block-rank tables
+ public static BinSearch[] ybrTables = null; // block-rank tables
public static final int maxYBR = 3; // the lower this value, the faster the search
private static boolean useYBR = true;
private static final int maxDoubleDomAll = 20, maxDoubleDomSpecial = 10000;
@@ -66,7 +66,7 @@ public final class plasmaSearchRankingProcess {
private int remote_peerCount, remote_indexCount, remote_resourceSize, local_resourceSize;
private final indexRWIEntryOrder order;
private final ConcurrentHashMap<String, Integer> urlhashes; // map for double-check; String/Long relation, addresses ranking number (backreference for deletion)
- private final kelondroMScoreCluster<String> ref; // reference score computation for the commonSense heuristic
+ private final ScoreCluster<String> ref; // reference score computation for the commonSense heuristic
private final int[] flagcount; // flag counter
private final TreeSet<String> misses; // contains url-hashes that could not been found in the LURL-DB
private final plasmaWordIndex wordIndex;
@@ -89,7 +89,7 @@ public final class plasmaSearchRankingProcess {
this.remote_resourceSize = 0;
this.local_resourceSize = 0;
this.urlhashes = new ConcurrentHashMap<String, Integer>(0, 0.75f, concurrency);
- this.ref = new kelondroMScoreCluster<String>();
+ this.ref = new ScoreCluster<String>();
this.misses = new TreeSet<String>();
this.wordIndex = wordIndex;
this.flagcount = new int[32];
@@ -395,15 +395,15 @@ public final class plasmaSearchRankingProcess {
public static void loadYBR(final File rankingPath, final int count) {
// load ranking tables
if (rankingPath.exists()) {
- ybrTables = new kelondroBinSearch[count];
+ ybrTables = new BinSearch[count];
String ybrName;
File f;
try {
for (int i = 0; i < count; i++) {
- ybrName = "YBR-4-" + kelondroDigest.encodeHex(i, 2) + ".idx";
+ ybrName = "YBR-4-" + Digest.encodeHex(i, 2) + ".idx";
f = new File(rankingPath, ybrName);
if (f.exists()) {
- ybrTables[i] = new kelondroBinSearch(serverFileUtils.read(f), 6);
+ ybrTables[i] = new BinSearch(serverFileUtils.read(f), 6);
} else {
ybrTables[i] = null;
}
diff --git a/source/de/anomic/plasma/plasmaSnippetCache.java b/source/de/anomic/plasma/plasmaSnippetCache.java
index efdac2291..4dcb14303 100644
--- a/source/de/anomic/plasma/plasmaSnippetCache.java
+++ b/source/de/anomic/plasma/plasmaSnippetCache.java
@@ -46,8 +46,8 @@ import de.anomic.http.httpResponseHeader;
import de.anomic.index.indexDocumentMetadata;
import de.anomic.index.indexURLReference;
import de.anomic.index.indexWord;
-import de.anomic.kelondro.kelondroMScoreCluster;
-import de.anomic.kelondro.kelondroMSetTools;
+import de.anomic.kelondro.tools.ScoreCluster;
+import de.anomic.kelondro.tools.SetTools;
import de.anomic.plasma.parser.ParserException;
import de.anomic.server.logging.serverLog;
import de.anomic.yacy.yacySearch;
@@ -70,7 +70,7 @@ public class plasmaSnippetCache {
public static final int ERROR_NO_MATCH = 16;
private static int snippetsScoreCounter = 0;
- private static kelondroMScoreCluster<String> snippetsScore = null;
+ private static ScoreCluster<String> snippetsScore = null;
private static final HashMap<String, String> snippetsCache = new HashMap<String, String>();
/**
@@ -93,7 +93,7 @@ public class plasmaSnippetCache {
log = logx;
sb = switchboard;
snippetsScoreCounter = 0;
- snippetsScore = new kelondroMScoreCluster<String>();
+ snippetsScore = new ScoreCluster<String>();
snippetsCache.clear();
faviconCache.clear();
}
@@ -518,7 +518,7 @@ public class plasmaSnippetCache {
// care for counter
if (snippetsScoreCounter == java.lang.Integer.MAX_VALUE) {
snippetsScoreCounter = 0;
- snippetsScore = new kelondroMScoreCluster<String>();
+ snippetsScore = new ScoreCluster<String>();
snippetsCache.clear();
}
@@ -940,7 +940,7 @@ public class plasmaSnippetCache {
public static String failConsequences(final TextSnippet snippet, final String eventID) {
// problems with snippet fetch
final String urlHash = snippet.getUrl().hash();
- final String querystring = kelondroMSetTools.setToString(snippet.getRemainingHashes(), ' ');
+ final String querystring = SetTools.setToString(snippet.getRemainingHashes(), ' ');
if ((snippet.getErrorCode() == ERROR_SOURCE_LOADING) ||
(snippet.getErrorCode() == ERROR_RESOURCE_LOADING) ||
(snippet.getErrorCode() == ERROR_PARSER_FAILED) ||
diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.java
index 444459218..38afaa60d 100644
--- a/source/de/anomic/plasma/plasmaSwitchboard.java
+++ b/source/de/anomic/plasma/plasmaSwitchboard.java
@@ -85,7 +85,6 @@
package de.anomic.plasma;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -145,11 +144,11 @@ import de.anomic.index.indexReferenceBlacklist;
import de.anomic.index.indexURLReference;
import de.anomic.kelondro.kelondroCache;
import de.anomic.kelondro.kelondroCachedRecords;
-import de.anomic.kelondro.kelondroDigest;
-import de.anomic.kelondro.kelondroMSetTools;
-import de.anomic.kelondro.kelondroNaturalOrder;
-import de.anomic.kelondro.kelondroDate;
-import de.anomic.kelondro.kelondroMemory;
+import de.anomic.kelondro.coding.DateFormatter;
+import de.anomic.kelondro.coding.Digest;
+import de.anomic.kelondro.coding.NaturalOrder;
+import de.anomic.kelondro.tools.SetTools;
+import de.anomic.kelondro.tools.MemoryControl;
import de.anomic.plasma.parser.ParserException;
import de.anomic.server.serverAbstractSwitch;
import de.anomic.server.serverBusyThread;
@@ -342,7 +341,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
// read only once upon first instantiation of this class
final String f = getConfig(plasmaSwitchboardConstants.LIST_BLUE, plasmaSwitchboardConstants.LIST_BLUE_DEFAULT);
final File plasmaBlueListFile = new File(f);
- if (f != null) blueList = kelondroMSetTools.loadList(plasmaBlueListFile, kelondroNaturalOrder.naturalComparator); else blueList= new TreeSet<String>();
+ if (f != null) blueList = SetTools.loadList(plasmaBlueListFile, NaturalOrder.naturalComparator); else blueList= new TreeSet<String>();
this.log.logConfig("loaded blue-list from file " + plasmaBlueListFile.getName() + ", " +
blueList.size() + " entries, " +
ppRamString(plasmaBlueListFile.length()/1024));
@@ -380,7 +379,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
// load badwords (to filter the topwords)
if (badwords == null) {
final File badwordsFile = new File(rootPath, plasmaSwitchboardConstants.LIST_BADWORDS_DEFAULT);
- badwords = kelondroMSetTools.loadList(badwordsFile, kelondroNaturalOrder.naturalComparator);
+ badwords = SetTools.loadList(badwordsFile, NaturalOrder.naturalComparator);
this.log.logConfig("loaded badwords from file " + badwordsFile.getName() +
", " + badwords.size() + " entries, " +
ppRamString(badwordsFile.length()/1024));
@@ -389,7 +388,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
// load stopwords
if (stopwords == null) {
final File stopwordsFile = new File(rootPath, plasmaSwitchboardConstants.LIST_STOPWORDS_DEFAULT);
- stopwords = kelondroMSetTools.loadList(stopwordsFile, kelondroNaturalOrder.naturalComparator);
+ stopwords = SetTools.loadList(stopwordsFile, NaturalOrder.naturalComparator);
this.log.logConfig("loaded stopwords from file " + stopwordsFile.getName() + ", " +
stopwords.size() + " entries, " +
ppRamString(stopwordsFile.length()/1024));
@@ -593,7 +592,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
// deploy busy threads
log.logConfig("Starting Threads");
- kelondroMemory.gc(1000, "plasmaSwitchboard, help for profiler"); // help for profiler - thq
+ MemoryControl.gc(1000, "plasmaSwitchboard, help for profiler"); // help for profiler - thq
moreMemory = new Timer(); // init GC Thread - thq
moreMemory.schedule(new MoreMemory(), 300000, 600000);
@@ -1292,7 +1291,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
boolean hasDoneSomething = false;
// clear caches if necessary
- if (!kelondroMemory.request(8000000L, false)) {
+ if (!MemoryControl.request(8000000L, false)) {
webIndex.clearCache();
plasmaSearchEvent.cleanupEvents(true);
}
@@ -1300,7 +1299,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
// set a random password if no password is configured
if (!crawlStacker.acceptLocalURLs() && getConfigBool("adminAccountForLocalhost", false) && getConfig(httpd.ADMIN_ACCOUNT_B64MD5, "").length() == 0) {
// make a 'random' password
- setConfig(httpd.ADMIN_ACCOUNT_B64MD5, "0000" + kelondroDigest.encodeMD5Hex(System.getProperties().toString() + System.currentTimeMillis()));
+ setConfig(httpd.ADMIN_ACCOUNT_B64MD5, "0000" + Digest.encodeMD5Hex(System.getProperties().toString() + System.currentTimeMillis()));
setConfig("adminAccount", "");
}
@@ -1719,10 +1718,10 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
}
}
- private static SimpleDateFormat DateFormatter = new SimpleDateFormat("EEE, dd MMM yyyy");
+ private static SimpleDateFormat DateFormat1 = new SimpleDateFormat("EEE, dd MMM yyyy");
public static String dateString(final Date date) {
if (date == null) return "";
- return DateFormatter.format(date);
+ return DateFormat1.format(date);
}
// we need locale independent RFC-822 dates at some places
@@ -2150,7 +2149,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
webIndex.seedDB.mySeed().put(yacySeed.VERSION, getConfig("version", ""));
webIndex.seedDB.mySeed().setFlagDirectConnect(true);
webIndex.seedDB.mySeed().setLastSeenUTC();
- webIndex.seedDB.mySeed().put(yacySeed.UTC, kelondroDate.UTCDiffString());
+ webIndex.seedDB.mySeed().put(yacySeed.UTC, DateFormatter.UTCDiffString());
webIndex.seedDB.mySeed().setFlagAcceptRemoteCrawl(getConfig("crawlResponse", "").equals("true"));
webIndex.seedDB.mySeed().setFlagAcceptRemoteIndex(getConfig("allowReceiveIndex", "").equals("true"));
//mySeed.setFlagAcceptRemoteIndex(true);
@@ -2282,7 +2281,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
class MoreMemory extends TimerTask {
public final void run() {
- kelondroMemory.gc(10000, "MoreMemory()");
+ MemoryControl.gc(10000, "MoreMemory()");
}
}
diff --git a/source/de/anomic/plasma/plasmaWebStructure.java b/source/de/anomic/plasma/plasmaWebStructure.java
index bfd223fcc..1f14d86e8 100644
--- a/source/de/anomic/plasma/plasmaWebStructure.java
+++ b/source/de/anomic/plasma/plasmaWebStructure.java
@@ -37,9 +37,9 @@ import java.util.SortedMap;
import java.util.TreeMap;
import java.util.TreeSet;
-import de.anomic.kelondro.kelondroBase64Order;
-import de.anomic.kelondro.kelondroMicroDate;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.DateFormatter;
+import de.anomic.kelondro.coding.MicroDate;
import de.anomic.server.serverFileUtils;
import de.anomic.server.logging.serverLog;
import de.anomic.yacy.yacyURL;
@@ -120,16 +120,16 @@ public class plasmaWebStructure {
// append this reference to buffer
// generate header info
final String head = url.hash() + "=" +
- kelondroMicroDate.microDateHoursStr(docDate.getTime()) + // latest update timestamp of the URL
- kelondroMicroDate.microDateHoursStr(System.currentTimeMillis()) + // last visit timestamp of the URL
- kelondroBase64Order.enhancedCoder.encodeLongSmart(LCount, 2) + // count of links to local resources
- kelondroBase64Order.enhancedCoder.encodeLongSmart(GCount, 2) + // count of links to global resources
- kelondroBase64Order.enhancedCoder.encodeLongSmart(document.getImages().size(), 2) + // count of Images in document
- kelondroBase64Order.enhancedCoder.encodeLongSmart(0, 2) + // count of links to other documents
- kelondroBase64Order.enhancedCoder.encodeLongSmart(document.getTextLength(), 3) + // length of plain text in bytes
- kelondroBase64Order.enhancedCoder.encodeLongSmart(condenser.RESULT_NUMB_WORDS, 3) + // count of all appearing words
- kelondroBase64Order.enhancedCoder.encodeLongSmart(condenser.words().size(), 3) + // count of all unique words
- kelondroBase64Order.enhancedCoder.encodeLongSmart(0, 1); // Flags (update, popularity, attention, vote)
+ MicroDate.microDateHoursStr(docDate.getTime()) + // latest update timestamp of the URL
+ MicroDate.microDateHoursStr(System.currentTimeMillis()) + // last visit timestamp of the URL
+ Base64Order.enhancedCoder.encodeLongSmart(LCount, 2) + // count of links to local resources
+ Base64Order.enhancedCoder.encodeLongSmart(GCount, 2) + // count of links to global resources
+ Base64Order.enhancedCoder.encodeLongSmart(document.getImages().size(), 2) + // count of Images in document
+ Base64Order.enhancedCoder.encodeLongSmart(0, 2) + // count of links to other documents
+ Base64Order.enhancedCoder.encodeLongSmart(document.getTextLength(), 3) + // length of plain text in bytes
+ Base64Order.enhancedCoder.encodeLongSmart(condenser.RESULT_NUMB_WORDS, 3) + // count of all appearing words
+ Base64Order.enhancedCoder.encodeLongSmart(condenser.words().size(), 3) + // count of all unique words
+ Base64Order.enhancedCoder.encodeLongSmart(0, 1); // Flags (update, popularity, attention, vote)
//crl.append(head); crl.append ('|'); crl.append(cpl); crl.append((char) 13); crl.append((char) 10);
crg.append(head); crg.append('|'); crg.append(cpg); crg.append((char) 13); crg.append((char) 10);
@@ -153,7 +153,7 @@ public class plasmaWebStructure {
public void flushCitationReference(final String type) {
if (crg.length() < 12) return;
- final String filename = type.toUpperCase() + "-A-" + new kelondroDate().toShortString(true) + "." + crg.substring(0, 12) + ".cr.gz";
+ final String filename = type.toUpperCase() + "-A-" + new DateFormatter().toShortString(true) + "." + crg.substring(0, 12) + ".cr.gz";
final File path = new File(rankingPath, (type.equals("crl")) ? crlFile : crgFile);
path.mkdirs();
final File file = new File(path, filename);
@@ -193,7 +193,7 @@ public class plasmaWebStructure {
private static String map2refstr(final Map<String, Integer> map) {
final StringBuilder s = new StringBuilder(map.size() * 10);
- s.append(kelondroDate.formatShortDay(new Date()));
+ s.append(DateFormatter.formatShortDay(new Date()));
String h;
for (final Map.Entry<String, Integer> entry : map.entrySet()) {
s.append(entry.getKey());
diff --git a/source/de/anomic/plasma/plasmaWordIndex.java b/source/de/anomic/plasma/plasmaWordIndex.java
index 3fdf42958..21b2d1c18 100644
--- a/source/de/anomic/plasma/plasmaWordIndex.java
+++ b/source/de/anomic/plasma/plasmaWordIndex.java
@@ -53,15 +53,15 @@ import de.anomic.index.indexRepositoryReference;
import de.anomic.index.indexURLReference;
import de.anomic.index.indexWord;
import de.anomic.index.indexRepositoryReference.Export;
-import de.anomic.kelondro.kelondroBase64Order;
-import de.anomic.kelondro.kelondroByteOrder;
import de.anomic.kelondro.kelondroCloneableIterator;
import de.anomic.kelondro.kelondroException;
import de.anomic.kelondro.kelondroMergeIterator;
-import de.anomic.kelondro.kelondroOrder;
import de.anomic.kelondro.kelondroRotateIterator;
-import de.anomic.kelondro.kelondroRowCollection;
-import de.anomic.kelondro.kelondroMemory;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.ByteOrder;
+import de.anomic.kelondro.coding.kelondroOrder;
+import de.anomic.kelondro.index.RowCollection;
+import de.anomic.kelondro.tools.MemoryControl;
import de.anomic.server.serverProfiling;
import de.anomic.server.logging.serverLog;
import de.anomic.tools.iso639;
@@ -97,7 +97,7 @@ public final class plasmaWordIndex implements indexRI {
public static final long CRAWL_PROFILE_SNIPPET_GLOBAL_MEDIA_RECRAWL_CYCLE = 60L * 24L * 30L;
- private final kelondroByteOrder indexOrder = kelondroBase64Order.enhancedCoder;
+ private final ByteOrder indexOrder = Base64Order.enhancedCoder;
private final indexRAMRI dhtCache;
private final indexCollectionRI collections; // new database structure to replace AssortmentCluster and FileCluster
private final serverLog log;
@@ -476,7 +476,7 @@ public final class plasmaWordIndex implements indexRI {
// next flush more entries if the size exceeds the maximum size of the cache
while (theCache.size() > 0 &&
((theCache.size() > theCache.getMaxWordCount()) ||
- (kelondroMemory.available() < collections.minMem()))) {
+ (MemoryControl.available() < collections.minMem()))) {
flushCacheOne(theCache);
}
if (cacheSize() != cs) serverProfiling.update("wordcache", Long.valueOf(cacheSize()));
@@ -606,8 +606,8 @@ public final class plasmaWordIndex implements indexRI {
// check doubles
final int beforeDouble = container.size();
- final ArrayList<kelondroRowCollection> d = container.removeDoubles();
- kelondroRowCollection set;
+ final ArrayList<RowCollection> d = container.removeDoubles();
+ RowCollection set;
for (int i = 0; i < d.size(); i++) {
// for each element in the double-set, take that one that is the most recent one
set = d.get(i);
@@ -903,7 +903,7 @@ public final class plasmaWordIndex implements indexRI {
public synchronized kelondroCloneableIterator<indexContainer> wordContainers(final String startHash, final boolean ram, final boolean rot) {
final kelondroCloneableIterator<indexContainer> i = wordContainers(startHash, ram);
if (rot) {
- return new kelondroRotateIterator<indexContainer>(i, new String(kelondroBase64Order.zero(startHash.length())), dhtCache.size() + ((ram) ? 0 : collections.size()));
+ return new kelondroRotateIterator<indexContainer>(i, new String(Base64Order.zero(startHash.length())), dhtCache.size() + ((ram) ? 0 : collections.size()));
}
return i;
}
diff --git a/source/de/anomic/server/serverAbstractBlockingThread.java b/source/de/anomic/server/serverAbstractBlockingThread.java
index f9e2cf8e9..3046ec59b 100644
--- a/source/de/anomic/server/serverAbstractBlockingThread.java
+++ b/source/de/anomic/server/serverAbstractBlockingThread.java
@@ -24,7 +24,7 @@
package de.anomic.server;
-import de.anomic.kelondro.kelondroMemory;
+import de.anomic.kelondro.tools.MemoryControl;
import de.anomic.server.logging.serverLog;
public abstract class serverAbstractBlockingThread<J extends serverProcessorJob> extends serverAbstractThread implements serverBlockingThread<J> {
@@ -52,7 +52,7 @@ public abstract class serverAbstractBlockingThread<J extends serverProcessorJob>
try {
// do job
timestamp = System.currentTimeMillis();
- memstamp0 = kelondroMemory.used();
+ memstamp0 = MemoryControl.used();
final J in = this.manager.take();
if ((in == null) || (in == serverProcessorJob.poisonPill) || (in.status == serverProcessorJob.STATUS_POISON)) {
// the poison pill: shutdown
@@ -65,7 +65,7 @@ public abstract class serverAbstractBlockingThread<J extends serverProcessorJob>
final J out = this.job(in);
if (out != null) this.manager.passOn(out);
// do memory and busy/idle-count/time monitoring
- memstamp1 = kelondroMemory.used();
+ memstamp1 = MemoryControl.used();
if (memstamp1 >= memstamp0) {
// no GC in between. this is not shure but most probable
memuse += memstamp1 - memstamp0;
diff --git a/source/de/anomic/server/serverAbstractBusyThread.java b/source/de/anomic/server/serverAbstractBusyThread.java
index 2ba116d57..e5cbfc2cf 100644
--- a/source/de/anomic/server/serverAbstractBusyThread.java
+++ b/source/de/anomic/server/serverAbstractBusyThread.java
@@ -26,7 +26,7 @@ package de.anomic.server;
import java.net.SocketException;
-import de.anomic.kelondro.kelondroMemory;
+import de.anomic.kelondro.tools.MemoryControl;
import de.anomic.server.logging.serverLog;
public abstract class serverAbstractBusyThread extends serverAbstractThread implements serverBusyThread {
@@ -136,14 +136,14 @@ public abstract class serverAbstractBusyThread extends serverAbstractThread impl
ratz(this.idlePause);
idletime += System.currentTimeMillis() - timestamp;
//} else if ((memnow = serverMemory.available()) > memprereq) try {
- } else if (kelondroMemory.request(memprereq, false)) try {
+ } else if (MemoryControl.request(memprereq, false)) try {
// do job
timestamp = System.currentTimeMillis();
- memstamp0 = kelondroMemory.used();
+ memstamp0 = MemoryControl.used();
isBusy = this.job();
// do memory and busy/idle-count/time monitoring
if (isBusy) {
- memstamp1 = kelondroMemory.used();
+ memstamp1 = MemoryControl.used();
if (memstamp1 >= memstamp0) {
// no GC in between. this is not shure but most probable
memuse += memstamp1 - memstamp0;
@@ -173,7 +173,7 @@ public abstract class serverAbstractBusyThread extends serverAbstractThread impl
busyCycles++;
} else {
log.logWarning("Thread '" + this.getName() + "' runs short memory cycle. Free mem: " +
- (kelondroMemory.available() / 1024) + " KB, needed: " + (memprereq / 1024) + " KB");
+ (MemoryControl.available() / 1024) + " KB, needed: " + (memprereq / 1024) + " KB");
// omit job, not enough memory
// process scheduled pause
timestamp = System.currentTimeMillis();
diff --git a/source/de/anomic/server/serverCore.java b/source/de/anomic/server/serverCore.java
index 2b8145df8..3342e753d 100644
--- a/source/de/anomic/server/serverCore.java
+++ b/source/de/anomic/server/serverCore.java
@@ -57,8 +57,8 @@ import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import de.anomic.icap.icapd;
-import de.anomic.kelondro.kelondroMemory;
-import de.anomic.kelondro.kelondroByteBuffer;
+import de.anomic.kelondro.tools.ByteBuffer;
+import de.anomic.kelondro.tools.MemoryControl;
import de.anomic.server.logging.serverLog;
import de.anomic.tools.PKCS12Tool;
import de.anomic.urlRedirector.urlRedirectord;
@@ -315,7 +315,7 @@ public final class serverCore extends serverAbstractBusyThread implements server
public void freemem() {
// FIXME: can we something here to flush memory? Idea: Reduce the size of some of our various caches.
- kelondroMemory.gc(2000, "serverCore.freemem()"); // thq
+ MemoryControl.gc(2000, "serverCore.freemem()"); // thq
}
// class body
@@ -855,7 +855,7 @@ public final class serverCore extends serverAbstractBusyThread implements server
public static byte[] receive(final PushbackInputStream pbis, final int maxSize, final boolean logerr) {
// reuse an existing linebuffer
- final kelondroByteBuffer readLineBuffer = new kelondroByteBuffer(80);
+ final ByteBuffer readLineBuffer = new ByteBuffer(80);
int bufferSize = 0, b = 0;
try {
diff --git a/source/de/anomic/server/serverFileUtils.java b/source/de/anomic/server/serverFileUtils.java
index 3960850ad..279f1e333 100644
--- a/source/de/anomic/server/serverFileUtils.java
+++ b/source/de/anomic/server/serverFileUtils.java
@@ -51,8 +51,8 @@ import java.util.zip.GZIPOutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
-import de.anomic.kelondro.kelondroRow;
-import de.anomic.kelondro.kelondroRowSet;
+import de.anomic.kelondro.index.Row;
+import de.anomic.kelondro.index.RowSet;
import de.anomic.server.logging.serverLog;
import de.anomic.tools.nxTools;
@@ -448,7 +448,7 @@ public final class serverFileUtils {
forceMove(tf, file);
}
- public static void saveSet(final File file, final String format, final kelondroRowSet set, final String sep) throws IOException {
+ public static void saveSet(final File file, final String format, final RowSet set, final String sep) throws IOException {
final File tf = new File(file.toString() + ".tmp" + (System.currentTimeMillis() % 1000));
OutputStream os = null;
if ((format == null) || (format.equals("plain"))) {
@@ -463,7 +463,7 @@ public final class serverFileUtils {
os = zos;
}
if(os != null) {
- final Iterator<kelondroRow.Entry> i = set.iterator();
+ final Iterator<Row.Entry> i = set.iterator();
String key;
if (i.hasNext()) {
key = new String(i.next().getColBytes(0));
diff --git a/source/de/anomic/server/serverObjects.java b/source/de/anomic/server/serverObjects.java
index 671ccc8d9..79bfc0119 100644
--- a/source/de/anomic/server/serverObjects.java
+++ b/source/de/anomic/server/serverObjects.java
@@ -53,7 +53,7 @@ import java.util.HashMap;
import java.util.Map;
import de.anomic.htmlFilter.htmlFilterCharacterCoding;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.DateFormatter;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.tools.yFormatter;
@@ -134,7 +134,7 @@ public class serverObjects extends HashMap<String, String> implements Cloneable
return this.put(key, value.toString());
}
- public String put(final String key, final kelondroDate value) {
+ public String put(final String key, final DateFormatter value) {
return this.put(key, value.toString());
}
diff --git a/source/de/anomic/server/serverProfiling.java b/source/de/anomic/server/serverProfiling.java
index 2fbc9df38..400d306d2 100644
--- a/source/de/anomic/server/serverProfiling.java
+++ b/source/de/anomic/server/serverProfiling.java
@@ -31,7 +31,7 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
-import de.anomic.kelondro.kelondroMemory;
+import de.anomic.kelondro.tools.MemoryControl;
public class serverProfiling extends Thread {
@@ -58,7 +58,7 @@ public class serverProfiling extends Thread {
public void run() {
while (running) {
- update("memory", Long.valueOf(kelondroMemory.used()));
+ update("memory", Long.valueOf(MemoryControl.used()));
try {
Thread.sleep(this.delaytime);
} catch (final InterruptedException e) {
diff --git a/source/de/anomic/tools/crypt.java b/source/de/anomic/tools/crypt.java
index 6a7346c99..74e2cb3f0 100644
--- a/source/de/anomic/tools/crypt.java
+++ b/source/de/anomic/tools/crypt.java
@@ -28,7 +28,7 @@ import java.text.SimpleDateFormat;
import java.util.Locale;
import java.util.Random;
-import de.anomic.kelondro.kelondroBase64Order;
+import de.anomic.kelondro.coding.Base64Order;
public class crypt {
@@ -45,7 +45,7 @@ public class crypt {
saltcounter++;
// we generate 48-bit salt values, that are represented as 8-character
// b64-encoded strings
- return kelondroBase64Order.standardCoder.encodeLong(salt & 0XffffffffffffL, 8);
+ return Base64Order.standardCoder.encodeLong(salt & 0XffffffffffffL, 8);
}
// --------------------------------------------------------
@@ -94,8 +94,8 @@ public class crypt {
public static String simpleEncode(final String content, String key, final char method) {
if (key == null) { key = "NULL"; }
switch (method) {
- case 'b' : return "b|" + kelondroBase64Order.enhancedCoder.encodeString(content);
- case 'z' : return "z|" + kelondroBase64Order.enhancedCoder.encode(gzip.gzipString(content));
+ case 'b' : return "b|" + Base64Order.enhancedCoder.encodeString(content);
+ case 'z' : return "z|" + Base64Order.enhancedCoder.encode(gzip.gzipString(content));
case 'p' : return "p|" + content;
default : return null;
}
@@ -110,11 +110,11 @@ public class crypt {
} // not encoded
switch (encoded.charAt(0)) {
case 'b': {
- return kelondroBase64Order.enhancedCoder.decodeString(encoded.substring(2), "de.anomic.tools.crypt.simpleDecode()");
+ return Base64Order.enhancedCoder.decodeString(encoded.substring(2), "de.anomic.tools.crypt.simpleDecode()");
}
case 'z':
try {
- return gzip.gunzipString(kelondroBase64Order.enhancedCoder.decode(encoded.substring(2), "de.anomic.tools.crypt.simpleDecode()"));
+ return gzip.gunzipString(Base64Order.enhancedCoder.decode(encoded.substring(2), "de.anomic.tools.crypt.simpleDecode()"));
} catch (final Exception e) {
e.printStackTrace();
return null;
diff --git a/source/de/anomic/tools/cryptbig.java b/source/de/anomic/tools/cryptbig.java
index 9b2b79da8..022402b5b 100644
--- a/source/de/anomic/tools/cryptbig.java
+++ b/source/de/anomic/tools/cryptbig.java
@@ -52,8 +52,8 @@ import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.PBEParameterSpec;
-import de.anomic.kelondro.kelondroBase64Order;
-import de.anomic.kelondro.kelondroDigest;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.Digest;
public class cryptbig {
@@ -70,7 +70,7 @@ public class cryptbig {
saltcounter++;
// we generate 48-bit salt values, that are represented as 8-character
// b64-encoded strings
- return kelondroBase64Order.standardCoder.encodeLong(salt & 0XffffffffffffL, 8);
+ return Base64Order.standardCoder.encodeLong(salt & 0XffffffffffffL, 8);
}
// --------------------------------------------------------
@@ -132,7 +132,7 @@ public class cryptbig {
final byte[] utf = str.getBytes("UTF8");
final byte[] enc = encryptArray(utf);
if (enc == null) return null;
- return kelondroBase64Order.standardCoder.encode(enc);
+ return Base64Order.standardCoder.encode(enc);
} catch (final UnsupportedEncodingException e) {
}
return null;
@@ -141,7 +141,7 @@ public class cryptbig {
// Decode a string into a new string using b64, crypt and utf-8
public String decryptString(final String str) {
try {
- final byte[] b64dec = kelondroBase64Order.standardCoder.decode(str, "de.anomic.tools.cryptbig.decryptString()");
+ final byte[] b64dec = Base64Order.standardCoder.decode(str, "de.anomic.tools.cryptbig.decryptString()");
if (b64dec == null) return null; // error in input string (inconsistency)
final byte[] dec = decryptArray(b64dec);
if (dec == null) return null;
@@ -232,7 +232,7 @@ public class cryptbig {
final File inFile = new File(inFileName);
final String inFileDate = dateFormatter.format(new Date(inFile.lastModified())); // 17 byte
final String encryptionDate = dateFormatter.format(new Date()); // 17 byte
- final String inFileSize = kelondroBase64Order.standardCoder.encodeLong(inFile.length(), 11); // 64 / 6 = 11; 11 byte
+ final String inFileSize = Base64Order.standardCoder.encodeLong(inFile.length(), 11); // 64 / 6 = 11; 11 byte
final String flag = "1"; // 1 byte
//int inFileNameLength = inFileName.length(); // 256
final String X = inFileDate + encryptionDate + inFileSize + flag + inFileName;
@@ -257,8 +257,8 @@ public class cryptbig {
// - after the magic String we write C, B and A
try {
final String A = new String(ecipher.doFinal(X.getBytes("UTF8")));
- final String B = new String(ecipher.doFinal(kelondroBase64Order.standardCoder.encodeLong(A.length(), 2).getBytes("UTF8"))); // most probable not longer than 4
- final String C = kelondroBase64Order.standardCoder.encodeLong(B.length(), 1); // fixed length 1 (6 bits, that should be enough)
+ final String B = new String(ecipher.doFinal(Base64Order.standardCoder.encodeLong(A.length(), 2).getBytes("UTF8"))); // most probable not longer than 4
+ final String C = Base64Order.standardCoder.encodeLong(B.length(), 1); // fixed length 1 (6 bits, that should be enough)
fout.write(magicString.getBytes()); // the magic string, used to identify a 'crypt'-file
fout.write(C.getBytes());
fout.write(B.getBytes());
@@ -297,9 +297,9 @@ public class cryptbig {
}
final byte[] C = new byte[1];
fin.read(C); // the length of the following String, encoded as b64
- final byte[] B = new byte[(int) kelondroBase64Order.standardCoder.decodeLong(new String(C))];
+ final byte[] B = new byte[(int) Base64Order.standardCoder.decodeLong(new String(C))];
fin.read(B); // this is again the length of the following string, as encrypted b64-ed integer
- final byte[] A = new byte[(int) kelondroBase64Order.standardCoder.decodeLong(new String(dcipher.doFinal(B), "UTF8"))];
+ final byte[] A = new byte[(int) Base64Order.standardCoder.decodeLong(new String(dcipher.doFinal(B), "UTF8"))];
fin.read(A);
final String X = new String(dcipher.doFinal(A), "UTF8");
@@ -308,7 +308,7 @@ public class cryptbig {
// reconstruct the properties
final Date inFileDate = dateFormatter.parse(X.substring(0, 17), new ParsePosition(0));
final Date encryptionDate = dateFormatter.parse(X.substring(17, 34), new ParsePosition(0));
- final long inFileSize = kelondroBase64Order.standardCoder.decodeLong(X.substring(34, 45));
+ final long inFileSize = Base64Order.standardCoder.decodeLong(X.substring(34, 45));
final String flag = X.substring(45, 46);
final String origFileName = X.substring(46);
@@ -382,7 +382,7 @@ public class cryptbig {
if (gz == null) return null;
final byte[] enc = c.encryptArray(gz);
if (enc == null) return null;
- return salt + ((gzFlag) ? "1" : "0") + kelondroBase64Order.enhancedCoder.encode(enc);
+ return salt + ((gzFlag) ? "1" : "0") + Base64Order.enhancedCoder.encode(enc);
}
public static String descrambleString(final String key, String s) throws IOException {
@@ -390,7 +390,7 @@ public class cryptbig {
final boolean gzFlag = (s.charAt(8) == '1');
s = s.substring(9);
final cryptbig c = new cryptbig(key, salt);
- final byte[] b64dec = kelondroBase64Order.enhancedCoder.decode(s, "de.anomic.tools.cryptbig.descrambleString()");
+ final byte[] b64dec = Base64Order.enhancedCoder.decode(s, "de.anomic.tools.cryptbig.descrambleString()");
if (b64dec == null) return null; // error in input string (inconsistency)
final byte[] dec = c.decryptArray(b64dec);
if (dec == null) return null;
@@ -420,8 +420,8 @@ public class cryptbig {
public static String simpleEncode(final String content, String key, final char method) {
if (key == null) key = "NULL";
if (method == 'p') return "p|" + content;
- if (method == 'b') return "b|" + kelondroBase64Order.enhancedCoder.encodeString(content);
- if (method == 'z') return "z|" + kelondroBase64Order.enhancedCoder.encode(gzip.gzipString(content));
+ if (method == 'b') return "b|" + Base64Order.enhancedCoder.encodeString(content);
+ if (method == 'z') return "z|" + Base64Order.enhancedCoder.encode(gzip.gzipString(content));
if (method == 'c') return "c|" + scrambleString(key, content);
return null;
}
@@ -432,8 +432,8 @@ public class cryptbig {
final char method = encoded.charAt(0);
encoded = encoded.substring(2);
if (method == 'p') return encoded;
- if (method == 'b') return kelondroBase64Order.enhancedCoder.decodeString(encoded, "de.anomic.tools.cryptbig.simpleDecode()");
- if (method == 'z') return gzip.gunzipString(kelondroBase64Order.enhancedCoder.decode(encoded, "de.anomic.tools.cryptbig.simpleDecode()"));
+ if (method == 'b') return Base64Order.enhancedCoder.decodeString(encoded, "de.anomic.tools.cryptbig.simpleDecode()");
+ if (method == 'z') return gzip.gunzipString(Base64Order.enhancedCoder.decode(encoded, "de.anomic.tools.cryptbig.simpleDecode()"));
if (method == 'c') return descrambleString(key, encoded);
return null;
}
@@ -579,25 +579,25 @@ public class cryptbig {
if (s[0].equals("-ec64")) {
// generate a b64 encoding from a given cardinal
if (s.length != 2) {help(); System.exit(-1);}
- System.out.println(kelondroBase64Order.standardCoder.encodeLong(Long.parseLong(s[1]), 0));
+ System.out.println(Base64Order.standardCoder.encodeLong(Long.parseLong(s[1]), 0));
System.exit(0);
}
if (s[0].equals("-dc64")) {
// generate a b64 decoding from a given cardinal
if (s.length != 2) {help(); System.exit(-1);}
- System.out.println(kelondroBase64Order.standardCoder.decodeLong(s[1]));
+ System.out.println(Base64Order.standardCoder.decodeLong(s[1]));
System.exit(0);
}
if (s[0].equals("-es64")) {
// generate a b64 encoding from a given string
if (s.length != 2) {help(); System.exit(-1);}
- System.out.println(kelondroBase64Order.standardCoder.encodeString(s[1]));
+ System.out.println(Base64Order.standardCoder.encodeString(s[1]));
System.exit(0);
}
if (s[0].equals("-ds64")) {
// generate a b64 decoding from a given string
if (s.length != 2) {help(); System.exit(-1);}
- System.out.println(kelondroBase64Order.standardCoder.decodeString(s[1], ""));
+ System.out.println(Base64Order.standardCoder.decodeString(s[1], ""));
System.exit(0);
}
if (s[0].equals("-ess")) {
@@ -634,7 +634,7 @@ public class cryptbig {
if (s[0].equals("-md5")) {
// generate a public key from a password that can be used for encryption
if (s.length != 2) {help(); System.exit(-1);}
- final String md5s = kelondroDigest.encodeMD5Hex(new File(s[1]));
+ final String md5s = Digest.encodeMD5Hex(new File(s[1]));
System.out.println(md5s);
System.exit(0);
}
diff --git a/source/de/anomic/tools/mediawikiIndex.java b/source/de/anomic/tools/mediawikiIndex.java
index bf3187e5d..f6aba6b4f 100644
--- a/source/de/anomic/tools/mediawikiIndex.java
+++ b/source/de/anomic/tools/mediawikiIndex.java
@@ -47,7 +47,7 @@ import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import de.anomic.kelondro.kelondroByteBuffer;
+import de.anomic.kelondro.tools.ByteBuffer;
/*
* this class provides data structures to read a mediawiki dump file in xml format
@@ -267,16 +267,16 @@ public class mediawikiIndex {
private InputStream is;
private long seekpos;
- private kelondroByteBuffer bb;
+ private ByteBuffer bb;
public PositionAwareReader(File dumpFile) throws FileNotFoundException {
this.is = new BufferedInputStream(new FileInputStream(dumpFile), 64 *1024);
this.seekpos = 0;
- this.bb = new kelondroByteBuffer();
+ this.bb = new ByteBuffer();
}
public void resetBuffer() {
- if (bb.length() > 10 * 1024) bb = new kelondroByteBuffer(); else bb.clear();
+ if (bb.length() > 10 * 1024) bb = new ByteBuffer(); else bb.clear();
}
public boolean seek(byte[] pattern) throws IOException {
diff --git a/source/de/anomic/xml/RSSReader.java b/source/de/anomic/xml/RSSReader.java
index 4526e109a..59e8178e4 100644
--- a/source/de/anomic/xml/RSSReader.java
+++ b/source/de/anomic/xml/RSSReader.java
@@ -38,7 +38,7 @@ import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
-import de.anomic.kelondro.kelondroByteBuffer;
+import de.anomic.kelondro.tools.ByteBuffer;
import de.anomic.server.logging.serverLog;
public class RSSReader extends DefaultHandler {
@@ -95,7 +95,7 @@ public class RSSReader extends DefaultHandler {
serverLog.logWarning("rssReader", "response=" + new String(a));
return null;
}
- if (!kelondroByteBuffer.equals(a, "<?xml".getBytes())) {
+ if (!ByteBuffer.equals(a, "<?xml".getBytes())) {
serverLog.logWarning("rssReader", "response does not contain valid xml");
return null;
}
diff --git a/source/de/anomic/xml/opensearchdescriptionReader.java b/source/de/anomic/xml/opensearchdescriptionReader.java
index 8a2b03895..2518e98a0 100644
--- a/source/de/anomic/xml/opensearchdescriptionReader.java
+++ b/source/de/anomic/xml/opensearchdescriptionReader.java
@@ -40,7 +40,7 @@ import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
-import de.anomic.kelondro.kelondroByteBuffer;
+import de.anomic.kelondro.tools.ByteBuffer;
import de.anomic.server.logging.serverLog;
public class opensearchdescriptionReader extends DefaultHandler {
@@ -143,7 +143,7 @@ public class opensearchdescriptionReader extends DefaultHandler {
serverLog.logWarning("opensearchdescriptionReader", "response=" + new String(a));
return null;
}
- if (!kelondroByteBuffer.equals(a, "<?xml".getBytes())) {
+ if (!ByteBuffer.equals(a, "<?xml".getBytes())) {
serverLog.logWarning("opensearchdescriptionReader", "response does not contain valid xml");
return null;
}
diff --git a/source/de/anomic/yacy/yacyClient.java b/source/de/anomic/yacy/yacyClient.java
index dd895150c..8bbd91ba4 100644
--- a/source/de/anomic/yacy/yacyClient.java
+++ b/source/de/anomic/yacy/yacyClient.java
@@ -73,10 +73,10 @@ import de.anomic.index.indexRWIRowEntry;
import de.anomic.index.indexReferenceBlacklist;
import de.anomic.index.indexURLReference;
import de.anomic.index.indexWord;
-import de.anomic.kelondro.kelondroBase64Order;
-import de.anomic.kelondro.kelondroBitfield;
-import de.anomic.kelondro.kelondroDigest;
-import de.anomic.kelondro.kelondroByteBuffer;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.Bitfield;
+import de.anomic.kelondro.coding.Digest;
+import de.anomic.kelondro.tools.ByteBuffer;
import de.anomic.plasma.plasmaSearchRankingProcess;
import de.anomic.plasma.plasmaSearchRankingProfile;
import de.anomic.plasma.plasmaSnippetCache;
@@ -436,7 +436,7 @@ public final class yacyClient {
final Map<String, TreeMap<String, String>> abstractCache,
final indexReferenceBlacklist blacklist,
final plasmaSearchRankingProfile rankingProfile,
- final kelondroBitfield constraint
+ final Bitfield constraint
) {
// send a search request to peer with remote Hash
// this mainly converts the words into word hashes
@@ -615,7 +615,7 @@ public final class yacyClient {
Map.Entry<String, String> entry;
TreeMap<String, String> singleAbstract;
String wordhash;
- kelondroByteBuffer ci;
+ ByteBuffer ci;
while (i.hasNext()) {
entry = i.next();
if (entry.getKey().startsWith("indexabstract.")) {
@@ -624,7 +624,7 @@ public final class yacyClient {
singleAbstract = abstractCache.get(wordhash); // a mapping from url-hashes to a string of peer-hashes
if (singleAbstract == null) singleAbstract = new TreeMap<String, String>();
try {
- ci = new kelondroByteBuffer(entry.getValue().getBytes("UTF-8"));
+ ci = new ByteBuffer(entry.getValue().getBytes("UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return null;
@@ -757,7 +757,7 @@ public final class yacyClient {
post.add(new DefaultCharsetStringPart("process", "store"));
post.add(new DefaultCharsetStringPart("purpose", "crcon"));
post.add(new DefaultCharsetStringPart("filesize", Long.toString(file.length)));
- post.add(new DefaultCharsetStringPart("md5", kelondroDigest.encodeMD5Hex(file)));
+ post.add(new DefaultCharsetStringPart("md5", Digest.encodeMD5Hex(file)));
post.add(new DefaultCharsetStringPart("access", access));
post.add(new DefaultCharsetFilePart("filename", new ByteArrayPartSource(filename, file)));
@@ -783,7 +783,7 @@ public final class yacyClient {
String response = phase1.get("response");
if ((response == null) || (protocol == null) || (access == null)) return "wrong return values from other peer; phase 1";
if (!(response.equals("ok"))) return "remote peer rejected transfer: " + response;
- final String accesscode = kelondroDigest.encodeMD5Hex(kelondroBase64Order.standardCoder.encodeString(access));
+ final String accesscode = Digest.encodeMD5Hex(Base64Order.standardCoder.encodeString(access));
if (protocol.equals("http")) {
final HashMap<String, String> phase2 = transferStore(nextaddress, accesscode, filename, file);
if (phase2 == null) return "no connection to remote address " + targetAddress + "; phase 2";
diff --git a/source/de/anomic/yacy/yacyCore.java b/source/de/anomic/yacy/yacyCore.java
index adcc76913..230b57282 100644
--- a/source/de/anomic/yacy/yacyCore.java
+++ b/source/de/anomic/yacy/yacyCore.java
@@ -51,7 +51,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.DateFormatter;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverCore;
import de.anomic.server.serverSemaphore;
@@ -253,14 +253,14 @@ public class yacyCore {
if (newSeed.getLastSeenUTC() >= this.seed.getLastSeenUTC()) {
if (log.isFine()) log.logFine("publish: recently handshaked " + this.seed.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_SENIOR) +
" peer '" + this.seed.getName() + "' at " + this.seed.getPublicAddress() + " with old LastSeen: '" +
- kelondroDate.formatShortSecond(new Date(newSeed.getLastSeenUTC())) + "'");
+ DateFormatter.formatShortSecond(new Date(newSeed.getLastSeenUTC())) + "'");
newSeed.setLastSeenUTC();
sb.webIndex.peerActions.peerArrival(newSeed, true);
} else {
if (log.isFine()) log.logFine("publish: recently handshaked " + this.seed.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_SENIOR) +
" peer '" + this.seed.getName() + "' at " + this.seed.getPublicAddress() + " with old LastSeen: '" +
- kelondroDate.formatShortSecond(new Date(newSeed.getLastSeenUTC())) + "', this is more recent: '" +
- kelondroDate.formatShortSecond(new Date(this.seed.getLastSeenUTC())) + "'");
+ DateFormatter.formatShortSecond(new Date(newSeed.getLastSeenUTC())) + "', this is more recent: '" +
+ DateFormatter.formatShortSecond(new Date(this.seed.getLastSeenUTC())) + "'");
this.seed.setLastSeenUTC();
sb.webIndex.peerActions.peerArrival(this.seed, true);
}
diff --git a/source/de/anomic/yacy/yacyNetwork.java b/source/de/anomic/yacy/yacyNetwork.java
index 840fd92b8..9c255fde2 100644
--- a/source/de/anomic/yacy/yacyNetwork.java
+++ b/source/de/anomic/yacy/yacyNetwork.java
@@ -34,8 +34,8 @@ import java.util.List;
import org.apache.commons.httpclient.methods.multipart.Part;
import de.anomic.http.DefaultCharsetStringPart;
-import de.anomic.kelondro.kelondroDigest;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.DateFormatter;
+import de.anomic.kelondro.coding.Digest;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaSwitchboardConstants;
import de.anomic.server.serverObjects;
@@ -64,7 +64,7 @@ public class yacyNetwork {
final String salt = post.get("key", "");
final String iam = post.get("iam", "");
final String magic = env.getConfig("network.unit.protocol.request.authentification.essentials", "");
- final String md5 = kelondroDigest.encodeMD5Hex(salt + iam + magic);
+ final String md5 = Digest.encodeMD5Hex(salt + iam + magic);
return post.get("magicmd5", "").equals(md5);
}
@@ -83,7 +83,7 @@ public class yacyNetwork {
if (targetHash != null) post.add(new DefaultCharsetStringPart("youare", targetHash));
// time information for synchronization
- post.add(new DefaultCharsetStringPart("mytime", kelondroDate.formatShortSecond(new Date())));
+ post.add(new DefaultCharsetStringPart("mytime", DateFormatter.formatShortSecond(new Date())));
post.add(new DefaultCharsetStringPart("myUTC", Long.toString(System.currentTimeMillis())));
// network identification
@@ -96,7 +96,7 @@ public class yacyNetwork {
if (authentificationMethod.equals("salted-magic-sim")) {
// generate an authentification essential using the salt, the iam-hash and the network magic
final String magic = sb.getConfig("network.unit.protocol.request.authentification.essentials", "");
- final String md5 = kelondroDigest.encodeMD5Hex(salt + sb.webIndex.seedDB.mySeed().hash + magic);
+ final String md5 = Digest.encodeMD5Hex(salt + sb.webIndex.seedDB.mySeed().hash + magic);
post.add(new DefaultCharsetStringPart("magicmd5", md5));
}
}
diff --git a/source/de/anomic/yacy/yacyNewsDB.java b/source/de/anomic/yacy/yacyNewsDB.java
index 89a03f0d1..ba7df96bd 100644
--- a/source/de/anomic/yacy/yacyNewsDB.java
+++ b/source/de/anomic/yacy/yacyNewsDB.java
@@ -49,18 +49,18 @@ import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Iterator;
-import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroEcoTable;
import de.anomic.kelondro.kelondroException;
-import de.anomic.kelondro.kelondroIndex;
-import de.anomic.kelondro.kelondroRow;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.DateFormatter;
+import de.anomic.kelondro.index.Row;
+import de.anomic.kelondro.index.ObjectIndex;
import de.anomic.server.serverCodings;
public class yacyNewsDB {
private final File path;
- protected kelondroIndex news;
+ protected ObjectIndex news;
public yacyNewsDB(final File path) {
this.path = path;
@@ -107,7 +107,7 @@ public class yacyNewsDB {
public class recordIterator implements Iterator<yacyNewsRecord> {
- Iterator<kelondroRow.Entry> rowIterator;
+ Iterator<Row.Entry> rowIterator;
public recordIterator() throws IOException {
rowIterator = news.rows(true, null);
@@ -135,27 +135,27 @@ public class yacyNewsDB {
}
}
- protected final static yacyNewsRecord b2r(final kelondroRow.Entry b) {
+ protected final static yacyNewsRecord b2r(final Row.Entry b) {
if (b == null) return null;
return yacyNewsRecord.newRecord(
b.getColString(0, null),
b.getColString(1, "UTF-8"),
- (b.empty(2)) ? null : kelondroDate.parseShortSecond(b.getColString(2, null), kelondroDate.UTCDiffString()),
+ (b.empty(2)) ? null : DateFormatter.parseShortSecond(b.getColString(2, null), DateFormatter.UTCDiffString()),
(int) b.getColLong(3),
serverCodings.string2map(b.getColString(4, "UTF-8"), ",")
);
}
- protected final kelondroRow.Entry r2b(final yacyNewsRecord r) {
+ protected final Row.Entry r2b(final yacyNewsRecord r) {
if (r == null) return null;
try {
final String attributes = r.attributes().toString();
if (attributes.length() > yacyNewsRecord.attributesMaxLength) throw new IllegalArgumentException("attribute length=" + attributes.length() + " exceeds maximum size=" + yacyNewsRecord.attributesMaxLength);
- final kelondroRow.Entry entry = this.news.row().newEntry();
+ final Row.Entry entry = this.news.row().newEntry();
entry.setCol(0, r.id().getBytes());
entry.setCol(1, r.category().getBytes("UTF-8"));
- entry.setCol(2, (r.received() == null) ? null : kelondroDate.formatShortSecond(r.received()).getBytes());
- entry.setCol(3, kelondroBase64Order.enhancedCoder.encodeLong(r.distributed(), 2).getBytes());
+ entry.setCol(2, (r.received() == null) ? null : DateFormatter.formatShortSecond(r.received()).getBytes());
+ entry.setCol(3, Base64Order.enhancedCoder.encodeLong(r.distributed(), 2).getBytes());
entry.setCol(4, attributes.getBytes("UTF-8"));
return entry;
} catch(final UnsupportedEncodingException e) {
diff --git a/source/de/anomic/yacy/yacyNewsQueue.java b/source/de/anomic/yacy/yacyNewsQueue.java
index 9d0f08bb8..5c846f678 100644
--- a/source/de/anomic/yacy/yacyNewsQueue.java
+++ b/source/de/anomic/yacy/yacyNewsQueue.java
@@ -50,11 +50,11 @@ import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
-import de.anomic.kelondro.kelondroColumn;
-import de.anomic.kelondro.kelondroNaturalOrder;
-import de.anomic.kelondro.kelondroRow;
import de.anomic.kelondro.kelondroStack;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.DateFormatter;
+import de.anomic.kelondro.coding.NaturalOrder;
+import de.anomic.kelondro.index.Column;
+import de.anomic.kelondro.index.Row;
public class yacyNewsQueue {
@@ -62,11 +62,11 @@ public class yacyNewsQueue {
kelondroStack queueStack;
private final yacyNewsDB newsDB;
- public static final kelondroRow rowdef = new kelondroRow(new kelondroColumn[]{
- new kelondroColumn("newsid", kelondroColumn.celltype_string, kelondroColumn.encoder_bytes, yacyNewsRecord.idLength, "id = created + originator"),
- new kelondroColumn("last touched", kelondroColumn.celltype_string, kelondroColumn.encoder_bytes, kelondroDate.PATTERN_SHORT_SECOND.length(), "")
+ public static final Row rowdef = new Row(new Column[]{
+ new Column("newsid", Column.celltype_string, Column.encoder_bytes, yacyNewsRecord.idLength, "id = created + originator"),
+ new Column("last touched", Column.celltype_string, Column.encoder_bytes, DateFormatter.PATTERN_SHORT_SECOND.length(), "")
},
- kelondroNaturalOrder.naturalOrder, 0
+ NaturalOrder.naturalOrder, 0
);
public yacyNewsQueue(final File path, final yacyNewsDB newsDB) {
@@ -145,14 +145,14 @@ public class yacyNewsQueue {
return null;
}
- yacyNewsRecord b2r(final kelondroRow.Entry b) throws IOException {
+ yacyNewsRecord b2r(final Row.Entry b) throws IOException {
if (b == null) return null;
final String id = b.getColString(0, null);
//Date touched = yacyCore.parseUniversalDate(new String(b[1]));
return newsDB.get(id);
}
- private kelondroRow.Entry r2b(final yacyNewsRecord r, final boolean updateDB) throws IOException {
+ private Row.Entry r2b(final yacyNewsRecord r, final boolean updateDB) throws IOException {
if (r == null) return null;
if (updateDB) {
newsDB.put(r);
@@ -160,9 +160,9 @@ public class yacyNewsQueue {
final yacyNewsRecord r1 = newsDB.get(r.id());
if (r1 == null) newsDB.put(r);
}
- final kelondroRow.Entry b = queueStack.row().newEntry(new byte[][]{
+ final Row.Entry b = queueStack.row().newEntry(new byte[][]{
r.id().getBytes(),
- kelondroDate.formatShortSecond(new Date()).getBytes()});
+ DateFormatter.formatShortSecond(new Date()).getBytes()});
return b;
}
@@ -175,7 +175,7 @@ public class yacyNewsQueue {
public class newsIterator implements Iterator<yacyNewsRecord> {
// iterates yacyNewsRecord-type objects
- Iterator<kelondroRow.Entry> stackNodeIterator;
+ Iterator<Row.Entry> stackNodeIterator;
public newsIterator(final boolean up) {
stackNodeIterator = queueStack.stackIterator(up);
@@ -186,7 +186,7 @@ public class yacyNewsQueue {
}
public yacyNewsRecord next() {
- final kelondroRow.Entry row = stackNodeIterator.next();
+ final Row.Entry row = stackNodeIterator.next();
try {
return b2r(row);
} catch (final IOException e) {
diff --git a/source/de/anomic/yacy/yacyNewsRecord.java b/source/de/anomic/yacy/yacyNewsRecord.java
index 4ccff25eb..69624bc58 100644
--- a/source/de/anomic/yacy/yacyNewsRecord.java
+++ b/source/de/anomic/yacy/yacyNewsRecord.java
@@ -51,16 +51,16 @@ import java.util.Map;
import java.util.Properties;
import java.util.Map.Entry;
-import de.anomic.kelondro.kelondroNaturalOrder;
-import de.anomic.kelondro.kelondroRow;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.DateFormatter;
+import de.anomic.kelondro.coding.NaturalOrder;
+import de.anomic.kelondro.index.Row;
import de.anomic.server.serverCodings;
public class yacyNewsRecord {
public static final int maxNewsRecordLength = 512;
public static final int categoryStringLength = 8;
- public static final int idLength = kelondroDate.PATTERN_SHORT_SECOND.length() + yacySeedDB.commonHashLength;
+ public static final int idLength = DateFormatter.PATTERN_SHORT_SECOND.length() + yacySeedDB.commonHashLength;
private final String originator; // hash of originating peer
private final Date created; // Date when news was created by originator
@@ -72,16 +72,16 @@ public class yacyNewsRecord {
public static final int attributesMaxLength = maxNewsRecordLength
- idLength
- categoryStringLength
- - kelondroDate.PATTERN_SHORT_SECOND.length()
+ - DateFormatter.PATTERN_SHORT_SECOND.length()
- 2;
- public static final kelondroRow rowdef = new kelondroRow(
+ public static final Row rowdef = new Row(
"String idx-" + idLength + " \"id = created + originator\"," +
"String cat-" + categoryStringLength + "," +
- "String rec-" + kelondroDate.PATTERN_SHORT_SECOND.length() + "," +
+ "String rec-" + DateFormatter.PATTERN_SHORT_SECOND.length() + "," +
"short dis-2 {b64e}," +
"String att-" + attributesMaxLength,
- kelondroNaturalOrder.naturalOrder, 0
+ NaturalOrder.naturalOrder, 0
);
public static yacyNewsRecord newRecord(final String newsString) {
@@ -132,8 +132,8 @@ public class yacyNewsRecord {
if (attributes.toString().length() > attributesMaxLength) throw new IllegalArgumentException("attributes length (" + attributes.toString().length() + ") exceeds maximum (" + attributesMaxLength + ")");
this.category = (attributes.containsKey("cat")) ? (String) attributes.get("cat") : "";
if (category.length() > categoryStringLength) throw new IllegalArgumentException("category length (" + category.length() + ") exceeds maximum (" + categoryStringLength + ")");
- this.received = (attributes.containsKey("rec")) ? kelondroDate.parseShortSecond(attributes.get("rec"), kelondroDate.UTCDiffString()) : new Date();
- this.created = (attributes.containsKey("cre")) ? kelondroDate.parseShortSecond(attributes.get("cre"), kelondroDate.UTCDiffString()) : new Date();
+ this.received = (attributes.containsKey("rec")) ? DateFormatter.parseShortSecond(attributes.get("rec"), DateFormatter.UTCDiffString()) : new Date();
+ this.created = (attributes.containsKey("cre")) ? DateFormatter.parseShortSecond(attributes.get("cre"), DateFormatter.UTCDiffString()) : new Date();
this.distributed = (attributes.containsKey("dis")) ? Integer.parseInt(attributes.get("dis")) : 0;
this.originator = (attributes.containsKey("ori")) ? (String) attributes.get("ori") : "";
removeStandards();
@@ -156,10 +156,10 @@ public class yacyNewsRecord {
if (attributes.toString().length() > attributesMaxLength) throw new IllegalArgumentException("attributes length (" + attributes.toString().length() + ") exceeds maximum (" + attributesMaxLength + ")");
this.attributes = attributes;
this.received = received;
- this.created = kelondroDate.parseShortSecond(id.substring(0, kelondroDate.PATTERN_SHORT_SECOND.length()), kelondroDate.UTCDiffString());
+ this.created = DateFormatter.parseShortSecond(id.substring(0, DateFormatter.PATTERN_SHORT_SECOND.length()), DateFormatter.UTCDiffString());
this.category = category;
this.distributed = distributed;
- this.originator = id.substring(kelondroDate.PATTERN_SHORT_SECOND.length());
+ this.originator = id.substring(DateFormatter.PATTERN_SHORT_SECOND.length());
removeStandards();
}
@@ -176,8 +176,8 @@ public class yacyNewsRecord {
// attention: this has no additional encoding
if (this.originator != null) attributes.put("ori", this.originator);
if (this.category != null) attributes.put("cat", this.category);
- if (this.created != null) attributes.put("cre", kelondroDate.formatShortSecond(this.created));
- if (this.received != null) attributes.put("rec", kelondroDate.formatShortSecond(this.received));
+ if (this.created != null) attributes.put("cre", DateFormatter.formatShortSecond(this.created));
+ if (this.received != null) attributes.put("rec", DateFormatter.formatShortSecond(this.received));
attributes.put("dis", Integer.toString(this.distributed));
final String theString = attributes.toString();
removeStandards();
@@ -185,7 +185,7 @@ public class yacyNewsRecord {
}
public String id() {
- return kelondroDate.formatShortSecond(created) + originator;
+ return DateFormatter.formatShortSecond(created) + originator;
}
public String originator() {
diff --git a/source/de/anomic/yacy/yacyPeerActions.java b/source/de/anomic/yacy/yacyPeerActions.java
index c4fa59687..555d01490 100644
--- a/source/de/anomic/yacy/yacyPeerActions.java
+++ b/source/de/anomic/yacy/yacyPeerActions.java
@@ -27,7 +27,7 @@ package de.anomic.yacy;
import java.io.IOException;
import java.util.HashMap;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.DateFormatter;
import de.anomic.server.serverCodings;
import de.anomic.server.logging.serverLog;
import de.anomic.xml.RSSFeed;
@@ -107,7 +107,7 @@ public class yacyPeerActions {
}
if (Math.abs(nowUTC0Time - ctimeUTC0) > 60 * 60 * 24 * 1000) {
// the new connection is out-of-age, we reject the connection
- if (yacyCore.log.isFine()) yacyCore.log.logFine("connect: rejecting out-dated peer '" + seed.getName() + "' from " + seed.getPublicAddress() + "; nowUTC0=" + nowUTC0Time + ", seedUTC0=" + ctimeUTC0 + ", TimeDiff=" + kelondroDate.formatInterval(Math.abs(nowUTC0Time - ctimeUTC0)));
+ if (yacyCore.log.isFine()) yacyCore.log.logFine("connect: rejecting out-dated peer '" + seed.getName() + "' from " + seed.getPublicAddress() + "; nowUTC0=" + nowUTC0Time + ", seedUTC0=" + ctimeUTC0 + ", TimeDiff=" + DateFormatter.formatInterval(Math.abs(nowUTC0Time - ctimeUTC0)));
return false;
}
diff --git a/source/de/anomic/yacy/yacyPeerSelection.java b/source/de/anomic/yacy/yacyPeerSelection.java
index 31d2c7eaf..85a75afae 100644
--- a/source/de/anomic/yacy/yacyPeerSelection.java
+++ b/source/de/anomic/yacy/yacyPeerSelection.java
@@ -28,10 +28,10 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
-import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroException;
-import de.anomic.kelondro.kelondroMScoreCluster;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.DateFormatter;
+import de.anomic.kelondro.tools.ScoreCluster;
import de.anomic.server.logging.serverLog;
@@ -42,7 +42,7 @@ import de.anomic.server.logging.serverLog;
public class yacyPeerSelection {
- public static void selectDHTPositions(final yacySeedDB seedDB, String wordhash, int redundancy, int partitionExponent, HashMap<String, yacySeed> regularSeeds, kelondroMScoreCluster<String> ranking) {
+ public static void selectDHTPositions(final yacySeedDB seedDB, String wordhash, int redundancy, int partitionExponent, HashMap<String, yacySeed> regularSeeds, ScoreCluster<String> ranking) {
// this method is called from the search target computation
long[] dhtVerticalTargets = yacySeed.dhtPositions(wordhash, partitionExponent);
yacySeed seed;
@@ -100,7 +100,7 @@ public class yacyPeerSelection {
this.remaining = max;
this.doublecheck = new HashSet<String>();
this.nextSeed = nextInternal();
- this.alsoMyOwn = alsoMyOwn && nextSeed != null && (kelondroBase64Order.enhancedCoder.compare(seedDB.mySeed().hash.getBytes(), nextSeed.hash.getBytes()) > 0);
+ this.alsoMyOwn = alsoMyOwn && nextSeed != null && (Base64Order.enhancedCoder.compare(seedDB.mySeed().hash.getBytes(), nextSeed.hash.getBytes()) > 0);
}
public boolean hasNext() {
@@ -131,7 +131,7 @@ public class yacyPeerSelection {
}
public yacySeed next() {
- if (alsoMyOwn && kelondroBase64Order.enhancedCoder.compare(seedDB.mySeed().hash.getBytes(), nextSeed.hash.getBytes()) < 0) {
+ if (alsoMyOwn && Base64Order.enhancedCoder.compare(seedDB.mySeed().hash.getBytes(), nextSeed.hash.getBytes()) < 0) {
// take my own seed hash instead the enumeration result
alsoMyOwn = false;
return seedDB.mySeed();
@@ -253,7 +253,7 @@ public class yacyPeerSelection {
if (count > seedDB.sizeConnected()) count = seedDB.sizeConnected();
// fill a score object
- final kelondroMScoreCluster<String> seedScore = new kelondroMScoreCluster<String>();
+ final ScoreCluster<String> seedScore = new ScoreCluster<String>();
yacySeed ys;
long absage;
final Iterator<yacySeed> s = seedDB.seedsConnected(true, false, null, (float) 0.0);
@@ -263,7 +263,7 @@ public class yacyPeerSelection {
while ((s.hasNext()) && (searchcount-- > 0)) {
ys = s.next();
if ((ys != null) && (ys.get(yacySeed.LASTSEEN, "").length() > 10)) try {
- absage = Math.abs(System.currentTimeMillis() + kelondroDate.dayMillis - ys.getLastSeenUTC());
+ absage = Math.abs(System.currentTimeMillis() + DateFormatter.dayMillis - ys.getLastSeenUTC());
seedScore.addScore(ys.hash, (int) absage); // the higher absage, the older is the peer
} catch (final Exception e) {}
}
diff --git a/source/de/anomic/yacy/yacySearch.java b/source/de/anomic/yacy/yacySearch.java
index 7aa06f48a..973bc1076 100644
--- a/source/de/anomic/yacy/yacySearch.java
+++ b/source/de/anomic/yacy/yacySearch.java
@@ -52,8 +52,8 @@ import java.util.TreeMap;
import de.anomic.crawler.ResultURLs;
import de.anomic.index.indexReferenceBlacklist;
-import de.anomic.kelondro.kelondroBitfield;
-import de.anomic.kelondro.kelondroMScoreCluster;
+import de.anomic.kelondro.coding.Bitfield;
+import de.anomic.kelondro.tools.ScoreCluster;
import de.anomic.plasma.plasmaSearchQuery;
import de.anomic.plasma.plasmaSearchRankingProcess;
import de.anomic.plasma.plasmaSearchRankingProfile;
@@ -74,7 +74,7 @@ public class yacySearch extends Thread {
private final int count, maxDistance;
final private plasmaSearchRankingProfile rankingProfile;
final private String prefer, filter, language;
- final private kelondroBitfield constraint;
+ final private Bitfield constraint;
ResultURLs crawlResults;
@@ -87,7 +87,7 @@ public class yacySearch extends Thread {
final Map<String, TreeMap<String, String>> abstractCache,
final indexReferenceBlacklist blacklist,
final plasmaSearchRankingProfile rankingProfile,
- final kelondroBitfield constraint) {
+ final Bitfield constraint) {
super("yacySearch_" + targetPeer.getName());
//System.out.println("DEBUG - yacySearch thread " + this.getName() + " initialized " + ((urlhashes.length() == 0) ? "(primary)" : "(secondary)"));
this.wordhashes = wordhashes;
@@ -179,7 +179,7 @@ public class yacySearch extends Thread {
}
// put in seeds according to dht
- final kelondroMScoreCluster<String> ranking = new kelondroMScoreCluster<String>();
+ final ScoreCluster<String> ranking = new ScoreCluster<String>();
final HashMap<String, yacySeed> regularSeeds = new HashMap<String, yacySeed>();
final HashMap<String, yacySeed> matchingSeeds = new HashMap<String, yacySeed>();
yacySeed seed;
@@ -255,7 +255,7 @@ public class yacySearch extends Thread {
int targets,
final indexReferenceBlacklist blacklist,
final plasmaSearchRankingProfile rankingProfile,
- final kelondroBitfield constraint,
+ final Bitfield constraint,
final TreeMap<String, String> clusterselection) {
// check own peer status
//if (wordIndex.seedDB.mySeed() == null || wordIndex.seedDB.mySeed().getPublicAddress() == null) { return null; }
@@ -292,7 +292,7 @@ public class yacySearch extends Thread {
final plasmaSearchRankingProcess containerCache,
final String targethash, final indexReferenceBlacklist blacklist,
final plasmaSearchRankingProfile rankingProfile,
- final kelondroBitfield constraint, final TreeMap<String, String> clusterselection) {
+ final Bitfield constraint, final TreeMap<String, String> clusterselection) {
// check own peer status
if (wordIndex.seedDB.mySeed() == null || wordIndex.seedDB.mySeed().getPublicAddress() == null) { return null; }
diff --git a/source/de/anomic/yacy/yacySeed.java b/source/de/anomic/yacy/yacySeed.java
index 9944bb571..1d58b3297 100644
--- a/source/de/anomic/yacy/yacySeed.java
+++ b/source/de/anomic/yacy/yacySeed.java
@@ -56,9 +56,9 @@ import java.util.Set;
import java.util.TreeMap;
import de.anomic.index.indexWord;
-import de.anomic.kelondro.kelondroBase64Order;
-import de.anomic.kelondro.kelondroDigest;
-import de.anomic.kelondro.kelondroDate;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.DateFormatter;
+import de.anomic.kelondro.coding.Digest;
import de.anomic.net.natLib;
import de.anomic.server.serverCodings;
import de.anomic.server.serverDomains;
@@ -212,7 +212,7 @@ public class yacySeed implements Cloneable {
this.dna.put(yacySeed.IPTYPE, "&empty;");
// settings that can only be computed by visiting peer
- this.dna.put(yacySeed.LASTSEEN, kelondroDate.formatShortSecond(new Date(System.currentTimeMillis() - kelondroDate.UTCDiff()))); // for last-seen date
+ this.dna.put(yacySeed.LASTSEEN, DateFormatter.formatShortSecond(new Date(System.currentTimeMillis() - DateFormatter.UTCDiff()))); // for last-seen date
this.dna.put(yacySeed.USPEED, yacySeed.ZERO); // the computated uplink speed of the peer
this.dna.put(yacySeed.CRWCNT, yacySeed.ZERO);
@@ -406,7 +406,7 @@ public class yacySeed implements Cloneable {
* @return the octal representation of the given base64 hash
*/
public static String b64Hash2octalHash(final String b64Hash) {
- return kelondroDigest.encodeOctal(kelondroBase64Order.enhancedCoder.decode(b64Hash, "de.anomic.yacy.yacySeed.b64Hash2octalHash()"));
+ return Digest.encodeOctal(Base64Order.enhancedCoder.decode(b64Hash, "de.anomic.yacy.yacySeed.b64Hash2octalHash()"));
}
/**
@@ -416,7 +416,7 @@ public class yacySeed implements Cloneable {
*/
public static String b64Hash2hexHash(final String b64Hash) {
// the hash string represents 12 * 6 bit = 72 bits. This is too much for a long integer.
- return kelondroDigest.encodeHex(kelondroBase64Order.enhancedCoder.decode(b64Hash, "de.anomic.yacy.yacySeed.b64Hash2hexHash()"));
+ return Digest.encodeHex(Base64Order.enhancedCoder.decode(b64Hash, "de.anomic.yacy.yacySeed.b64Hash2hexHash()"));
}
/**
@@ -424,7 +424,7 @@ public class yacySeed implements Cloneable {
* @return the base64 representation of the given hex hash
*/
public static String hexHash2b64Hash(final String hexHash) {
- return kelondroBase64Order.enhancedCoder.encode(kelondroDigest.decodeHex(hexHash));
+ return Base64Order.enhancedCoder.encode(Digest.decodeHex(hexHash));
}
/**
@@ -434,7 +434,7 @@ public class yacySeed implements Cloneable {
*/
public static byte[] b64Hash2b256Hash(final String b64Hash) {
assert b64Hash.length() == 12;
- return kelondroBase64Order.enhancedCoder.decode(b64Hash, "de.anomic.yacy.yacySeed.b64Hash2b256Hash()");
+ return Base64Order.enhancedCoder.decode(b64Hash, "de.anomic.yacy.yacySeed.b64Hash2b256Hash()");
}
/**
@@ -443,7 +443,7 @@ public class yacySeed implements Cloneable {
*/
public static String b256Hash2b64Hash(final byte[] b256Hash) {
assert b256Hash.length == 9;
- return kelondroBase64Order.enhancedCoder.encode(b256Hash);
+ return Base64Order.enhancedCoder.encode(b256Hash);
}
/**
@@ -516,7 +516,7 @@ public class yacySeed implements Cloneable {
String utc = this.dna.get(yacySeed.UTC);
if (utc == null) { utc = "+0130"; }
try {
- return kelondroDate.UTCDiff(utc);
+ return DateFormatter.UTCDiff(utc);
} catch (final IllegalArgumentException e) {
return 0;
}
@@ -527,7 +527,7 @@ public class yacySeed implements Cloneable {
// because java thinks it must apply the UTC offset to the current time,
// to create a string that looks like our current time, it adds the local UTC offset to the
// time. To create a corrected UTC Date string, we first subtract the local UTC offset.
- dna.put(yacySeed.LASTSEEN, kelondroDate.formatShortSecond(new Date(System.currentTimeMillis() - kelondroDate.UTCDiff())) );
+ dna.put(yacySeed.LASTSEEN, DateFormatter.formatShortSecond(new Date(System.currentTimeMillis() - DateFormatter.UTCDiff())) );
}
/**
@@ -535,18 +535,18 @@ public class yacySeed implements Cloneable {
*/
public final long getLastSeenUTC() {
try {
- final long t = kelondroDate.parseShortSecond(get(yacySeed.LASTSEEN, "20040101000000")).getTime();
+ final long t = DateFormatter.parseShortSecond(get(yacySeed.LASTSEEN, "20040101000000")).getTime();
// getTime creates a UTC time number. But in this case java thinks, that the given
// time string is a local time, which has a local UTC offset applied.
// Therefore java subtracts the local UTC offset, to get a UTC number.
// But the given time string is already in UTC time, so the subtraction
// of the local UTC offset is wrong. We correct this here by adding the local UTC
// offset again.
- return t + kelondroDate.UTCDiff();
+ return t + DateFormatter.UTCDiff();
} catch (final java.text.ParseException e) { // in case of an error make seed look old!!!
- return System.currentTimeMillis() - kelondroDate.dayMillis;
+ return System.currentTimeMillis() - DateFormatter.dayMillis;
} catch (final java.lang.NumberFormatException e) {
- return System.currentTimeMillis() - kelondroDate.dayMillis;
+ return System.currentTimeMillis() - DateFormatter.dayMillis;
}
}
@@ -562,8 +562,8 @@ public class yacySeed implements Cloneable {
/** @return the age of the seed in number of days */
public final int getAge() {
try {
- final long t = kelondroDate.parseShortSecond(get(yacySeed.BDATE, "20040101000000")).getTime();
- return (int) ((System.currentTimeMillis() - (t - getUTCDiff() + kelondroDate.UTCDiff())) / 1000 / 60 / 60 / 24);
+ final long t = DateFormatter.parseShortSecond(get(yacySeed.BDATE, "20040101000000")).getTime();
+ return (int) ((System.currentTimeMillis() - (t - getUTCDiff() + DateFormatter.UTCDiff())) / 1000 / 60 / 60 / 24);
} catch (final java.text.ParseException e) {
return -1;
} catch (final java.lang.NumberFormatException e) {
@@ -688,7 +688,7 @@ public class yacySeed implements Cloneable {
*/
private final static long dhtPosition(final String wordHash) {
// normalized to Long.MAX_VALUE
- long c = kelondroBase64Order.enhancedCoder.cardinal(wordHash.getBytes());
+ long c = Base64Order.enhancedCoder.cardinal(wordHash.getBytes());
assert c != Long.MAX_VALUE;
if (c == Long.MAX_VALUE) return Long.MAX_VALUE - 1;
return c;
@@ -835,13 +835,13 @@ public class yacySeed implements Cloneable {
assert t >= 0.0 : "t = " + t;
assert t < 1.0 : "t = " + t;
- return new String(kelondroBase64Order.enhancedCoder.uncardinal((long) (((double) Long.MAX_VALUE) * t))) + "AA";
+ return new String(Base64Order.enhancedCoder.uncardinal((long) (((double) Long.MAX_VALUE) * t))) + "AA";
}
public static String positionToHash(final long l) {
// transform the position of a peer position into a close peer hash
- return new String(kelondroBase64Order.enhancedCoder.uncardinal(l)) + "AA";
+ return new String(Base64Order.enhancedCoder.uncardinal(l)) + "AA";
}
public static yacySeed genLocalSeed(final yacySeedDB db) {
@@ -860,9 +860,9 @@ public class yacySeed implements Cloneable {
// now calculate other information about the host
newSeed.dna.put(yacySeed.NAME, (name) == null ? "anonymous" : name);
newSeed.dna.put(yacySeed.PORT, Integer.toString((port <= 0) ? 8080 : port));
- newSeed.dna.put(yacySeed.BDATE, kelondroDate.formatShortSecond(new Date(System.currentTimeMillis() - kelondroDate.UTCDiff())) );
+ newSeed.dna.put(yacySeed.BDATE, DateFormatter.formatShortSecond(new Date(System.currentTimeMillis() - DateFormatter.UTCDiff())) );
newSeed.dna.put(yacySeed.LASTSEEN, newSeed.dna.get(yacySeed.BDATE)); // just as initial setting
- newSeed.dna.put(yacySeed.UTC, kelondroDate.UTCDiffString());
+ newSeed.dna.put(yacySeed.UTC, DateFormatter.UTCDiffString());
newSeed.dna.put(yacySeed.PEERTYPE, yacySeed.PEERTYPE_VIRGIN);
return newSeed;
@@ -872,8 +872,8 @@ public class yacySeed implements Cloneable {
public static String randomHash() {
final String hash =
- kelondroBase64Order.enhancedCoder.encode(kelondroDigest.encodeMD5Raw(Long.toString(random.nextLong()))).substring(0, 6) +
- kelondroBase64Order.enhancedCoder.encode(kelondroDigest.encodeMD5Raw(Long.toString(random.nextLong()))).substring(0, 6);
+ Base64Order.enhancedCoder.encode(Digest.encodeMD5Raw(Long.toString(random.nextLong()))).substring(0, 6) +
+ Base64Order.enhancedCoder.encode(Digest.encodeMD5Raw(Long.toString(random.nextLong()))).substring(0, 6);
return hash;
}
diff --git a/source/de/anomic/yacy/yacySeedDB.java b/source/de/anomic/yacy/yacySeedDB.java
index 7d3d89436..9b444546d 100644
--- a/source/de/anomic/yacy/yacySeedDB.java
+++ b/source/de/anomic/yacy/yacySeedDB.java
@@ -47,9 +47,9 @@ import de.anomic.http.httpRequestHeader;
import de.anomic.http.httpd;
import de.anomic.http.httpdAlternativeDomainNames;
import de.anomic.kelondro.kelondroBLOBHeap;
-import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroException;
import de.anomic.kelondro.kelondroMapDataMining;
+import de.anomic.kelondro.coding.Base64Order;
import de.anomic.plasma.plasmaHTCache;
import de.anomic.server.serverCore;
import de.anomic.server.serverDomains;
@@ -248,12 +248,12 @@ public final class yacySeedDB implements httpdAlternativeDomainNames {
initializeHandlerMethod = null;
}
try {
- return new kelondroMapDataMining(new kelondroBLOBHeap(seedDBFile, commonHashLength, kelondroBase64Order.enhancedCoder, 1024 * 512), 500, sortFields, longaccFields, doubleaccFields, initializeHandlerMethod, this);
+ return new kelondroMapDataMining(new kelondroBLOBHeap(seedDBFile, commonHashLength, Base64Order.enhancedCoder, 1024 * 512), 500, sortFields, longaccFields, doubleaccFields, initializeHandlerMethod, this);
} catch (final Exception e) {
// try again
seedDBFile.delete();
try {
- return new kelondroMapDataMining(new kelondroBLOBHeap(seedDBFile, commonHashLength, kelondroBase64Order.enhancedCoder, 1024 * 512), 500, sortFields, longaccFields, doubleaccFields, initializeHandlerMethod, this);
+ return new kelondroMapDataMining(new kelondroBLOBHeap(seedDBFile, commonHashLength, Base64Order.enhancedCoder, 1024 * 512), 500, sortFields, longaccFields, doubleaccFields, initializeHandlerMethod, this);
} catch (IOException e1) {
e1.printStackTrace();
System.exit(-1);
@@ -315,7 +315,7 @@ public final class yacySeedDB implements httpdAlternativeDomainNames {
// address ::= (<peername>'.yacy'|<peerhexhash>'.yacyh'){'='<ip>{':'<port}}
// clusterdef ::= {address}{','address}*
final String[] addresses = (clusterdefinition.length() == 0) ? new String[0] : clusterdefinition.split(",");
- final TreeMap<String, String> clustermap = new TreeMap<String, String>(kelondroBase64Order.enhancedComparator);
+ final TreeMap<String, String> clustermap = new TreeMap<String, String>(Base64Order.enhancedComparator);
yacySeed seed;
String hash, yacydom, ipport;
int p;
diff --git a/source/de/anomic/yacy/yacyURL.java b/source/de/anomic/yacy/yacyURL.java
index 96c41cdd1..5361d7677 100644
--- a/source/de/anomic/yacy/yacyURL.java
+++ b/source/de/anomic/yacy/yacyURL.java
@@ -35,8 +35,8 @@ import java.util.TreeSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import de.anomic.kelondro.kelondroBase64Order;
-import de.anomic.kelondro.kelondroDigest;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.Digest;
import de.anomic.server.serverDomains;
import de.anomic.tools.Punycode;
import de.anomic.tools.Punycode.PunycodeException;
@@ -659,15 +659,15 @@ public class yacyURL implements Serializable {
// static methods from plasmaURL
public static final int flagTypeID(final String hash) {
- return (kelondroBase64Order.enhancedCoder.decodeByte(hash.charAt(11)) & 32) >> 5;
+ return (Base64Order.enhancedCoder.decodeByte(hash.charAt(11)) & 32) >> 5;
}
public static final int flagTLDID(final String hash) {
- return (kelondroBase64Order.enhancedCoder.decodeByte(hash.charAt(11)) & 28) >> 2;
+ return (Base64Order.enhancedCoder.decodeByte(hash.charAt(11)) & 28) >> 2;
}
public static final int flagLengthID(final String hash) {
- return (kelondroBase64Order.enhancedCoder.decodeByte(hash.charAt(11)) & 3);
+ return (Base64Order.enhancedCoder.decodeByte(hash.charAt(11)) & 3);
}
public final String hash() {
@@ -715,18 +715,18 @@ public class yacyURL implements Serializable {
// combine the attributes
final StringBuilder hash = new StringBuilder(12);
// form the 'local' part of the hash
- hash.append(kelondroBase64Order.enhancedCoder.encode(kelondroDigest.encodeMD5Raw(toNormalform(true, true))).substring(0, 5)); // 5 chars
+ hash.append(Base64Order.enhancedCoder.encode(Digest.encodeMD5Raw(toNormalform(true, true))).substring(0, 5)); // 5 chars
hash.append(subdomPortPath(subdom, port, rootpath)); // 1 char
// form the 'global' part of the hash
hash.append(hosthash5(this.protocol, host, port)); // 5 chars
- hash.append(kelondroBase64Order.enhancedCoder.encodeByte(flagbyte)); // 1 char
+ hash.append(Base64Order.enhancedCoder.encodeByte(flagbyte)); // 1 char
// return result hash
return hash.toString();
}
private static char subdomPortPath(final String subdom, final int port, final String rootpath) {
- return kelondroBase64Order.enhancedCoder.encode(kelondroDigest.encodeMD5Raw(subdom + ":" + port + ":" + rootpath)).charAt(0);
+ return Base64Order.enhancedCoder.encode(Digest.encodeMD5Raw(subdom + ":" + port + ":" + rootpath)).charAt(0);
}
private static final char rootURLFlag0 = subdomPortPath("", 80, "");
@@ -737,7 +737,7 @@ public class yacyURL implements Serializable {
}
private static final String hosthash5(final String protocol, final String host, final int port) {
- return kelondroBase64Order.enhancedCoder.encode(kelondroDigest.encodeMD5Raw(protocol + ":" + host + ":" + port)).substring(0, 5);
+ return Base64Order.enhancedCoder.encode(Digest.encodeMD5Raw(protocol + ":" + host + ":" + port)).substring(0, 5);
}
/**
@@ -758,7 +758,7 @@ public class yacyURL implements Serializable {
final int domlengthKey = (l <= 8) ? 0 : (l <= 12) ? 1 : (l <= 16) ? 2 : 3;
final byte flagbyte = (byte) (((protocol.equals("http")) ? 0 : 32) | (id << 2) | domlengthKey);
hash.append(hosthash5(protocol, host, port)); // 5 chars
- hash.append(kelondroBase64Order.enhancedCoder.encodeByte(flagbyte)); // 1 char
+ hash.append(Base64Order.enhancedCoder.encodeByte(flagbyte)); // 1 char
// return result hash
return hash.toString();
@@ -801,7 +801,7 @@ public class yacyURL implements Serializable {
// generates an estimation of the original domain length
assert (urlHash != null);
assert (urlHash.length() == 12) : "urlhash = " + urlHash;
- final int flagbyte = kelondroBase64Order.enhancedCoder.decodeByte(urlHash.charAt(11));
+ final int flagbyte = Base64Order.enhancedCoder.decodeByte(urlHash.charAt(11));
final int domLengthKey = flagbyte & 3;
switch (domLengthKey) {
case 0:
@@ -824,7 +824,7 @@ public class yacyURL implements Serializable {
// returns the ID of the domain of the domain
assert (urlHash != null);
assert (urlHash.length() == 12 || urlHash.length() == 6) : "urlhash = " + urlHash;
- return (kelondroBase64Order.enhancedCoder.decodeByte(urlHash.charAt((urlHash.length() == 12) ? 11 : 5)) & 28) >> 2;
+ return (Base64Order.enhancedCoder.decodeByte(urlHash.charAt((urlHash.length() == 12) ? 11 : 5)) & 28) >> 2;
}
public static boolean isDomDomain(final String urlHash, final int id) {
diff --git a/source/de/anomic/ymage/ymageMatrix.java b/source/de/anomic/ymage/ymageMatrix.java
index a9c789c9d..461b12897 100644
--- a/source/de/anomic/ymage/ymageMatrix.java
+++ b/source/de/anomic/ymage/ymageMatrix.java
@@ -44,8 +44,8 @@ import java.util.ArrayList;
import javax.imageio.ImageIO;
-import de.anomic.kelondro.kelondroMemory;
-import de.anomic.kelondro.kelondroByteBuffer;
+import de.anomic.kelondro.tools.ByteBuffer;
+import de.anomic.kelondro.tools.MemoryControl;
public class ymageMatrix {
@@ -75,7 +75,7 @@ public class ymageMatrix {
}
public ymageMatrix(final int width, final int height, final byte drawMode, final long backgroundColor) {
- if (!(kelondroMemory.request(1024 * 1024 + 3 * width * height, false))) throw new RuntimeException("ymage: not enough memory (" + kelondroMemory.available() + ") available");
+ if (!(MemoryControl.request(1024 * 1024 + 3 * width * height, false))) throw new RuntimeException("ymage: not enough memory (" + MemoryControl.available() + ") available");
this.width = width;
this.height = height;
this.backgroundCol = backgroundColor;
@@ -661,11 +661,11 @@ public class ymageMatrix {
}
*/
private static class sbbBuffer {
- protected kelondroByteBuffer buffer;
+ protected ByteBuffer buffer;
protected int pixel;
protected long access;
public sbbBuffer(final int width, final int height) {
- this.buffer = new kelondroByteBuffer();
+ this.buffer = new ByteBuffer();
this.access = System.currentTimeMillis();
this.pixel = width * height;
}
@@ -677,7 +677,7 @@ public class ymageMatrix {
}
}
private static final ArrayList<sbbBuffer> sbbPool = new ArrayList<sbbBuffer>();
- private static kelondroByteBuffer sbbFromPool(final int width, final int height, final long timeout) {
+ private static ByteBuffer sbbFromPool(final int width, final int height, final long timeout) {
// returns an Image object from the image pool
// if the pooled Image was created recently (before timeout), it is not used
synchronized (sbbPool) {
@@ -698,10 +698,10 @@ public class ymageMatrix {
}
}
- public static kelondroByteBuffer exportImage(final BufferedImage image, final String targetExt) {
+ public static ByteBuffer exportImage(final BufferedImage image, final String targetExt) {
// generate an byte array from the given image
//serverByteBuffer baos = new serverByteBuffer();
- final kelondroByteBuffer baos = sbbFromPool(image.getWidth(), image.getHeight(), 1000);
+ final ByteBuffer baos = sbbFromPool(image.getWidth(), image.getHeight(), 1000);
try {
ImageIO.write(image, targetExt, baos);
return baos;
diff --git a/source/genpw.java b/source/genpw.java
index c93cdae55..358d11e9c 100644
--- a/source/genpw.java
+++ b/source/genpw.java
@@ -2,8 +2,8 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
-import de.anomic.kelondro.kelondroBase64Order;
-import de.anomic.kelondro.kelondroDigest;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.Digest;
// migration.java
// -----------------------
@@ -50,6 +50,6 @@ public class genpw {
}
}
- System.out.println(kelondroDigest.encodeMD5Hex(kelondroBase64Order.standardCoder.encodeString(username+":"+password)));
+ System.out.println(Digest.encodeMD5Hex(Base64Order.standardCoder.encodeString(username+":"+password)));
}
}
diff --git a/source/migration.java b/source/migration.java
index 9b7ea62cf..1fda15823 100644
--- a/source/migration.java
+++ b/source/migration.java
@@ -24,8 +24,8 @@ import java.util.List;
import de.anomic.data.listManager;
import de.anomic.http.httpd;
-import de.anomic.kelondro.kelondroBase64Order;
-import de.anomic.kelondro.kelondroDigest;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.Digest;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaSwitchboardConstants;
import de.anomic.server.serverFileUtils;
@@ -186,33 +186,33 @@ public class migration {
// set preset accounts/passwords
String acc;
if ((acc = sb.getConfig("serverAccount", "")).length() > 0) {
- sb.setConfig("serverAccountBase64MD5", kelondroDigest.encodeMD5Hex(kelondroBase64Order.standardCoder.encodeString(acc)));
+ sb.setConfig("serverAccountBase64MD5", Digest.encodeMD5Hex(Base64Order.standardCoder.encodeString(acc)));
sb.setConfig("serverAccount", "");
}
if ((acc = sb.getConfig("adminAccount", "")).length() > 0) {
- sb.setConfig(httpd.ADMIN_ACCOUNT_B64MD5, kelondroDigest.encodeMD5Hex(kelondroBase64Order.standardCoder.encodeString(acc)));
+ sb.setConfig(httpd.ADMIN_ACCOUNT_B64MD5, Digest.encodeMD5Hex(Base64Order.standardCoder.encodeString(acc)));
sb.setConfig("adminAccount", "");
}
// fix unsafe old passwords
if ((acc = sb.getConfig("proxyAccountBase64", "")).length() > 0) {
- sb.setConfig("proxyAccountBase64MD5", kelondroDigest.encodeMD5Hex(acc));
+ sb.setConfig("proxyAccountBase64MD5", Digest.encodeMD5Hex(acc));
sb.setConfig("proxyAccountBase64", "");
}
if ((acc = sb.getConfig("serverAccountBase64", "")).length() > 0) {
- sb.setConfig("serverAccountBase64MD5", kelondroDigest.encodeMD5Hex(acc));
+ sb.setConfig("serverAccountBase64MD5", Digest.encodeMD5Hex(acc));
sb.setConfig("serverAccountBase64", "");
}
if ((acc = sb.getConfig("adminAccountBase64", "")).length() > 0) {
- sb.setConfig(httpd.ADMIN_ACCOUNT_B64MD5, kelondroDigest.encodeMD5Hex(acc));
+ sb.setConfig(httpd.ADMIN_ACCOUNT_B64MD5, Digest.encodeMD5Hex(acc));
sb.setConfig("adminAccountBase64", "");
}
if ((acc = sb.getConfig("uploadAccountBase64", "")).length() > 0) {
- sb.setConfig("uploadAccountBase64MD5", kelondroDigest.encodeMD5Hex(acc));
+ sb.setConfig("uploadAccountBase64MD5", Digest.encodeMD5Hex(acc));
sb.setConfig("uploadAccountBase64", "");
}
if ((acc = sb.getConfig("downloadAccountBase64", "")).length() > 0) {
- sb.setConfig("downloadAccountBase64MD5", kelondroDigest.encodeMD5Hex(acc));
+ sb.setConfig("downloadAccountBase64MD5", Digest.encodeMD5Hex(acc));
sb.setConfig("downloadAccountBase64", "");
}
}
diff --git a/source/yacy.java b/source/yacy.java
index d8ba7fb3c..bcc2ed1b5 100644
--- a/source/yacy.java
+++ b/source/yacy.java
@@ -60,12 +60,12 @@ import de.anomic.index.indexRepositoryReference;
import de.anomic.index.indexURLReference;
import de.anomic.index.indexWord;
import de.anomic.kelondro.kelondroBLOBHeap;
-import de.anomic.kelondro.kelondroBase64Order;
-import de.anomic.kelondro.kelondroMScoreCluster;
import de.anomic.kelondro.kelondroMapDataMining;
-import de.anomic.kelondro.kelondroRowCollection;
-import de.anomic.kelondro.kelondroDate;
-import de.anomic.kelondro.kelondroMemory;
+import de.anomic.kelondro.coding.Base64Order;
+import de.anomic.kelondro.coding.DateFormatter;
+import de.anomic.kelondro.index.RowCollection;
+import de.anomic.kelondro.tools.ScoreCluster;
+import de.anomic.kelondro.tools.MemoryControl;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaSwitchboardConstants;
import de.anomic.plasma.plasmaWordIndex;
@@ -200,7 +200,7 @@ public final class yacy {
serverLog.logConfig("STARTUP", "Java version: " + System.getProperty("java.version", "no-java-version"));
serverLog.logConfig("STARTUP", "Operation system: " + System.getProperty("os.name","unknown"));
serverLog.logConfig("STARTUP", "Application root-path: " + homePath);
- serverLog.logConfig("STARTUP", "Time zone: UTC" + kelondroDate.UTCDiffString() + "; UTC+0000 is " + System.currentTimeMillis());
+ serverLog.logConfig("STARTUP", "Time zone: UTC" + DateFormatter.UTCDiffString() + "; UTC+0000 is " + System.currentTimeMillis());
serverLog.logConfig("STARTUP", "Maximum file system path length: " + serverSystem.maxPathLength);
f = new File(homePath, "DATA/yacy.running");
@@ -264,7 +264,7 @@ public final class yacy {
sb.setConfig("version", Double.toString(version));
sb.setConfig("vString", yacyVersion.combined2prettyVersion(Double.toString(version)));
- sb.setConfig("vdate", (vDATE.startsWith("@")) ? kelondroDate.formatShortDay() : vDATE);
+ sb.setConfig("vdate", (vDATE.startsWith("@")) ? DateFormatter.formatShortDay() : vDATE);
sb.setConfig("applicationRoot", homePath.toString());
serverLog.logConfig("STARTUP", "YACY Version: " + version + ", Built " + sb.getConfig("vdate", "00000000"));
yacyVersion.latestRelease = version;
@@ -405,11 +405,11 @@ public final class yacy {
// save information about available memory after all initializations
//try {
- sb.setConfig("memoryFreeAfterInitBGC", kelondroMemory.free());
- sb.setConfig("memoryTotalAfterInitBGC", kelondroMemory.total());
+ sb.setConfig("memoryFreeAfterInitBGC", MemoryControl.free());
+ sb.setConfig("memoryTotalAfterInitBGC", MemoryControl.total());
System.gc();
- sb.setConfig("memoryFreeAfterInitAGC", kelondroMemory.free());
- sb.setConfig("memoryTotalAfterInitAGC", kelondroMemory.total());
+ sb.setConfig("memoryFreeAfterInitAGC", MemoryControl.free());
+ sb.setConfig("memoryTotalAfterInitAGC", MemoryControl.total());
//} catch (ConcurrentModificationException e) {}
// signal finished startup
@@ -422,7 +422,7 @@ public final class yacy {
serverLog.logSevere("MAIN CONTROL LOOP", "PANIC: " + e.getMessage(),e);
}
// shut down
- if (kelondroRowCollection.sortingthreadexecutor != null) kelondroRowCollection.sortingthreadexecutor.shutdown();
+ if (RowCollection.sortingthreadexecutor != null) RowCollection.sortingthreadexecutor.shutdown();
serverLog.logConfig("SHUTDOWN", "caught termination signal");
server.terminate(false);
server.interrupt();
@@ -629,7 +629,7 @@ public final class yacy {
final enumerateFiles ef = new enumerateFiles(new File(dbRoot, "WORDS"), true, false, true, true);
File f;
String h;
- final kelondroMScoreCluster<String> hs = new kelondroMScoreCluster<String>();
+ final ScoreCluster<String> hs = new ScoreCluster<String>();
while (ef.hasMoreElements()) {
f = ef.nextElement();
h = f.getName().substring(0, yacySeedDB.commonHashLength);
@@ -671,7 +671,7 @@ public final class yacy {
// db used to hold all neede urls
final indexRepositoryReference minimizedUrlDB = new indexRepositoryReference(new File(indexRoot2, networkName));
- final int cacheMem = (int)(kelondroMemory.max() - kelondroMemory.total());
+ final int cacheMem = (int)(MemoryControl.max() - MemoryControl.total());
if (cacheMem < 2048000) throw new OutOfMemoryError("Not enough memory available to start clean up.");
final plasmaWordIndex wordIndex = new plasmaWordIndex(networkName, log, indexPrimaryRoot, indexSecondaryRoot, 10000, false, 1, 0);
@@ -710,8 +710,8 @@ public final class yacy {
log.logInfo(wordCounter + " words scanned " +
"[" + wordChunkStartHash + " .. " + wordChunkEndHash + "]\n" +
"Duration: "+ 500*1000/duration + " words/s" +
- " | Free memory: " + kelondroMemory.free() +
- " | Total memory: " + kelondroMemory.total());
+ " | Free memory: " + MemoryControl.free() +
+ " | Total memory: " + MemoryControl.total());
wordChunkStart = wordChunkEnd;
wordChunkStartHash = wordChunkEndHash;
}
@@ -929,7 +929,7 @@ public final class yacy {
final String[] dbFileNames = {"seed.new.db","seed.old.db","seed.pot.db"};
for (int i=0; i < dbFileNames.length; i++) {
final File dbFile = new File(yacyDBPath,dbFileNames[i]);
- final kelondroMapDataMining db = new kelondroMapDataMining(new kelondroBLOBHeap(dbFile, yacySeedDB.commonHashLength, kelondroBase64Order.enhancedCoder, 1024 * 512), 500, yacySeedDB.sortFields, yacySeedDB.longaccFields, yacySeedDB.doubleaccFields, null, null);
+ final kelondroMapDataMining db = new kelondroMapDataMining(new kelondroBLOBHeap(dbFile, yacySeedDB.commonHashLength, Base64Order.enhancedCoder, 1024 * 512), 500, yacySeedDB.sortFields, yacySeedDB.longaccFields, yacySeedDB.doubleaccFields, null, null);
kelondroMapDataMining.mapIterator it;
it = db.maps(true, false);
@@ -970,8 +970,8 @@ public final class yacy {
// check memory amount
System.gc();
- final long startupMemFree = kelondroMemory.free();
- final long startupMemTotal = kelondroMemory.total();
+ final long startupMemFree = MemoryControl.free();
+ final long startupMemTotal = MemoryControl.total();
// go into headless awt mode
System.setProperty("java.awt.headless", "true");