Skip to content

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

more performance hacks

orbiter47292e696a68
diff --git a/htroot/BlogComments.java b/htroot/BlogComments.java
index b73bda6c5..c8eeb3c7a 100644
--- a/htroot/BlogComments.java
+++ b/htroot/BlogComments.java
@@ -332,7 +332,7 @@ public class BlogComments {
final String[] sendMail = sendMailStr.trim().split(" ");
// building the message text
- final StringBuffer emailTxt = new StringBuffer();
+ final StringBuilder emailTxt = new StringBuilder();
emailTxt.append("To: ")
.append(sendMailTo)
.append("\nFrom: ")
diff --git a/htroot/IndexControlURLs_p.java b/htroot/IndexControlURLs_p.java
index 95c9a111d..4e9fd85b6 100644
--- a/htroot/IndexControlURLs_p.java
+++ b/htroot/IndexControlURLs_p.java
@@ -182,7 +182,7 @@ public class IndexControlURLs_p {
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 StringBuffer result = new StringBuffer("Sequential List of URL-Hashes:<br />");
+ final StringBuilder result = new StringBuilder("Sequential List of URL-Hashes:<br />");
indexURLReference entry;
int i = 0;
int rows = 0, cols = 0;
diff --git a/htroot/SettingsAck_p.java b/htroot/SettingsAck_p.java
index 27dffc254..dd3fb4827 100644
--- a/htroot/SettingsAck_p.java
+++ b/htroot/SettingsAck_p.java
@@ -485,7 +485,7 @@ public class SettingsAck_p {
}
int enabledMimesCount = 0;
- final StringBuffer currEnabledMimesTxt = new StringBuffer();
+ final StringBuilder currEnabledMimesTxt = new StringBuilder();
parserModeIter = newConfigList.keySet().iterator();
while (parserModeIter.hasNext()) {
final String currParserMode = parserModeIter.next();
diff --git a/htroot/Threaddump_p.java b/htroot/Threaddump_p.java
index f5db00219..f99124d60 100644
--- a/htroot/Threaddump_p.java
+++ b/htroot/Threaddump_p.java
@@ -55,7 +55,7 @@ public class Threaddump_p {
prop.clear();
sb = (plasmaSwitchboard) env;
- final StringBuffer buffer = new StringBuffer(1000);
+ final StringBuilder buffer = new StringBuilder(1000);
final boolean plain = post.get("plain", "false").equals("true");
final int sleep = post.getInt("sleep", 0); // a sleep before creation of a thread dump can be used for profiling
@@ -76,7 +76,7 @@ public class Threaddump_p {
if (post != null && post.containsKey("multipleThreaddump")) {
final ArrayList<Map<Thread,StackTraceElement[]>> traces = new ArrayList<Map<Thread,StackTraceElement[]>>();
- for (int i = 0; i < 100; i++) {
+ for (int i = 0; i < 1000; i++) {
traces.add(Thread.getAllStackTraces());
}
appendStackTraceStats(sb.getRootPath(), buffer, traces, plain, Thread.State.BLOCKED);
@@ -104,7 +104,7 @@ public class Threaddump_p {
return prop; // return from serverObjects respond()
}
- private static void appendStackTraces(final File rootPath, final StringBuffer buffer, final Map<Thread,StackTraceElement[]> stackTraces, final boolean plain, final Thread.State stateIn) {
+ private static void appendStackTraces(final File rootPath, final StringBuilder buffer, final Map<Thread,StackTraceElement[]> stackTraces, final boolean plain, final Thread.State stateIn) {
bufferappend(buffer, plain, "THREADS WITH STATES: " + stateIn.toString());
bufferappend(buffer, plain, "");
// collect single dumps
@@ -120,7 +120,7 @@ public class Threaddump_p {
bufferappend(buffer, plain, "");
}
- private static void appendStackTraceStats(final File rootPath, final StringBuffer buffer, final ArrayList<Map<Thread,StackTraceElement[]>> traces, final boolean plain, final Thread.State stateIn) {
+ private static void appendStackTraceStats(final File rootPath, final StringBuilder buffer, final ArrayList<Map<Thread,StackTraceElement[]>> traces, final boolean plain, final Thread.State stateIn) {
bufferappend(buffer, plain, "THREADS WITH STATES: " + stateIn.toString());
bufferappend(buffer, plain, "");
// collect single dumps
@@ -180,7 +180,7 @@ public class Threaddump_p {
String tracename = "";
File classFile;
if ((stateIn.equals(thread.getState())) && (stackTraceElements.length > 0)) {
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder(3000);
if (plain) {
classFile = getClassFile(classPath, stackTraceElements[stackTraceElements.length - 1].getClassName());
tracename = classFile.getName();
@@ -231,7 +231,7 @@ public class Threaddump_p {
}
}
- private static void bufferappend(final StringBuffer buffer, final boolean plain, final String a) {
+ private static void bufferappend(final StringBuilder buffer, final boolean plain, final String a) {
buffer.append(a);
if (plain) {
buffer.append("\n");
diff --git a/htroot/ViewFile.java b/htroot/ViewFile.java
index 792052df7..dbdc6bf3f 100644
--- a/htroot/ViewFile.java
+++ b/htroot/ViewFile.java
@@ -276,7 +276,7 @@ public class ViewFile {
} else if (viewMode.equals("sentences")) {
prop.put("viewMode", VIEW_MODE_AS_PARSED_SENTENCES);
- final Iterator<StringBuffer> sentences = document.getSentences(pre);
+ final Iterator<StringBuilder> sentences = document.getSentences(pre);
boolean dark = true;
int i = 0;
diff --git a/htroot/yacy/hello.java b/htroot/yacy/hello.java
index c7466fa9a..f02cc3b7c 100644
--- a/htroot/yacy/hello.java
+++ b/htroot/yacy/hello.java
@@ -177,7 +177,7 @@ public final class hello {
}
serverCore.checkInterruption();
- final StringBuffer seeds = new StringBuffer(768);
+ final StringBuilder seeds = new StringBuilder(768);
// attach some more seeds, as requested
if (sb.webIndex.seedDB.sizeConnected() > 0) {
if (count > sb.webIndex.seedDB.sizeConnected()) { count = sb.webIndex.seedDB.sizeConnected(); }
diff --git a/htroot/yacy/list.java b/htroot/yacy/list.java
index 8bec85177..7627699cd 100644
--- a/htroot/yacy/list.java
+++ b/htroot/yacy/list.java
@@ -66,7 +66,7 @@ public final class list {
}
if (col.equals("black")) {
- final StringBuffer out = new StringBuffer();
+ final StringBuilder out = new StringBuilder();
final String filenames=env.getConfig("BlackLists.Shared", "");
final String[] filenamesarray = filenames.split(",");
diff --git a/htroot/yacy/message.java b/htroot/yacy/message.java
index 9802ccffa..e1dcdf270 100644
--- a/htroot/yacy/message.java
+++ b/htroot/yacy/message.java
@@ -174,7 +174,7 @@ public final class message {
final String[] sendMail = sendMailStr.trim().split(" ");
// building the message text
- final StringBuffer emailTxt = new StringBuffer();
+ final StringBuilder emailTxt = new StringBuilder();
emailTxt.append("To: ")
.append(sendMailTo)
.append("\nFrom: ")
diff --git a/htroot/yacy/search.java b/htroot/yacy/search.java
index ad8d429ba..0909a071c 100644
--- a/htroot/yacy/search.java
+++ b/htroot/yacy/search.java
@@ -172,7 +172,7 @@ public final class search {
final plasmaSearchRankingProfile rankingProfile = (profile.length() == 0) ? new plasmaSearchRankingProfile(plasmaSearchQuery.contentdomParser(contentdom)) : new plasmaSearchRankingProfile("", profile);
// prepare an abstract result
- final StringBuffer indexabstract = new StringBuffer();
+ final StringBuilder indexabstract = new StringBuilder();
int indexabstractContainercount = 0;
int joincount = 0;
plasmaSearchQuery theQuery = null;
@@ -220,7 +220,7 @@ public final class search {
prop.put("joincount", "0");
} else {
// attach information about index abstracts
- final StringBuffer indexcount = new StringBuffer();
+ final StringBuilder indexcount = new StringBuilder();
Map.Entry<String, Integer> entry;
final Iterator<Map.Entry<String, Integer>> i = theSearch.IACount.entrySet().iterator();
while (i.hasNext()) {
@@ -272,7 +272,7 @@ public final class search {
// prepare reference hints
final long timer = System.currentTimeMillis();
final Set<String> ws = theSearch.references(10);
- final StringBuffer refstr = new StringBuffer();
+ final StringBuilder refstr = new StringBuilder();
final Iterator<String> j = ws.iterator();
while (j.hasNext()) {
refstr.append(",").append(j.next());
@@ -293,7 +293,7 @@ public final class search {
} else {
// result is a List of urlEntry elements
final long timer = System.currentTimeMillis();
- final StringBuffer links = new StringBuffer();
+ final StringBuilder links = new StringBuilder();
String resource = null;
kelondroSortStack<plasmaSearchEvent.ResultEntry>.stackElement entry;
for (int i = 0; i < accu.size(); i++) {
diff --git a/htroot/yacy/transferRWI.java b/htroot/yacy/transferRWI.java
index f0ad7ae1e..7b1a27148 100644
--- a/htroot/yacy/transferRWI.java
+++ b/htroot/yacy/transferRWI.java
@@ -87,7 +87,7 @@ public final class transferRWI {
// response values
String result = "ok";
- final StringBuffer unknownURLs = new StringBuffer();
+ final StringBuilder unknownURLs = new StringBuilder();
int pause = 10000;
if ((youare == null) || (!youare.equals(sb.webIndex.seedDB.mySeed().hash))) {
diff --git a/htroot/yacy/user/sidebar_navigation.java b/htroot/yacy/user/sidebar_navigation.java
index 3473ca66f..3fdc43ee9 100644
--- a/htroot/yacy/user/sidebar_navigation.java
+++ b/htroot/yacy/user/sidebar_navigation.java
@@ -149,7 +149,7 @@ public class sidebar_navigation {
prop.put("navigation_languagezone", (z) ? "1" : "0");
// compose page navigation
- final StringBuffer resnav = new StringBuffer();
+ final StringBuilder resnav = new StringBuilder();
final int thispage = offset / theQuery.displayResults();
if (thispage == 0) resnav.append("&lt;&nbsp;"); else {
resnav.append(navurla(thispage - 1, theQuery));
diff --git a/htroot/yacysearch.java b/htroot/yacysearch.java
index 8a5e68f1c..55e585472 100644
--- a/htroot/yacysearch.java
+++ b/htroot/yacysearch.java
@@ -356,7 +356,7 @@ public class yacysearch {
prop.put("num-results_globalresults_remotePeerCount", yFormatter.number(theSearch.getRankingResult().getRemotePeerCount(), true));
// compose page navigation
- final StringBuffer resnav = new StringBuffer();
+ final StringBuilder resnav = new StringBuilder();
final int thispage = offset / theQuery.displayResults();
if (thispage == 0) resnav.append("&lt;&nbsp;"); else {
resnav.append(navurla(thispage - 1, display, theQuery));
diff --git a/source/de/anomic/crawler/CrawlProfile.java b/source/de/anomic/crawler/CrawlProfile.java
index 99ae67397..8b7383570 100644
--- a/source/de/anomic/crawler/CrawlProfile.java
+++ b/source/de/anomic/crawler/CrawlProfile.java
@@ -316,7 +316,7 @@ public class CrawlProfile {
}
public String toString() {
- final StringBuffer str = new StringBuffer();
+ final StringBuilder str = new StringBuilder();
if (this.mem != null) {
str.append(this.mem.toString());
diff --git a/source/de/anomic/crawler/NoticeURLImporter.java b/source/de/anomic/crawler/NoticeURLImporter.java
index f37ab009e..f0c08bdc7 100644
--- a/source/de/anomic/crawler/NoticeURLImporter.java
+++ b/source/de/anomic/crawler/NoticeURLImporter.java
@@ -99,7 +99,7 @@ public class NoticeURLImporter extends AbstractImporter implements Importer {
}
public String getStatus() {
- final StringBuffer theStatus = new StringBuffer();
+ final StringBuilder theStatus = new StringBuilder();
theStatus.append("#URLs=").append(this.urlCount).append("\n");
theStatus.append("#Profiles=").append(this.profileCount);
diff --git a/source/de/anomic/crawler/RobotsTxt.java b/source/de/anomic/crawler/RobotsTxt.java
index ea8877330..8d6e1544d 100644
--- a/source/de/anomic/crawler/RobotsTxt.java
+++ b/source/de/anomic/crawler/RobotsTxt.java
@@ -322,7 +322,7 @@ public class RobotsTxt {
if ((allowPathList != null)&&(allowPathList.size()>0)) {
this.allowPathList.addAll(allowPathList);
- final StringBuffer pathListStr = new StringBuffer();
+ final StringBuilder pathListStr = new StringBuilder();
for (int i=0; i<allowPathList.size();i++) {
pathListStr.append(allowPathList.get(i))
.append(ROBOTS_DB_PATH_SEPARATOR);
@@ -333,7 +333,7 @@ public class RobotsTxt {
if ((disallowPathList != null)&&(disallowPathList.size()>0)) {
this.denyPathList.addAll(disallowPathList);
- final StringBuffer pathListStr = new StringBuffer();
+ final StringBuilder pathListStr = new StringBuilder();
for (int i=0; i<disallowPathList.size();i++) {
pathListStr.append(disallowPathList.get(i))
.append(ROBOTS_DB_PATH_SEPARATOR);
@@ -343,7 +343,7 @@ public class RobotsTxt {
}
public String toString() {
- final StringBuffer str = new StringBuffer();
+ final StringBuilder str = new StringBuilder();
str.append((this.hostName==null)?"null":this.hostName)
.append(": ");
diff --git a/source/de/anomic/crawler/SitemapImporter.java b/source/de/anomic/crawler/SitemapImporter.java
index 6ea03dbb6..5dd352122 100644
--- a/source/de/anomic/crawler/SitemapImporter.java
+++ b/source/de/anomic/crawler/SitemapImporter.java
@@ -81,7 +81,7 @@ public class SitemapImporter extends AbstractImporter implements Importer {
* @see Importer#getStatus()
*/
public String getStatus() {
- final StringBuffer theStatus = new StringBuffer();
+ final StringBuilder theStatus = new StringBuilder();
theStatus.append("#URLs=").append((this.parser==null)?0:this.parser.getUrlcount());
diff --git a/source/de/anomic/data/diff.java b/source/de/anomic/data/diff.java
index 1c3c327b0..9844a8370 100644
--- a/source/de/anomic/data/diff.java
+++ b/source/de/anomic/data/diff.java
@@ -177,7 +177,7 @@ public class diff {
public Part[] getParts() { return this.parts.toArray(new Part[this.parts.size()]); }
public String toString() {
- final StringBuffer sb = new StringBuffer(this.parts.size() * 20);
+ final StringBuilder sb = new StringBuilder(this.parts.size() * 20);
for (int j=0; j<this.parts.size(); j++)
sb.append(this.parts.get(j).toString()).append("\n");
return new String(sb);
@@ -217,7 +217,7 @@ public class diff {
* @return the plain string this diff-part cares about
*/
public String getString() {
- final StringBuffer sb = new StringBuffer(this.posNew - this.posOld);
+ final StringBuilder sb = new StringBuilder(this.posNew - this.posOld);
if (this.action == ADDED) {
for (int i=this.posOld; i<this.posNew; i++)
sb.append(diff.this.n[i]);
@@ -243,7 +243,7 @@ public class diff {
}
public static String toHTML(final diff[] diffs) {
- final StringBuffer sb = new StringBuffer(diffs.length * 60);
+ final StringBuilder sb = new StringBuilder(diffs.length * 60);
diff.Part[] ps;
for (int i=0; i<diffs.length; i++) {
sb.append("<p class=\"diff\">\n");
diff --git a/source/de/anomic/data/listManager.java b/source/de/anomic/data/listManager.java
index 8edba1265..e8e30fcc1 100644
--- a/source/de/anomic/data/listManager.java
+++ b/source/de/anomic/data/listManager.java
@@ -172,7 +172,7 @@ public class listManager {
* @return returns <code>true</code> if successful, <code>false</code> otherwise
*/
public static boolean writeList(final File listFile, final String[] list){
- final StringBuffer out = new StringBuffer();
+ final StringBuilder out = new StringBuilder();
for(int i=0;i < list.length; i++){
out
.append(list[i])
@@ -195,7 +195,7 @@ public class listManager {
* @return String representation of the file content.
*/
public static String getListString(final File listFile, final boolean withcomments){
- final StringBuffer temp = new StringBuffer();
+ final StringBuilder temp = new StringBuilder();
BufferedReader br = null;
try{
@@ -321,7 +321,7 @@ public class listManager {
* @return String with elements from set separated by comma.
*/
public static String collection2string(final Collection<String> col){
- final StringBuffer str = new StringBuffer();
+ final StringBuilder str = new StringBuilder();
if (col != null && (col.size() > 0)) {
final Iterator<String> it = col.iterator();
diff --git a/source/de/anomic/data/userDB.java b/source/de/anomic/data/userDB.java
index a941cb4ab..92b8dfbf4 100644
--- a/source/de/anomic/data/userDB.java
+++ b/source/de/anomic/data/userDB.java
@@ -556,7 +556,7 @@ public final class userDB {
logout("xxxxxx");
}
public String toString() {
- final StringBuffer str = new StringBuffer();
+ final StringBuilder str = new StringBuilder();
str.append((this.userName==null)?"null":this.userName)
.append(": ");
diff --git a/source/de/anomic/data/wiki/knwikiParser.java b/source/de/anomic/data/wiki/knwikiParser.java
index 5517ae585..006f7b16f 100644
--- a/source/de/anomic/data/wiki/knwikiParser.java
+++ b/source/de/anomic/data/wiki/knwikiParser.java
@@ -188,7 +188,7 @@ public class knwikiParser implements wikiParser {
}
private String replaceBRs(final String text) {
- final StringBuffer sb = new StringBuffer(text.length());
+ final StringBuilder sb = new StringBuilder(text.length());
final String[] tt = text.split("\n");
boolean replace;
for (int i=0, j; i<tt.length; i++) {
@@ -266,7 +266,7 @@ public class knwikiParser implements wikiParser {
}
static String mergeTexts(final Text[] texts) {
- final StringBuffer sb = new StringBuffer();
+ final StringBuilder sb = new StringBuilder(2000);
for (int n=0; n < texts.length; n++)
sb.append(texts[n].getTextPlain());
return new String(sb);
diff --git a/source/de/anomic/data/wiki/tokens/DefinitionListToken.java b/source/de/anomic/data/wiki/tokens/DefinitionListToken.java
index b5eebee1d..27dd80ad4 100644
--- a/source/de/anomic/data/wiki/tokens/DefinitionListToken.java
+++ b/source/de/anomic/data/wiki/tokens/DefinitionListToken.java
@@ -36,7 +36,7 @@ public class DefinitionListToken extends ListToken {
super(';', null, null);
}
- protected StringBuffer parse(final String[] t, final int depth, final StringBuffer sb) {
+ protected StringBuilder parse(final String[] t, final int depth, final StringBuilder sb) {
sb.append("<dl>\n");
while (super.aktline < t.length && getGrade(t[super.aktline]) >= depth) {
for (int j=0; j<depth + 1; j++) sb.append("\t");
diff --git a/source/de/anomic/data/wiki/tokens/LinkToken.java b/source/de/anomic/data/wiki/tokens/LinkToken.java
index 7e763cfbe..7060a77e5 100644
--- a/source/de/anomic/data/wiki/tokens/LinkToken.java
+++ b/source/de/anomic/data/wiki/tokens/LinkToken.java
@@ -88,7 +88,7 @@ public class LinkToken extends AbstractToken {
}
protected void parse() throws wikiParserException {
- final StringBuffer sb = new StringBuffer();
+ final StringBuilder sb = new StringBuilder();
if (this.patternNr < 0 || this.patternNr >= patterns.length)
throw new wikiParserException("patternNr was not set correctly: " + this.patternNr);
final Matcher m = patterns[this.patternNr].matcher(this.text);
@@ -139,7 +139,7 @@ public class LinkToken extends AbstractToken {
return link;
}
- private StringBuffer appendLinks(final Link[] links, final StringBuffer sb) {
+ private StringBuilder appendLinks(final Link[] links, final StringBuilder sb) {
for (int i=0; i<links.length; i++)
sb.append(links[i].toString());
return sb;
@@ -172,7 +172,7 @@ public class LinkToken extends AbstractToken {
}
public String toString() {
- final StringBuffer sb = new StringBuffer();
+ final StringBuilder sb = new StringBuilder();
sb.append("<a href=\"").append(this.href).append("\"");
if (this.title != null) sb.append(" title=\"").append(this.title).append("\"");
sb.append(">");
diff --git a/source/de/anomic/data/wiki/tokens/ListToken.java b/source/de/anomic/data/wiki/tokens/ListToken.java
index 9bd2f6afe..5062f9e62 100644
--- a/source/de/anomic/data/wiki/tokens/ListToken.java
+++ b/source/de/anomic/data/wiki/tokens/ListToken.java
@@ -86,13 +86,13 @@ public class ListToken extends AbstractToken {
}
protected void parse() {
- final StringBuffer sb = new StringBuffer(this.text.length());
+ final StringBuilder sb = new StringBuilder(this.text.length());
parse(this.text.split("\n"), 0, sb);
this.markup = new String(sb);
this.parsed = true;
}
- protected StringBuffer parse(final String[] t, final int depth, final StringBuffer sb) {
+ protected StringBuilder parse(final String[] t, final int depth, final StringBuilder sb) {
if (this.listBlockElement != null) sb.append("<").append(this.listBlockElement).append(">\n");
while (this.aktline < t.length && getGrade(t[this.aktline]) >= depth) {
if (recursion) for (int j=0; j<depth + 1; j++) sb.append("\t");
diff --git a/source/de/anomic/data/wiki/tokens/SimpleToken.java b/source/de/anomic/data/wiki/tokens/SimpleToken.java
index 9c6b8cd4a..8b47673d2 100644
--- a/source/de/anomic/data/wiki/tokens/SimpleToken.java
+++ b/source/de/anomic/data/wiki/tokens/SimpleToken.java
@@ -93,7 +93,7 @@ public class SimpleToken extends AbstractToken {
}
protected String getMarkup(final String[] es, final boolean closing) {
- final StringBuffer result = new StringBuffer();
+ final StringBuilder result = new StringBuilder();
// backwards if closing
for (
int i = (closing) ? es.length - 1 : 0, j;
diff --git a/source/de/anomic/data/wiki/tokens/TableToken.java b/source/de/anomic/data/wiki/tokens/TableToken.java
index 2aa52f360..f917983ab 100644
--- a/source/de/anomic/data/wiki/tokens/TableToken.java
+++ b/source/de/anomic/data/wiki/tokens/TableToken.java
@@ -45,7 +45,7 @@ public class TableToken extends AbstractToken {
protected void parse() {
final String[] t = text.split("\n");
String[] tds;
- final StringBuffer sb = new StringBuffer();
+ final StringBuilder sb = new StringBuilder();
sb.append("<table");
if (t[0].length() > 2) sb.append(parseTableProperties(t[0].substring(2)));
sb.append(">\n");
@@ -95,9 +95,9 @@ public class TableToken extends AbstractToken {
* @param properties A string that may contain several table properties and/or junk.
* @return A string that only contains table properties.
*/
- private static StringBuffer parseTableProperties(final String properties) {
+ private static StringBuilder parseTableProperties(final String properties) {
final String[] values = properties.replaceAll("&quot;", "").split("[= ]"); //splitting the string at = and blanks
- final StringBuffer sb = new StringBuffer(properties.length());
+ final StringBuilder sb = new StringBuilder(properties.length());
String key, value;
String[] posVals;
final int numberofvalues = values.length;
@@ -121,7 +121,7 @@ public class TableToken extends AbstractToken {
return sb;
}
- private static StringBuffer addPair(final String key, final String value, final StringBuffer sb) {
+ private static StringBuilder addPair(final String key, final String value, final StringBuilder sb) {
return sb.append(" ").append(key).append("=\"").append(value).append("\"");
}
diff --git a/source/de/anomic/data/wikiCode.java b/source/de/anomic/data/wikiCode.java
index 044b413c0..d79a4076c 100644
--- a/source/de/anomic/data/wikiCode.java
+++ b/source/de/anomic/data/wikiCode.java
@@ -89,7 +89,7 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
final int length,
final String publicAddress,
final plasmaSwitchboard switchboard) throws IOException {
- final StringBuffer out = new StringBuffer(length);
+ final StringBuilder out = new StringBuilder(length);
String line;
while ((line = reader.readLine()) != null)
out.append(transformLine(line, publicAddress, switchboard)).append(serverCore.CRLF_STRING);
@@ -187,9 +187,9 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
* @param properties A string that may contain several table properties and/or junk.
* @return A string that only contains table properties.
*/
- private static StringBuffer parseTableProperties(final String properties) {
+ private static StringBuilder parseTableProperties(final String properties) {
final String[] values = properties.replaceAll("&quot;", "").split("[= ]"); //splitting the string at = and blanks
- final StringBuffer sb = new StringBuffer(properties.length());
+ final StringBuilder sb = new StringBuilder(properties.length());
String key, value;
String[] posVals;
final int numberofvalues = values.length;
@@ -213,7 +213,7 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
return sb;
}
- private static StringBuffer addPair(final String key, final String value, final StringBuffer sb) {
+ private static StringBuilder addPair(final String key, final String value, final StringBuilder sb) {
return sb.append(" ").append(key).append("=\"").append(value).append("\"");
}
diff --git a/source/de/anomic/htmlFilter/htmlFilterAbstractScraper.java b/source/de/anomic/htmlFilter/htmlFilterAbstractScraper.java
index 0e7b8de14..09b980784 100644
--- a/source/de/anomic/htmlFilter/htmlFilterAbstractScraper.java
+++ b/source/de/anomic/htmlFilter/htmlFilterAbstractScraper.java
@@ -65,7 +65,7 @@ public abstract class htmlFilterAbstractScraper implements htmlFilterScraper {
public abstract void scrapeTag1(String tagname, Properties tagopts, char[] text);
protected static String stripAllTags(String s) {
- StringBuffer r = new StringBuffer(s.length());
+ StringBuilder r = new StringBuilder(s.length());
int bc = 0;
char c;
for (int p = 0; p < s.length(); p++) {
diff --git a/source/de/anomic/htmlFilter/htmlFilterCharacterCoding.java b/source/de/anomic/htmlFilter/htmlFilterCharacterCoding.java
index 14076b591..6957521c9 100644
--- a/source/de/anomic/htmlFilter/htmlFilterCharacterCoding.java
+++ b/source/de/anomic/htmlFilter/htmlFilterCharacterCoding.java
@@ -198,7 +198,7 @@ public class htmlFilterCharacterCoding {
private static String unicode2html(final String text, boolean amp, boolean html) {
if (text == null) return null;
- final StringBuffer sb = new StringBuffer(text.length() * 12 / 10);
+ final StringBuilder sb = new StringBuilder(text.length() * 12 / 10);
int textpos = 0;
String r;
char c;
@@ -229,7 +229,7 @@ public class htmlFilterCharacterCoding {
public static String html2unicode(final String text) {
if (text == null) return null;
int p = 0, p1, q;
- final StringBuffer sb = new StringBuffer(text.length());
+ final StringBuilder sb = new StringBuilder(text.length());
String s;
Character r;
while (p < text.length()) {
diff --git a/source/de/anomic/http/httpHeader.java b/source/de/anomic/http/httpHeader.java
index 578a3b926..37343d33c 100644
--- a/source/de/anomic/http/httpHeader.java
+++ b/source/de/anomic/http/httpHeader.java
@@ -390,12 +390,12 @@ public class httpHeader extends TreeMap<String, String> implements Map<String, S
return !(httpVer.equals(HTTP_VERSION_0_9) || httpVer.equals(HTTP_VERSION_1_0));
}
- public StringBuffer toHeaderString(
+ public StringBuilder toHeaderString(
final String httpVersion,
final int httpStatusCode,
final String httpStatusText) {
// creating a new buffer to store the header as string
- final StringBuffer theHeader = new StringBuffer();
+ final StringBuilder theHeader = new StringBuilder();
// generating the header string
this.toHeaderString(httpVersion,httpStatusCode,httpStatusText,theHeader);
@@ -409,7 +409,7 @@ public class httpHeader extends TreeMap<String, String> implements Map<String, S
String httpVersion,
final int httpStatusCode,
String httpStatusText,
- final StringBuffer theHeader) {
+ final StringBuilder theHeader) {
if (theHeader == null) throw new IllegalArgumentException();
diff --git a/source/de/anomic/http/httpd.java b/source/de/anomic/http/httpd.java
index efb5415f0..21f3ceef2 100644
--- a/source/de/anomic/http/httpd.java
+++ b/source/de/anomic/http/httpd.java
@@ -1356,12 +1356,12 @@ public final class httpd implements serverHandler, Cloneable {
else httpStatusText = "Unknown";
}
- final StringBuffer headerStringBuffer = new StringBuffer(560);
+ final StringBuilder header = new StringBuilder(560);
// "HTTP/0.9" does not have a status line or header in the response
if (! httpVersion.toUpperCase().equals(httpHeader.HTTP_VERSION_0_9)) {
// write status line
- headerStringBuffer.append(httpVersion).append(" ")
+ header.append(httpVersion).append(" ")
.append(Integer.toString(httpStatusCode)).append(" ")
.append(httpStatusText).append("\r\n");
@@ -1398,7 +1398,7 @@ public final class httpd implements serverHandler, Cloneable {
//Append user properties to the main String
//TODO: Should we check for user properites. What if they intersect properties that are already in header?
final httpResponseHeader.Entry e = it.next();
- headerStringBuffer.append(e.getKey()).append(": ").append(e.getValue()).append("\r\n");
+ header.append(e.getKey()).append(": ").append(e.getValue()).append("\r\n");
}
/*
@@ -1417,17 +1417,17 @@ public final class httpd implements serverHandler, Cloneable {
if ((tag != '*') && (tag != '#')) { // '#' in key is reserved for proxy attributes as artificial header values
count = responseHeader.keyCount(key);
for (int j = 0; j < count; j++) {
- headerStringBuffer.append(key).append(": ").append((String) responseHeader.getSingle(key, j)).append("\r\n");
+ header.append(key).append(": ").append((String) responseHeader.getSingle(key, j)).append("\r\n");
}
//System.out.println("#" + key + ": " + value);
}
}
// end header
- headerStringBuffer.append("\r\n");
+ header.append("\r\n");
// sending headers to the client
- respond.write(headerStringBuffer.toString().getBytes());
+ respond.write(header.toString().getBytes());
// flush stream
respond.flush();
diff --git a/source/de/anomic/http/httpdFileHandler.java b/source/de/anomic/http/httpdFileHandler.java
index 5dfbc070c..c7b68894b 100644
--- a/source/de/anomic/http/httpdFileHandler.java
+++ b/source/de/anomic/http/httpdFileHandler.java
@@ -424,7 +424,7 @@ public final class httpdFileHandler {
//no defaultfile, send a dirlisting
if (targetFile == null || !targetFile.exists()) {
- final StringBuffer aBuffer = new StringBuffer();
+ final StringBuilder aBuffer = new StringBuilder();
aBuffer.append("<html>\n<head>\n</head>\n<body>\n<h1>Index of " + path + "</h1>\n <ul>\n");
final File dir = new File(htDocsPath, path);
String[] list = dir.list();
@@ -875,7 +875,7 @@ public final class httpdFileHandler {
// doing some errorhandling ...
int httpStatusCode = 400;
final String httpStatusText = null;
- final StringBuffer errorMessage = new StringBuffer();
+ final StringBuilder errorMessage = new StringBuilder(2000);
Exception errorExc = null;
final String errorMsg = e.getMessage();
diff --git a/source/de/anomic/http/httpdProxyHandler.java b/source/de/anomic/http/httpdProxyHandler.java
index 2364106d0..8ab31af7f 100644
--- a/source/de/anomic/http/httpdProxyHandler.java
+++ b/source/de/anomic/http/httpdProxyHandler.java
@@ -222,9 +222,9 @@ public final class httpdProxyHandler {
private static final StringBuilder logMessage = new StringBuilder();
/**
- * Reusable {@link StringBuffer} to generate the useragent string
+ * Reusable {@link StringBuilder} to generate the useragent string
*/
- private static final StringBuffer userAgentStr = new StringBuffer();
+ private static final StringBuilder userAgentStr = new StringBuilder();
/**
* A Set of media types which are known to only contain binary data (no readable text)
@@ -1307,7 +1307,7 @@ public final class httpdProxyHandler {
if (myAddress != null) {
// getting header set by other proxies in the chain
- final StringBuffer viaValue = new StringBuffer();
+ final StringBuilder viaValue = new StringBuilder();
if (header.containsKey(httpHeader.VIA)) viaValue.append(header.get(httpHeader.VIA));
if (viaValue.length() > 0) viaValue.append(", ");
diff --git a/source/de/anomic/http/httpdRobotsTxtConfig.java b/source/de/anomic/http/httpdRobotsTxtConfig.java
index 147313d15..b2e19d3e3 100644
--- a/source/de/anomic/http/httpdRobotsTxtConfig.java
+++ b/source/de/anomic/http/httpdRobotsTxtConfig.java
@@ -91,7 +91,7 @@ public final class httpdRobotsTxtConfig {
public String toString() {
if (this.allDisallowed) return ALL;
- final StringBuffer sb = new StringBuffer();
+ final StringBuilder sb = new StringBuilder();
if (this.blogDisallowed) sb.append(BLOG).append(",");
if (this.bookmarksDisallowed) sb.append(BOOKMARKS).append(",");
if (this.dirsDisallowed) sb.append(DIRS).append(",");
diff --git a/source/de/anomic/icap/icapHeader.java b/source/de/anomic/icap/icapHeader.java
index 1abef8698..fecbb7b35 100644
--- a/source/de/anomic/icap/icapHeader.java
+++ b/source/de/anomic/icap/icapHeader.java
@@ -151,14 +151,14 @@ public class icapHeader extends TreeMap<String, String> implements Map<String, S
return get("*" + key + "-" + count, null);
}
- public StringBuffer toHeaderString(final String icapVersion, final int icapStatusCode, String icapStatusText) {
+ public StringBuilder toHeaderString(final String icapVersion, final int icapStatusCode, String icapStatusText) {
if ((icapStatusText == null)||(icapStatusText.length()==0)) {
if (icapVersion.equals("ICAP/1.0") && icapHeader.icap1_0.containsKey(Integer.toString(icapStatusCode)))
icapStatusText = icapHeader.icap1_0.get(Integer.toString(icapStatusCode));
}
- final StringBuffer theHeader = new StringBuffer();
+ final StringBuilder theHeader = new StringBuilder();
// write status line
theHeader.append(icapVersion).append(" ")
diff --git a/source/de/anomic/icap/icapd.java b/source/de/anomic/icap/icapd.java
index 62e817f5d..9f789424b 100644
--- a/source/de/anomic/icap/icapd.java
+++ b/source/de/anomic/icap/icapd.java
@@ -171,8 +171,8 @@ public class icapd implements serverHandler, Cloneable {
}
- final StringBuffer headerStringBuffer = resHeader.toHeaderString("ICAP/1.0",200,null);
- out.write(headerStringBuffer.toString().getBytes());
+ final StringBuilder header = resHeader.toHeaderString("ICAP/1.0",200,null);
+ out.write(header.toString().getBytes());
out.flush();
return this.prop.getProperty(icapHeader.CONNECTION_PROP_PERSISTENT).equals("keep-alive") ? serverCore.RESUME_CONNECTION : serverCore.TERMINATE_CONNECTION;
@@ -206,8 +206,8 @@ public class icapd implements serverHandler, Cloneable {
icapResHeader.put(icapHeader.SERVICE, "YaCy ICAP Service 1.0");
// icapResHeader.put(icapHeader.CONNECTION, "close");
- final StringBuffer headerStringBuffer = icapResHeader.toHeaderString("ICAP/1.0",404,null);
- out.write((new String(headerStringBuffer)).getBytes());
+ final StringBuilder header = icapResHeader.toHeaderString("ICAP/1.0",404,null);
+ out.write((new String(header)).getBytes());
out.flush();
}
@@ -286,16 +286,16 @@ public class icapd implements serverHandler, Cloneable {
icapResHeader.put(icapHeader.SERVICE, "YaCy ICAP Service 1.0");
// resHeader.put(icapHeader.CONNECTION, "close");
- final StringBuffer headerStringBuffer = icapResHeader.toHeaderString("ICAP/1.0",204,null);
- out.write((new String(headerStringBuffer)).getBytes());
+ final StringBuilder header = icapResHeader.toHeaderString("ICAP/1.0",204,null);
+ out.write((new String(header)).getBytes());
out.flush();
} else {
icapResHeader.put(icapHeader.ENCAPSULATED,reqHeader.get(icapHeader.ENCAPSULATED));
icapResHeader.put(icapHeader.SERVICE, "YaCy ICAP Service 1.0");
// icapResHeader.put(icapHeader.CONNECTION, "close");
- final StringBuffer headerStringBuffer = icapResHeader.toHeaderString("ICAP/1.0",503,null);
- out.write((new String(headerStringBuffer)).getBytes());
+ final StringBuilder header = icapResHeader.toHeaderString("ICAP/1.0",503,null);
+ out.write((new String(header)).getBytes());
out.flush();
}
diff --git a/source/de/anomic/index/indexContainerHeap.java b/source/de/anomic/index/indexContainerHeap.java
index aba7a5d53..879e1f962 100755
--- a/source/de/anomic/index/indexContainerHeap.java
+++ b/source/de/anomic/index/indexContainerHeap.java
@@ -34,6 +34,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
@@ -231,6 +232,66 @@ public final class indexContainerHeap {
}
}
+ public synchronized int maxReferences() {
+ // iterate to find the max score
+ int max = 0;
+ for (indexContainer container : cache.values()) {
+ if (container.size() > max) max = container.size();
+ }
+ return max;
+ }
+
+ public synchronized String maxReferencesHash() {
+ // iterate to find the max score
+ int max = 0;
+ String hash = null;
+ for (indexContainer container : cache.values()) {
+ if (container.size() > max) {
+ max = container.size();
+ hash = container.getWordHash();
+ }
+ }
+ return hash;
+ }
+
+ public synchronized ArrayList<String> maxReferencesHash(int bound) {
+ // iterate to find the max score
+ ArrayList<String> hashes = new ArrayList<String>();
+ for (indexContainer container : cache.values()) {
+ if (container.size() >= bound) {
+ hashes.add(container.getWordHash());
+ }
+ }
+ return hashes;
+ }
+
+ public synchronized indexContainer latest() {
+ indexContainer c = null;
+ for (indexContainer container : cache.values()) {
+ if (c == null) {c = container; continue;}
+ if (container.lastWrote() > c.lastWrote()) {c = container; continue;}
+ }
+ return c;
+ }
+
+ public synchronized indexContainer first() {
+ indexContainer c = null;
+ for (indexContainer container : cache.values()) {
+ if (c == null) {c = container; continue;}
+ if (container.lastWrote() < c.lastWrote()) {c = container; continue;}
+ }
+ return c;
+ }
+
+ public synchronized ArrayList<String> overAge(long maxage) {
+ ArrayList<String> hashes = new ArrayList<String>();
+ long limit = System.currentTimeMillis() - maxage;
+ for (indexContainer container : cache.values()) {
+ if (container.lastWrote() < limit) hashes.add(container.getWordHash());
+ }
+ return hashes;
+ }
+
/**
* return an iterator object that creates top-level-clones of the indexContainers
* in the cache, so that manipulations of the iterated objects do not change
diff --git a/source/de/anomic/index/indexURLReference.java b/source/de/anomic/index/indexURLReference.java
index f01675e2f..7e1c742d4 100644
--- a/source/de/anomic/index/indexURLReference.java
+++ b/source/de/anomic/index/indexURLReference.java
@@ -280,10 +280,10 @@ public class indexURLReference {
}
}
- private StringBuffer corePropList() {
+ private StringBuilder corePropList() {
// generate a parseable string; this is a simple property-list
final indexURLReference.Components comp = this.comp();
- final StringBuffer s = new StringBuffer(300);
+ final StringBuilder s = new StringBuilder(300);
//System.out.println("author=" + comp.author());
try {
s.append("hash=").append(hash());
@@ -443,7 +443,7 @@ public class indexURLReference {
public String toString(final String snippet) {
// add information needed for remote transport
- final StringBuffer core = corePropList();
+ final StringBuilder core = corePropList();
if (core == null)
return null;
@@ -475,7 +475,7 @@ public class indexURLReference {
* <pre>{hash=jmqfMk7Y3NKw,referrer=------------,mod=20050610,load=20051003,size=51666,wc=1392,cc=0,local=true,q=AEn,dt=h,lang=uk,url=b|aHR0cDovL3d3dy50cmFuc3BhcmVuY3kub3JnL3N1cnZleXMv,descr=b|S25vd2xlZGdlIENlbnRyZTogQ29ycnVwdGlvbiBTdXJ2ZXlzIGFuZCBJbmRpY2Vz}</pre>
*/
public String toString() {
- final StringBuffer core = corePropList();
+ final StringBuilder core = corePropList();
if (core == null) return null;
core.insert(0, "{");
diff --git a/source/de/anomic/index/indexWord.java b/source/de/anomic/index/indexWord.java
index 01b5609f1..d6959b888 100644
--- a/source/de/anomic/index/indexWord.java
+++ b/source/de/anomic/index/indexWord.java
@@ -26,6 +26,7 @@
package de.anomic.index;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Locale;
@@ -77,12 +78,14 @@ public class indexWord {
// static methods
// create a word hash
+ private static final HashMap<String, String> hashCache = new HashMap<String, String>();
public static final String word2hash(final String word) {
- String e = kelondroBase64Order.enhancedCoder.encode(serverCodings.encodeMD5Raw(word.toLowerCase(Locale.ENGLISH))).substring(0, yacySeedDB.commonHashLength);
- if (word.startsWith("hofbr")) {
- System.out.println("*** DEBUG ENCODING: " + word + " -> " + e);
- }
- return e;
+ String h = hashCache.get(word);
+ if (h != null) return h;
+ h = kelondroBase64Order.enhancedCoder.encode(serverCodings.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) {
@@ -92,7 +95,7 @@ public class indexWord {
}
public static final String words2hashString(final String[] words) {
- final StringBuffer sb = new StringBuffer();
+ final StringBuilder sb = new StringBuilder();
for (int i = 0; i < words.length; i++) sb.append(word2hash(words[i]));
return new String(sb);
}
diff --git a/source/de/anomic/kelondro/kelondroAbstractIOChunks.java b/source/de/anomic/kelondro/kelondroAbstractIOChunks.java
index efadf5832..361122040 100644
--- a/source/de/anomic/kelondro/kelondroAbstractIOChunks.java
+++ b/source/de/anomic/kelondro/kelondroAbstractIOChunks.java
@@ -24,7 +24,7 @@ package de.anomic.kelondro;
import java.io.IOException;
-public abstract class kelondroAbstractIOChunks {
+public abstract class kelondroAbstractIOChunks implements kelondroIOChunks {
// logging support
protected String name = null;
@@ -42,18 +42,7 @@ public abstract class kelondroAbstractIOChunks {
abstract public long length() throws IOException;
abstract public void write(long pos, byte[] b, int off, int len) throws IOException;
abstract public void close() throws IOException;
-
-
- // derived methods:
- public synchronized void readFully(long pos, final byte[] b, int off, int len) throws IOException {
- final long handle = profile.startRead();
- if (len < 0) throw new IndexOutOfBoundsException("length is negative:" + len);
- if (b.length < off + len) throw new IndexOutOfBoundsException("bounds do not fit: b.length=" + b.length + ", off=" + off + ", len=" + len);
- if (len > 0) {
- readFully(pos, b, off, len);
- }
- profile.stopRead(handle);
- }
+ abstract public void readFully(long pos, final byte[] b, int off, int len) throws IOException;
public synchronized byte readByte(final long pos) throws IOException {
final byte[] b = new byte[1];
diff --git a/source/de/anomic/kelondro/kelondroAbstractRA.java b/source/de/anomic/kelondro/kelondroAbstractRA.java
index feefd998f..052d93ff6 100644
--- a/source/de/anomic/kelondro/kelondroAbstractRA.java
+++ b/source/de/anomic/kelondro/kelondroAbstractRA.java
@@ -51,12 +51,7 @@ abstract class kelondroAbstractRA implements kelondroRA {
// pseudo-native methods:
abstract public long length() throws IOException;
abstract public long available() throws IOException;
-
- abstract public int read() throws IOException;
- abstract public void write(int b) throws IOException;
-
abstract public void write(byte[] b, int off, int len) throws IOException;
-
abstract public void seek(long pos) throws IOException;
abstract public void close() throws IOException;
@@ -68,40 +63,35 @@ abstract class kelondroAbstractRA implements kelondroRA {
this.readFully(buffer, 0, a);
return buffer;
}
-
- public byte readByte() throws IOException {
- final int ch = this.read();
- if (ch < 0) throw new IOException();
- return (byte)(ch);
- }
-
- public void writeByte(final int v) throws IOException {
- this.write(v);
- }
public short readShort() throws IOException {
- final int ch1 = this.read();
- final int ch2 = this.read();
- if ((ch1 | ch2) < 0) throw new IOException();
- return (short) ((ch1 << 8) | (ch2 << 0));
+ byte[] b = new byte[2];
+ this.readFully(b, 0, 2);
+ if ((b[0] | b[1]) < 0) throw new IOException("kelondroAbstractRA.readInt: wrong values; ch1=" + (b[0] & 0xFF) + ", ch2=" + (b[1] & 0xFF));
+ return (short) (((b[0] & 0xFF) << 8) | (b[1] & 0xFF));
}
public void writeShort(final int v) throws IOException {
- this.write((v >>> 8) & 0xFF); this.write((v >>> 0) & 0xFF);
+ byte[] b = new byte[2];
+ b[0] = (byte) ((v >>> 8) & 0xFF);
+ b[1] = (byte) ( v & 0xFF);
+ this.write(b);
}
public int readInt() throws IOException {
- final int ch1 = this.read();
- final int ch2 = this.read();
- final int ch3 = this.read();
- final int ch4 = this.read();
- if ((ch1 | ch2 | ch3 | ch4) < 0) throw new IOException("kelondroAbstractRA.readInt: wrong values; ch1=" + ch1 + ", ch2=" + ch2 + ", ch3=" + ch3 + ", ch4=" + ch4);
- return ((ch1 << 24) | (ch2 << 16) | (ch3 << 8) | ch4);
+ byte[] b = new byte[4];
+ this.readFully(b, 0, 4);
+ if ((b[0] | b[1] | b[2] | b[3]) < 0) throw new IOException("kelondroAbstractRA.readInt: wrong values; ch1=" + (b[0] & 0xFF) + ", ch2=" + (b[1] & 0xFF) + ", ch3=" + (b[2] & 0xFF) + ", ch4=" + (b[3] & 0xFF));
+ return (((b[0] & 0xFF) << 24) | ((b[1] & 0xFF) << 16) | ((b[2] & 0xFF) << 8) | (b[3] & 0xFF));
}
public void writeInt(final int v) throws IOException {
- this.write((v >>> 24) & 0xFF); this.write((v >>> 16) & 0xFF);
- this.write((v >>> 8) & 0xFF); this.write((v >>> 0) & 0xFF);
+ byte[] b = new byte[4];
+ b[0] = (byte) ((v >>> 24) & 0xFF);
+ b[1] = (byte) ((v >>> 16) & 0xFF);
+ b[2] = (byte) ((v >>> 8) & 0xFF);
+ b[3] = (byte) ( v & 0xFF);
+ this.write(b);
}
public long readLong() throws IOException {
@@ -109,10 +99,16 @@ abstract class kelondroAbstractRA implements kelondroRA {
}
public void writeLong(final long v) throws IOException {
- this.write((int) (v >>> 56) & 0xFF); this.write((int) (v >>> 48) & 0xFF);
- this.write((int) (v >>> 40) & 0xFF); this.write((int) (v >>> 32) & 0xFF);
- this.write((int) (v >>> 24) & 0xFF); this.write((int) (v >>> 16) & 0xFF);
- this.write((int) (v >>> 8) & 0xFF); this.write((int) (v >>> 0) & 0xFF);
+ byte[] b = new byte[8];
+ b[0] = (byte) ((v >>> 56) & 0xFF);
+ b[1] = (byte) ((v >>> 48) & 0xFF);
+ b[2] = (byte) ((v >>> 40) & 0xFF);
+ b[3] = (byte) ((v >>> 32) & 0xFF);
+ b[4] = (byte) ((v >>> 24) & 0xFF);
+ b[5] = (byte) ((v >>> 16) & 0xFF);
+ b[6] = (byte) ((v >>> 8) & 0xFF);
+ b[7] = (byte) ( v & 0xFF);
+ this.write(b);
}
public void write(final byte[] b) throws IOException {
@@ -137,33 +133,7 @@ abstract class kelondroAbstractRA implements kelondroRA {
b[b.length - 1] = lf;
this.write(b);
}
-
- public String readLine() throws IOException {
- // with these functions, we consider a line as always terminated by CRLF
- byte[] bb = new byte[80];
- int bbsize = 0;
- int c;
- while (true) {
- c = read();
- if (c < 0) {
- if (bbsize == 0) return null;
- return new String(bb, 0, bbsize);
- }
- if (c == cr) continue;
- if (c == lf) return new String(bb, 0, bbsize, "UTF-8");
-
- // append to bb
- if (bbsize == bb.length) {
- // extend bb size
- byte[] newbb = new byte[bb.length * 2];
- System.arraycopy(bb, 0, newbb, 0, bb.length);
- bb = newbb;
- newbb = null;
- }
- bb[bbsize++] = (byte) c;
- }
- }
-
+
public void writeMap(final Map<String, String> map, final String comment) throws IOException {
this.seek(0);
final Iterator<Map.Entry<String, String>> iter = map.entrySet().iterator();
@@ -199,26 +169,6 @@ abstract class kelondroAbstractRA implements kelondroRA {
return map;
}
-
- /**
- * this does not write the content to the see position
- * but to the very beginning of the record
- * some additional bytes will ensure that we know the correct content size later on
- */
- public void writeArray(final byte[] b) throws IOException {
- seek(0);
- writeInt(b.length);
- write(b);
- }
-
- public byte[] readArray() throws IOException {
- seek(0);
- final int l = readInt();
- final byte[] b = new byte[l];
- readFully(b, 0, l);
- return b;
- }
-
public void deleteOnExit() {
if (this.file != null) this.file.deleteOnExit();
}
diff --git a/source/de/anomic/kelondro/kelondroAbstractRecords.java b/source/de/anomic/kelondro/kelondroAbstractRecords.java
index 40946984f..ad1a1c7fa 100644
--- a/source/de/anomic/kelondro/kelondroAbstractRecords.java
+++ b/source/de/anomic/kelondro/kelondroAbstractRecords.java
@@ -44,6 +44,8 @@ import de.anomic.server.logging.serverLog;
public abstract class kelondroAbstractRecords implements kelondroRecords {
+ private static final boolean useChannel = false;
+
// static seek pointers
private static int LEN_DESCR = 60;
private static long POS_MAGIC = 0; // 1 byte, byte: file type magic
@@ -247,7 +249,7 @@ public abstract class kelondroAbstractRecords implements kelondroRecords {
} else {
// read link to next element of FREEH chain
USAGE.FREEH.index = entryFile.readInt(seekp);
- assert ((USAGE.FREEH.index == kelondroHandle.NUL) && (USAGE.FREEC == 0)) || seekpos(USAGE.FREEH) < entryFile.length() : "allocatePayload: USAGE.FREEH.index = " + USAGE.FREEH.index + ", seekp = " + seekp;
+ assert ((USAGE.FREEH.index == kelondroHandle.NUL) && (USAGE.FREEC == 0)) || seekpos(USAGE.FREEH) < entryFile.length() : "allocatePayload: USAGE.FREEH.index = " + USAGE.FREEH.index + ", entryFile.length() = " + entryFile.length();
}
}
USAGE.writeused(false);
@@ -321,7 +323,7 @@ public abstract class kelondroAbstractRecords implements kelondroRecords {
public static int staticsize(final File file) {
if (!(file.exists())) return 0;
try {
- final kelondroRA ra = new kelondroFileRA(file.getCanonicalPath());
+ 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 int used = entryFile.readInt(POS_USEDC); // works only if consistency with file size is given
@@ -355,14 +357,14 @@ public abstract class kelondroAbstractRecords implements kelondroRecords {
if (file.exists()) {
// opens an existing tree
this.filename = file.getCanonicalPath();
- final kelondroRA raf = new kelondroFileRA(this.filename);
+ final kelondroRA raf = (useChannel) ? new kelondroChannelRA(new File(this.filename)) : new kelondroFileRA(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);
initExistingFile(raf, useNodeCache);
} else {
this.filename = file.getCanonicalPath();
- final kelondroRA raf = new kelondroFileRA(this.filename);
+ final kelondroRA raf = (useChannel) ? new kelondroChannelRA(new File(this.filename)) : new kelondroFileRA(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);
@@ -408,7 +410,7 @@ public abstract class kelondroAbstractRecords implements kelondroRecords {
assert f != null;
this.entryFile.close();
f.delete();
- ra = new kelondroFileRA(f);
+ ra = (useChannel) ? new kelondroChannelRA(f) : new kelondroFileRA(f);
initNewFile(ra, this.HANDLES.length, this.TXTPROPS.length);
}
@@ -743,7 +745,6 @@ public abstract class kelondroAbstractRecords implements kelondroRecords {
return markedDeleted;
}
-
public synchronized void close() {
if (entryFile == null) {
theLogger.severe("close(): file '" + this.filename + "' was closed before close was called.");
diff --git a/source/de/anomic/kelondro/kelondroAttrSeq.java b/source/de/anomic/kelondro/kelondroAttrSeq.java
index f19b36ac8..78d9744a9 100644
--- a/source/de/anomic/kelondro/kelondroAttrSeq.java
+++ b/source/de/anomic/kelondro/kelondroAttrSeq.java
@@ -164,7 +164,7 @@ public class kelondroAttrSeq {
public void toFile(final File out) throws IOException {
// generate header
- final StringBuffer sb = new StringBuffer(2000);
+ final StringBuilder sb = new StringBuilder(2000);
sb.append("# Name=" + this.name); sb.append((char) 13); sb.append((char) 10);
sb.append("# Created=" + this.created); sb.append((char) 13); sb.append((char) 10);
sb.append("# Structure=" + this.structure.toString()); sb.append((char) 13); sb.append((char) 10);
@@ -302,7 +302,7 @@ public class kelondroAttrSeq {
}
// generate rowdef for seq row definition
- final StringBuffer rowdef = new StringBuffer();
+ final StringBuilder rowdef = new StringBuilder();
rowdef.append("byte[] ");
rowdef.append(seq_names[0]);
rowdef.append('-');
@@ -318,7 +318,7 @@ public class kelondroAttrSeq {
}
public String toString() {
- final StringBuffer sb = new StringBuffer(100);
+ final StringBuilder sb = new StringBuilder(100);
sb.append('<'); sb.append(pivot_name); sb.append('-'); sb.append(Integer.toString(pivot_len)); sb.append(">,'=',");
if (prop_names.length > 0) {
for (int i = 0; i < prop_names.length; i++) {
@@ -405,7 +405,7 @@ public class kelondroAttrSeq {
public String toString() {
// creates only the attribute field and the sequence, not the pivot
- final StringBuffer sb = new StringBuffer(100 + structure.seq_len[0] * seq.size());
+ final StringBuilder sb = new StringBuilder(100 + structure.seq_len[0] * seq.size());
Long val;
for (int i = 0; i < structure.prop_names.length; i++) {
val = attrs.get(structure.prop_names[i]);
diff --git a/source/de/anomic/kelondro/kelondroBase64Order.java b/source/de/anomic/kelondro/kelondroBase64Order.java
index 2356d1b6f..3343ed809 100644
--- a/source/de/anomic/kelondro/kelondroBase64Order.java
+++ b/source/de/anomic/kelondro/kelondroBase64Order.java
@@ -124,7 +124,7 @@ public class kelondroBase64Order extends kelondroAbstractOrder<byte[]> implement
public final String encodeLongSmart(final long c, int length) {
if (c >= max(length)) {
- final StringBuffer s = new StringBuffer(length);
+ final StringBuilder s = new StringBuilder(length);
s.setLength(length);
while (length > 0) s.setCharAt(--length, alpha[63]);
return new String(s);
@@ -133,7 +133,7 @@ public class kelondroBase64Order extends kelondroAbstractOrder<byte[]> implement
}
public final String encodeLong(long c, int length) {
- final StringBuffer s = new StringBuffer(length);
+ final StringBuilder s = new StringBuilder(length);
s.setLength(length);
while (length > 0) {
s.setCharAt(--length, alpha[(byte) (c & 0x3F)]);
@@ -185,7 +185,7 @@ public class kelondroBase64Order extends kelondroAbstractOrder<byte[]> implement
// we will do that by grouping each three input bytes to four output bytes.
public final String encode(final byte[] in) {
if (in.length == 0) return "";
- StringBuffer out = new StringBuffer(in.length / 3 * 4 + 3);
+ StringBuilder out = new StringBuilder(in.length / 3 * 4 + 3);
int pos = 0;
long l;
while (in.length - pos >= 3) {
diff --git a/source/de/anomic/kelondro/kelondroBitfield.java b/source/de/anomic/kelondro/kelondroBitfield.java
index 5c03914f3..7f491e97a 100644
--- a/source/de/anomic/kelondro/kelondroBitfield.java
+++ b/source/de/anomic/kelondro/kelondroBitfield.java
@@ -98,7 +98,7 @@ public class kelondroBitfield implements Cloneable {
}
public String toString() {
- final StringBuffer sb = new StringBuffer(length());
+ final StringBuilder sb = new StringBuilder(length());
for (int i = length() - 1; i >= 0; i--) sb.append((this.get(i)) ? '1' : '0');
return new String(sb);
}
diff --git a/source/de/anomic/kelondro/kelondroChannelRA.java b/source/de/anomic/kelondro/kelondroChannelRA.java
new file mode 100644
index 000000000..083444ced
--- /dev/null
+++ b/source/de/anomic/kelondro/kelondroChannelRA.java
@@ -0,0 +1,77 @@
+// kelondroFileRA.java
+// -----------------------
+// part of The Kelondro Database
+// (C) by Michael Peter Christen; [email protected]
+// first published on http://www.anomic.de
+// Frankfurt, Germany, 2004
+// last major change: 05.02.2004
+//
+// 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
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// 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;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.nio.ByteBuffer;
+import java.nio.channels.FileChannel;
+
+public final class kelondroChannelRA extends kelondroAbstractRA implements kelondroRA {
+
+ private FileChannel channel;
+ private RandomAccessFile raf;
+
+ public kelondroChannelRA(final File file) throws IOException, FileNotFoundException {
+ this.name = file.getName();
+ this.file = file;
+ this.raf = new RandomAccessFile(file, "rw");
+ this.channel = raf.getChannel();
+ }
+
+ public long length() throws IOException {
+ return channel.size();
+ }
+
+ public long available() throws IOException {
+ return channel.size() - channel.position();
+ }
+
+ public final void readFully(final byte[] b, final int off, final int len) throws IOException {
+ ByteBuffer bb = ByteBuffer.wrap(b);
+ channel.read(bb);
+ }
+
+ public void write(final byte[] b, final int off, final int len) throws IOException {
+ ByteBuffer bb = ByteBuffer.wrap(b, off, len);
+ channel.write(bb);
+ }
+
+ public void seek(final long pos) throws IOException {
+ channel.position(pos);
+ }
+
+ public void close() throws IOException {
+ channel.close();
+ raf.close();
+ }
+
+ protected void finalize() throws Throwable {
+ if (channel != null) {
+ this.close();
+ }
+ super.finalize();
+ }
+}
diff --git a/source/de/anomic/kelondro/kelondroColumn.java b/source/de/anomic/kelondro/kelondroColumn.java
index abd7b48bf..f01b67fe7 100644
--- a/source/de/anomic/kelondro/kelondroColumn.java
+++ b/source/de/anomic/kelondro/kelondroColumn.java
@@ -193,7 +193,7 @@ public class kelondroColumn {
}
public String toString() {
- final StringBuffer s = new StringBuffer();
+ final StringBuilder s = new StringBuilder();
switch (celltype) {
case celltype_undefined:
s.append(nickname);
diff --git a/source/de/anomic/kelondro/kelondroFileRA.java b/source/de/anomic/kelondro/kelondroFileRA.java
index e11fe4b2a..d9b7a2b81 100644
--- a/source/de/anomic/kelondro/kelondroFileRA.java
+++ b/source/de/anomic/kelondro/kelondroFileRA.java
@@ -30,11 +30,7 @@ import java.util.Map;
public final class kelondroFileRA extends kelondroAbstractRA implements kelondroRA {
- protected RandomAccessFile RAFile;
-
- public kelondroFileRA(final String file) throws IOException, FileNotFoundException {
- this(new File(file));
- }
+ private RandomAccessFile RAFile;
public kelondroFileRA(final File file) throws IOException, FileNotFoundException {
this.name = file.getName();
diff --git a/source/de/anomic/kelondro/kelondroFullRecords.java b/source/de/anomic/kelondro/kelondroFullRecords.java
index ba85e419d..c0a79016a 100644
--- a/source/de/anomic/kelondro/kelondroFullRecords.java
+++ b/source/de/anomic/kelondro/kelondroFullRecords.java
@@ -69,8 +69,8 @@ public class kelondroFullRecords extends kelondroAbstractRecords {
}
public synchronized void close() {
- recordTracker.remove(this.filename);
super.close();
+ recordTracker.remove(this.filename);
}
public kelondroNode newNode(final kelondroHandle handle, final byte[] bulk, final int offset) throws IOException {
diff --git a/source/de/anomic/kelondro/kelondroMSetTools.java b/source/de/anomic/kelondro/kelondroMSetTools.java
index 234cfde23..70614c585 100644
--- a/source/de/anomic/kelondro/kelondroMSetTools.java
+++ b/source/de/anomic/kelondro/kelondroMSetTools.java
@@ -423,7 +423,7 @@ public class kelondroMSetTools {
public static String setToString(final Set<String> set, final char separator) {
final Iterator<String> i = set.iterator();
- final StringBuffer sb = new StringBuffer(set.size() * 7);
+ final StringBuilder sb = new StringBuilder(set.size() * 7);
if (i.hasNext()) sb.append(i.next());
while (i.hasNext()) {
sb.append(separator).append(i.next());
diff --git a/source/de/anomic/kelondro/kelondroMap.java b/source/de/anomic/kelondro/kelondroMap.java
index 24744f099..f5816aaca 100644
--- a/source/de/anomic/kelondro/kelondroMap.java
+++ b/source/de/anomic/kelondro/kelondroMap.java
@@ -75,7 +75,7 @@ public class kelondroMap {
private static String map2string(final Map<String, String> map, final String comment) {
final Iterator<Map.Entry<String, String>> iter = map.entrySet().iterator();
Map.Entry<String, String> entry;
- final StringBuffer bb = new StringBuffer(map.size() * 40);
+ final StringBuilder bb = new StringBuilder(map.size() * 40);
bb.append("# ").append(comment).append("\r\n");
while (iter.hasNext()) {
entry = iter.next();
diff --git a/source/de/anomic/kelondro/kelondroNIOFileRA.java b/source/de/anomic/kelondro/kelondroNIOFileRA.java
deleted file mode 100644
index 022ebfb49..000000000
--- a/source/de/anomic/kelondro/kelondroNIOFileRA.java
+++ /dev/null
@@ -1,253 +0,0 @@
-// kelondroNIOFileRA.java
-// -----------------------
-// part of The Kelondro Database
-// (C) by Michael Peter Christen; [email protected]
-// first published on http://www.anomic.de
-// Frankfurt, Germany, 2002
-// last major change: 21.04.2004
-//
-// 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
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// 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;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.nio.MappedByteBuffer;
-import java.nio.channels.FileChannel;
-
-public class kelondroNIOFileRA extends kelondroAbstractRA implements kelondroRA {
-
- protected final static long headSize = 1024;
-
- protected RandomAccessFile RAFile;
- protected FileChannel RAChannel;
- protected MappedByteBuffer bufferHead, bufferBody, bufferTail;
- protected long seekPos;
- protected long bodyOffset, tailOffset, tailCurrSize, tailMaxSize;
- protected boolean mapBody;
- protected boolean wroteHead, wroteBody, wroteTail;
-
- public kelondroNIOFileRA(final String file, final boolean mapBody, final long tailMaxSize) throws IOException {
- this(new File(file), mapBody, tailMaxSize);
- }
-
- public kelondroNIOFileRA(final File file, boolean mapBody, final long tailMaxSize) throws IOException {
- this.name = file.getName();
- this.file = file;
- this.seekPos = 0;
- this.bodyOffset = headSize;
- if (bodyOffset >= file.length()) {
- bodyOffset = file.length();
- mapBody = false;
- }
- this.tailOffset = file.length();
- this.tailMaxSize = tailMaxSize;
- this.tailCurrSize = 0;
- this.mapBody = mapBody;
- this.RAFile = new RandomAccessFile(file, "rw");
- this.RAChannel = RAFile.getChannel();
- this.bufferHead = RAChannel.map(FileChannel.MapMode.READ_WRITE, 0, (int) bodyOffset);
- if (mapBody)
- this.bufferBody = RAChannel.map(FileChannel.MapMode.READ_WRITE, bodyOffset, (int) (tailOffset - bodyOffset));
- else
- this.bufferBody = null;
- this.bufferTail = null;
- this.wroteHead = false;
- this.wroteBody = false;
- this.wroteTail = false;
- System.out.println("initialized " + name + " mapBody = " + ((mapBody) ? "true" : "false") +
- ", bodyOffset = " + bodyOffset + ", tailOffset = " + tailOffset);
- }
-
- private boolean growTail(final long newPos) throws IOException {
- if (newPos >= tailMaxSize) {
- System.out.println("cannot grow " + name);
- return false;
- }
- if (tailCurrSize == 0) {
- // first grow
- this.tailCurrSize = newPos;
- if (tailCurrSize < 1024) tailCurrSize = 1024;
- if (tailCurrSize > tailMaxSize) tailCurrSize = tailMaxSize;
- } else {
- // next grow
- tailCurrSize = tailCurrSize * 2;
- if (tailCurrSize < newPos) tailCurrSize = newPos;
- if (tailCurrSize > tailMaxSize) tailCurrSize = tailMaxSize;
- bufferTail.force();
- }
- System.out.println("growing " + name + " nextSize=" + tailCurrSize);
- bufferTail = RAChannel.map(FileChannel.MapMode.READ_WRITE, tailOffset, (int) tailCurrSize);
- wroteTail = false;
- return true;
- }
-
- public long length() throws IOException {
- return RAFile.length();
- }
-
- public long available() throws IOException {
- return RAFile.length() - RAFile.getFilePointer();
- }
-
- // pseudo-native method read
- public int read() throws IOException {
- int r;
- if (seekPos < bodyOffset) {
- r = 0xFF & (bufferHead.get((int) seekPos));
- } else if (seekPos < tailOffset) {
- if (mapBody) {
- r = 0xFF & (bufferBody.get((int) (seekPos - bodyOffset)));
- } else {
- RAFile.seek(seekPos);
- r = RAFile.read();
- }
- } else if (seekPos < (tailOffset + tailCurrSize)) {
- r = 0xFF & (bufferTail.get((int) (seekPos - tailOffset)));
- } else {
- r = -1;
- while (growTail(seekPos)) {
- if (seekPos < (tailOffset + tailCurrSize)) {
- r = 0xFF & (bufferTail.get((int) (seekPos - tailOffset)));
- } else {
- RAFile.seek(seekPos);
- r = RAFile.read();
- }
- break;
- }
- }
- seekPos++;
- return r;
- }
-
- // pseudo-native method write
- public void write(final int b) throws IOException {
- if (seekPos < bodyOffset) {
- bufferHead.put((int) seekPos, (byte) (b & 0xff));
- wroteHead = true;
- } else if (seekPos < tailOffset) {
- if (mapBody) {
- bufferBody.put((int) (seekPos - bodyOffset), (byte) (b & 0xff));
- wroteBody = true;
- } else {
- RAFile.seek(seekPos);
- RAFile.write(b);
- }
- } else if (seekPos < (tailOffset + tailCurrSize)) {
- bufferTail.put((int) (seekPos - tailOffset), (byte) (b & 0xff));
- wroteTail = true;
- } else {
- while (growTail(seekPos)) {
- if (seekPos < (tailOffset + tailCurrSize)) {
- bufferTail.put((int) (seekPos - tailOffset), (byte) (b & 0xff));
- wroteTail = true;
- } else {
- RAFile.seek(seekPos);
- RAFile.write(b);
- }
- break;
- }
- }
- seekPos++;
- }
-
- public void readFully(final byte[] b, final int off, final int len) throws IOException {
- for (int i = 0; i < len; i++) {
- b[off + i] = (byte) read();
- }
- }
-
- public void write(final byte[] b, final int off, final int len) throws IOException {
- for (int i = 0; i < len; i++) {
- write(b[off + i]);
- }
- }
-
- public void seek(final long pos) throws IOException {
- seekPos = pos;
- }
-
- public void close() throws IOException {
- if (wroteHead) {
- bufferHead.force();
- System.out.println("wrote " + name + " head");
- }
- if ((wroteBody) && (mapBody)) {
- bufferBody.force();
- System.out.println("wrote " + name + " body");
- }
- if (wroteTail) {
- bufferTail.force();
- System.out.println("wrote " + name + " tail");
- }
- RAChannel.close();
- RAChannel = null;
- RAFile.close();
- RAFile = null;
- }
-
- protected void finalize() throws Throwable {
- if (RAChannel != null) {
- try {RAChannel.close();}catch(final Exception e){}
- }
- if (RAFile != null) {
- try {RAFile.close();}catch(final Exception e){}
- }
- }
-
-
- public static void test1(final kelondroRA ra) throws IOException {
- for (int i = 0; i < 2048; i++) {
- ra.seek(i);
- ra.write(32);
- }
- }
-
- public static void main(final String[] args) {
- // tests...
- final File f = new File("/yacy/nio.test.txt");
- if (f.exists()) f.delete();
-
- System.out.println("* fill with blanks");
- try { final kelondroRA ra = new kelondroNIOFileRA(f, true, 2046); test1(ra); ra.close();
- } catch (final IOException e) { e.printStackTrace(); }
-
- System.out.println("* write in at head");
- try { final kelondroRA ra = new kelondroNIOFileRA(f, true, 10);
- ra.seek(8); ra.write((byte) 'h');
- ra.close();
- } catch (final IOException e) { e.printStackTrace(); }
-
- System.out.println("* write in at body");
- try { final kelondroRA ra = new kelondroNIOFileRA(f, true, 10);
- ra.seek(1024); ra.write((byte) 'b');
- ra.close();
- } catch (final IOException e) { e.printStackTrace(); }
-
- System.out.println("* write in at tail");
- try { final kelondroRA ra = new kelondroNIOFileRA(f, true, 10);
- ra.seek(2048); ra.write((byte) 't');
- ra.close();
- } catch (final IOException e) { e.printStackTrace(); }
-
- System.out.println("* write in behind tail");
- try { final kelondroRA ra = new kelondroNIOFileRA(f, true, 10);
- ra.seek(2059); ra.write((byte) 'x');
- ra.close();
- } catch (final IOException e) { e.printStackTrace(); }
- }
-
-}
diff --git a/source/de/anomic/kelondro/kelondroRA.java b/source/de/anomic/kelondro/kelondroRA.java
index 24467baf8..f98e109b3 100644
--- a/source/de/anomic/kelondro/kelondroRA.java
+++ b/source/de/anomic/kelondro/kelondroRA.java
@@ -45,10 +45,8 @@ public interface kelondroRA {
public long length() throws IOException;
public long available() throws IOException;
- public int read() throws IOException;
public void readFully(byte[] b, int off, int len) throws IOException;
- public void write(int b) throws IOException;
-
+
public void write(byte[] b, int off, int len) throws IOException;
public void seek(long pos) throws IOException;
@@ -56,9 +54,7 @@ public interface kelondroRA {
// derived methods:
public byte[] readFully() throws IOException;
- public byte readByte() throws IOException;
- public void writeByte(int v) throws IOException;
-
+
public short readShort() throws IOException;
public void writeShort(int v) throws IOException;
@@ -71,13 +67,9 @@ public interface kelondroRA {
public void write(byte[] b) throws IOException;
public void writeLine(String line) throws IOException;
- public String readLine() throws IOException;
-
+
public void writeMap(Map<String, String> props, String comment) throws IOException;
public HashMap<String, String> readMap() throws IOException;
- public void writeArray(byte[] b) throws IOException;
- public byte[] readArray() throws IOException;
-
public void deleteOnExit();
}
diff --git a/source/de/anomic/kelondro/kelondroRAIOChunks.java b/source/de/anomic/kelondro/kelondroRAIOChunks.java
index 45b4beeae..b495b561b 100644
--- a/source/de/anomic/kelondro/kelondroRAIOChunks.java
+++ b/source/de/anomic/kelondro/kelondroRAIOChunks.java
@@ -41,6 +41,11 @@ public final class kelondroRAIOChunks extends kelondroAbstractIOChunks implement
return ra.length();
}
+ public synchronized void readFully(long pos, final byte[] b, int off, int len) throws IOException {
+ this.ra.seek(pos);
+ this.ra.readFully(b, off, len);
+ }
+
public synchronized void write(final long pos, final byte[] b, final int off, final int len) throws IOException {
this.ra.seek(pos);
this.ra.write(b, off, len);
diff --git a/source/de/anomic/kelondro/kelondroRow.java b/source/de/anomic/kelondro/kelondroRow.java
index 2b1f370fc..3752101ca 100644
--- a/source/de/anomic/kelondro/kelondroRow.java
+++ b/source/de/anomic/kelondro/kelondroRow.java
@@ -135,7 +135,7 @@ public final class kelondroRow {
}
public final String toString() {
- final StringBuffer s = new StringBuffer();
+ final StringBuilder s = new StringBuilder();
s.append(row[0].toString());
for (int i = 1; i < row.length; i++) {
s.append(", ");
diff --git a/source/de/anomic/kelondro/kelondroRowCollection.java b/source/de/anomic/kelondro/kelondroRowCollection.java
index f02599bae..2689e8f08 100644
--- a/source/de/anomic/kelondro/kelondroRowCollection.java
+++ b/source/de/anomic/kelondro/kelondroRowCollection.java
@@ -840,7 +840,7 @@ public class kelondroRowCollection {
}
public synchronized String toString() {
- final StringBuffer s = new StringBuffer();
+ final StringBuilder s = new StringBuilder();
final Iterator<kelondroRow.Entry> i = rows();
if (i.hasNext()) s.append(i.next().toString());
while (i.hasNext()) s.append(", " + (i.next()).toString());
diff --git a/source/de/anomic/kelondro/kelondroSplitTable.java b/source/de/anomic/kelondro/kelondroSplitTable.java
index b7092268f..845300022 100644
--- a/source/de/anomic/kelondro/kelondroSplitTable.java
+++ b/source/de/anomic/kelondro/kelondroSplitTable.java
@@ -167,7 +167,7 @@ public class kelondroSplitTable implements kelondroIndex {
private static final Calendar thisCalendar = Calendar.getInstance();
public static final String dateSuffix(final Date date) {
int month, year;
- final StringBuffer suffix = new StringBuffer(6);
+ final StringBuilder suffix = new StringBuilder(6);
synchronized (thisCalendar) {
thisCalendar.setTime(date);
month = thisCalendar.get(Calendar.MONTH) + 1;
diff --git a/source/de/anomic/plasma/parser/ParserInfo.java b/source/de/anomic/plasma/parser/ParserInfo.java
index 2a51c5d38..7d68928ff 100644
--- a/source/de/anomic/plasma/parser/ParserInfo.java
+++ b/source/de/anomic/plasma/parser/ParserInfo.java
@@ -18,7 +18,7 @@ public class ParserInfo {
public int usageCount = 0;
public String toString() {
- final StringBuffer toStr = new StringBuffer();
+ final StringBuilder toStr = new StringBuilder();
toStr.append(this.parserName).append(" V")
.append((this.parserVersionNr==null)?"0.0":this.parserVersionNr).append(" | ")
diff --git a/source/de/anomic/plasma/parser/ps/psParser.java b/source/de/anomic/plasma/parser/ps/psParser.java
index 34c71ca62..77717afcc 100644
--- a/source/de/anomic/plasma/parser/ps/psParser.java
+++ b/source/de/anomic/plasma/parser/ps/psParser.java
@@ -79,7 +79,7 @@ public class psParser extends AbstractParser implements Parser {
public boolean testForPs2Ascii() {
try {
String procOutputLine = null;
- final StringBuffer procOutput = new StringBuffer();
+ final StringBuilder procOutput = new StringBuilder();
final Process ps2asciiProc = Runtime.getRuntime().exec(new String[]{"ps2ascii", "--version"});
final BufferedReader stdOut = new BufferedReader(new InputStreamReader(ps2asciiProc.getInputStream()));
@@ -177,7 +177,7 @@ public class psParser extends AbstractParser implements Parser {
}
} else if (version.startsWith("3")) {
- final StringBuffer stmt = new StringBuffer();
+ final StringBuilder stmt = new StringBuilder();
boolean isBMP = false;
boolean isStore = false;
int store = 0;
@@ -234,11 +234,11 @@ public class psParser extends AbstractParser implements Parser {
*/
private void parseUsingPS2ascii(final File inputFile, final File outputFile) throws Exception {
int execCode = 0;
- StringBuffer procErr = null;
+ StringBuilder procErr = null;
try {
String procOutputLine = null;
- final StringBuffer procOut = new StringBuffer();
- procErr = new StringBuffer();
+ final StringBuilder procOut = new StringBuilder();
+ procErr = new StringBuilder();
final Process ps2asciiProc = Runtime.getRuntime().exec(new String[]{"ps2ascii", inputFile.getAbsolutePath(),outputFile.getAbsolutePath()});
final BufferedReader stdOut = new BufferedReader(new InputStreamReader(ps2asciiProc.getInputStream()));
diff --git a/source/de/anomic/plasma/parser/rpm/rpmParser.java b/source/de/anomic/plasma/parser/rpm/rpmParser.java
index 7667c0e87..4abaf1214 100644
--- a/source/de/anomic/plasma/parser/rpm/rpmParser.java
+++ b/source/de/anomic/plasma/parser/rpm/rpmParser.java
@@ -94,7 +94,7 @@ public class rpmParser extends AbstractParser implements Parser {
try {
String summary = null, description = null, packager = null, name = sourceFile.getName();
final HashMap<yacyURL, String> anchors = new HashMap<yacyURL, String>();
- final StringBuffer content = new StringBuffer();
+ final StringBuilder content = new StringBuilder();
// opening the rpm file
rpmFile = new RPMFile(sourceFile);
diff --git a/source/de/anomic/plasma/parser/tar/tarParser.java b/source/de/anomic/plasma/parser/tar/tarParser.java
index 0eef6abc1..a7ff83944 100644
--- a/source/de/anomic/plasma/parser/tar/tarParser.java
+++ b/source/de/anomic/plasma/parser/tar/tarParser.java
@@ -107,10 +107,10 @@ public class tarParser extends AbstractParser implements Parser {
// TODO: what about bzip ....
- final StringBuffer docKeywords = new StringBuffer();
- final StringBuffer docLongTitle = new StringBuffer();
+ final StringBuilder docKeywords = new StringBuilder();
+ final StringBuilder docLongTitle = new StringBuilder();
final LinkedList<String> docSections = new LinkedList<String>();
- final StringBuffer docAbstrct = new StringBuffer();
+ final StringBuilder docAbstrct = new StringBuilder();
final Map<yacyURL, String> docAnchors = new HashMap<yacyURL, String>();
final HashMap<String, htmlFilterImageEntry> docImages = new HashMap<String, htmlFilterImageEntry>();
diff --git a/source/de/anomic/plasma/parser/vcf/vcfParser.java b/source/de/anomic/plasma/parser/vcf/vcfParser.java
index 085cb85b8..e36f3e79a 100644
--- a/source/de/anomic/plasma/parser/vcf/vcfParser.java
+++ b/source/de/anomic/plasma/parser/vcf/vcfParser.java
@@ -81,8 +81,8 @@ public class vcfParser extends AbstractParser implements Parser {
public plasmaParserDocument parse(final yacyURL url, final String mimeType, final String charset, final InputStream source) throws ParserException, InterruptedException {
try {
- final StringBuffer parsedTitle = new StringBuffer();
- final StringBuffer parsedDataText = new StringBuffer();
+ final StringBuilder parsedTitle = new StringBuilder();
+ final StringBuilder parsedDataText = new StringBuilder();
final HashMap<String, String> parsedData = new HashMap<String, String>();
final HashMap<yacyURL, String> anchors = new HashMap<yacyURL, String>();
final LinkedList<String> parsedNames = new LinkedList<String>();
@@ -251,7 +251,7 @@ public class vcfParser extends AbstractParser implements Parser {
public static final String decodeQuotedPrintable(final String s) {
if (s == null) return null;
final byte[] b = s.getBytes();
- final StringBuffer sb = new StringBuffer();
+ final StringBuilder sb = new StringBuilder();
for (int i = 0; i < b.length; i++) {
final int c = b[i];
if (c == '=') {
diff --git a/source/de/anomic/plasma/parser/xls/xlsParser.java b/source/de/anomic/plasma/parser/xls/xlsParser.java
index dcb452ed4..a7633a311 100644
--- a/source/de/anomic/plasma/parser/xls/xlsParser.java
+++ b/source/de/anomic/plasma/parser/xls/xlsParser.java
@@ -44,8 +44,8 @@ import de.anomic.yacy.yacyURL;
public class xlsParser extends AbstractParser implements Parser, HSSFListener {
- //StringBuffer for parsed text
- private StringBuffer sbFoundStrings = null;
+ //StringBuilder for parsed text
+ private StringBuilder sbFoundStrings = null;
//sstrecord needed for event parsing
private SSTRecord sstrec;
@@ -86,8 +86,8 @@ public class xlsParser extends AbstractParser implements Parser, HSSFListener {
final String charset, final InputStream source) throws ParserException,
InterruptedException {
try {
- //generate new StringBuffer for parsing
- sbFoundStrings = new StringBuffer();
+ //generate new StringBuilder for parsing
+ sbFoundStrings = new StringBuilder();
//create a new org.apache.poi.poifs.filesystem.Filesystem
final POIFSFileSystem poifs = new POIFSFileSystem(source);
@@ -104,7 +104,7 @@ public class xlsParser extends AbstractParser implements Parser, HSSFListener {
//close our document input stream (don't want to leak these!)
din.close();
- //now the parsed strings are in the StringBuffer, now convert them to a String
+ //now the parsed strings are in the StringBuilder, now convert them to a String
final String contents = sbFoundStrings.toString();
/*
diff --git a/source/de/anomic/plasma/parser/zip/zipParser.java b/source/de/anomic/plasma/parser/zip/zipParser.java
index c524984bd..717771aae 100644
--- a/source/de/anomic/plasma/parser/zip/zipParser.java
+++ b/source/de/anomic/plasma/parser/zip/zipParser.java
@@ -91,10 +91,10 @@ public class zipParser extends AbstractParser implements Parser {
docText = new serverByteBuffer();
}
- final StringBuffer docKeywords = new StringBuffer();
- final StringBuffer docLongTitle = new StringBuffer();
+ final StringBuilder docKeywords = new StringBuilder();
+ final StringBuilder docLongTitle = new StringBuilder();
final LinkedList<String> docSections = new LinkedList<String>();
- final StringBuffer docAbstrct = new StringBuffer();
+ final StringBuilder docAbstrct = new StringBuilder();
final Map<yacyURL, String> docAnchors = new HashMap<yacyURL, String>();
final HashMap<String, htmlFilterImageEntry> docImages = new HashMap<String, htmlFilterImageEntry>();
diff --git a/source/de/anomic/plasma/plasmaCondenser.java b/source/de/anomic/plasma/plasmaCondenser.java
index 524a1ce6a..b0a92d097 100644
--- a/source/de/anomic/plasma/plasmaCondenser.java
+++ b/source/de/anomic/plasma/plasmaCondenser.java
@@ -280,7 +280,7 @@ public final class plasmaCondenser {
private void createCondensement(final InputStream is, final String charset) throws UnsupportedEncodingException {
final HashSet<String> currsentwords = new HashSet<String>();
- StringBuffer sentence = new StringBuffer(100);
+ StringBuilder sentence = new StringBuilder(100);
String word = "";
String k;
int wordlen;
@@ -296,7 +296,7 @@ public final class plasmaCondenser {
boolean comb_indexof = false, last_last = false, last_index = false;
RandomAccessFile fa;
final boolean dumpWords = false;
- final HashMap<StringBuffer, indexPhrase> sentences = new HashMap<StringBuffer, indexPhrase>();
+ final HashMap<StringBuilder, indexPhrase> sentences = new HashMap<StringBuilder, indexPhrase>();
if (dumpWords) try {
fa = new RandomAccessFile(new File("dump.txt"), "rw");
@@ -351,7 +351,7 @@ public final class plasmaCondenser {
words.put(k, wsp); // is that necessary?
}
}
- sentence = new StringBuffer(100);
+ sentence = new StringBuilder(100);
currsentwords.clear();
wordInSentenceCounter = 1;
} else {
@@ -413,11 +413,11 @@ public final class plasmaCondenser {
String[] s;
int wc;
Object o;
- final Iterator<StringBuffer> sit = sentences.keySet().iterator();
+ final Iterator<StringBuilder> sit = sentences.keySet().iterator();
while (sit.hasNext()) {
o = sit.next();
if (o != null) {
- sentence = (StringBuffer) o;
+ sentence = (StringBuilder) o;
wc = (sentence.length() - 1) / numlength;
s = new String[wc + 2];
psp = sentences.get(sentence);
@@ -492,7 +492,7 @@ public final class plasmaCondenser {
return true;
}
- public static Enumeration<StringBuffer> wordTokenizer(final String s, final String charset) {
+ public static Enumeration<StringBuilder> wordTokenizer(final String s, final String charset) {
try {
return new sievedWordsEnum(new ByteArrayInputStream(s.getBytes("UTF-8")));
} catch (final Exception e) {
@@ -500,10 +500,10 @@ public final class plasmaCondenser {
}
}
- public static class sievedWordsEnum implements Enumeration<StringBuffer> {
+ public static class sievedWordsEnum implements Enumeration<StringBuilder> {
// this enumeration removes all words that contain either wrong characters or are too short
- StringBuffer buffer = null;
+ StringBuilder buffer = null;
unsievedWordsEnum e;
public sievedWordsEnum(final InputStream is) throws UnsupportedEncodingException {
@@ -515,8 +515,8 @@ public final class plasmaCondenser {
e.pre(x);
}
- private StringBuffer nextElement0() {
- StringBuffer s;
+ private StringBuilder nextElement0() {
+ StringBuilder s;
loop: while (e.hasMoreElements()) {
s = e.nextElement();
if ((s.length() == 1) && (htmlFilterContentScraper.punctuation(s.charAt(0)))) return s;
@@ -532,23 +532,23 @@ public final class plasmaCondenser {
return buffer != null;
}
- public StringBuffer nextElement() {
- final StringBuffer r = buffer;
+ public StringBuilder nextElement() {
+ final StringBuilder r = buffer;
buffer = nextElement0();
return r;
}
}
- private static class unsievedWordsEnum implements Enumeration<StringBuffer> {
- // returns an enumeration of StringBuffer Objects
- StringBuffer buffer = null;
+ private static class unsievedWordsEnum implements Enumeration<StringBuilder> {
+ // returns an enumeration of StringBuilder Objects
+ StringBuilder buffer = null;
sentencesFromInputStreamEnum e;
- StringBuffer s;
+ StringBuilder s;
public unsievedWordsEnum(final InputStream is) throws UnsupportedEncodingException {
e = new sentencesFromInputStreamEnum(is);
- s = new StringBuffer(20);
+ s = new StringBuilder(20);
buffer = nextElement0();
}
@@ -556,16 +556,16 @@ public final class plasmaCondenser {
e.pre(x);
}
- private StringBuffer nextElement0() {
- StringBuffer r;
- StringBuffer sb;
+ private StringBuilder nextElement0() {
+ StringBuilder r;
+ StringBuilder sb;
char c;
while (s.length() == 0) {
if (e.hasNext()) {
r = e.next();
if (r == null) return null;
r = trim(r);
- sb = new StringBuffer(r.length() * 2);
+ sb = new StringBuilder(r.length() * 2);
for (int i = 0; i < r.length(); i++) {
c = r.charAt(i);
if (invisible(c)) sb = sb.append(' '); // TODO: Bugfix needed for UTF-8
@@ -581,10 +581,10 @@ public final class plasmaCondenser {
final int p = s.indexOf(" ");
if (p < 0) {
r = s;
- s = new StringBuffer();
+ s = new StringBuilder();
return r;
}
- r = trim(new StringBuffer(s.substring(0, p)));
+ r = trim(new StringBuilder(s.substring(0, p)));
s = trim(s.delete(0, p + 1));
return r;
}
@@ -593,15 +593,15 @@ public final class plasmaCondenser {
return buffer != null;
}
- public StringBuffer nextElement() {
- final StringBuffer r = buffer;
+ public StringBuilder nextElement() {
+ final StringBuilder r = buffer;
buffer = nextElement0();
return r;
}
}
- static StringBuffer trim(StringBuffer sb) {
+ static StringBuilder trim(StringBuilder sb) {
while ((sb.length() > 0) && (sb.charAt(0) <= ' ')) sb = sb.deleteCharAt(0);
while ((sb.length() > 0) && (sb.charAt(sb.length() - 1) <= ' ')) sb = sb.deleteCharAt(sb.length() - 1);
return sb;
@@ -615,11 +615,11 @@ public final class plasmaCondenser {
}
}
- public static class sentencesFromInputStreamEnum implements Iterator<StringBuffer> {
+ public static class sentencesFromInputStreamEnum implements Iterator<StringBuilder> {
// read sentences from a given input stream
- // this enumerates StringBuffer objects
+ // this enumerates StringBuilder objects
- StringBuffer buffer = null;
+ StringBuilder buffer = null;
BufferedReader raf;
int counter = 0;
boolean pre = false;
@@ -635,9 +635,9 @@ public final class plasmaCondenser {
this.pre = x;
}
- private StringBuffer nextElement0() {
+ private StringBuilder nextElement0() {
try {
- final StringBuffer s = readSentence(raf, pre);
+ final StringBuilder s = readSentence(raf, pre);
//System.out.println(" SENTENCE='" + s + "'"); // DEBUG
if (s == null) {
raf.close();
@@ -657,12 +657,12 @@ public final class plasmaCondenser {
return buffer != null;
}
- public StringBuffer next() {
+ public StringBuilder next() {
if (buffer == null) {
return null;
}
counter = counter + buffer.length() + 1;
- final StringBuffer r = buffer;
+ final StringBuilder r = buffer;
buffer = nextElement0();
return r;
}
@@ -676,8 +676,8 @@ public final class plasmaCondenser {
}
}
- static StringBuffer readSentence(final Reader reader, final boolean pre) throws IOException {
- final StringBuffer s = new StringBuffer(40);
+ static StringBuilder readSentence(final Reader reader, final boolean pre) throws IOException {
+ final StringBuilder s = new StringBuilder(40);
int nextChar;
char c, lc = ' '; // starting with ' ' as last character prevents that the result string starts with a ' '
@@ -728,7 +728,7 @@ public final class plasmaCondenser {
final File f = new File(args[0]);
final Properties p = new Properties();
p.load(new FileInputStream(f));
- final StringBuffer sb = new StringBuffer();
+ final StringBuilder sb = new StringBuilder();
sb.append("{\n");
for (int i = 0; i <= 15; i++) {
sb.append('"');
diff --git a/source/de/anomic/plasma/plasmaDbImporter.java b/source/de/anomic/plasma/plasmaDbImporter.java
index f9604645a..f8a4b82f2 100644
--- a/source/de/anomic/plasma/plasmaDbImporter.java
+++ b/source/de/anomic/plasma/plasmaDbImporter.java
@@ -50,7 +50,7 @@ public class plasmaDbImporter extends AbstractImporter implements Importer {
* @see Importer#getStatus()
*/
public String getStatus() {
- final StringBuffer theStatus = new StringBuffer();
+ final StringBuilder theStatus = new StringBuilder();
theStatus.append("Hash=").append(this.wordHash).append("\n");
theStatus.append("#URL=").append(this.urlCounter).append("\n");
diff --git a/source/de/anomic/plasma/plasmaParser.java b/source/de/anomic/plasma/plasmaParser.java
index 02fb21638..ec82ab722 100644
--- a/source/de/anomic/plasma/plasmaParser.java
+++ b/source/de/anomic/plasma/plasmaParser.java
@@ -475,7 +475,7 @@ public final class plasmaParser {
// testing if all needed libx libraries are available
final String[] neededLibx = theParser.getLibxDependences();
- final StringBuffer neededLibxBuf = new StringBuffer();
+ final StringBuilder neededLibxBuf = new StringBuilder();
if (neededLibx != null) {
for (int libxId=0; libxId < neededLibx.length; libxId++) {
if (javaClassPath.indexOf(neededLibx[libxId]) == -1) {
@@ -937,7 +937,7 @@ public final class plasmaParser {
System.out.println(document.dc_title());
// found text
- final Iterator<StringBuffer> sentences = document.getSentences(false);
+ final Iterator<StringBuilder> sentences = document.getSentences(false);
int i = 0;
if (sentences != null) while (sentences.hasNext()) {
System.out.print("line " + i + ": ");
diff --git a/source/de/anomic/plasma/plasmaParserDocument.java b/source/de/anomic/plasma/plasmaParserDocument.java
index 66fefeecd..4794d2e59 100644
--- a/source/de/anomic/plasma/plasmaParserDocument.java
+++ b/source/de/anomic/plasma/plasmaParserDocument.java
@@ -52,10 +52,10 @@ public class plasmaParserDocument {
private final String mimeType; // mimeType as taken from http header
private final String charset; // the charset of the document
private final List<String> keywords; // most resources provide a keyword field
- private final StringBuffer title; // a document title, taken from title or h1 tag; shall appear as headline of search result
- private final StringBuffer creator; // author or copyright
- private final List<String> sections; // if present: more titles/headlines appearing in the document
- private final StringBuffer description; // an abstract, if present: short content description
+ private final StringBuilder title; // a document title, taken from title or h1 tag; shall appear as headline of search result
+ private final StringBuilder creator; // author or copyright
+ private final List<String> sections; // if present: more titles/headlines appearing in the document
+ private final StringBuilder description; // an abstract, if present: short content description
private Object text; // the clear text, all that is visible
private final Map<yacyURL, String> anchors; // all links embedded as clickeable entities (anchor tags)
private final HashMap<String, htmlFilterImageEntry> images; // all visible pictures in document
@@ -78,10 +78,10 @@ public class plasmaParserDocument {
this.mimeType = (mimeType == null) ? "application/octet-stream" : mimeType;
this.charset = charset;
this.keywords = (keywords == null) ? new LinkedList<String>() : Arrays.asList(keywords);
- this.title = (title == null) ? new StringBuffer() : new StringBuffer(title);
- this.creator = (author == null) ? new StringBuffer() : new StringBuffer(author);
+ this.title = (title == null) ? new StringBuilder(0) : new StringBuilder(title);
+ this.creator = (author == null) ? new StringBuilder(0) : new StringBuilder(author);
this.sections = (sections == null) ? new LinkedList<String>() : Arrays.asList(sections);
- this.description = (abstrct == null) ? new StringBuffer() : new StringBuffer(abstrct);
+ this.description = (abstrct == null) ? new StringBuilder(0) : new StringBuilder(abstrct);
this.anchors = (anchors == null) ? new HashMap<yacyURL, String>(0) : anchors;
this.images = (images == null) ? new HashMap<String, htmlFilterImageEntry>() : images;
this.hyperlinks = null;
@@ -98,7 +98,7 @@ public class plasmaParserDocument {
this.text = new serverCachedFileOutputStream(Parser.MAX_KEEP_IN_MEMORY_SIZE);
} catch (final IOException e) {
e.printStackTrace();
- this.text = new StringBuffer();
+ this.text = new StringBuilder();
} else {
this.text = text;
}
@@ -187,7 +187,7 @@ dc_rights
}
if (hs.size() == 0) return "";
// generate a new list
- final StringBuffer sb = new StringBuffer(this.keywords.size() * 6);
+ final StringBuilder sb = new StringBuilder(this.keywords.size() * 6);
final Iterator<String> i = hs.iterator();
while (i.hasNext()) sb.append(i.next()).append(separator);
return sb.substring(0, sb.length() - 1);
@@ -280,7 +280,7 @@ dc_rights
return -1;
}
- public Iterator<StringBuffer> getSentences(final boolean pre) {
+ public Iterator<StringBuilder> getSentences(final boolean pre) {
if (this.text == null) return null;
final plasmaCondenser.sentencesFromInputStreamEnum e = plasmaCondenser.sentencesFromInputStream(getText());
e.pre(pre);
diff --git a/source/de/anomic/plasma/plasmaSearchQuery.java b/source/de/anomic/plasma/plasmaSearchQuery.java
index 7972b8a0a..98b097d81 100644
--- a/source/de/anomic/plasma/plasmaSearchQuery.java
+++ b/source/de/anomic/plasma/plasmaSearchQuery.java
@@ -204,7 +204,7 @@ public final class plasmaSearchQuery {
public static String hashSet2hashString(final Set<String> hashes) {
final Iterator<String> i = hashes.iterator();
- final StringBuffer sb = new StringBuffer(hashes.size() * yacySeedDB.commonHashLength);
+ final StringBuilder sb = new StringBuilder(hashes.size() * yacySeedDB.commonHashLength);
while (i.hasNext()) sb.append(i.next());
return new String(sb);
}
@@ -212,7 +212,7 @@ public final class plasmaSearchQuery {
public static String anonymizedQueryHashes(final Set<String> hashes) {
// create a more anonymized representation of a query hashes for logging
final Iterator<String> i = hashes.iterator();
- final StringBuffer sb = new StringBuffer(hashes.size() * (yacySeedDB.commonHashLength + 2) + 2);
+ final StringBuilder sb = new StringBuilder(hashes.size() * (yacySeedDB.commonHashLength + 2) + 2);
sb.append("[");
String hash;
if (i.hasNext()) {
diff --git a/source/de/anomic/plasma/plasmaSearchRankingProfile.java b/source/de/anomic/plasma/plasmaSearchRankingProfile.java
index 66a5a7083..bb3ab9907 100644
--- a/source/de/anomic/plasma/plasmaSearchRankingProfile.java
+++ b/source/de/anomic/plasma/plasmaSearchRankingProfile.java
@@ -227,7 +227,7 @@ public class plasmaSearchRankingProfile {
public String toExternalURLGet(final String prefix) {
final Iterator<Map.Entry<String, String>> i = toExternalMap("").entrySet().iterator();
Map.Entry<String, String> entry;
- final StringBuffer ext = new StringBuffer();
+ final StringBuilder ext = new StringBuilder();
while (i.hasNext()) {
entry = i.next();
ext.append("&");
diff --git a/source/de/anomic/plasma/plasmaSnippetCache.java b/source/de/anomic/plasma/plasmaSnippetCache.java
index 2144a6e22..e6c340e2b 100644
--- a/source/de/anomic/plasma/plasmaSnippetCache.java
+++ b/source/de/anomic/plasma/plasmaSnippetCache.java
@@ -184,7 +184,7 @@ public class plasmaSnippetCache {
}
}
}
- final StringBuffer l = new StringBuffer(line.length() + queryHashes.size() * 8);
+ final StringBuilder l = new StringBuilder(line.length() + queryHashes.size() * 8);
for (int j = 0; j < w.length; j++) {
l.append(w[j]);
l.append(' ');
@@ -405,7 +405,7 @@ public class plasmaSnippetCache {
// we have found a parseable non-empty file: use the lines
// compute snippet from text
- final Iterator<StringBuffer> sentences = document.getSentences(pre);
+ final Iterator<StringBuilder> sentences = document.getSentences(pre);
if (sentences == null) return new TextSnippet(url, null, ERROR_PARSER_NO_LINES, queryhashes, "parser returned no sentences",resFavicon);
final Object[] tsr = computeTextSnippet(sentences, queryhashes, snippetMaxLength);
final String textline = (tsr == null) ? null : (String) tsr[0];
@@ -570,14 +570,14 @@ public class plasmaSnippetCache {
@SuppressWarnings("unchecked")
private static Object[] /*{String - the snippet, Set - remaining hashes}*/
- computeTextSnippet(final Iterator<StringBuffer> sentences, final Set<String> queryhashes, int maxLength) {
+ computeTextSnippet(final Iterator<StringBuilder> sentences, final Set<String> queryhashes, int maxLength) {
try {
if (sentences == null) return null;
if ((queryhashes == null) || (queryhashes.size() == 0)) return null;
Iterator<String> j;
HashMap<String, Integer> hs;
- StringBuffer sentence;
- final TreeMap<Integer, StringBuffer> os = new TreeMap<Integer, StringBuffer>();
+ StringBuilder sentence;
+ final TreeMap<Integer, StringBuilder> os = new TreeMap<Integer, StringBuilder>();
int uniqCounter = 9999;
int score;
while (sentences.hasNext()) {
@@ -800,9 +800,9 @@ public class plasmaSnippetCache {
private static HashMap<String, Integer> hashSentence(final String sentence) {
// generates a word-wordPos mapping
final HashMap<String, Integer> map = new HashMap<String, Integer>();
- final Enumeration<StringBuffer> words = plasmaCondenser.wordTokenizer(sentence, "UTF-8");
+ final Enumeration<StringBuilder> words = plasmaCondenser.wordTokenizer(sentence, "UTF-8");
int pos = 0;
- StringBuffer word;
+ StringBuilder word;
String hash;
while (words.hasMoreElements()) {
word = words.nextElement();
diff --git a/source/de/anomic/plasma/plasmaWebStructure.java b/source/de/anomic/plasma/plasmaWebStructure.java
index e2b78bf68..ef86ec3f2 100644
--- a/source/de/anomic/plasma/plasmaWebStructure.java
+++ b/source/de/anomic/plasma/plasmaWebStructure.java
@@ -51,7 +51,7 @@ public class plasmaWebStructure {
public static int maxref = 300; // maximum number of references, to avoid overflow when a large link farm occurs (i.e. wikipedia)
public static int maxhosts = 8000; // maximum number of hosts in web structure map
- private StringBuffer crg; // global citation references
+ private StringBuilder crg; // global citation references
private final serverLog log;
private final File rankingPath, structureFile;
private final String crlFile, crgFile;
@@ -62,7 +62,7 @@ public class plasmaWebStructure {
this.rankingPath = rankingPath;
this.crlFile = crlFile;
this.crgFile = crgFile;
- this.crg = new StringBuffer(maxCRGDump);
+ this.crg = new StringBuilder(maxCRGDump);
this.structure_old = new TreeMap<String, String>();
this.structure_new = new TreeMap<String, String>();
this.structureFile = structureFile;
@@ -97,8 +97,8 @@ public class plasmaWebStructure {
final Map<yacyURL, String> hl = document.getHyperlinks();
final Iterator<yacyURL> it = hl.keySet().iterator();
String nexturlhash;
- final StringBuffer cpg = new StringBuffer(12 * (hl.size() + 1) + 1);
- final StringBuffer cpl = new StringBuffer(12 * (hl.size() + 1) + 1);
+ final StringBuilder cpg = new StringBuilder(12 * (hl.size() + 1) + 1);
+ final StringBuilder cpl = new StringBuilder(12 * (hl.size() + 1) + 1);
final String lhp = url.hash().substring(6); // local hash part
int GCount = 0;
int LCount = 0;
@@ -140,12 +140,12 @@ public class plasmaWebStructure {
/*
if (crl.length() > maxCRLDump) {
flushCitationReference(crl, "crl");
- crl = new StringBuffer(maxCRLDump);
+ crl = new StringBuilder(maxCRLDump);
}
**/
if (crg.length() > maxCRGDump) {
flushCitationReference("crg");
- crg = new StringBuffer(maxCRGDump);
+ crg = new StringBuilder(maxCRGDump);
}
return new Integer[] {Integer.valueOf(LCount), Integer.valueOf(GCount)};
@@ -159,7 +159,7 @@ public class plasmaWebStructure {
final File file = new File(path, filename);
// generate header
- final StringBuffer header = new StringBuffer(200);
+ final StringBuilder header = new StringBuilder(200);
header.append("# Name=YaCy " + ((type.equals("crl")) ? "Local" : "Global") + " Citation Reference Ticket"); header.append((char) 13); header.append((char) 10);
header.append("# Created=" + System.currentTimeMillis()); header.append((char) 13); header.append((char) 10);
header.append("# Structure=<Referee-12>,'=',<UDate-3>,<VDate-3>,<LCount-2>,<GCount-2>,<ICount-2>,<DCount-2>,<TLength-3>,<WACount-3>,<WUCount-3>,<Flags-1>,'|',*<Anchor-" + ((type.equals("crl")) ? "6" : "12") + ">"); header.append((char) 13); header.append((char) 10);
@@ -192,7 +192,7 @@ public class plasmaWebStructure {
}
private static String map2refstr(final Map<String, Integer> map) {
- final StringBuffer s = new StringBuffer(map.size() * 10);
+ final StringBuilder s = new StringBuilder(map.size() * 10);
s.append(serverDate.formatShortDay(new Date()));
String h;
for (final Map.Entry<String, Integer> entry : map.entrySet()) {
@@ -292,7 +292,7 @@ public class plasmaWebStructure {
return null;
}
- private void learn(final yacyURL url, final StringBuffer reference /*string of b64(12digits)-hashes*/) {
+ private void learn(final yacyURL url, final StringBuilder reference /*string of b64(12digits)-hashes*/) {
final String domhash = url.hash().substring(6);
// parse the new reference string and join it with the stored references
diff --git a/source/de/anomic/server/logging/GuiHandler.java b/source/de/anomic/server/logging/GuiHandler.java
index ec00e7fd3..a5540237c 100644
--- a/source/de/anomic/server/logging/GuiHandler.java
+++ b/source/de/anomic/server/logging/GuiHandler.java
@@ -152,7 +152,7 @@ public class GuiHandler extends Handler{
if ((lineCount > this.count)||(lineCount < 0)) lineCount = this.count;
- final StringBuffer logMessages = new StringBuffer(this.count*40);
+ final StringBuilder logMessages = new StringBuilder(this.count*40);
final Formatter logFormatter = getFormatter();
try {
diff --git a/source/de/anomic/server/logging/serverLog.java b/source/de/anomic/server/logging/serverLog.java
index e311d7f61..87f40ba99 100644
--- a/source/de/anomic/server/logging/serverLog.java
+++ b/source/de/anomic/server/logging/serverLog.java
@@ -200,7 +200,7 @@ public final class serverLog {
public static final String format(final String s, int n, final int fillChar) {
final int l = s.length();
if (l >= n) return s;
- final StringBuffer sb = new StringBuffer(l + n);
+ final StringBuilder sb = new StringBuilder(l + n);
for (final int i = l + n; i > n; n--) sb.insert(0, fillChar);
return sb.toString();
}
@@ -209,7 +209,7 @@ public final class serverLog {
if (b == null) return "NULL";
if (b.length == 0) return "[]";
length = Math.min(length, b.length - start);
- final StringBuffer sb = new StringBuffer(b.length * 4);
+ final StringBuilder sb = new StringBuilder(b.length * 4);
sb.append('[').append(Integer.toString(b[start])).append(',');
for (int i = 1; i < length; i++) sb.append(' ').append(Integer.toString(b[start + i])).append(',');
sb.append(']');
@@ -219,7 +219,7 @@ public final class serverLog {
public static final String table(final byte[] b, final int linewidth, final int marker) {
if (b == null) return "NULL";
if (b.length == 0) return "[]";
- final StringBuffer sb = new StringBuffer(b.length * 4);
+ final StringBuilder sb = new StringBuilder(b.length * 4);
for (int i = 0; i < b.length; i++) {
if (i % linewidth == 0)
sb.append('\n').append("# ").append(Integer.toHexString(i)).append(": ");
diff --git a/source/de/anomic/server/logging/serverMiniLogFormatter.java b/source/de/anomic/server/logging/serverMiniLogFormatter.java
index 65a719ba5..2642614b3 100644
--- a/source/de/anomic/server/logging/serverMiniLogFormatter.java
+++ b/source/de/anomic/server/logging/serverMiniLogFormatter.java
@@ -30,7 +30,7 @@ import java.util.logging.SimpleFormatter;
public final class serverMiniLogFormatter extends SimpleFormatter {
- private final StringBuffer buffer = new StringBuffer();
+ private final StringBuilder buffer = new StringBuilder();
public serverMiniLogFormatter() {
super();
@@ -38,7 +38,7 @@ public final class serverMiniLogFormatter extends SimpleFormatter {
public synchronized String format(final LogRecord record) {
- final StringBuffer buffer = this.buffer;
+ final StringBuilder buffer = this.buffer;
buffer.setLength(0);
buffer.append(formatMessage(record));
diff --git a/source/de/anomic/server/serverCodings.java b/source/de/anomic/server/serverCodings.java
index 02a1eb2d4..4ba6152d2 100644
--- a/source/de/anomic/server/serverCodings.java
+++ b/source/de/anomic/server/serverCodings.java
@@ -61,7 +61,7 @@ public final class serverCodings {
public static String encodeOctal(final byte[] in) {
if (in == null) return "";
- final StringBuffer result = new StringBuffer(in.length * 8 / 3);
+ final StringBuilder result = new StringBuilder(in.length * 8 / 3);
for (int i = 0; i < in.length; i++) {
if ((0Xff & in[i]) < 8) result.append('0');
result.append(Integer.toOctalString(0Xff & in[i]));
@@ -71,7 +71,7 @@ public final class serverCodings {
public static String encodeHex(final byte[] in) {
if (in == null) return "";
- final StringBuffer result = new StringBuffer(in.length * 2);
+ final StringBuilder result = new StringBuilder(in.length * 2);
for (int i = 0; i < in.length; i++) {
if ((0Xff & in[i]) < 16) result.append('0');
result.append(Integer.toHexString(0Xff & in[i]));
@@ -281,7 +281,7 @@ public final class serverCodings {
public static String map2string(final Map<String, String> m, final String separator, final boolean braces) {
// m must be synchronized to prevent that a ConcurrentModificationException occurs
synchronized (m) {
- final StringBuffer buf = new StringBuffer(20 * m.size());
+ final StringBuilder buf = new StringBuilder(20 * m.size());
if (braces) { buf.append("{"); }
int retry = 10;
critical: while (retry > 0) {
@@ -320,7 +320,7 @@ public final class serverCodings {
}
public static String set2string(final Set<String> s, final String separator, final boolean braces) {
- final StringBuffer buf = new StringBuffer();
+ final StringBuilder buf = new StringBuilder();
if (braces) buf.append("{");
final Iterator<String> i = s.iterator();
boolean hasNext = i.hasNext();
diff --git a/source/de/anomic/server/serverDate.java b/source/de/anomic/server/serverDate.java
index 1ea6b0533..781a21194 100644
--- a/source/de/anomic/server/serverDate.java
+++ b/source/de/anomic/server/serverDate.java
@@ -372,7 +372,7 @@ public final class serverDate {
try {
final long mins = millis / 60000;
- final StringBuffer uptime = new StringBuffer();
+ final StringBuilder uptime = new StringBuilder();
final int uptimeDays = (int) (Math.floor(mins/1440.0));
final int uptimeHours = (int) (Math.floor(mins/60.0)%24);
diff --git a/source/de/anomic/server/serverMemory.java b/source/de/anomic/server/serverMemory.java
index 00cd0592a..25f374a89 100644
--- a/source/de/anomic/server/serverMemory.java
+++ b/source/de/anomic/server/serverMemory.java
@@ -183,7 +183,7 @@ public class serverMemory {
*/
public static String bytesToString(final long byteCount) {
try {
- final StringBuffer byteString = new StringBuffer();
+ final StringBuilder byteString = new StringBuilder();
if (byteCount > 1073741824) {
byteString.append(yFormatter.number((double)byteCount / (double)1073741824 ))
diff --git a/source/de/anomic/tools/Punycode.java b/source/de/anomic/tools/Punycode.java
index 4568d7359..8b3916729 100644
--- a/source/de/anomic/tools/Punycode.java
+++ b/source/de/anomic/tools/Punycode.java
@@ -48,7 +48,7 @@ public class Punycode
int n = INITIAL_N;
int delta = 0;
int bias = INITIAL_BIAS;
- final StringBuffer output = new StringBuffer();
+ final StringBuilder output = new StringBuilder();
// Copy all basic code points to the output
int b = 0;
@@ -136,7 +136,7 @@ public class Punycode
int n = INITIAL_N;
int i = 0;
int bias = INITIAL_BIAS;
- final StringBuffer output = new StringBuffer();
+ final StringBuilder output = new StringBuilder();
int d = input.lastIndexOf(DELIMITER);
if (d > 0) {
diff --git a/source/de/anomic/tools/bitfield.java b/source/de/anomic/tools/bitfield.java
index d02ea956e..625c14c34 100644
--- a/source/de/anomic/tools/bitfield.java
+++ b/source/de/anomic/tools/bitfield.java
@@ -79,7 +79,7 @@ public class bitfield {
public String toString() {
throw new UnsupportedOperationException("testing");
/*
- StringBuffer sb = new StringBuffer(length());
+ StringBuilder sb = new StringBuilder(length());
for (int i = length() - 1; i >= 0; i--) sb.append((get(i)) ? '1' : '0');
return sb.toString();
*/
diff --git a/source/de/anomic/xml/RSSReader.java b/source/de/anomic/xml/RSSReader.java
index 133f91b5d..1e9241003 100644
--- a/source/de/anomic/xml/RSSReader.java
+++ b/source/de/anomic/xml/RSSReader.java
@@ -44,13 +44,13 @@ public class RSSReader extends DefaultHandler {
// class variables
private RSSMessage item;
- private final StringBuffer buffer;
+ private final StringBuilder buffer;
private boolean parsingChannel, parsingImage, parsingItem;
private final RSSFeed theChannel;
public RSSReader() {
theChannel = new RSSFeed();
- buffer = new StringBuffer();
+ buffer = new StringBuilder();
item = null;
parsingChannel = false;
parsingImage = false;
diff --git a/source/de/anomic/xml/crawlHandler.java b/source/de/anomic/xml/crawlHandler.java
index c78429ce3..ab10b589b 100644
--- a/source/de/anomic/xml/crawlHandler.java
+++ b/source/de/anomic/xml/crawlHandler.java
@@ -63,7 +63,7 @@ public class crawlHandler extends DefaultHandler {
// class variables
private Startpoint channel, startpoint;
- private StringBuffer buffer;
+ private StringBuilder buffer;
private boolean parsingAttributes, parsingStartpoint;
private ArrayList<String> startpointsGUID; // a list of GUIDs, so the items can be retrieved by a specific order
private HashMap<String, Startpoint> startpoints; // a guid:Item map
@@ -82,7 +82,7 @@ public class crawlHandler extends DefaultHandler {
private void init() {
startpointsGUID = new ArrayList<String>();
startpoints = new HashMap<String, Startpoint>();
- buffer = new StringBuffer();
+ buffer = new StringBuilder();
startpoint = null;
channel = null;
parsingAttributes = false;
diff --git a/source/de/anomic/xml/opensearchdescriptionReader.java b/source/de/anomic/xml/opensearchdescriptionReader.java
index 625bd5a09..8390e8591 100644
--- a/source/de/anomic/xml/opensearchdescriptionReader.java
+++ b/source/de/anomic/xml/opensearchdescriptionReader.java
@@ -95,7 +95,7 @@ public class opensearchdescriptionReader extends DefaultHandler {
// class variables
private Item channel;
- private final StringBuffer buffer;
+ private final StringBuilder buffer;
private boolean parsingChannel;
private final String imageURL = null;
private final ArrayList<String> itemsGUID; // a list of GUIDs, so the items can be retrieved by a specific order
@@ -105,7 +105,7 @@ public class opensearchdescriptionReader extends DefaultHandler {
public opensearchdescriptionReader() {
itemsGUID = new ArrayList<String>();
items = new HashMap<String, Item>();
- buffer = new StringBuffer();
+ buffer = new StringBuilder();
channel = null;
parsingChannel = false;
}
diff --git a/source/de/anomic/yacy/seedUpload/yacySeedUploadScp.java b/source/de/anomic/yacy/seedUpload/yacySeedUploadScp.java
index fadad9681..d1f9f7be1 100644
--- a/source/de/anomic/yacy/seedUpload/yacySeedUploadScp.java
+++ b/source/de/anomic/yacy/seedUpload/yacySeedUploadScp.java
@@ -196,7 +196,7 @@ class sshc {
if(b==-1) return b;
if(b==1 || b==2){
- final StringBuffer sb=new StringBuffer();
+ final StringBuilder sb=new StringBuilder();
int c;
do {
c=in.read();
@@ -272,7 +272,7 @@ implements UserInfo, UIKeyboardInteractive {
}
String arrayToString2(final String[] a, final String separator) {
- final StringBuffer result = new StringBuffer();// start with first element
+ final StringBuilder result = new StringBuilder();// start with first element
if (a.length > 0) {
result.append(a[0]);
for (int i=1; i<a.length; i++) {
@@ -284,7 +284,7 @@ implements UserInfo, UIKeyboardInteractive {
}
String arrayToString2(final boolean[] a, final String separator) {
- final StringBuffer result = new StringBuffer();// start with first element
+ final StringBuilder result = new StringBuilder();// start with first element
if (a.length > 0) {
result.append(a[0]);
for (int i=1; i<a.length; i++) {
diff --git a/source/de/anomic/yacy/yacyClient.java b/source/de/anomic/yacy/yacyClient.java
index 5e9e2676f..a57be65fc 100644
--- a/source/de/anomic/yacy/yacyClient.java
+++ b/source/de/anomic/yacy/yacyClient.java
@@ -952,7 +952,7 @@ public final class yacyClient {
post.add(new DefaultCharsetStringPart("wordc", Integer.toString(indexes.length)));
int indexcount = 0;
- final StringBuffer entrypost = new StringBuffer(indexes.length*73);
+ final StringBuilder entrypost = new StringBuilder(indexes.length*73);
Iterator<indexRWIRowEntry> eenum;
indexRWIEntry entry;
for (int i = 0; i < indexes.length; i++) {
diff --git a/source/de/anomic/yacy/yacySearch.java b/source/de/anomic/yacy/yacySearch.java
index b049111a5..4eabd5c59 100644
--- a/source/de/anomic/yacy/yacySearch.java
+++ b/source/de/anomic/yacy/yacySearch.java
@@ -119,7 +119,7 @@ public class yacySearch extends Thread {
blacklist, rankingProfile, constraint);
if (urls != null) {
// urls is an array of url hashes. this is only used for log output
- final StringBuffer urllist = new StringBuffer(this.urls.length * 13);
+ final StringBuilder urllist = new StringBuilder(this.urls.length * 13);
for (int i = 0; i < this.urls.length; i++) urllist.append(this.urls[i]).append(' ');
yacyCore.log.logInfo("REMOTE SEARCH - remote peer " + targetPeer.hash + ":" + targetPeer.getName() + " contributed " + urls.length + " links for word hash " + wordhashes + ": " + new String(urllist));
wordIndex.seedDB.mySeed().incRI(urls.length);
diff --git a/source/de/anomic/yacy/yacyURL.java b/source/de/anomic/yacy/yacyURL.java
index f3156deb9..0752d1ced 100644
--- a/source/de/anomic/yacy/yacyURL.java
+++ b/source/de/anomic/yacy/yacyURL.java
@@ -356,7 +356,7 @@ public class yacyURL implements Serializable {
// from: http://www.w3.org/International/URLUTF8Encoder.java
public static String escape(final String s)
{
- final StringBuffer sbuf = new StringBuffer();
+ final StringBuilder sbuf = new StringBuilder();
final int len = s.length();
for (int i = 0; i < len; i++) {
final int ch = s.charAt(i);
@@ -391,7 +391,7 @@ public class yacyURL implements Serializable {
// from: http://www.w3.org/International/unescape.java
public static String unescape(final String s) {
- final StringBuffer sbuf = new StringBuffer();
+ final StringBuilder sbuf = new StringBuilder();
final int l = s.length();
int ch = -1;
int b, sumb = 0;