Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dynamically size extra info buffer #1821

Merged
merged 2 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ RELEASING:
### Fixed
### Security

## [unreleased]

### Added
### Changed
### Deprecated
### Removed
### Fixed
- allow any number of csv columns ([#1436](https://github.com/GIScience/openrouteservice/issues/1436))
### Security

## [8.1.1] - 2024-07-17
### Added
- added danish tranlations ([#1809](https://github.com/GIScience/openrouteservice/pull/1809))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ public class ExtraInfoProcessor implements PathProcessor {
encoderWithPriority = encoder.supports(PriorityWeighting.class);
List<String> skippedExtras = new ArrayList<>();

//Sufficient size for every extra info except csv.
int buffer_size = 4;

try {
PMap params = opts;
if (params == null) {
Expand Down Expand Up @@ -274,6 +277,9 @@ public class ExtraInfoProcessor implements PathProcessor {
csvInfo = new RouteExtraInfo("csv");
csvInfoBuilder = new AppendableRouteExtraInfoBuilder(csvInfo);
csvColumn = extCsvData.columnIndex(params.getString("weighting_#csv#column", ""));

//Determine minimal size buffer size, as 4 might not be sufficient.
buffer_size = Math.max(extCsvData.numEntries(), buffer_size);
} else {
skippedExtras.add("csv");
}
Expand All @@ -284,7 +290,7 @@ public class ExtraInfoProcessor implements PathProcessor {
if (!skippedExtras.isEmpty()) {
skippedExtraInfo = String.join(", ", skippedExtras);
}
buffer = new byte[4];
buffer = new byte[buffer_size];
}

/**
Expand Down
Loading