Archived
0

add full scan options to specificator

This commit is contained in:
iMoHax
2015-11-19 15:33:38 +03:00
parent 89f943d6e5
commit a9e80ec693
3 changed files with 14 additions and 3 deletions

View File

@@ -15,6 +15,7 @@ public class CrawlerSpecificator {
private final Collection<Offer> offers; private final Collection<Offer> offers;
private int groupCount; private int groupCount;
private boolean byTime; private boolean byTime;
private boolean fullScan;
public CrawlerSpecificator() { public CrawlerSpecificator() {
any = new HashSet<>(); any = new HashSet<>();
@@ -22,12 +23,21 @@ public class CrawlerSpecificator {
containsAny = new HashSet<>(); containsAny = new HashSet<>();
offers = new ArrayList<>(); offers = new ArrayList<>();
byTime = false; byTime = false;
fullScan = true;
} }
public void setByTime(boolean byTime){ public void setByTime(boolean byTime){
this.byTime = byTime; this.byTime = byTime;
} }
public void setFullScan(boolean fullScan) {
this.fullScan = fullScan;
}
public boolean isFullScan() {
return fullScan;
}
public void all(Collection<Vendor> vendors){ public void all(Collection<Vendor> vendors){
all.addAll(vendors); all.addAll(vendors);
} }

View File

@@ -86,6 +86,7 @@ public class RouteSearcher {
VendorsCrawlerSpecification specification = specificator.build(vendors, collector::add); VendorsCrawlerSpecification specification = specificator.build(vendors, collector::add);
Crawler<Vendor> crawler = vGraph.crawler(specification, callback); Crawler<Vendor> crawler = vGraph.crawler(specification, callback);
int lands = Math.max(scorer.getProfile().getLands(), specification.getMinLands()); int lands = Math.max(scorer.getProfile().getLands(), specification.getMinLands());
if (!specificator.isFullScan()) lands = specificator.getMinHop();
crawler.setMaxSize(lands); crawler.setMaxSize(lands);
crawler.findMin(target, count); crawler.findMin(target, count);
return collector.get(); return collector.get();
@@ -108,6 +109,7 @@ public class RouteSearcher {
crawler.findMin(source, vendors.size()); crawler.findMin(source, vendors.size());
specification = specificator.build(vendors, collector::add, new RouteSpecificationByTarget<>(source), false); specification = specificator.build(vendors, collector::add, new RouteSpecificationByTarget<>(source), false);
lands = Math.max(scorer.getProfile().getLands(), specification.getMinLands()); lands = Math.max(scorer.getProfile().getLands(), specification.getMinLands());
if (!specificator.isFullScan()) lands = specificator.getMinHop();
crawler = vGraph.crawler(specification, callback); crawler = vGraph.crawler(specification, callback);
crawler.setMaxSize(lands); crawler.setMaxSize(lands);
crawler.findMin(source, 1); crawler.findMin(source, 1);

View File

@@ -286,13 +286,12 @@ public class MarketAnalyzer {
private Collection<Vendor> getVendors(CrawlerSpecificator specificator, boolean withTransit){ private Collection<Vendor> getVendors(CrawlerSpecificator specificator, boolean withTransit){
Collection<Vendor> vendors; Collection<Vendor> vendors;
if (specificator.getMinHop() >= profile.getLands()){ if (!specificator.isFullScan() || specificator.getMinHop() >= profile.getLands()){
vendors = withTransit ? market.get().map(Place::asTransit).collect(Collectors.toList()) : new ArrayList<>(); vendors = withTransit ? market.get().map(Place::asTransit).collect(Collectors.toList()) : new ArrayList<>();
market.getVendors().filter(specificator::contains).forEach(vendors::add);
} else { } else {
vendors = market.getMarkets(withTransit).collect(Collectors.toList()); vendors = market.getMarkets(withTransit).collect(Collectors.toList());
vendors = specificator.getVendors(vendors);
} }
vendors = specificator.getVendors(vendors);
return vendors; return vendors;
} }