Skip to content

Commit

Permalink
fix: dynamically size extra info buffer (#1821)
Browse files Browse the repository at this point in the history
  • Loading branch information
aoles authored Jul 23, 2024
2 parents 1375347 + 2a0cfae commit 83c33b6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
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

0 comments on commit 83c33b6

Please sign in to comment.