Skip to content

When updating geometry, reuse area of existing edge #500 - #769

Closed
highsource wants to merge 2 commits into
graphhopper:masterfrom
dbsystel:issue-500-1
Closed

highsource wants to merge 2 commits into
graphhopper:masterfrom
dbsystel:issue-500-1

Conversation

@highsource

Copy link
Copy Markdown
Contributor

Solves a part of #500 by reusing the geometry area of existing edge if the new point list is not larger.

I had to expose maxGeoRef to be able to test it, I hope it's ok.

I've also decided it would be good to erase existing contents if new point list is smaller than existing. Otherwise we'll have some old coordinates laying around.

Another improvement would be to store the maximum size of the area. Then it would be possible to reuse it even if point list grows but stays beyond that maximum size. Would require storing max size next to count which is probably not so good.

// If old array was smaller, erase contents
if (len < count)
{
eraseWayGeometryAtGeoRef(count, existingGeoRef);

@karussell karussell Aug 17, 2016 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it is cleaner: but why would we need to erase this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok to drop the erasure. Zeroes would make it easier to see empty parts. It would also make data blocks better compressible. But that's not really necessary.

Am 17.08.2016 um 22:34 schrieb Peter [email protected]:

In core/src/main/java/com/graphhopper/storage/BaseGraph.java:

  •            bitUtil.fromInt(bytes, Helper.degreeToInt(pillarNodes.getLongitude(i)), tmpOffset);
    

- tmpOffset += 4;

  •            if (is3D)
    
  •            {
    
  •                bitUtil.fromInt(bytes, Helper.eleToInt(pillarNodes.getElevation(i)), tmpOffset);
    
  •                tmpOffset += 4;
    
  •            }
    
  •           long existingGeoRefPos = existingGeoRef \* 4L;
    
  •           final int count = wayGeometry.getInt(existingGeoRefPos);
    
  •           if (len <= count)
    
  •           {
    
  •               // If old array was smaller, erase contents
    
  •               if (len < count)
    
  •               {
    
  •                   eraseWayGeometryAtGeoRef(count, existingGeoRef);
    
    I know it is cleaner: but why would we need to clear this?

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I remove the erasure and send another PR?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to just do another commit in your branch and it should show up here. But I'll do the code formatting and merge this with your changes (+could remove the method) - let me know what to do :)

Regarding compressibility: that is indeed true. But I'm unsure how we can apply compression to the geometry and still keep everything else working & fast.

@highsource

Copy link
Copy Markdown
Contributor Author

Ok, will do. And yes, you'll need to reformat. I used default Eclipse code formatter, but will probably switch to IntelliJ later on.

Compressibility - I was not thinking about realtime compression, more about storage compression on disc. But let's drop it for now.

@karussell

Copy link
Copy Markdown
Member

Compressibility - I was not thinking about realtime compression, more about storage compression on disc. But let's drop it for now.

We 'store' stuff in-memory (via byte or int arrays) in the identical format we store data on disc. So reading stuff into memory is very simple and also switching to memory mapped. E.g. for memory mapped we read edge properties from a DataAccess but the same happens for an in-memory DataAccess. So at the end there is (currently) no difference between storage compression and realtime compression ... I hope I have not misunderstood what you mean :)

@highsource

Copy link
Copy Markdown
Contributor Author

Yes, I understand that and you got me right. I was just thinking of use cases like data transfer where you download the prepared files of the graph as a zipped package and the unzip them. But really, let's drop it, it does not seem to be a direct use case at the moment.
I'll send the fix shortly.

@karussell

Copy link
Copy Markdown
Member

But really, let's drop it, it does not seem to be a direct use case at the moment.

Ah, I now understand what you mean: that is indeed true and could lead to smaller compressed files. We are currently doing compressed graphhopper files for Android (".ghz").

@highsource

Copy link
Copy Markdown
Contributor Author

I've removed erasure for now. It's easy to add it later on.

@karussell karussell added this to the 0.8 milestone Aug 19, 2016
@karussell

karussell commented Aug 19, 2016 •

Copy link
Copy Markdown
Member

Thanks a lot for this fix! I've just applied minor code formatting and moved the test into the abstract tester, so that all graph implementations run through this. BTW: there is no need to close the graph as this is part of the shutdown method. Also I've removed the (hopefully?) unrelated checkGraph call and some other method calls. Furthermore have added you as contributor :)

See dfd62e2

@karussell karussell closed this Aug 19, 2016
@highsource
highsource deleted the issue-500-1 branch August 19, 2016 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants