early freeing resources on deleting index reference if search-verification fails (aka Switchboard.cleanupJob)

doing same thingy on other methods of touched files as well

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7860 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
sixcooler 14 years ago
parent a311596881
commit 5cd07d7f84

@ -216,9 +216,11 @@ public class WorkTables extends Tables {
final HTTPClient client = new HTTPClient();
client.setRealm(realm);
client.setTimout(120000);
Tables.Row row;
String url;
LinkedHashMap<String, Integer> l = new LinkedHashMap<String, Integer>();
for (String pk: pks) {
Tables.Row row = null;
for (final String pk: pks) {
row = null;
try {
row = select(WorkTables.TABLE_API_NAME, UTF8.getBytes(pk));
} catch (IOException e) {
@ -227,7 +229,7 @@ public class WorkTables extends Tables {
Log.logException(e);
}
if (row == null) continue;
String url = "http://" + host + ":" + port + UTF8.String(row.get(WorkTables.TABLE_API_COL_URL));
url = "http://" + host + ":" + port + UTF8.String(row.get(WorkTables.TABLE_API_COL_URL));
url += "&" + WorkTables.TABLE_API_COL_APICALL_PK + "=" + UTF8.String(row.getPK());
Log.logInfo("WorkTables", "executing url: " + url);
try {
@ -299,7 +301,7 @@ public class WorkTables extends Tables {
public void failURLsRegisterMissingWord(IndexCell<WordReference> indexCell, final DigestURI url, HandleSet queryHashes, final String reason) {
// remove words from index
for (byte[] word: queryHashes) {
for (final byte[] word: queryHashes) {
indexCell.removeDelayed(word, url.hash());
}
@ -333,10 +335,12 @@ public class WorkTables extends Tables {
public void cleanFailURLS(long timeout) {
if (timeout >= 0) {
try {
Iterator<Row> iter = this.iterator(WorkTables.TABLE_SEARCH_FAILURE_NAME);
Row row;
Date date;
Iterator<Row> iter = this.iterator(WorkTables.TABLE_SEARCH_FAILURE_NAME);
while (iter.hasNext()) {
Row row = iter.next();
Date date = new Date();
row = iter.next();
date = new Date();
date = row.get(TABLE_SEARCH_FAILURE_COL_DATE, date);
if(date.before(new Date(System.currentTimeMillis() - timeout))) {
this.delete(TABLE_SEARCH_FAILURE_NAME, row.getPK());

@ -145,7 +145,7 @@ public class BEncodedHeap implements Map<byte[], Map<String, byte[]>>, Iterable<
if (bobj.getType() != BDecoder.BType.dictionary) return null;
Map<String, BDecoder.BObject> map = bobj.getMap();
Map<String, byte[]> m = new HashMap<String, byte[]>();
for (Map.Entry<String, BDecoder.BObject> entry: map.entrySet()) {
for (final Map.Entry<String, BDecoder.BObject> entry: map.entrySet()) {
if (entry.getValue().getType() != BDecoder.BType.string) continue;
m.put(entry.getKey(), entry.getValue().getString());
}
@ -404,7 +404,7 @@ public class BEncodedHeap implements Map<byte[], Map<String, byte[]>>, Iterable<
* @param m mappings to be stored in this map
*/
public void putAll(Map<? extends byte[], ? extends Map<String, byte[]>> map) {
for (Map.Entry<? extends byte[], ? extends Map<String, byte[]>> me: map.entrySet()) {
for (final Map.Entry<? extends byte[], ? extends Map<String, byte[]>> me: map.entrySet()) {
try {
this.insert(me.getKey(), me.getValue());
} catch (RowSpaceExceededException e) {
@ -548,7 +548,7 @@ public class BEncodedHeap implements Map<byte[], Map<String, byte[]>>, Iterable<
*/
public ArrayList<String> columns() {
if (this.columnames.size() == 0) {
for (Map.Entry<byte[], Map<String, byte[]>> row: this) {
for (final Map.Entry<byte[], Map<String, byte[]>> row: this) {
this.columnames.addAll(row.getValue().keySet());
}
}
@ -572,9 +572,10 @@ public class BEncodedHeap implements Map<byte[], Map<String, byte[]>>, Iterable<
m.put("k", "111".getBytes()); map.insert("456".getBytes(), m);
m.put("k", "222".getBytes()); map.insert("789".getBytes(), m);
// iterate over keys
Map.Entry<byte[], Map<String, byte[]>> entry;
Iterator<Map.Entry<byte[], Map<String, byte[]>>> i = map.iterator();
while (i.hasNext()) {
Map.Entry<byte[], Map<String, byte[]>> entry = i.next();
entry = i.next();
System.out.println(ASCII.String(entry.getKey()) + ": " + entry.getValue());
}
// clean up
@ -587,10 +588,11 @@ public class BEncodedHeap implements Map<byte[], Map<String, byte[]>>, Iterable<
} else {
File f = new File(args[0]);
try {
Map.Entry<byte[], Map<String, byte[]>> entry;
BEncodedHeap map = new BEncodedHeap(f, 12);
Iterator<Map.Entry<byte[], Map<String, byte[]>>> i = map.iterator();
while (i.hasNext()) {
Map.Entry<byte[], Map<String, byte[]>> entry = i.next();
entry = i.next();
System.out.println(ASCII.String(entry.getKey()) + ": " + entry.getValue());
}
map.close();

@ -72,7 +72,7 @@ public class Tables {
String[] files = this.location.list();
String tablename;
File file;
for (String f: files) {
for (final String f: files) {
if (f.endsWith(suffix)) {
file = new File(this.location, f);
if (file.length() == 0) {
@ -99,7 +99,7 @@ public class Tables {
}
public void close() {
for (BEncodedHeap heap: this.tables.values()) heap.close();
for (final BEncodedHeap heap: this.tables.values()) heap.close();
this.tables.clear();
}
@ -362,14 +362,15 @@ public class Tables {
}
protected Row next0() {
Row r;
while (i.hasNext()) {
Row r = new Row(i.next());
r = new Row(i.next());
if (this.whereValue != null) {
if (ByteBuffer.equals(r.get(this.whereColumn), this.whereValue)) return r;
} else if (this.wherePattern != null) {
if (this.whereColumn == null) {
// shall match any column
for (byte[] b: r.values()) {
for (final byte[] b: r.values()) {
if (this.wherePattern.matcher(UTF8.String(b)).matches()) return r;
}
} else {
@ -461,7 +462,7 @@ public class Tables {
public String toString() {
StringBuilder sb = new StringBuilder(this.size() * 40);
sb.append('{');
for (Map.Entry<String, byte[]> entry: this.entrySet()) {
for (final Map.Entry<String, byte[]> entry: this.entrySet()) {
sb.append(entry.getKey()).append('=').append(UTF8.String(entry.getValue())).append(", ");
}
if (sb.length() > 1) sb.setLength(sb.length() - 2);

@ -149,14 +149,14 @@ public class BDecoder {
public String toString() {
StringBuilder s = new StringBuilder(l.size() * 40 + 1);
s.append("[");
for (BObject o: l) s.append(o.toString()).append(",");
for (final BObject o: l) s.append(o.toString()).append(",");
s.setLength(s.length() - 1);
s.append("]");
return s.toString();
}
public void toStream(OutputStream os) throws IOException {
os.write(_l);
for (BObject bo: this.l) bo.toStream(os);
for (final BObject bo: this.l) bo.toStream(os);
os.write(_e);
}
}
@ -178,14 +178,14 @@ public class BDecoder {
public String toString() {
StringBuilder s = new StringBuilder(m.size() * 40 + 1);
s.append('{');
for (Map.Entry<String, BObject> e: m.entrySet()) s.append(e.getKey()).append(':').append(e.getValue().toString()).append(',');
for (final Map.Entry<String, BObject> e: m.entrySet()) s.append(e.getKey()).append(':').append(e.getValue().toString()).append(',');
s.setLength(s.length() - 1);
s.append('}');
return s.toString();
}
public void toStream(OutputStream os) throws IOException {
os.write(_d);
for (Map.Entry<String, BObject> e: this.m.entrySet()) {
for (final Map.Entry<String, BObject> e: this.m.entrySet()) {
BStringObject.toStream(os, e.getKey());
e.getValue().toStream(os);
}
@ -226,9 +226,11 @@ public class BDecoder {
private Map<String, BObject> convertToMap(final List<BObject> list) {
final Map<String, BObject> m = new LinkedHashMap<String, BObject>();
final int length = list.size();
byte[] key;
BObject value;
for (int i = 0; i < length; i += 2) {
final byte[] key = list.get(i).getString();
BObject value = null;
key = list.get(i).getString();
value = null;
if (i + 1 < length) {
value = list.get(i + 1);
}
@ -240,8 +242,9 @@ public class BDecoder {
private List<BObject> readList() {
final List<BObject> list = new ArrayList<BObject>();
char ch = (char) b[pos];
BObject bo;
while (ch != 'e') {
BObject bo = parse();
bo = parse();
if (bo == null) {pos++; break;}
list.add(bo);
ch = (char) b[pos];
@ -287,13 +290,13 @@ public class BDecoder {
if (bo.getType() == BType.list) {
System.out.println("[");
//for (int i = 0; i < t + 1; i++) System.out.print(" ");
for (BObject o: bo.getList()) print(o, t + 1);
for (final BObject o: bo.getList()) print(o, t + 1);
for (int i = 0; i < t; i++) System.out.print(" ");
System.out.println("]");
}
if (bo.getType() == BType.dictionary) {
System.out.println("{");
for (Map.Entry<String, BObject> e: bo.getMap().entrySet()) {
for (final Map.Entry<String, BObject> e: bo.getMap().entrySet()) {
for (int i = 0; i < t + 1; i++) System.out.print(" ");
System.out.print(e.getKey());
System.out.println(":");

Loading…
Cancel
Save