public synchronized void putCurrentVersions() { put("nodes.version", Constants.VERSION_NODE); put("edges.version", Constants.VERSION_EDGE); put("geometry.version", Constants.VERSION_GEOMETRY); put("location_index.version", Constants.VERSION_LOCATION_IDX); put("name_index.version", Constants.VERSION_NAME_IDX); put("shortcuts.version", Constants.VERSION_SHORTCUT); }
/** * After configuring this storage you need to create it explicitly. */ @Override public GraphHopperStorage create(long byteCount) { baseGraph.checkInit(); if (encodingManager == null) throw new IllegalStateException("EncodingManager can only be null if you call loadExisting"); dir.create(); long initSize = Math.max(byteCount, 100); properties.create(100); properties.put("graph.bytes_for_flags", encodingManager.getBytesForFlags()); properties.put("graph.flag_encoders", encodingManager.toDetailsString()); properties.put("graph.byte_order", dir.getByteOrder()); properties.put("graph.dimension", baseGraph.nodeAccess.getDimension()); properties.putCurrentVersions(); baseGraph.create(initSize); for (CHGraphImpl cg : chGraphs) { cg.create(byteCount); } properties.put("graph.ch.weightings", getCHWeightings().toString()); return this; }
@Override public void run() { // toString is not taken into account so we need to cheat, see http://stackoverflow.com/q/6113746/194609 for other options Thread.currentThread().setName(name); prepare.doWork(); properties.put(CH.PREPARE + "date." + name, createFormatter().format(new Date())); } }, name);
@Test public void testVersionCheck() { StorableProperties instance = new StorableProperties(createDir("", false)); instance.putCurrentVersions(); assertTrue(instance.checkVersions(true)); instance.put("nodes.version", 0); assertFalse(instance.checkVersions(true)); try { instance.checkVersions(false); assertTrue(false); } catch (Exception ex) { } instance.close(); }
@Override public void run() { if (plm.loadExisting()) return; LOGGER.info(tmpCounter + "/" + getPreparations().size() + " calling LM prepare.doWork for " + plm.getWeighting() + " ... (" + getMemInfo() + ")"); prepared.set(true); Thread.currentThread().setName(name); plm.doWork(); properties.put(Landmark.PREPARE + "date." + name, createFormatter().format(new Date())); } }, name);
/** * For landmarks it is required to always call this method: either it creates the landmark data or it loads it. */ protected void loadOrPrepareLM() { boolean tmpPrepare = lmFactoryDecorator.isEnabled() && !lmFactoryDecorator.getPreparations().isEmpty(); if (tmpPrepare) { ensureWriteAccess(); ghStorage.freeze(); if (lmFactoryDecorator.loadOrDoWork(ghStorage.getProperties())) ghStorage.getProperties().put(Landmark.PREPARE + "done", true); } }
protected void prepareCH() { boolean tmpPrepare = chFactoryDecorator.isEnabled(); if (tmpPrepare) { ensureWriteAccess(); ghStorage.freeze(); chFactoryDecorator.prepare(ghStorage.getProperties()); ghStorage.getProperties().put(CH.PREPARE + "done", true); } }
DataReader reader = importData(); DateFormat f = createFormatter(); ghStorage.getProperties().put("datareader.import.date", f.format(new Date())); if (reader.getDataDate() != null) ghStorage.getProperties().put("datareader.data.date", f.format(reader.getDataDate())); } catch (IOException ex) { throw new RuntimeException("Cannot read file " + getDataReaderFile(), ex);
@Test public void testStore() { String dir = "./target/test"; Helper.removeDir(new File(dir)); StorableProperties instance = new StorableProperties(createDir(dir, true)); instance.create(1000); instance.put("test.min", 123); instance.put("test.max", 321); instance.flush(); instance.close(); instance = new StorableProperties(createDir(dir, true)); assertTrue(instance.loadExisting()); assertEquals("123", instance.get("test.min")); assertEquals("321", instance.get("test.max")); instance.close(); Helper.removeDir(new File(dir)); }
public synchronized void putCurrentVersions() { put("nodes.version", Constants.VERSION_NODE); put("edges.version", Constants.VERSION_EDGE); put("geometry.version", Constants.VERSION_GEOMETRY); put("location_index.version", Constants.VERSION_LOCATION_IDX); put("name_index.version", Constants.VERSION_NAME_IDX); put("shortcuts.version", Constants.VERSION_SHORTCUT); }
public synchronized void putCurrentVersions() { put("nodes.version", Constants.VERSION_NODE); put("edges.version", Constants.VERSION_EDGE); put("geometry.version", Constants.VERSION_GEOMETRY); put("location_index.version", Constants.VERSION_LOCATION_IDX); put("name_index.version", Constants.VERSION_NAME_IDX); put("shortcuts.version", Constants.VERSION_SHORTCUT); }
public void putCurrentVersions() { put("nodes.version", Constants.VERSION_NODE); put("edges.version", Constants.VERSION_EDGE); put("geometry.version", Constants.VERSION_GEOMETRY); put("location_index.version", Constants.VERSION_LOCATION_IDX); put("name_index.version", Constants.VERSION_NAME_IDX); put("shortcuts.version", Constants.VERSION_SHORTCUT); }
@Override public void run() { String errorKey = Landmark.PREPARE + "error." + name; try { Thread.currentThread().setName(name); properties.put(errorKey, "LM preparation incomplete"); plm.doWork(); properties.remove(errorKey); properties.put(Landmark.PREPARE + "date." + name, Helper.createFormatter().format(new Date())); } catch (Exception ex) { LOGGER.error("Problem while LM preparation " + name, ex); properties.put(errorKey, ex.getMessage()); } } });
@Override public void run() { // toString is not taken into account so we need to cheat, see http://stackoverflow.com/q/6113746/194609 for other options Thread.currentThread().setName(name); prepare.doWork(); properties.put(CH.PREPARE + "date." + name, createFormatter().format(new Date())); } }, name);
@Override public void run() { if (plm.loadExisting()) return; LOGGER.info(tmpCounter + "/" + getPreparations().size() + " calling LM prepare.doWork for " + plm.getWeighting() + " ... (" + getMemInfo() + ")"); prepared.set(true); Thread.currentThread().setName(name); plm.doWork(); properties.put(Landmark.PREPARE + "date." + name, createFormatter().format(new Date())); } }, name);
/** * For landmarks it is required to always call this method: either it creates the landmark data or it loads it. */ protected void loadOrPrepareLM() { boolean tmpPrepare = lmFactoryDecorator.isEnabled() && !lmFactoryDecorator.getPreparations().isEmpty(); if (tmpPrepare) { ensureWriteAccess(); ghStorage.freeze(); if (lmFactoryDecorator.loadOrDoWork(ghStorage.getProperties())) ghStorage.getProperties().put(Landmark.PREPARE + "done", true); } }
protected void prepareCH() { boolean tmpPrepare = chFactoryDecorator.isEnabled(); if (tmpPrepare) { ensureWriteAccess(); ghStorage.freeze(); chFactoryDecorator.prepare(ghStorage.getProperties()); ghStorage.getProperties().put(CH.PREPARE + "done", true); } }
/** * For landmarks it is required to always call this method: either it creates the landmark data or it loads it. */ protected void loadOrPrepareLM() { boolean tmpPrepare = lmFactoryDecorator.isEnabled(); if (tmpPrepare) { ensureWriteAccess(); ghStorage.freeze(); if (lmFactoryDecorator.loadOrDoWork(ghStorage.getProperties())) ghStorage.getProperties().put(Landmark.PREPARE + "done", true); } }
protected void prepareCH() { boolean tmpPrepare = chFactoryDecorator.isEnabled(); if (tmpPrepare) { ensureWriteAccess(); if (chFactoryDecorator.getPreparationThreads() > 1 && dataAccessType.isMMap() && !dataAccessType.isSynched()) throw new IllegalStateException("You cannot execute CH preparation in parallel for MMAP without synching! Specify MMAP_SYNC or use 1 thread only"); ghStorage.freeze(); chFactoryDecorator.prepare(ghStorage.getProperties()); ghStorage.getProperties().put(CH.PREPARE + "done", true); } }
protected void prepare() { boolean tmpPrepare = chFactoryDecorator.isEnabled(); if (tmpPrepare) { ensureWriteAccess(); if (chFactoryDecorator.getPreparationThreads() > 1 && dataAccessType.isMMap() && !dataAccessType.isSynched()) throw new IllegalStateException("You cannot execute CH preparation in parallel for MMAP without synching! Specify MMAP_SYNC or use 1 thread only"); ghStorage.freeze(); chFactoryDecorator.prepare(ghStorage.getProperties()); } ghStorage.getProperties().put("prepare.done", tmpPrepare); }