Skip to content

Properties segments - #3129

Merged
karussell merged 7 commits into
graphhopper:masterfrom
otbutz:properties_segments
Mar 3, 2025
Merged

karussell merged 7 commits into
graphhopper:masterfrom
otbutz:properties_segments

Conversation

@otbutz

@otbutz otbutz commented Feb 25, 2025

Copy link
Copy Markdown
Contributor

Fixes #3102

Allow StorableProperties to use multiple segments of the underlying DataAccess to persist its entries.

Comment on lines +57 to +60
int segmentSize = da.getSegmentSize();
int segmentCount = (int) Math.ceil((double) len / segmentSize);
for (int i = 0; i < segmentCount; i++) {
int bytePos = i * segmentSize;

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.

For clarity we could use:

for (long bytePos = 0; bytePos < len; bytePos += segmentSize)

?

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.

Done

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.

Thanks! As DataAccess.length could be long we should use long, also for bytePos. This also avoids the cast (to len).

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 can add a check for overflows, but ultimately this all needs to be converted to a simple byte array backing the String, which only allows a length of up to Integer.MAX_VALUE.

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.

Ah, sure. Of course. Thanks.

@karussell karussell left a comment

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.

Thank you!

@karussell karussell added this to the 11.0 milestone Feb 26, 2025
@karussell karussell added the bug label Feb 26, 2025
@karussell
karussell merged commit 54fd284 into graphhopper:master Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ArrayIndexOutOfBoundsException encountered with flushing properties to disk with large number of StringEncodedValues.

2 participants