- fix for broken news queue during iteration

- enhancement for searching special news (usage of new iterator)

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3957 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 18 years ago
parent 1ea5fa2c04
commit 4968556668

@ -292,7 +292,7 @@ public final class kelondroStack extends kelondroRecords {
Handle h = getHandle(side); Handle h = getHandle(side);
if (h == null) return null; if (h == null) return null;
if (dist >= size()) return null; // that would exceed the stack if (dist >= size()) return null; // that would exceed the stack
while (dist-- > 0) h = getNode(h, false).getOHHandle(dir); // track through elements while ((dist-- > 0) && (h != null)) h = getNode(h, false).getOHHandle(dir); // track through elements
if (h == null) return null; else return getNode(h, true); if (h == null) return null; else return getNode(h, true);
} }

@ -402,30 +402,13 @@ public class yacyNewsPool {
return false; return false;
} }
/*
public yacyNewsRecord get(int dbKey, int element) throws IOException {
yacyNewsQueue queue = switchQueue(dbKey);
yacyNewsRecord record = null;
int s;
synchronized (queue) {
while ((record == null) && ((s = queue.size()) > 0)) {
record = queue.top(element);
if (record == null) {
queue.pop(element);
if (queue.size() == s) break;
}
}
}
return record;
}
*/
public synchronized yacyNewsRecord getSpecific(int dbKey, String category, String key, String value) throws IOException { public synchronized yacyNewsRecord getSpecific(int dbKey, String category, String key, String value) throws IOException {
yacyNewsQueue queue = switchQueue(dbKey); yacyNewsQueue queue = switchQueue(dbKey);
yacyNewsRecord record; yacyNewsRecord record;
String s; String s;
for (int i = queue.size() - 1; i >= 0; i--) { Iterator i = queue.records(true);
record = queue.top(i); while (i.hasNext()) {
record = (yacyNewsRecord) i.next();
if ((record != null) && (record.category().equals(category))) { if ((record != null) && (record.category().equals(category))) {
s = (String) record.attributes().get(key); s = (String) record.attributes().get(key);
if ((s != null) && (s.equals(value))) return record; if ((s != null) && (s.equals(value))) return record;

@ -164,6 +164,7 @@ public class yacyNewsQueue {
} }
public Iterator records(boolean up) { public Iterator records(boolean up) {
// iterates yacyNewsRecord-type objects
return new newsIterator(up); return new newsIterator(up);
} }

Loading…
Cancel
Save