- more abstraction (HashMap -> Map)

- more concurrency-awareness (HashMap -> ConcurrentHashMap)

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6910 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 15 years ago
parent a83772c71b
commit 60e71876ad

@ -28,8 +28,8 @@
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import de.anomic.http.server.RequestHeader;
import de.anomic.search.Switchboard;
@ -68,7 +68,7 @@ public class MessageSend_p {
// open an editor page for the message
// first ask if the other peer is online, and also what kind of document it accepts
final HashMap<String, String> result = yacyClient.permissionMessage(sb.peers, hash);
final Map<String, String> result = yacyClient.permissionMessage(sb.peers, hash);
//System.out.println("DEBUG: permission request result = " + result.toString());
String peerName;
yacySeed targetPeer = null;
@ -132,7 +132,7 @@ public class MessageSend_p {
} catch (final UnsupportedEncodingException e) {
mb = message.getBytes();
}
final HashMap<String, String> result = yacyClient.postMessage(sb.peers, hash, subject, mb);
final Map<String, String> result = yacyClient.postMessage(sb.peers, hash, subject, mb);
//message has been sent
prop.put("mode_status_response", result.get("response"));

@ -73,7 +73,7 @@ public class ViewProfile {
prop.put("hash", hash);
// get the profile
HashMap profile = null;
Map profile = null;
if (hash.equals("localhash")) {
// read the profile from local peer
final Properties p = new Properties();

@ -24,7 +24,6 @@ package de.anomic.crawler;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
@ -49,7 +48,7 @@ public class CrawlProfile {
public static final String MATCH_NEVER = "";
public static final String MATCH_BAD_URL = ".*memberlist.*|.*previous.*|.*next.*|.*p=.*";
static HashMap<String, ConcurrentHashMap<String, DomProfile>> domsCache = new HashMap<String, ConcurrentHashMap<String, DomProfile>>();
static ConcurrentHashMap<String, Map<String, DomProfile>> domsCache = new ConcurrentHashMap<String, Map<String, DomProfile>>();
MapHeap profileTable;
private final File profileTableFile;
@ -282,8 +281,8 @@ public class CrawlProfile {
public static final String XPSTOPW = "xpstopw";
public static final String CACHE_STRAGEGY = "cacheStrategy";
Map<String, String> mem;
private ConcurrentHashMap<String, DomProfile> doms;
private Map<String, String> mem;
private Map<String, DomProfile> doms;
private Pattern mustmatch = null, mustnotmatch = null;
@ -301,7 +300,7 @@ public class CrawlProfile {
final CacheStrategy cacheStrategy) {
if (name == null || name.length() == 0) throw new NullPointerException("name must not be null");
final String handle = (startURL == null) ? Base64Order.enhancedCoder.encode(Digest.encodeMD5Raw(name)).substring(0, Word.commonHashLength) : new String(startURL.hash());
mem = new HashMap<String, String>(40);
mem = new ConcurrentHashMap<String, String>(40);
mem.put(HANDLE, handle);
mem.put(NAME, name);
mem.put(START_URL, (startURL == null) ? "" : startURL.toNormalform(true, false));

@ -27,10 +27,10 @@ package de.anomic.crawler;
import java.net.MalformedURLException;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import net.yacy.kelondro.data.meta.DigestURI;
import net.yacy.kelondro.data.meta.URIMetadataRow;
@ -43,7 +43,7 @@ import de.anomic.crawler.retrieval.EventOrigin;
public final class ResultURLs {
private final Map<EventOrigin, LinkedHashMap<String, InitExecEntry>> resultStacks; // a mapping from urlHash to Entries
private final Map<EventOrigin, Map<String, InitExecEntry>> resultStacks; // a mapping from urlHash to Entries
private final Map<EventOrigin, ScoreCluster<String>> resultDomains;
public class InitExecEntry {
@ -56,8 +56,8 @@ public final class ResultURLs {
public ResultURLs(int initialStackCapacity) {
// init result stacks
resultStacks = new HashMap<EventOrigin, LinkedHashMap<String, InitExecEntry>>(initialStackCapacity);
resultDomains = new HashMap<EventOrigin, ScoreCluster<String>>(initialStackCapacity);
resultStacks = new ConcurrentHashMap<EventOrigin, Map<String, InitExecEntry>>(initialStackCapacity);
resultDomains = new ConcurrentHashMap<EventOrigin, ScoreCluster<String>>(initialStackCapacity);
for (EventOrigin origin: EventOrigin.values()) {
resultStacks.put(origin, new LinkedHashMap<String, InitExecEntry>());
resultDomains.put(origin, new ScoreCluster<String>());
@ -73,7 +73,7 @@ public final class ResultURLs {
assert executorHash != null;
if (e == null) { return; }
try {
final LinkedHashMap<String, InitExecEntry> resultStack = getStack(stackType);
final Map<String, InitExecEntry> resultStack = getStack(stackType);
if (resultStack != null) {
resultStack.put(new String(e.hash()), new InitExecEntry(initiatorHash, executorHash));
}
@ -92,20 +92,20 @@ public final class ResultURLs {
}
}
public synchronized int getStackSize(final EventOrigin stack) {
final LinkedHashMap<String, InitExecEntry> resultStack = getStack(stack);
public int getStackSize(final EventOrigin stack) {
final Map<String, InitExecEntry> resultStack = getStack(stack);
if (resultStack == null) return 0;
return resultStack.size();
}
public synchronized int getDomainListSize(final EventOrigin stack) {
public int getDomainListSize(final EventOrigin stack) {
final ScoreCluster<String> domains = getDomains(stack);
if (domains == null) return 0;
return domains.size();
}
public synchronized Iterator<Map.Entry<String, InitExecEntry>> results(final EventOrigin stack) {
final LinkedHashMap<String, InitExecEntry> resultStack = getStack(stack);
public Iterator<Map.Entry<String, InitExecEntry>> results(final EventOrigin stack) {
final Map<String, InitExecEntry> resultStack = getStack(stack);
if (resultStack == null) return new LinkedHashMap<String, InitExecEntry>().entrySet().iterator();
return new ReverseMapIterator<String, InitExecEntry>(resultStack);
}
@ -152,7 +152,7 @@ public final class ResultURLs {
* @param stack id of resultStack
* @return null if stack does not exist (id is unknown or stack is null (which should not occur and an error is logged))
*/
private LinkedHashMap<String, InitExecEntry> getStack(final EventOrigin stack) {
private Map<String, InitExecEntry> getStack(final EventOrigin stack) {
return resultStacks.get(stack);
}
private ScoreCluster<String> getDomains(final EventOrigin stack) {
@ -160,7 +160,7 @@ public final class ResultURLs {
}
public synchronized void clearStack(final EventOrigin stack) {
final LinkedHashMap<String, InitExecEntry> resultStack = getStack(stack);
final Map<String, InitExecEntry> resultStack = getStack(stack);
if (resultStack != null) resultStack.clear();
final ScoreCluster<String> resultDomains = getDomains(stack);
if (resultDomains != null) {
@ -172,7 +172,7 @@ public final class ResultURLs {
public synchronized boolean remove(final String urlHash) {
if (urlHash == null) return false;
LinkedHashMap<String, InitExecEntry> resultStack;
Map<String, InitExecEntry> resultStack;
for (EventOrigin origin: EventOrigin.values()) {
resultStack = getStack(origin);
if (resultStack != null) resultStack.remove(urlHash);

@ -73,7 +73,6 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URLDecoder;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
@ -353,7 +352,7 @@ public final class HTTPDFileHandler {
if ((requestHeader.containsKey(HeaderFramework.CONTENT_TYPE)) &&
(requestHeader.get(HeaderFramework.CONTENT_TYPE).toLowerCase().startsWith("multipart"))) {
// parse multipart
final HashMap<String, byte[]> files = HTTPDemon.parseMultipart(requestHeader, args, body);
final Map<String, byte[]> files = HTTPDemon.parseMultipart(requestHeader, args, body);
// integrate these files into the args
if (files != null) {
final Iterator<Map.Entry<String, byte[]>> fit = files.entrySet().iterator();

@ -47,6 +47,7 @@ import java.util.Map;
import java.util.Properties;
import java.util.StringTokenizer;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.zip.GZIPInputStream;
import net.yacy.document.parser.html.CharacterCoding;
@ -119,13 +120,13 @@ public final class HTTPDemon implements serverHandler, Cloneable {
public static final String copyright = "[ HTTP SERVER: AnomicHTTPD v" + vDATE + " by Michael Christen / www.anomic.de ]";
public static final String hline = "-------------------------------------------------------------------------------";
public static final HashMap<String, String> reverseMappingCache = new HashMap<String, String>();
public static final Map<String, String> reverseMappingCache = new ConcurrentHashMap<String, String>();
private static volatile Switchboard switchboard = null;
private static String virtualHost = null;
public static boolean keepAliveSupport = false;
private static HashMap<String, Long> YaCyHopAccessRequester = new HashMap<String, Long>();
private static HashMap<String, Long> YaCyHopAccessTargets = new HashMap<String, Long>();
private static Map<String, Long> YaCyHopAccessRequester = new ConcurrentHashMap<String, Long>();
private static Map<String, Long> YaCyHopAccessTargets = new ConcurrentHashMap<String, Long>();
// for authentication
private boolean use_proxyAccounts = false;
@ -310,7 +311,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
return true;
}
private static long lastAccessDelta(final HashMap<String, Long> accessTable, final String domain) {
private static long lastAccessDelta(final Map<String, Long> accessTable, final String domain) {
final Long lastAccess = accessTable.get(domain);
if (lastAccess == null) return Long.MAX_VALUE; // never accessed
return System.currentTimeMillis() - lastAccess.longValue();
@ -798,7 +799,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
* @throws IOException
*/
@SuppressWarnings("unchecked")
public static HashMap<String, byte[]> parseMultipart(final RequestHeader header, final serverObjects args, final InputStream in)
public static Map<String, byte[]> parseMultipart(final RequestHeader header, final serverObjects args, final InputStream in)
throws IOException {
final InputStream body = prepareBody(header, in);

@ -42,13 +42,13 @@ import java.io.IOException;
import java.net.MalformedURLException;
import java.text.Collator;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.TreeMap;
import java.util.Vector;
import java.util.concurrent.ConcurrentHashMap;
import net.yacy.kelondro.data.meta.DigestURI;
import net.yacy.kelondro.util.DateFormatter;
@ -132,8 +132,8 @@ public class HeaderFramework extends TreeMap<String, String> implements Map<Stri
/* =============================================================
* defining default http status messages
* ============================================================= */
public static final HashMap<String, String> http0_9 = new HashMap<String, String>();
public static final HashMap<String, String> http1_0 = new HashMap<String, String>();
public static final Map<String, String> http0_9 = new ConcurrentHashMap<String, String>();
public static final Map<String, String> http1_0 = new ConcurrentHashMap<String, String>();
static {
http1_0.putAll(http0_9);
http1_0.put("200","OK");
@ -153,7 +153,7 @@ public class HeaderFramework extends TreeMap<String, String> implements Map<Stri
http1_0.put("502","Bad Gateway");
http1_0.put("503","Service Unavailable");
}
public static final HashMap<String, String> http1_1 = new HashMap<String, String>();
public static final Map<String, String> http1_1 = new ConcurrentHashMap<String, String>();
static {
http1_1.putAll(http1_0);
http1_1.put("100","Continue");
@ -211,7 +211,7 @@ public class HeaderFramework extends TreeMap<String, String> implements Map<Stri
public static final String CONNECTION_PROP_PROXY_RESPOND_HEADER = "PROXY_RESPOND_HEADER";
public static final String CONNECTION_PROP_PROXY_RESPOND_SIZE = "PROXY_REQUEST_SIZE";
private final HashMap<String, String> reverseMappingCache;
private final Map<String, String> reverseMappingCache;
private static final Collator insensitiveCollator = Collator.getInstance(Locale.US);
@ -224,7 +224,7 @@ public class HeaderFramework extends TreeMap<String, String> implements Map<Stri
this(null);
}
public HeaderFramework(final HashMap<String, String> reverseMappingCache) {
public HeaderFramework(final Map<String, String> reverseMappingCache) {
// this creates a new TreeMap with a case insensitive mapping
// to provide a put-method that translates given keys into their
// 'proper' appearance, a translation cache is needed.
@ -234,7 +234,7 @@ public class HeaderFramework extends TreeMap<String, String> implements Map<Stri
this.reverseMappingCache = reverseMappingCache;
}
public HeaderFramework(final HashMap<String, String> reverseMappingCache, final Map<String, String> othermap) {
public HeaderFramework(final Map<String, String> reverseMappingCache, final Map<String, String> othermap) {
// creates a case insensitive map from another map
super((Collator) insensitiveCollator.clone());
this.reverseMappingCache = reverseMappingCache;

@ -26,7 +26,6 @@ package de.anomic.http.server;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.regex.Pattern;
@ -77,11 +76,11 @@ public class RequestHeader extends HeaderFramework {
super();
}
public RequestHeader(final HashMap<String, String> reverseMappingCache) {
public RequestHeader(final Map<String, String> reverseMappingCache) {
super(reverseMappingCache);
}
public RequestHeader(final HashMap<String, String> reverseMappingCache, final Map<String, String> othermap) {
public RequestHeader(final Map<String, String> reverseMappingCache, final Map<String, String> othermap) {
super(reverseMappingCache, othermap);
}

@ -57,6 +57,7 @@ import java.io.OutputStream;
import java.io.PushbackInputStream;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;
import net.yacy.kelondro.logging.Log;
import net.yacy.kelondro.util.ByteBuffer;
@ -181,7 +182,7 @@ public final class TemplateEngine {
return false;
}
public final static void writeTemplate(final InputStream in, final OutputStream out, final HashMap<String, String> pattern, final byte[] dflt) throws IOException {
public final static void writeTemplate(final InputStream in, final OutputStream out, final Map<String, String> pattern, final byte[] dflt) throws IOException {
if (pattern == null) {
FileUtils.copy(in, out);
} else {
@ -192,7 +193,7 @@ public final class TemplateEngine {
/**
* Reads a input stream, and writes the data with replaced templates on a output stream
*/
private final static byte[] writeTemplate(final InputStream in, final OutputStream out, final HashMap<String, String> pattern, final byte[] dflt, final byte[] prefix) throws IOException {
private final static byte[] writeTemplate(final InputStream in, final OutputStream out, final Map<String, String> pattern, final byte[] dflt, final byte[] prefix) throws IOException {
final PushbackInputStream pis = new PushbackInputStream(in, 100);
ByteArrayOutputStream keyStream = new ByteArrayOutputStream(512);
byte[] key;
@ -415,7 +416,7 @@ public final class TemplateEngine {
return structure.getBytes();
}
private final static byte[] replacePattern(final String key, final HashMap<String, String> pattern, final byte dflt[]) {
private final static byte[] replacePattern(final String key, final Map<String, String> pattern, final byte dflt[]) {
byte[] replacement;
Object value;
if (pattern.containsKey(key)) {
@ -496,7 +497,7 @@ public final class TemplateEngine {
// arg1 = test input; arg2 = replacement for pattern 'test'; arg3 = default replacement
try {
final InputStream i = new ByteArrayInputStream(args[0].getBytes("UTF-8"));
final HashMap<String, String> h = new HashMap<String, String>();
final Map<String, String> h = new HashMap<String, String>();
h.put("test", args[1]);
writeTemplate(new PushbackInputStream(i, 100), System.out, h, args[2].getBytes("UTF-8"));
System.out.flush();

@ -558,8 +558,8 @@ public final class MetadataRepository implements Iterable<byte[]> {
}
private HashMap<String, hashStat> domainSampleCollector() throws IOException {
HashMap<String, hashStat> map = new HashMap<String, hashStat>();
private Map<String, hashStat> domainSampleCollector() throws IOException {
Map<String, hashStat> map = new HashMap<String, hashStat>();
// first collect all domains and calculate statistics about it
CloneableIterator<byte[]> i = this.urlIndexFile.keys(true, null);
String urlhash, hosthash;
@ -580,7 +580,7 @@ public final class MetadataRepository implements Iterable<byte[]> {
public TreeSet<String> domainNameCollector(int count) throws IOException {
// collect hashes from all domains
HashMap<String, hashStat> map = domainSampleCollector();
Map<String, hashStat> map = domainSampleCollector();
// fetch urls from the database to determine the host in clear text
URIMetadataRow urlref;
@ -603,7 +603,7 @@ public final class MetadataRepository implements Iterable<byte[]> {
if (statsDump != null && count <= statsDump.size()) return statsDump.iterator();
// collect hashes from all domains
HashMap<String, hashStat> map = domainSampleCollector();
Map<String, hashStat> map = domainSampleCollector();
// order elements by size
ScoreCluster<String> s = new ScoreCluster<String>();

@ -123,7 +123,7 @@ public class RankingProfile {
this(ContentDomain.TEXT); // set defaults
if ((profile != null) && (profile.length() > 0)) {
//parse external form
final HashMap<String, Integer> coeff = new HashMap<String, Integer>(40);
final Map<String, Integer> coeff = new HashMap<String, Integer>(40);
final String[] elts;
if (profile.length() > 0 && profile.charAt(0) == '{' && profile.endsWith("}")) {
profile = profile.substring(1, profile.length() - 1);
@ -182,7 +182,7 @@ public class RankingProfile {
}
}
private static int parseMap(final HashMap<String, Integer> coeff, final String attr, final int dflt) {
private static int parseMap(final Map<String, Integer> coeff, final String attr, final int dflt) {
if (!coeff.containsKey(attr))
return dflt;
return (coeff.get(attr)).intValue();

@ -132,7 +132,7 @@ public class ReferenceOrder {
public void run() {
HashMap<String, Integer> doms0 = new HashMap<String, Integer>();
Map<String, Integer> doms0 = new HashMap<String, Integer>();
Integer int1 = 1;
WordReferenceVars iEntry;

@ -31,6 +31,7 @@ import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import net.yacy.document.Condenser;
import net.yacy.document.Document;
@ -68,7 +69,7 @@ public class Segments implements Iterable<Segment> {
private final File segmentsPath;
private final int entityCacheMaxSize;
private final long maxFileSize;
private HashMap<String, Segment> segments;
private Map<String, Segment> segments;
private final HashMap<Process, String> process_assignment;
private final boolean useTailCache;
private final boolean exceed134217727;

@ -208,7 +208,7 @@ public final class Switchboard extends serverSwitch {
public boolean rankingOn;
public CRDistribution rankingOwnDistribution;
public CRDistribution rankingOtherDistribution;
public HashMap<String, Object[]> outgoingCookies, incomingCookies;
public Map<String, Object[]> outgoingCookies, incomingCookies;
public volatile long proxyLastAccess, localSearchLastAccess, remoteSearchLastAccess;
public yacyCore yc;
public ResourceObserver observer;
@ -510,8 +510,8 @@ public final class Switchboard extends serverSwitch {
// init cookie-Monitor
this.log.logConfig("Starting Cookie Monitor");
this.outgoingCookies = new HashMap<String, Object[]>();
this.incomingCookies = new HashMap<String, Object[]>();
this.outgoingCookies = new ConcurrentHashMap<String, Object[]>();
this.incomingCookies = new ConcurrentHashMap<String, Object[]>();
// init search history trackers
this.localSearchTracker = new ConcurrentHashMap<String, TreeSet<Long>>(); // String:TreeSet - IP:set of Long(accessTime)
@ -735,7 +735,7 @@ public final class Switchboard extends serverSwitch {
netload: for (String netdef: netdefs) {
netdef = netdef.trim();
try {
netdefmap = Switchboard.loadHashMap(new DigestURI(netdef, null));
netdefmap = Switchboard.loadFileAsMap(new DigestURI(netdef, null));
if (netdefmap == null || netdefmap.size() == 0) continue netload;
setConfig(netdefmap);
break netload;
@ -750,7 +750,7 @@ public final class Switchboard extends serverSwitch {
}
if (networkGroupDefinition.startsWith("http://")) {
try {
setConfig(Switchboard.loadHashMap(new DigestURI(networkGroupDefinition, null)));
setConfig(Switchboard.loadFileAsMap(new DigestURI(networkGroupDefinition, null)));
} catch (final MalformedURLException e) { }
} else {
final File networkGroupDefinitionFile = new File(getRootPath(), networkGroupDefinition);
@ -2314,12 +2314,16 @@ public final class Switchboard extends serverSwitch {
* @param url
* @return
*/
public static Map<String, String> loadHashMap(final DigestURI url) {
/**
* @param url
* @return
*/
public static Map<String, String> loadFileAsMap(final DigestURI url) {
try {
// sending request
final RequestHeader reqHeader = new RequestHeader();
reqHeader.put(HeaderFramework.USER_AGENT, HTTPLoader.yacyUserAgent);
final HashMap<String, String> result = FileUtils.table(Client.wget(url.toString(), reqHeader, 10000));
final Map<String, String> result = FileUtils.table(Client.wget(url.toString(), reqHeader, 10000));
if (result == null) return new HashMap<String, String>();
return result;
} catch (final Exception e) {

@ -20,7 +20,6 @@
package de.anomic.server;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@ -151,7 +150,7 @@ public class serverAccessTracker {
public Iterator<String> accessHosts() {
// returns an iterator of hosts in tracker (String)
final HashMap<String, List<Track>> accessTrackerClone = new HashMap<String, List<Track>>();
final Map<String, List<Track>> accessTrackerClone = new ConcurrentHashMap<String, List<Track>>();
accessTrackerClone.putAll(accessTracker);
return accessTrackerClone.keySet().iterator();
}

@ -23,7 +23,8 @@ package de.anomic.server;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import net.yacy.kelondro.util.FileUtils;
@ -32,17 +33,17 @@ public final class serverClassLoader extends ClassLoader {
/**
* directory of class files
*/
private final HashMap<File, Class<?>> classes;
private final Map<File, Class<?>> classes;
public serverClassLoader() {
//super(ClassLoader.getSystemClassLoader());
super(Thread.currentThread().getContextClassLoader());
this.classes = new HashMap<File, Class<?>>(100);
this.classes = new ConcurrentHashMap<File, Class<?>>(100);
}
public serverClassLoader(final ClassLoader parent) {
super(parent);
classes = new HashMap<File, Class<?>>(100);
classes = new ConcurrentHashMap<File, Class<?>>(100);
}
public Package[] packages() {

@ -47,8 +47,8 @@ import java.security.KeyStore;
import java.util.ArrayList;
import java.util.ConcurrentModificationException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.net.ssl.HandshakeCompletedEvent;
@ -88,13 +88,13 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {
/**
* Line End of HTTP/ICAP headers
*/
public static final byte[] CRLF = {CR, LF};
public static final String CRLF_STRING = new String(CRLF);
public static final String LF_STRING = new String(new byte[]{LF});
public static final Class<?>[] sessionCallType = {String.class, Session.class}; // set up some reflection
public static final long startupTime = System.currentTimeMillis();
static final ThreadGroup sessionThreadGroup = new ThreadGroup("sessionThreadGroup");
static final HashMap<String, Object> commandObjMethodCache = new HashMap<String, Object>(5);
public static final byte[] CRLF = {CR, LF};
public static final String CRLF_STRING = new String(CRLF);
public static final String LF_STRING = new String(new byte[]{LF});
public static final Class<?>[] sessionCallType = {String.class, Session.class}; // set up some reflection
public static final long startupTime = System.currentTimeMillis();
private static final ThreadGroup sessionThreadGroup = new ThreadGroup("sessionThreadGroup");
private static final Map<String, Object> commandObjMethodCache = new ConcurrentHashMap<String, Object>(5);
/**
* will be increased with each session and is used to return a hash code
@ -102,14 +102,14 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {
static int sessionCounter = 0;
// static variables
private static final long keepAliveTimeout = 60000; // time that a connection is kept alive if requested with a keepAlive statement
public static final Boolean TERMINATE_CONNECTION = Boolean.FALSE;
public static final Boolean RESUME_CONNECTION = Boolean.TRUE;
private static final long keepAliveTimeout = 60000; // time that a connection is kept alive if requested with a keepAlive statement
public static final Boolean TERMINATE_CONNECTION = Boolean.FALSE;
public static final Boolean RESUME_CONNECTION = Boolean.TRUE;
/**
* for brute-force prevention
*/
public static final ConcurrentHashMap<String, Integer> bfHost = new ConcurrentHashMap<String, Integer>();
public static final Map<String, Integer> bfHost = new ConcurrentHashMap<String, Integer>();
// class variables
/**
@ -133,7 +133,7 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {
serverHandler handlerPrototype; // the command class (a serverHandler)
private final serverSwitch switchboard; // the command class switchboard
HashMap<String, String> denyHost;
private Map<String, String> denyHost;
int commandMaxLength;
private int maxBusySessions;
private long lastAutoTermination;
@ -185,7 +185,7 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {
this.timeout = timeout;
this.commandMaxLength = commandMaxLength;
this.denyHost = (blockAttack) ? new HashMap<String, String>() : null;
this.denyHost = (blockAttack) ? new ConcurrentHashMap<String, String>() : null;
this.handlerPrototype = handlerPrototype;
this.switchboard = switchboard;

@ -25,11 +25,11 @@ import java.io.File;
import java.io.IOException;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
import net.yacy.kelondro.logging.Log;
import net.yacy.kelondro.util.Domains;
@ -51,8 +51,8 @@ public class serverSwitch {
protected int serverJobs;
private Map<String, String> configProps;
private final Map<String, String> configRemoved;
private final HashMap<InetAddress, String> authorization;
private final TreeMap<String, BusyThread> workerThreads;
private final Map<InetAddress, String> authorization;
private final TreeMap<String, BusyThread> workerThreads;
private final TreeMap<String, serverSwitchAction> switchActions;
private final serverAccessTracker accessTracker;
@ -75,7 +75,7 @@ public class serverSwitch {
if (initFile.exists())
initProps = FileUtils.loadMap(initFile);
else
initProps = new HashMap<String, String>();
initProps = new ConcurrentHashMap<String, String>();
// if 'pro'-version is selected, overload standard settings with 'pro'-settings
Iterator<String> i;
@ -94,10 +94,10 @@ public class serverSwitch {
if (configFile.exists())
configProps = FileUtils.loadMap(configFile);
else
configProps = new HashMap<String, String>();
configProps = new ConcurrentHashMap<String, String>();
// remove all values from config that do not appear in init
configRemoved = new HashMap<String, String>();
configRemoved = new ConcurrentHashMap<String, String>();
synchronized (configProps) {
i = configProps.keySet().iterator();
String key;
@ -124,7 +124,7 @@ public class serverSwitch {
}
// other settings
authorization = new HashMap<InetAddress, String>();
authorization = new ConcurrentHashMap<InetAddress, String>();
// init thread control
workerThreads = new TreeMap<String, BusyThread>();

@ -28,8 +28,8 @@ package de.anomic.yacy.dht;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import net.yacy.kelondro.data.meta.URIMetadataRow;
import net.yacy.kelondro.data.word.WordReference;
@ -105,7 +105,7 @@ public class Dispatcher {
final boolean gzipBody,
final int timeout
) {
this.transmissionCloud = new LinkedHashMap<ByteArray, Transmission.Chunk>();
this.transmissionCloud = new ConcurrentHashMap<ByteArray, Transmission.Chunk>();
this.segment = segment;
this.seeds = seeds;
this.log = new Log("INDEX-TRANSFER-DISPATCHER");
@ -318,7 +318,7 @@ public class Dispatcher {
}
}
public synchronized boolean selectContainersEnqueueToCloud(
public boolean selectContainersEnqueueToCloud(
final byte[] hash,
final byte[] limitHash,
final int maxContainerCount,

@ -27,6 +27,7 @@ package de.anomic.yacy.dht;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import net.yacy.kelondro.data.word.Word;
import net.yacy.kelondro.index.HandleSet;
@ -333,7 +334,7 @@ public class PeerSelection {
* @param count number of wanted peers
* @return a hash map of peer hashes to seed object
*/
public static HashMap<String, yacySeed> seedsByAge(yacySeedDB seedDB, final boolean up, int count) {
public static Map<String, yacySeed> seedsByAge(yacySeedDB seedDB, final boolean up, int count) {
if (count > seedDB.sizeConnected()) count = seedDB.sizeConnected();
@ -354,7 +355,7 @@ public class PeerSelection {
}
// result is now in the score object; create a result vector
final HashMap<String, yacySeed> result = new HashMap<String, yacySeed>();
final Map<String, yacySeed> result = new HashMap<String, yacySeed>();
final Iterator<String> it = seedScore.scores(up);
int c = 0;
while ((c < count) && (it.hasNext())) {

@ -137,7 +137,7 @@ public final class yacyClient {
*/
public static int publishMySeed(final yacySeed mySeed, final yacyPeerActions peerActions, final String address, final String otherHash) {
HashMap<String, String> result = null;
Map<String, String> result = null;
final String salt = crypt.randomSalt();
final List<Part> post = yacyNetwork.basicRequestPost(Switchboard.getSwitchboard(), null, salt);
for (int retry = 0; retry < 4; retry++) try {
@ -259,7 +259,7 @@ public final class yacyClient {
// send request
try {
final byte[] content = postToFile(target, "query.html", post, 10000);
final HashMap<String, String> result = FileUtils.table(content);
final Map<String, String> result = FileUtils.table(content);
if (result == null || result.isEmpty()) { return null; }
//final Date remoteTime = yacyCore.parseUniversalDate((String) result.get(yacySeed.MYTIME)); // read remote time
@ -281,7 +281,7 @@ public final class yacyClient {
// send request
try {
final byte[] content = postToFile(target, "query.html", post, 5000);
final HashMap<String, String> result = FileUtils.table(content);
final Map<String, String> result = FileUtils.table(content);
if (result == null || result.isEmpty()) { return -1; }
return Integer.parseInt(result.get("response"));
@ -304,7 +304,7 @@ public final class yacyClient {
// send request
try {
final byte[] content = postToFile(target, "query.html", post, 5000);
final HashMap<String, String> result = FileUtils.table(content);
final Map<String, String> result = FileUtils.table(content);
if (result == null || result.isEmpty()) return -1;
final String resp = result.get("response");
@ -432,7 +432,7 @@ public final class yacyClient {
final long timestamp = System.currentTimeMillis();
// send request
HashMap<String, String> result = null;
Map<String, String> result = null;
try {
result = FileUtils.table(HttpConnector.wput("http://" + target.getClusterAddress() + "/yacy/search.html", target.getHexHash() + ".yacyh", post, 60000));
} catch (final IOException e) {
@ -631,7 +631,7 @@ public final class yacyClient {
return urls;
}
public static HashMap<String, String> permissionMessage(final yacySeedDB seedDB, final String targetHash) {
public static Map<String, String> permissionMessage(final yacySeedDB seedDB, final String targetHash) {
// ask for allowed message size and attachement size
// if this replies null, the peer does not answer
@ -643,7 +643,7 @@ public final class yacyClient {
// send request
try {
final byte[] content = postToFile(seedDB, targetHash, "message.html", post, 5000);
final HashMap<String, String> result = FileUtils.table(content);
final Map<String, String> result = FileUtils.table(content);
return result;
} catch (final Exception e) {
// most probably a network time-out exception
@ -652,7 +652,7 @@ public final class yacyClient {
}
}
public static HashMap<String, String> postMessage(final yacySeedDB seedDB, final String targetHash, final String subject, final byte[] message) {
public static Map<String, String> postMessage(final yacySeedDB seedDB, final String targetHash, final String subject, final byte[] message) {
// this post a message to the remote message board
// prepare request
@ -670,7 +670,7 @@ public final class yacyClient {
// send request
try {
final byte[] content = postToFile(seedDB, targetHash, "message.html", post, 20000);
final HashMap<String, String> result = FileUtils.table(content);
final Map<String, String> result = FileUtils.table(content);
return result;
} catch (final Exception e) {
yacyCore.log.logSevere("yacyClient.postMessage error:" + e.getMessage());
@ -692,7 +692,7 @@ public final class yacyClient {
return address;
}
public static HashMap<String, String> transferPermission(final String targetAddress, final long filesize, final String filename) {
public static Map<String, String> transferPermission(final String targetAddress, final long filesize, final String filename) {
// prepare request
final String salt = crypt.randomSalt();
@ -706,7 +706,7 @@ public final class yacyClient {
// send request
try {
final byte[] content = HttpConnector.wput("http://" + targetAddress + "/yacy/transfer.html", targetAddress, post, 10000);
final HashMap<String, String> result = FileUtils.table(content);
final Map<String, String> result = FileUtils.table(content);
return result;
} catch (final Exception e) {
// most probably a network time-out exception
@ -715,7 +715,7 @@ public final class yacyClient {
}
}
public static HashMap<String, String> transferStore(final String targetAddress, final String access, final String filename, final byte[] file) {
public static Map<String, String> transferStore(final String targetAddress, final String access, final String filename, final byte[] file) {
// prepare request
final String salt = crypt.randomSalt();
@ -730,7 +730,7 @@ public final class yacyClient {
// send request
try {
final byte[] content = HttpConnector.wput("http://" + targetAddress + "/yacy/transfer.html", targetAddress, post, 20000);
final HashMap<String, String> result = FileUtils.table(content);
final Map<String, String> result = FileUtils.table(content);
return result;
} catch (final Exception e) {
yacyCore.log.logSevere("yacyClient.postMessage error:" + e.getMessage());
@ -739,7 +739,7 @@ public final class yacyClient {
}
public static String transfer(final String targetAddress, final String filename, final byte[] file) {
final HashMap<String, String> phase1 = transferPermission(targetAddress, file.length, filename);
final Map<String, String> phase1 = transferPermission(targetAddress, file.length, filename);
if (phase1 == null) return "no connection to remote address " + targetAddress + "; phase 1";
final String access = phase1.get("access");
final String nextaddress = phase1.get("address");
@ -751,7 +751,7 @@ public final class yacyClient {
if (!(response.equals("ok"))) return "remote peer rejected transfer: " + response;
final String accesscode = Digest.encodeMD5Hex(Base64Order.standardCoder.encodeString(access));
if (protocol.equals("http")) {
final HashMap<String, String> phase2 = transferStore(nextaddress, accesscode, filename, file);
final Map<String, String> phase2 = transferStore(nextaddress, accesscode, filename, file);
if (phase2 == null) return "no connection to remote address " + targetAddress + "; phase 2";
response = phase2.get("response");
if (response == null) return "wrong return values from other peer; phase 2";
@ -763,7 +763,7 @@ public final class yacyClient {
return "wrong protocol: " + protocol;
}
public static HashMap<String, String> crawlReceipt(final yacySeed mySeed, final yacySeed target, final String process, final String result, final String reason, final URIMetadataRow entry, final String wordhashes) {
public static Map<String, String> crawlReceipt(final yacySeed mySeed, final yacySeed target, final String process, final String result, final String reason, final URIMetadataRow entry, final String wordhashes) {
assert (target != null);
assert (mySeed != null);
assert (mySeed != target);
@ -830,7 +830,7 @@ public final class yacyClient {
final boolean gzipBody,
final int timeout) {
final HashMap<String, Object> resultObj = new HashMap<String, Object>();
final Map<String, Object> resultObj = new HashMap<String, Object>();
int payloadSize = 0;
try {
@ -848,7 +848,7 @@ public final class yacyClient {
}
// transfer the RWI without the URLs
HashMap<String, String> in = transferRWI(targetSeed, indexes, gzipBody, timeout);
Map<String, String> in = transferRWI(targetSeed, indexes, gzipBody, timeout);
resultObj.put("resultTransferRWI", in);
if (in == null) {
@ -910,7 +910,7 @@ public final class yacyClient {
}
}
private static HashMap<String, String> transferRWI(
private static Map<String, String> transferRWI(
final yacySeed targetSeed,
final ReferenceContainerCache<WordReference> indexes,
boolean gzipBody,
@ -958,7 +958,7 @@ public final class yacyClient {
final Iterator<String> v = FileUtils.strings(content);
// this should return a list of urlhashes that are unknown
final HashMap<String, String> result = FileUtils.table(v);
final Map<String, String> result = FileUtils.table(v);
// return the transfered index data in bytes (for debugging only)
result.put("indexPayloadSize", Integer.toString(entrypost.length()));
return result;
@ -968,7 +968,7 @@ public final class yacyClient {
}
}
private static HashMap<String, String> transferURL(final yacySeed targetSeed, final URIMetadataRow[] urls, boolean gzipBody, final int timeout) {
private static Map<String, String> transferURL(final yacySeed targetSeed, final URIMetadataRow[] urls, boolean gzipBody, final int timeout) {
// this post a message to the remote message board
final String address = targetSeed.getPublicAddress();
if (address == null) { return null; }
@ -1001,7 +1001,7 @@ public final class yacyClient {
final byte[] content = HttpConnector.wput("http://" + address + "/yacy/transferURL.html", targetSeed.getHexHash() + ".yacyh", post, timeout, gzipBody);
final Iterator<String> v = FileUtils.strings(content);
final HashMap<String, String> result = FileUtils.table(v);
final Map<String, String> result = FileUtils.table(v);
// return the transfered url data in bytes (for debugging only)
result.put("urlPayloadSize", Integer.toString(urlPayloadSize));
return result;
@ -1011,7 +1011,7 @@ public final class yacyClient {
}
}
public static HashMap<String, String> getProfile(final yacySeed targetSeed) {
public static Map<String, String> getProfile(final yacySeed targetSeed) {
// this post a message to the remote message board
final String salt = crypt.randomSalt();
@ -1052,7 +1052,7 @@ public final class yacyClient {
"&query=" + new String(wordhashe) +
"&network.unit.name=" + Switchboard.getSwitchboard().getConfig(SwitchboardConstants.NETWORK_NAME, yacySeed.DFLT_NETWORK_UNIT),
reqHeader, 10000, target.getHexHash() + ".yacyh");
final HashMap<String, String> result = FileUtils.table(content);
final Map<String, String> result = FileUtils.table(content);
System.out.println("Result=" + result.toString());
} catch (final Exception e) {
Log.logException(e);

@ -46,6 +46,7 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Semaphore;
import net.yacy.cora.document.RSSFeed;
@ -70,7 +71,7 @@ public class yacyCore {
public static long lastOnlineTime = 0;
/** pseudo-random key derived from a time-interval while YaCy startup*/
public static long speedKey = 0;
public static final Map<String, yacyAccessible> amIAccessibleDB = Collections.synchronizedMap(new HashMap<String, yacyAccessible>()); // Holds PeerHash / yacyAccessible Relations
public static final Map<String, yacyAccessible> amIAccessibleDB = new ConcurrentHashMap<String, yacyAccessible>(); // Holds PeerHash / yacyAccessible Relations
// constants for PeerPing behavior
private static final int PING_INITIAL = 10;
private static final int PING_MAX_RUNNING = 3;

@ -216,7 +216,7 @@ public class yacyNewsDB {
public static Record newRecord(final yacySeed mySeed, final String category, final Properties attributes) {
try {
final HashMap<String, String> m = new HashMap<String, String>();
final Map<String, String> m = new HashMap<String, String>();
final Iterator<Entry<Object, Object>> e = attributes.entrySet().iterator();
Map.Entry<Object, Object> entry;
while (e.hasNext()) {

@ -24,7 +24,8 @@
package de.anomic.yacy;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import net.yacy.cora.document.RSSFeed;
import net.yacy.cora.document.RSSMessage;
@ -36,14 +37,14 @@ import net.yacy.kelondro.util.MapTools;
public class yacyPeerActions {
private final yacySeedDB seedDB;
private HashMap<String, String> userAgents;
private Map<String, String> userAgents;
public long disconnects;
private final yacyNewsPool newsPool;
public yacyPeerActions(final yacySeedDB seedDB, final yacyNewsPool newsPool) {
this.seedDB = seedDB;
this.newsPool = newsPool;
this.userAgents = new HashMap<String, String>();
this.userAgents = new ConcurrentHashMap<String, String>();
this.disconnects = 0;
}

@ -39,11 +39,11 @@ import java.security.NoSuchAlgorithmException;
import java.security.PublicKey;
import java.security.SignatureException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
import net.yacy.cora.document.MultiProtocolURI;
import net.yacy.document.parser.html.ContentScraper;
@ -71,7 +71,7 @@ public final class yacyRelease extends yacyVersion {
// information about latest release, retrieved from download pages
// this static information should be overwritten by network-specific locations
// for details see defaults/yacy.network.freeworld.unit
private static Map<yacyUpdateLocation, DevAndMainVersions> latestReleases = new HashMap<yacyUpdateLocation, DevAndMainVersions>();
private static Map<yacyUpdateLocation, DevAndMainVersions> latestReleases = new ConcurrentHashMap<yacyUpdateLocation, DevAndMainVersions>();
public final static List<yacyUpdateLocation> latestReleaseLocations = new ArrayList<yacyUpdateLocation>(); // will be initialized with value in defaults/yacy.network.freeworld.unit
private MultiProtocolURI url;

@ -21,10 +21,10 @@
package net.yacy.cora.document;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
public class RSSMessage implements Hit {
@ -77,7 +77,7 @@ public class RSSMessage implements Hit {
}
}
private final HashMap<String, String> map;
private final Map<String, String> map;
public RSSMessage(final String title, final String description, final String link) {
this();
@ -89,7 +89,7 @@ public class RSSMessage implements Hit {
}
public RSSMessage() {
this.map = new HashMap<String, String>();
this.map = new ConcurrentHashMap<String, String>();
this.map.put("guid", Long.toHexString(System.currentTimeMillis()) + ":" + guidcount++);
}

@ -76,7 +76,7 @@ public class GeonamesLocalization implements Localization {
insensitiveCollator.setDecomposition(Collator.NO_DECOMPOSITION);
}
private final HashMap<Integer, Location> id2loc;
private final Map<Integer, Location> id2loc;
private final TreeMap<String, List<Integer>> name2ids;
private final File file;

@ -65,13 +65,13 @@ public class OpenGeoDBLocalization implements Localization {
insensitiveCollator.setDecomposition(Collator.NO_DECOMPOSITION);
}
private final HashMap<Integer, String> locTypeHash2locType;
private final HashMap<Integer, Location> id2loc;
private final HashMap<Integer, Integer> id2locTypeHash;
private final Map<Integer, String> locTypeHash2locType;
private final Map<Integer, Location> id2loc;
private final Map<Integer, Integer> id2locTypeHash;
private final TreeMap<String, List<Integer>> name2ids;
private final TreeMap<String, List<Integer>> kfz2ids;
private final HashMap<String, List<Integer>> predial2ids;
private final HashMap<String, Integer> zip2id;
private final Map<String, List<Integer>> kfz2ids;
private final Map<String, List<Integer>> predial2ids;
private final Map<String, Integer> zip2id;
private final File file;
public OpenGeoDBLocalization(final File file, boolean lonlat) {

@ -37,7 +37,7 @@ public final class Identificator {
private static final LanguageStatisticsHolder languages = LanguageStatisticsHolder.getInstance();
private final HashMap<Character, Integer> letter;
private final Map<Character, Integer> letter;
private int letters;
private String language;

@ -25,6 +25,7 @@
package net.yacy.document.parser.html;
import java.util.HashMap;
import java.util.Map;
public class CharacterCoding {
@ -175,10 +176,10 @@ public class CharacterCoding {
"\u00FF","&yuml;"
};
private final static HashMap<String, Character> html2unicode4xml = new HashMap<String, Character>(mapping4xml.length * 2);
private final static HashMap<String, Character> html2unicode4html = new HashMap<String, Character>(mapping4html.length * 2);
private final static HashMap<Character, String> unicode2html4xml = new HashMap<Character, String>(mapping4xml.length * 2);
private final static HashMap<Character, String> unicode2html4html = new HashMap<Character, String>(mapping4html.length * 2);
private final static Map<String, Character> html2unicode4xml = new HashMap<String, Character>(mapping4xml.length * 2);
private final static Map<String, Character> html2unicode4html = new HashMap<String, Character>(mapping4html.length * 2);
private final static Map<Character, String> unicode2html4xml = new HashMap<Character, String>(mapping4xml.length * 2);
private final static Map<Character, String> unicode2html4html = new HashMap<Character, String>(mapping4html.length * 2);
static {
Character c;
for (int i = 0; i < mapping4html.length; i += 2) {

@ -32,9 +32,9 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
@ -52,7 +52,7 @@ public class Compressor implements BLOB {
static byte[] plainMagic = {(byte) 'p', (byte) '|'}; // magic for plain content (no encoding)
private final BLOB backend;
private HashMap<String, byte[]> buffer; // entries which are not yet compressed, format is RAW (without magic)
private Map<String, byte[]> buffer; // entries which are not yet compressed, format is RAW (without magic)
private BlockingQueue<Entity> writeQueue;
private long bufferlength;
private final long maxbufferlength;
@ -128,7 +128,7 @@ public class Compressor implements BLOB {
}
private void initBuffer() {
this.buffer = new HashMap<String, byte[]>();
this.buffer = new ConcurrentHashMap<String, byte[]>();
this.bufferlength = 0;
}

@ -506,7 +506,7 @@ public final class Heap extends HeapModifier implements BLOB {
}
private static Map<String, String> map(final String a, final String b) {
HashMap<String, String> m = new HashMap<String, String>();
Map<String, String> m = new HashMap<String, String>();
m.put(a, b);
return m;
}

@ -32,6 +32,7 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import net.yacy.kelondro.index.RowSpaceExceededException;
import net.yacy.kelondro.order.ByteOrder;
@ -45,9 +46,9 @@ public class MapDataMining extends MapHeap {
private final static Double DOUBLE0 = Double.valueOf(0.0);
private final String[] sortfields, longaccfields, doubleaccfields;
private HashMap<String, ScoreCluster<String>> sortClusterMap; // a String-kelondroMScoreCluster - relation
private HashMap<String, Long> accLong; // to store accumulations of Long cells
private HashMap<String, Double> accDouble; // to store accumulations of Double cells
private Map<String, ScoreCluster<String>> sortClusterMap; // a String-kelondroMScoreCluster - relation
private Map<String, Long> accLong; // to store accumulations of Long cells
private Map<String, Double> accDouble; // to store accumulations of Double cells
@SuppressWarnings("unchecked")
public MapDataMining(final File heapFile,
@ -68,7 +69,7 @@ public class MapDataMining extends MapHeap {
ScoreCluster<String>[] cluster = null;
if (sortfields == null) sortClusterMap = null; else {
sortClusterMap = new HashMap<String, ScoreCluster<String>>();
sortClusterMap = new ConcurrentHashMap<String, ScoreCluster<String>>();
cluster = new ScoreCluster[sortfields.length];
for (int i = 0; i < sortfields.length; i++) {
cluster[i] = new ScoreCluster<String>();
@ -80,7 +81,7 @@ public class MapDataMining extends MapHeap {
if (longaccfields == null) {
accLong = null;
} else {
accLong = new HashMap<String, Long>();
accLong = new ConcurrentHashMap<String, Long>();
longaccumulator = new Long[longaccfields.length];
for (int i = 0; i < longaccfields.length; i++) {
longaccumulator[i] = LONG0;
@ -89,7 +90,7 @@ public class MapDataMining extends MapHeap {
if (doubleaccfields == null) {
accDouble = null;
} else {
accDouble = new HashMap<String, Double>();
accDouble = new ConcurrentHashMap<String, Double>();
doubleaccumulator = new Double[doubleaccfields.length];
for (int i = 0; i < doubleaccfields.length; i++) {
doubleaccumulator[i] = DOUBLE0;

@ -35,6 +35,7 @@ import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import net.yacy.kelondro.index.ARC;
import net.yacy.kelondro.index.ConcurrentARC;
@ -103,7 +104,7 @@ public class MapHeap {
private static Map<String, String> bytes2map(byte[] b) throws IOException, RowSpaceExceededException {
final BufferedReader br = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(b)));
final Map<String, String> map = new HashMap<String, String>();
final Map<String, String> map = new ConcurrentHashMap<String, String>();
String line;
int pos;
try {

@ -307,7 +307,7 @@ public class Tables {
}
public byte[] createRow(String table) throws IOException {
return this.insert(table, new HashMap<String, byte[]>());
return this.insert(table, new ConcurrentHashMap<String, byte[]>());
}
public Row select(final String table, byte[] pk) throws IOException {
@ -490,7 +490,7 @@ public class Tables {
public Row(final byte[] pk, String k0, byte[] v0) {
assert k0 != null;
assert v0 != null;
HashMap<String, byte[]> map = new HashMap<String, byte[]>();
Map<String, byte[]> map = new ConcurrentHashMap<String, byte[]>();
map.put(k0, v0);
this.pk = pk;
this.map = map;

@ -30,11 +30,11 @@ package net.yacy.kelondro.index;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import net.yacy.kelondro.logging.Log;
import net.yacy.kelondro.order.AbstractOrder;
@ -111,7 +111,7 @@ public final class Row {
protected final void genNickRef() {
if (nickref != null) return;
nickref = new HashMap<String, Object[]>(row.length);
nickref = new ConcurrentHashMap<String, Object[]>(row.length);
for (int i = 0; i < row.length; i++) nickref.put(row[i].nickname, new Object[]{row[i], Integer.valueOf(colstart[i])});
}

@ -70,7 +70,7 @@ public class SplitTable implements ObjectIndex, Iterable<Row.Entry> {
// the thread pool for the keeperOf executor service
private ExecutorService executor;
private HashMap<String, ObjectIndex> tables; // a map from a date string to a kelondroIndex object
private Map<String, ObjectIndex> tables; // a map from a date string to a kelondroIndex object
private final Row rowdef;
private final File path;
private final String prefix;

@ -29,7 +29,6 @@ import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
@ -357,7 +356,7 @@ public class Domains {
"INT=International"
};
private static HashMap<String, Integer> TLDID = new HashMap<String, Integer>(32);
private static Map<String, Integer> TLDID = new ConcurrentHashMap<String, Integer>(32);
//private static HashMap<String, String> TLDName = new HashMap<String, String>();
private static void insertTLDProps(final String[] TLDList, final int id) {

@ -499,7 +499,7 @@ public final class FileUtils {
}
public static HashMap<String, String> table(Iterator<String> li) {
public static Map<String, String> table(Iterator<String> li) {
int pos;
String line;
final HashMap<String, String> props = new HashMap<String, String>();
@ -511,7 +511,7 @@ public final class FileUtils {
return props;
}
public static HashMap<String, String> table(final byte[] a) {
public static Map<String, String> table(final byte[] a) {
return table(strings(a));
}
@ -527,7 +527,7 @@ public final class FileUtils {
* @param list
* @return
*/
public static HashMap<String, String> table(final ArrayList<String> list) {
public static Map<String, String> table(final ArrayList<String> list) {
if (list == null) return new HashMap<String, String>();
final Iterator<String> i = list.iterator();
int pos;

@ -26,7 +26,8 @@
package net.yacy.kelondro.util;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class ISO639 {
@ -168,7 +169,7 @@ public class ISO639 {
"zh-Chinese",
"zu-Zulu"};
static HashMap<String, String> mapping = new HashMap<String, String>(codes.length);
static Map<String, String> mapping = new ConcurrentHashMap<String, String>(codes.length);
static {
for (int i = 0; i < codes.length; i++) {

@ -33,7 +33,7 @@ public class ObjectSpace {
private static final int minSize = 10;
private static final int maxSize = 256;
private static HashMap<Integer, ArrayList<byte[]>> objHeap = new HashMap<Integer, ArrayList<byte[]>>();
private static Map<Integer, ArrayList<byte[]>> objHeap = new HashMap<Integer, ArrayList<byte[]>>();
private static TreeMap<Integer, Integer> aliveNow = new TreeMap<Integer, Integer>();
//private static TreeMap aliveMax = new TreeMap();

Loading…
Cancel
Save