Archived
0

improve search if max size > SPLIT_SIZE

This commit is contained in:
iMoHax
2015-11-25 17:04:01 +03:00
parent 1b05da691c
commit 4b5931209e

View File

@@ -516,6 +516,14 @@ public class Crawler<T> {
return true; return true;
} }
private boolean checkLimit(CostTraversalEntry entry, double nextLimit){
return !Double.isNaN(limit) && nextLimit >= limit && (entry.size() >= SPLIT_SIZE || nextLimit - limit > 1);
}
private double computeLimit(CostTraversalEntry entry){
return entry.getWeight();
}
private void search(){ private void search(){
curr = root; curr = root;
LOG.trace("Start {}", root); LOG.trace("Start {}", root);
@@ -537,14 +545,18 @@ public class Crawler<T> {
nextEntry.sort(); nextEntry.sort();
} }
curr = new CTEntrySupport(curr, nextEntry); curr = new CTEntrySupport(curr, nextEntry);
double nextLimit = computeLimit(nextEntry);
boolean stop = checkLimit(nextEntry, nextLimit);
if (isTarget){ if (isTarget){
LOG.trace("Found, add entry {} to queue", nextEntry); LOG.trace("Found, add entry {} to queue", nextEntry);
targets.add(curr); targets.add(curr);
limit = Double.isNaN(limit) ? nextEntry.getWeight() : Math.min(limit, nextEntry.getWeight()); if (Double.isNaN(limit) || nextLimit < limit){
limit = nextLimit;
}
levelUp(); levelUp();
} else { } else {
if (skip()) continue; if (skip()) continue;
if (!Double.isNaN(limit) && nextEntry.getWeight() >= limit){ if (stop){
LOG.trace("Not found, limit {}, add entry {} to queue", limit, nextEntry); LOG.trace("Not found, limit {}, add entry {} to queue", limit, nextEntry);
queue.add(curr); queue.add(curr);
levelUp(); levelUp();