private void resetCache( boolean detailed ) { if ( hasInfo() && nodesCache != null ) { logInfo( "NodesCache status before reset=" + nodesCache.formatStatus() ); } nodesMap = new OsmNodesMap(); long maxmem = routingContext.memoryclass * 131072L; // 1/8 of total nodesCache = new NodesCache(segmentDir, nodesMap, routingContext.expctxWay, routingContext.forceSecondaryData, maxmem, nodesCache, detailed ); islandNodePairs.clearTempPairs(); }
private OsmTrack findTrack( String operationName, MatchedWaypoint startWp, MatchedWaypoint endWp, OsmTrack costCuttingTrack, OsmTrack refTrack, boolean fastPartialRecalc ) { try { boolean detailed = guideTrack != null; resetCache( detailed ); return _findTrack( operationName, startWp, endWp, costCuttingTrack, refTrack, fastPartialRecalc ); } finally { nodesCache.clean( false ); // clean only non-virgin caches } }
public int loadSegmentFor( int ilon, int ilat ) { MicroCache mc = getSegmentFor( ilon, ilat ); return mc == null ? 0 : mc.getSize(); }
osmf = fileForSegment( lonDegree, latDegree ); OsmFile[] newFileRow = new OsmFile[ndegrees + 1]; for ( int i = 0; i < ndegrees; i++ ) if ( segment == null ) checkEnableCacheCleaning(); segment = osmf.createMicroCache( ilon, ilat, dataBuffers, expCtxWay, waypointMatcher );
logInfo( "NodesCache status before close=" + nodesCache.formatStatus() ); nodesCache.close(); nodesCache = null;
private void expandHollowLinkTargets( OsmNode n ) { for( OsmLink link = n.firstlink; link != null; link = link.getNext( n ) ) { nodesCache.obtainNonHollowNode( link.getTarget( n ) ); } }
private void preloadPosition( OsmNode n ) { int d = 12500; nodesCache.first_file_access_failed = false; nodesCache.first_file_access_name = null; nodesCache.loadSegmentFor( n.ilon, n.ilat ); if ( nodesCache.first_file_access_failed ) { throw new IllegalArgumentException( "datafile " + nodesCache.first_file_access_name + " not found" ); } for( int idxLat=-1; idxLat<=1; idxLat++ ) for( int idxLon=-1; idxLon<=1; idxLon++ ) { if ( idxLon != 0 || idxLat != 0 ) { nodesCache.loadSegmentFor( n.ilon + d*idxLon , n.ilat +d*idxLat ); } } }
if ( nodesCache != null ) nodesCache.close(); nodesCache = null;
private OsmNode getStartNode( long startId ) { // initialize the start-node OsmNode start = new OsmNode( startId ); start.setHollow(); if ( !nodesCache.obtainNonHollowNode( start ) ) { return null; } expandHollowLinkTargets( start ); return start; }
if ( ! nodesCache.obtainNonHollowNode( nextNode ) ) if ( ! nodesCache.obtainNonHollowNode( nextNode ) )
private OsmTrack findTrack( OsmTrack[] refTracks, OsmTrack[] lastTracks ) { for(;;) { try { return tryFindTrack( refTracks, lastTracks ); } catch( RoutingIslandException rie ) { islandNodePairs.freezeTempPairs(); nodesCache.clean( true ); matchedWaypoints = null; } } }
public boolean obtainNonHollowNode( OsmNode node ) { if ( !node.isHollow() ) return true; MicroCache segment = getSegmentFor( node.ilon, node.ilat ); if ( segment == null ) { return false; } long id = node.getIdFromPos(); if ( segment.getAndClear( id ) ) { node.parseNodeBody( segment, nodesMap, expCtxWay ); } if ( garbageCollectionEnabled ) // garbage collection { cacheSum -= segment.collect( segment.getSize() >> 1 ); // threshold = 1/2 of size is deleted } return !node.isHollow(); }