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

Paths recording refactor #835

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.conveyal.analysis.results;

import com.conveyal.file.FileStorage;
import com.conveyal.r5.analyst.cluster.PathResult;
import com.conveyal.r5.analyst.cluster.RegionalPathResultsSummary;
import com.conveyal.r5.analyst.cluster.RegionalTask;
import com.conveyal.r5.analyst.cluster.RegionalWorkResult;
import org.apache.commons.lang3.ArrayUtils;
Expand All @@ -13,7 +13,6 @@
import static com.google.common.base.Preconditions.checkState;

public class PathCsvResultWriter extends CsvResultWriter {

public PathCsvResultWriter (RegionalTask task, FileStorage fileStorage) throws IOException {
super(task, fileStorage);
}
Expand All @@ -25,14 +24,14 @@ public CsvResultType resultType () {

@Override
public String[] columnHeaders () {
return ArrayUtils.addAll(new String[] {"origin", "destination"}, PathResult.DATA_COLUMNS);
return ArrayUtils.addAll(new String[]{"origin", "destination"}, RegionalPathResultsSummary.DATA_COLUMNS);
}

@Override
public Iterable<String[]> rowValues (RegionalWorkResult workResult) {
List<String[]> rows = new ArrayList<>();
for (int d = 0; d < workResult.pathResult.length; d++) {
ArrayList<String[]> pathsIterations = workResult.pathResult[d];
String[][] pathsIterations = workResult.pathResult[d];
for (String[] iterationDetails : pathsIterations) {
String originId = task.originPointSet.getId(workResult.taskId);
String destinationId = destinationId(workResult.taskId, d);
Expand All @@ -50,10 +49,10 @@ protected void checkDimension (RegionalWorkResult workResult) {
// the origin point. Otherwise, for each origin, we expect one value per destination.
final int nDestinations = task.oneToOne ? 1 : task.destinationPointSets[0].featureCount();
checkDimension(workResult, "destinations", workResult.pathResult.length, nDestinations);
for (ArrayList<String[]> oneDestination : workResult.pathResult) {
for (String[][] oneDestination : workResult.pathResult) {
// Number of distinct paths per destination is variable, don't validate it.
for (String[] iterationDetails : oneDestination) {
checkDimension(workResult, "columns", iterationDetails.length, PathResult.DATA_COLUMNS.length);
checkDimension(workResult, "columns", iterationDetails.length, RegionalPathResultsSummary.DATA_COLUMNS.length);
}
}
}
Expand Down
7 changes: 0 additions & 7 deletions src/main/java/com/conveyal/file/FileStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.conveyal.analysis.components.Component;
import com.conveyal.r5.analyst.PersistenceBuffer;
import com.conveyal.r5.analyst.cluster.AnalysisWorkerTask;

import java.io.BufferedInputStream;
import java.io.File;
Expand Down Expand Up @@ -78,12 +77,6 @@ public interface FileStorage extends Component {

//// Convenience methods usable with all concrete subclasses.

/** Store Taui output in subfolders by job ID. */
default void saveTauiData (AnalysisWorkerTask task, String fileName, PersistenceBuffer buffer) {
FileStorageKey key = new FileStorageKey(FileCategory.TAUI, String.join("/", task.jobId, fileName));
moveIntoStorage(key, buffer);
}

/** Read from a file as a stream, decompressing if the name indicates it's gzipped. */
default InputStream getInputStream (FileCategory fileCategory, String fileName) throws IOException {
InputStream inputStream = new FileInputStream(getFile(new FileStorageKey(fileCategory, fileName)));
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/com/conveyal/r5/OneOriginResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.conveyal.r5.analyst.AccessibilityResult;
import com.conveyal.r5.analyst.cluster.PathResult;
import com.conveyal.r5.analyst.cluster.PathResultsRecorder;
import com.conveyal.r5.analyst.cluster.TravelTimeResult;

/**
Expand All @@ -18,12 +19,17 @@ public class OneOriginResult {

public final AccessibilityResult accessibility;

public final PathResult paths;
public final PathResultsRecorder paths;

public OneOriginResult(TravelTimeResult travelTimes, AccessibilityResult accessibility, PathResult paths) {
public OneOriginResult(TravelTimeResult travelTimes, AccessibilityResult accessibility, PathResultsRecorder paths) {
this.travelTimes = travelTimes;
this.accessibility = accessibility;
this.paths = paths;
}

public PathResult[] getPathResults() {
if (paths == null) return null;
return paths.getPathResults();
}

}
124 changes: 0 additions & 124 deletions src/main/java/com/conveyal/r5/analyst/PathScorer.java

This file was deleted.

Loading