Skip to content

Commit

Permalink
Merge pull request #969 from GIScience/Fix_capacity_supercells
Browse files Browse the repository at this point in the history
EnsureCapacity when storing supercell to cellIds data
  • Loading branch information
takb authored Jun 8, 2021
2 parents 3923496 + 09acf24 commit 0932441
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ RELEASING:
- Clarified "Point not found"-Error message ([#922](https://github.com/GIScience/openrouteservice/issues/922))
- Correct isochrones response documentation ([#670](https://github.com/GIScience/openrouteservice/issues/670))
- Duplicate parameter in centrality docs due to spring reading getters for docs
- Bug where supercell subcell ids were out of bounds in storage

## [6.5.0] - 2021-05-17
### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ public void storeContourPointerMap() {
}

/**
* Store super cells.
* Store super cells. It's a block at the end of all other data that stores [superCellId0, subcell0, subcell1, ..., -1, superCellId1, subcell0, subcell1, ..., -1, ..., -1]
* End denomination is by -1 for each supercell block and for the whole block we add another trailing -1.
*
* @param superCells the super cells
*/
Expand All @@ -276,6 +277,8 @@ public void storeSuperCells(IntObjectMap<IntHashSet> superCells) {
cells.setHeader(8, (int) (cellContourPointer >> 32));
cells.setHeader(12, (int) cellContourPointer);
for (IntObjectCursor<IntHashSet> superCell : superCells) {
// + 1 for supercellId and + 1 for trailing -1
cells.ensureCapacity(cellContourPointer + (long) (superCell.value.size() + 2) * byteCount);
cells.setInt(cellContourPointer, superCell.key);
cellContourPointer = cellContourPointer + (long) byteCount;
for (IntCursor cellId : superCell.value) {
Expand All @@ -288,6 +291,7 @@ public void storeSuperCells(IntObjectMap<IntHashSet> superCells) {
cellContourPointer = cellContourPointer + (long) byteCount;
}
//Add second trailing -1 to mark end of superCell block
cells.ensureCapacity(cellContourPointer + (long) byteCount);
cells.setInt(cellContourPointer, -1);
cellContourPointer = cellContourPointer + (long) byteCount;
}
Expand Down

0 comments on commit 0932441

Please sign in to comment.