Repository navigation
When updating geometry, reuse area of existing edge #500 - #769
highsource wants to merge 2 commits into
Conversation
the new point list is not larger.
| // If old array was smaller, erase contents | ||
| if (len < count) | ||
| { | ||
| eraseWayGeometryAtGeoRef(count, existingGeoRef); |
There was a problem hiding this comment.
I know it is cleaner: but why would we need to erase this?
There was a problem hiding this comment.
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 contentsif (len < count){ I know it is cleaner: but why would we need to clear this?eraseWayGeometryAtGeoRef(count, existingGeoRef);—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
There was a problem hiding this comment.
Should I remove the erasure and send another PR?
There was a problem hiding this comment.
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.
|
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. |
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 :) |
|
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. |
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"). |
|
I've removed erasure for now. It's easy to add it later on. |
|
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 |
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.