protected void flush() { logger.info("flushing graph " + ghStorage.toString() + ", details:" + ghStorage.toDetailsString() + ", " + getMemInfo() + ")"); ghStorage.flush(); logger.info("flushed graph " + getMemInfo() + ")"); fullyLoaded = true; }
@Test public void testLoadingWithLessWeightings_works() { // we start with a gh storage with two ch weightings and flush it to disk FastestWeighting weighting1 = new FastestWeighting(carEncoder); ShortestWeighting weighting2 = new ShortestWeighting(carEncoder); GraphHopperStorage originalStorage = createStorageWithWeightings(weighting1, weighting2); originalStorage.create(defaultSize); originalStorage.flush(); // now we create a new storage but only use one of the weightings, which should be ok GraphHopperStorage smallStorage = createStorageWithWeightings(weighting1); smallStorage.loadExisting(); assertEquals(1, smallStorage.getCHWeightings().size()); smallStorage.flush(); // now we create yet another storage that uses both weightings again, which still works GraphHopperStorage fullStorage = createStorageWithWeightings(weighting1, weighting2); fullStorage.loadExisting(); assertEquals(2, fullStorage.getCHWeightings().size()); fullStorage.flush(); }
graphHopperStorage.flush(); return graphHopperStorage;
@Test(expected = IllegalStateException.class) public void testLoadingWithWrongWeighting_throws() { // we start with one weighting GraphHopperStorage ghStorage = newGHStorage(new GHDirectory(defaultGraphLoc, DAType.RAM_STORE), false); ghStorage.create(defaultSize); ghStorage.flush(); // but then configure another weighting and try to load the graph from disk -> error GraphHopperStorage newGHStorage = createStorageWithWeightings(new ShortestWeighting(carEncoder)); newGHStorage.loadExisting(); }
@Test(expected = IllegalStateException.class) public void testLoadingWithExtraWeighting_throws() { // we start with one weighting GraphHopperStorage ghStorage = newGHStorage(new GHDirectory(defaultGraphLoc, DAType.RAM_STORE), false); ghStorage.create(defaultSize); ghStorage.flush(); // but then add an additional weighting and try to load the graph from disk -> error GraphHopperStorage newGHStorage = createStorageWithWeightings( new FastestWeighting(carEncoder), new ShortestWeighting(carEncoder)); newGHStorage.loadExisting(); }
@Test public void testDoThrowExceptionIfDimDoesNotMatch() { graph = newGHStorage(new RAMDirectory(defaultGraphLoc, true), false); graph.create(1000); graph.flush(); graph.close(); graph = newGHStorage(new RAMDirectory(defaultGraphLoc, true), true); try { graph.loadExisting(); assertTrue(false); } catch (Exception ex) { } }
@Test public void testSave_and_Freeze() throws IOException { graph = newGHStorage(new RAMDirectory(defaultGraphLoc, true), true).create(defaultSize); graph.edge(1, 0); graph.freeze(); graph.flush(); graph.close(); graph = newGHStorage(new MMapDirectory(defaultGraphLoc), true); assertTrue(graph.loadExisting()); assertEquals(2, graph.getNodes()); assertTrue(graph.isFrozen()); }
@Test public void testCannotBeLoadedWithNormalGraphHopperStorageClass() { graph = newGHStorage(new RAMDirectory(defaultGraphLoc, true), false).create(defaultSize); graph.flush(); graph.close(); graph = new GraphBuilder(encodingManager).setLocation(defaultGraphLoc).setMmap(false).setStore(true).create(); try { graph.loadExisting(); fail(); } catch (Exception ex) { } graph = newGHStorage(new RAMDirectory(defaultGraphLoc, true), false); assertTrue(graph.loadExisting()); // empty graph still has invalid bounds assertEquals(graph.getBounds(), BBox.createInverse(false)); }
graph.getEdgeIteratorState(1, 2).setFlags(carFlagEncoder.handleWayTags(way_1_2, 1, 0)); graph.flush(); graph.close();
graph.getEdgeIteratorState(2, 0).setFlags(encoder.handleWayTags(way_2_0, 1, 0)); graph.flush(); graph.close();
@Test public void testSave_and_fileFormat() throws IOException { graph = newGHStorage(new RAMDirectory(defaultGraphLoc, true), true).create(defaultSize); NodeAccess na = graph.getNodeAccess(); assertTrue(na.is3D()); na.setNode(0, 10, 10, 0); na.setNode(1, 11, 20, 1); na.setNode(2, 12, 12, 0.4); EdgeIteratorState iter2 = graph.edge(0, 1, 100, true); iter2.setWayGeometry(Helper.createPointList3D(1.5, 1, 0, 2, 3, 0)); EdgeIteratorState iter1 = graph.edge(0, 2, 200, true); iter1.setWayGeometry(Helper.createPointList3D(3.5, 4.5, 0, 5, 6, 0)); graph.edge(9, 10, 200, true); graph.edge(9, 11, 200, true); graph.edge(1, 2, 120, false); iter1.setName("named street1"); iter2.setName("named street2"); checkGraph(graph); graph.flush(); graph.close(); graph = newGHStorage(new MMapDirectory(defaultGraphLoc), true); assertTrue(graph.loadExisting()); assertEquals(12, graph.getNodes()); checkGraph(graph); assertEquals("named street1", graph.getEdgeIteratorState(iter1.getEdge(), iter1.getAdjNode()).getName()); assertEquals("named street2", graph.getEdgeIteratorState(iter2.getEdge(), iter2.getAdjNode()).getName()); graph.edge(3, 4, 123, true).setWayGeometry(Helper.createPointList3D(4.4, 5.5, 0, 6.6, 7.7, 0)); checkGraph(graph); }
graph.flush(); graph.close();
assertEquals(1, GHUtility.count(chGraph.createEdgeExplorer().setBaseNode(2))); graph.flush(); graph.close();
protected void flush() { logger.info("flushing graph " + ghStorage.toString() + ", details:" + ghStorage.toDetailsString() + ", " + Helper.getMemInfo() + ")"); ghStorage.flush(); logger.info("flushed graph " + Helper.getMemInfo() + ")"); fullyLoaded = true; }
protected void flush() { logger.info("flushing graph " + ghStorage.toString() + ", details:" + ghStorage.toDetailsString() + ", " + getMemInfo() + ")"); ghStorage.flush(); logger.info("flushed graph " + getMemInfo() + ")"); fullyLoaded = true; }
protected void flush() { logger.info("flushing graph " + ghStorage.toString() + ", details:" + ghStorage.toDetailsString() + ", " + Helper.getMemInfo() + ")"); ghStorage.flush(); logger.info("flushed graph " + Helper.getMemInfo() + ")"); fullyLoaded = true; }