Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
saved a bit more ram using UTF8 String compression for OpenGeoDB and Geonames data files.
Michael Peter Christencde20911bbf2
diff --git a/source/net/yacy/document/geolocalization/GeoLocation.java b/source/net/yacy/document/geolocalization/GeoLocation.javaindex 6e0bda36f..c9b5e21f4 100644--- a/source/net/yacy/document/geolocalization/GeoLocation.java+++ b/source/net/yacy/document/geolocalization/GeoLocation.java@@ -24,10 +24,12 @@ package net.yacy.document.geolocalization;import java.util.Comparator;+import net.yacy.cora.document.UTF8;+public class GeoLocation extends IntegerGeoPoint implements Comparable<GeoLocation>, Comparator<GeoLocation> {- private String name;+ private byte[] name;private int population;public GeoLocation(double lat, double lon) {@@ -38,15 +40,15 @@ public class GeoLocation extends IntegerGeoPoint implements Comparable<GeoLocatipublic GeoLocation(double lat, double lon, String name) {super(lat, lon);- this.name = name;+ this.name = UTF8.getBytes(name);}public void setName(String name) {- this.name = name;+ this.name = UTF8.getBytes(name);}public String getName() {- return this.name;+ return UTF8.String(this.name);}public void setPopulation(int population) {@@ -61,7 +63,7 @@ public class GeoLocation extends IntegerGeoPoint implements Comparable<GeoLocatipublic boolean equals(Object loc) {if (!(loc instanceof GeoLocation)) return false;if (this.name == null || ((GeoLocation) loc).name == null) return super.equals(loc);- return super.equals(loc) && this.name.toLowerCase().equals(((GeoLocation) loc).name.toLowerCase());+ return super.equals(loc) && this.getName().toLowerCase().equals(((GeoLocation) loc).getName().toLowerCase());}/**diff --git a/source/net/yacy/document/geolocalization/OpenGeoDBLocalization.java b/source/net/yacy/document/geolocalization/OpenGeoDBLocalization.javaindex e02858a0e..f3173684a 100644--- a/source/net/yacy/document/geolocalization/OpenGeoDBLocalization.java+++ b/source/net/yacy/document/geolocalization/OpenGeoDBLocalization.java@@ -52,9 +52,7 @@ import net.yacy.kelondro.logging.Log;public class OpenGeoDBLocalization implements Localization{- private final Map<Integer, String> locTypeHash2locType;private final Map<Integer, GeoLocation> id2loc;- private final Map<Integer, Integer> id2locTypeHash;private final TreeMap<StringBuilder, List<Integer>> name2ids;private final TreeMap<StringBuilder, List<Integer>> kfz2ids;private final Map<String, List<Integer>> predial2ids;@@ -64,13 +62,9 @@ public class OpenGeoDBLocalization implements Localizationpublic OpenGeoDBLocalization(final File file, final boolean lonlat) {this.file = file;- this.locTypeHash2locType = new HashMap<Integer, String>();this.id2loc = new HashMap<Integer, GeoLocation>();- this.id2locTypeHash = new HashMap<Integer, Integer>();- this.name2ids =- new TreeMap<StringBuilder, List<Integer>>(StringBuilderComparator.CASE_INSENSITIVE_ORDER);- this.kfz2ids =- new TreeMap<StringBuilder, List<Integer>>(StringBuilderComparator.CASE_INSENSITIVE_ORDER);+ this.name2ids = new TreeMap<StringBuilder, List<Integer>>(StringBuilderComparator.CASE_INSENSITIVE_ORDER);+ this.kfz2ids = new TreeMap<StringBuilder, List<Integer>>(StringBuilderComparator.CASE_INSENSITIVE_ORDER);this.predial2ids = new HashMap<String, List<Integer>>();this.zip2id = new HashMap<String, Integer>();@@ -143,11 +137,13 @@ public class OpenGeoDBLocalization implements Localizationid = Integer.parseInt(v[0]);h = removeQuotes(v[2]);final Integer hc = h.hashCode();- final String t = this.locTypeHash2locType.get(hc);- if ( t == null ) {- this.locTypeHash2locType.put(hc, h);+ /*+ final byte[] tb = this.locTypeHash2locType.get(hc);+ if ( tb == null ) {+ this.locTypeHash2locType.put(hc, UTF8.getBytes(h));}this.id2locTypeHash.put(id, hc);+ */} else if ( v[1].equals("500300000") ) { // PLZthis.zip2id.put(removeQuotes(v[2]), Integer.parseInt(v[0]));} else if ( v[1].equals("500500000") ) { // KFZ-Kennzeichendiff --git a/source/net/yacy/search/Switchboard.java b/source/net/yacy/search/Switchboard.javaindex ce6aab283..7e40457be 100644--- a/source/net/yacy/search/Switchboard.java+++ b/source/net/yacy/search/Switchboard.java@@ -322,6 +322,7 @@ public final class Switchboard extends serverSwitchgetDataPath(SwitchboardConstants.HTDOCS_PATH, SwitchboardConstants.HTDOCS_PATH_DEFAULT);this.log.logConfig("HTDOCS Path: " + this.htDocsPath.toString());this.workPath = getDataPath(SwitchboardConstants.WORK_PATH, SwitchboardConstants.WORK_PATH_DEFAULT);+ this.workPath.mkdirs();this.log.logConfig("Work Path: " + this.workPath.toString());this.dictionariesPath =getDataPath(@@ -329,8 +330,16 @@ public final class Switchboard extends serverSwitchSwitchboardConstants.DICTIONARY_SOURCE_PATH_DEFAULT);this.log.logConfig("Dictionaries Path:" + this.dictionariesPath.toString());+ // init libraries+ this.log.logConfig("initializing libraries");+ new Thread() {+ @Override+ public void run() {+ LibraryProvider.initialize(Switchboard.this.dictionariesPath);+ }+ }.start();+// init global host name cache- this.workPath.mkdirs();Domains.init(new File(this.workPath, "globalhosts.list"));// init sessionid name file@@ -341,15 +350,6 @@ public final class Switchboard extends serverSwitch// init tablesthis.tables = new WorkTables(this.workPath);- // init libraries- this.log.logConfig("initializing libraries");- new Thread() {- @Override- public void run() {- LibraryProvider.initialize(Switchboard.this.dictionariesPath);- }- }.start();-// set a high maximum cache size to current size; this is adopted later automaticallyfinal int wordCacheMaxCount = (int) getConfigLong(SwitchboardConstants.WORDCACHE_MAX_COUNT, 20000);setConfig(SwitchboardConstants.WORDCACHE_MAX_COUNT, Integer.toString(wordCacheMaxCount));