/[projects]/dao/FuldDaekningWorker/src/main/java/dk/daoas/fulddaekning/LookupMain.java
ViewVC logotype

Diff of /dao/FuldDaekningWorker/src/main/java/dk/daoas/fulddaekning/LookupMain.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

dao/FuldDaekningWorker/src/dk/daoas/fulddaekning/LookupMain.java revision 2714 by torben, Sun Sep 27 20:00:46 2015 UTC dao/FuldDaekningWorker/src/main/java/dk/daoas/fulddaekning/LookupMain.java revision 2753 by torben, Thu Oct 15 15:34:27 2015 UTC
# Line 16  import java.util.logging.FileHandler; Line 16  import java.util.logging.FileHandler;
16  import java.util.logging.Logger;  import java.util.logging.Logger;
17  import java.util.logging.SimpleFormatter;  import java.util.logging.SimpleFormatter;
18    
19  import com.jwetherell.algorithms.data_structures.KdTree;  import ags.utils.dataStructures.trees.thirdGenKD.KdTree;
20    
21    
22    
23  public class LookupMain {  public class LookupMain {
# Line 24  public class LookupMain { Line 25  public class LookupMain {
25    
26          static final String CONFIG_FILENAME = "fulddaekning.properties";          static final String CONFIG_FILENAME = "fulddaekning.properties";
27    
28          static boolean rename_tables;          static boolean use_osrm;
29            static boolean test_mode;
30          static SafeProperties conf;          static SafeProperties conf;
31    
32          static int max_workers;          static int max_workers;
# Line 60  public class LookupMain { Line 62  public class LookupMain {
62                          System.exit(1);                          System.exit(1);
63                  }                  }
64    
65                    int antalIkkeDaekkede = -1;
66                    
67                  conf = new SafeProperties();                  conf = new SafeProperties();
68                  conf.load( new FileReader(confFile) );                  conf.load( new FileReader(confFile) );
69    
# Line 68  public class LookupMain { Line 72  public class LookupMain {
72                  verbose = Boolean.parseBoolean( conf.getSafeProperty("VERBOSE") );                  verbose = Boolean.parseBoolean( conf.getSafeProperty("VERBOSE") );
73                  logger.info("Starting with VERBOSE:" + verbose);                  logger.info("Starting with VERBOSE:" + verbose);
74    
75                  rename_tables = Boolean.parseBoolean( conf.getSafeProperty("RENAMETABLES") );                  test_mode = Boolean.parseBoolean( conf.getSafeProperty("TEST") );
76                  logger.info("Starting with RENAMETABLES:" + rename_tables);                  logger.info("Starting with TEST:" + test_mode);
77    
78                    use_osrm = Boolean.parseBoolean( conf.getSafeProperty("USE_OSRM") );
79                    logger.info("Starting with USE_OSRM:" + use_osrm);
80    
81                  distributor = conf.getSafeProperty("DISTRIBUTOR");                  distributor = conf.getSafeProperty("DISTRIBUTOR");
82                  distributor = distributor.toUpperCase();                  distributor = distributor.toUpperCase();
# Line 78  public class LookupMain { Line 85  public class LookupMain {
85                  Constants.init(distributor);                  Constants.init(distributor);
86                  Constants consts = Constants.getInstance();                  Constants consts = Constants.getInstance();
87    
                 Database db = new Database(conf);  
                 Queue<Adresse> ikkeDaekkede = db.hentAlleIkkedaekkedeAdresser(consts.getMinPostnr(), consts.getMaxPostnr() );  
                 logger.info("Antal ikke-daekkede: " + ikkeDaekkede.size() );  
   
   
88                  max_workers = Integer.parseInt( conf.getSafeProperty("MAX_WORKERS") );                    max_workers = Integer.parseInt( conf.getSafeProperty("MAX_WORKERS") );  
89                  if (max_workers <= 0) {                    if (max_workers <= 0) {  
90                          logger.info("!!! AUTO-DETECT MAX_WORKERS !!!");                            logger.info("!!! AUTO-DETECT MAX_WORKERS !!!");  
# Line 92  public class LookupMain { Line 94  public class LookupMain {
94                          max_workers = Math.max(1, cores); //Dog skal der som minimum være 1 core til beregning                            max_workers = Math.max(1, cores); //Dog skal der som minimum være 1 core til beregning  
95    
96                  }                          }        
97                    if (test_mode) {
98                            max_workers = 1;
99                    }
100                  logger.info("Starting with MAX_WORKERS:" + max_workers);                          logger.info("Starting with MAX_WORKERS:" + max_workers);        
101                  setupThreadPool();                  setupThreadPool();
102    
103                    
104                    Database db = new Database(conf);
105                    Queue<Adresse> ikkeDaekkede = db.hentAlleIkkedaekkedeAdresser(consts.getMinPostnr(), consts.getMaxPostnr() );
106                    antalIkkeDaekkede = ikkeDaekkede.size();
107                    logger.info("Antal ikke-daekkede: " + antalIkkeDaekkede );
108    
109    
110    
111                  boolean testRun= false;                  boolean testRun= false;
112    
113                  AtomicInteger antalFundne = new AtomicInteger(0);                  AtomicInteger antalFundne = new AtomicInteger(0);
# Line 130  public class LookupMain { Line 143  public class LookupMain {
143    
144                                  logger.info("Opbygger KDTree for " + ho + " - antal=" + geopoints.size() );                                  logger.info("Opbygger KDTree for " + ho + " - antal=" + geopoints.size() );
145    
146                                  @SuppressWarnings("unchecked")                                  int bucketSize = 96*12;
                                 List<KdTree.XYZPoint> tmpPoints = (List<KdTree.XYZPoint>)(List<?>) geopoints;  
147    
148                                  KdTree<Adresse> addressTree = new KdTree<Adresse>( tmpPoints );                                  KdTree<Adresse> addressTree = new KdTree<Adresse>( 3, bucketSize );
149                                    for(Adresse a: geopoints) {
150                                            addressTree.addPoint(a.xyz, a);
151                                    }
152                                    
153                                  hoTrees.put(ho, addressTree);                                                            hoTrees.put(ho, addressTree);                          
154                          }                          }
155    
# Line 153  public class LookupMain { Line 169  public class LookupMain {
169                                                    
170                          barrier.await(); // Afvent at workerne bliver færdige                          barrier.await(); // Afvent at workerne bliver færdige
171                                                    
172                            logger.info("Calc is done - cleaning up remaining bits");
173                            
174                          threadPool.shutdown(); //Calc is done now                          threadPool.shutdown(); //Calc is done now
175    
176    
177                          db.saveBatch();                          db.saveBatch();
178    
179                          if (rename_tables) {                          if (test_mode == false) {
180                                  db.renameResultTables();                                  db.renameResultTables();
181                          } else {                          } else {
182                                  logger.info( "Rename tables is disabled !!!" );                                  logger.info( "Rename tables is disabled !!!" );
# Line 189  public class LookupMain { Line 207  public class LookupMain {
207                  logger.info("Fuld load done : " + formatMilliSeconds(elapsed) );                  logger.info("Fuld load done : " + formatMilliSeconds(elapsed) );
208                  logger.info("Fuld load done (beregning) : " + formatMilliSeconds(elapsedBeregn) );                  logger.info("Fuld load done (beregning) : " + formatMilliSeconds(elapsedBeregn) );
209                  logger.info("Antal daekkede : " + antalDaekkedeAdresser );                  logger.info("Antal daekkede : " + antalDaekkedeAdresser );
210                  logger.info("Antal ikke-daekkede : " + ikkeDaekkede.size() );                  logger.info("Antal ikke-daekkede : " + antalIkkeDaekkede );
211                  logger.info("Heraf, antal fundne : " + antalFundne );                  logger.info("Heraf, antal fundne : " + antalFundne );
212    
213                  logger.info( String.format("Fandt adresser til : %.2f %%", (antalFundne.get() *100.0)/ikkeDaekkede.size() ) );                  logger.info( String.format("Fandt adresser til : %.2f %%", (antalFundne.get() *100.0)/antalIkkeDaekkede ) );
214                  //logger.info("Fandt adresser til : " + (antalFundne*100.0)/ikkeDaekkede.length + "%" );                  //logger.info("Fandt adresser til : " + (antalFundne*100.0)/ikkeDaekkede.length + "%" );
215          }          }
216    

Legend:
Removed from v.2714  
changed lines
  Added in v.2753

  ViewVC Help
Powered by ViewVC 1.1.20