Skip to content

Commit

Permalink
refactoring of method calling for objects from kelondroMapDataMining
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4985 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
orbiter committed Jul 11, 2008
1 parent 01d1ae6 commit 0f5fe8c
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 43 deletions.
7 changes: 6 additions & 1 deletion source/de/anomic/crawler/CrawlProfile.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,12 @@ public entry newEntry(String name, yacyURL startURL, String generalFilter, Strin
}

public entry getEntry(String handle) {
HashMap<String, String> m = profileTable.getMap(handle);
HashMap<String, String> m;
try {
m = profileTable.get(handle);
} catch (IOException e) {
return null;
}
if (m == null) return null;
return new entry(m);
}
Expand Down
5 changes: 4 additions & 1 deletion source/de/anomic/crawler/RobotsTxt.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,15 @@ public int size() {

private Entry getEntry(String hostName) {
try {
HashMap<String, String> record = this.robotsTable.getMap(hostName);
HashMap<String, String> record = this.robotsTable.get(hostName);
if (record == null) return null;
return new Entry(hostName, record);
} catch (kelondroException e) {
resetDatabase();
return null;
} catch (IOException e) {
resetDatabase();
return null;
}
}

Expand Down
10 changes: 7 additions & 3 deletions source/de/anomic/data/blogBoard.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,13 @@ public BlogEntry readBlogEntry(String key) {
}
private BlogEntry readBlogEntry(String key, kelondroMapDataMining base) {
key = normalize(key);
if (key.length() > keyLength)
key = key.substring(0, keyLength);
HashMap<String, String> record = base.getMap(key);
if (key.length() > keyLength) key = key.substring(0, keyLength);
HashMap<String, String> record;
try {
record = base.get(key);
} catch (IOException e) {
record = null;
}
if (record == null)
return newEntry(key, "".getBytes(), "anonymous".getBytes(), "127.0.0.1", new Date(), "".getBytes(), null, null);
return new BlogEntry(key, record);
Expand Down
7 changes: 6 additions & 1 deletion source/de/anomic/data/blogBoardComments.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,12 @@ public CommentEntry read(String key) {
private CommentEntry read(String key, kelondroMapDataMining base) {
key = normalize(key);
if (key.length() > keyLength) key = key.substring(0, keyLength);
HashMap<String, String> record = base.getMap(key);
HashMap<String, String> record;
try {
record = base.get(key);
} catch (IOException e) {
record = null;
}
if (record == null) return newEntry(key, "".getBytes(), "anonymous".getBytes(), "127.0.0.1", new Date(), "".getBytes());
return new CommentEntry(key, record);
}
Expand Down
12 changes: 10 additions & 2 deletions source/de/anomic/data/bookmarksDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,11 @@ public int tagSize(boolean flushed){
private Tag loadTag(String hash){
HashMap<String, String> map;
Tag ret=null;
map = tagsTable.getMap(hash);
try {
map = tagsTable.get(hash);
} catch (IOException e) {
return null;
}
if(map!=null){
ret=new Tag(hash, map);
tagCache.put(hash, ret);
Expand Down Expand Up @@ -520,7 +524,11 @@ public void rebuildTags(){

public bookmarksDate getDate(String date){
HashMap<String, String> map;
map=datesTable.getMap(date);
try {
map=datesTable.get(date);
} catch (IOException e) {
map = null;
}
if(map==null) return new bookmarksDate(date);
return new bookmarksDate(date, map);
}
Expand Down
7 changes: 6 additions & 1 deletion source/de/anomic/data/messageBoard.java
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,12 @@ public String write(entry message) {
}

public entry read(String key) {
HashMap<String, String> record = database.getMap(key);
HashMap<String, String> record;
try {
record = database.get(key);
} catch (IOException e) {
return null;
}
return new entry(key, record);
}

Expand Down
7 changes: 6 additions & 1 deletion source/de/anomic/data/userDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,12 @@ public Entry getEntry(String userName) {
if(userName.length()>128){
userName=userName.substring(0, 127);
}
HashMap<String, String> record = userTable.getMap(userName);
HashMap<String, String> record;
try {
record = userTable.get(userName);
} catch (IOException e) {
return null;
}
if (record == null) return null;
return new Entry(userName, record);
}
Expand Down
2 changes: 1 addition & 1 deletion source/de/anomic/data/wikiBoard.java
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ entry read(String key, kelondroMapDataMining base) {
try {
key = normalize(key);
if (key.length() > keyLength) key = key.substring(0, keyLength);
HashMap<String, String> record = base.getMap(key);
HashMap<String, String> record = base.get(key);
if (record == null) return newEntry(key, "anonymous", "127.0.0.1", "New Page", "".getBytes());
return new entry(key, record);
} catch (IOException e) {
Expand Down
34 changes: 8 additions & 26 deletions source/de/anomic/kelondro/kelondroMapDataMining.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public kelondroMapDataMining(kelondroBLOB dyn, int cachesize, String[] sortfield
this.elementCount = 0;
while (it.hasNext()) {
mapname = new String(it.next());
map = getMap(new String(mapname));
map = super.get(new String(mapname));
if (map == null) break;

if (sortfields != null) for (int i = 0; i < sortfields.length; i++) {
Expand Down Expand Up @@ -179,7 +179,7 @@ public synchronized void put(String key, HashMap<String, String> newMap) throws

// update elementCount
if ((longaccfields != null) || (doubleaccfields != null)) {
final Map<String, String> oldMap = getMap(key, false);
final Map<String, String> oldMap = super.get(key, false);
if (oldMap == null) {
// new element
elementCount++;
Expand Down Expand Up @@ -252,7 +252,7 @@ public synchronized void remove(String key) throws IOException {

// update elementCount
if ((sortfields != null) || (longaccfields != null) || (doubleaccfields != null)) {
final Map<String, String> map = getMap(key);
final Map<String, String> map = super.get(key);
if (map != null) {
// update count
elementCount--;
Expand All @@ -267,28 +267,6 @@ public synchronized void remove(String key) throws IOException {
super.remove(key);
}

public HashMap<String, String> getMap(String key) {
try {
HashMap<String, String> mapEntry = super.get(key);
if (mapEntry == null) return null;
return mapEntry;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}

protected Map<String, String> getMap(String key, boolean cache) {
try {
HashMap<String, String> mapEntry = super.get(key, cache);
if (mapEntry == null) return null;
return mapEntry;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}

private void deleteSortCluster(final String key) {
if (key == null) return;
kelondroMScoreCluster<String> cluster;
Expand Down Expand Up @@ -406,7 +384,11 @@ private HashMap<String, String> next0() {
finish = true;
return null;
}
map = getMap(nextKey);
try {
map = get(nextKey);
} catch (IOException e) {
break;
}
if (map == null) continue; // circumvention of a modified exception
map.put("key", nextKey);
return map;
Expand Down
14 changes: 12 additions & 2 deletions source/de/anomic/plasma/plasmaHTCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,12 @@ private static String dom(File f) {
public static IResourceInfo loadResourceInfo(yacyURL url) throws UnsupportedProtocolException, IllegalAccessException {

// loading data from database
Map<String, String> hdb = responseHeaderDB.getMap(url.hash());
Map<String, String> hdb;
try {
hdb = responseHeaderDB.get(url.hash());
} catch (IOException e) {
return null;
}
if (hdb == null) return null;

// generate the cached object
Expand Down Expand Up @@ -746,7 +751,12 @@ public static yacyURL getURL(final File f) {
}
if (url != null) return url;
// try responseHeaderDB
Map<String, String> hdb = responseHeaderDB.getMap(urlHash);
Map<String, String> hdb;
try {
hdb = responseHeaderDB.get(urlHash);
} catch (IOException e1) {
hdb = null;
}
if (hdb != null) {
Object origRequestLine = hdb.get(httpHeader.X_YACY_ORIGINAL_REQUEST_LINE);
if ((origRequestLine != null)&&(origRequestLine instanceof String)) {
Expand Down
13 changes: 9 additions & 4 deletions source/de/anomic/yacy/yacySeedDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -542,23 +542,23 @@ public synchronized void removePotential(String peerHash) {

public boolean hasConnected(String hash) {
try {
return (seedActiveDB.get(hash) != null);
return seedActiveDB.has(hash);
} catch (IOException e) {
return false;
}
}

public boolean hasDisconnected(String hash) {
try {
return (seedPassiveDB.get(hash) != null);
return seedPassiveDB.has(hash);
} catch (IOException e) {
return false;
}
}

public boolean hasPotential(String hash) {
try {
return (seedPotentialDB.get(hash) != null);
return seedPotentialDB.has(hash);
} catch (IOException e) {
return false;
}
Expand All @@ -567,7 +567,12 @@ public boolean hasPotential(String hash) {
private yacySeed get(String hash, kelondroMapDataMining database) {
if (hash == null) return null;
if ((this.mySeed != null) && (hash.equals(mySeed.hash))) return mySeed;
HashMap<String, String> entry = database.getMap(hash);
HashMap<String, String> entry;
try {
entry = database.get(hash);
} catch (IOException e) {
entry = null;
}
if (entry == null) return null;
return new yacySeed(hash, entry);
}
Expand Down

0 comments on commit 0f5fe8c

Please sign in to comment.