Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
lazy initialization of database tables
Michael Peter Christenba10caf89a7d
diff --git a/source/net/yacy/kelondro/blob/Tables.java b/source/net/yacy/kelondro/blob/Tables.javaindex aa459bbe3..73b263845 100644--- a/source/net/yacy/kelondro/blob/Tables.java+++ b/source/net/yacy/kelondro/blob/Tables.java@@ -70,8 +70,8 @@ public class Tables implements Iterable<String> {this.keymaxlen = keymaxlen;this.tables = new ConcurrentHashMap<String, BEncodedHeap>();final String[] files = this.location.list();- String tablename;File file;+ // lazy initialization: do not open the database files herefor (final String f: files) {if (f.endsWith(suffix)) {file = new File(this.location, f);@@ -79,6 +79,22 @@ public class Tables implements Iterable<String> {file.delete();continue;}+ }+ }+ }++ @Override+ public Iterator<String> iterator() {+ // we did a lazy initialization, but here we must discover all actually existing tables+ String tablename;+ File file;+ final String[] files = this.location.list();+ for (final String f: files) {+ if (f.endsWith(suffix)) {+ file = new File(this.location, f);+ if (file.length() == 0) {+ continue;+ }tablename = f.substring(0, f.length() - suffix.length());try {getHeap(tablename);@@ -86,10 +102,7 @@ public class Tables implements Iterable<String> {}}}- }-- @Override- public Iterator<String> iterator() {+ // now the list of tables is enriched, return an iteratorreturn this.tables.keySet().iterator();}@@ -376,6 +389,7 @@ public class Tables implements Iterable<String> {this.i = heap.iterator();}+ @Overrideprotected Row next0() {Row r;while (this.i.hasNext()) {