Skip to content

Commit

Permalink
Updating to R5 7.0 and Java 21
Browse files Browse the repository at this point in the history
  • Loading branch information
mvpsaraiva committed Dec 4, 2023
1 parent 359e72d commit 0c7d17f
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 28 deletions.
9 changes: 0 additions & 9 deletions java-r5rcore/.idea/libraries/r5_v6_9_all.xml

This file was deleted.

2 changes: 1 addition & 1 deletion java-r5rcore/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion java-r5rcore/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group 'org.ipea'
version '1.0.2-SNAPSHOT'
version '1.1.0999-SNAPSHOT'

// Build against the version of R5 that the current r5r download_r5 function will
// grab
Expand Down
2 changes: 1 addition & 1 deletion java-r5rcore/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
16 changes: 13 additions & 3 deletions java-r5rcore/src/org/ipea/r5r/Network/NetworkChecker.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package org.ipea.r5r.Network;

import com.conveyal.kryo.InstanceCountingClassResolver;
import com.conveyal.kryo.TIntArrayListSerializer;
import com.conveyal.kryo.TIntIntHashMapSerializer;
import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.serializers.ExternalizableSerializer;
import com.esotericsoftware.kryo.serializers.JavaSerializer;
import com.esotericsoftware.kryo.util.DefaultInstantiatorStrategy;
import gnu.trove.impl.hash.TPrimitiveHash;
import gnu.trove.list.array.TIntArrayList;
import gnu.trove.map.hash.TIntIntHashMap;
Expand All @@ -23,10 +25,13 @@ public class NetworkChecker {
* This string should be changed to a new value each time the network storage format changes.
* I considered using an ISO date string but that could get confusing when seen in filenames.
*/
public static final String NETWORK_FORMAT_VERSION = "nv2";
public static final String NETWORK_FORMAT_VERSION = "nv3";

public static final byte[] HEADER = "R5NETWORK".getBytes();

/** Set this to true to count instances and print a report including which serializer is handling each class. */
private static final boolean COUNT_CLASS_INSTANCES = false;

private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(NetworkChecker.class);

public static boolean checkR5NetworkVersion(String dataFolder) throws FileNotFoundException {
Expand Down Expand Up @@ -61,7 +66,12 @@ public static boolean checkR5NetworkVersion(String dataFolder) throws FileNotFou
* Registration is more important for small network messages.
*/
private static Kryo makeKryo () {
Kryo kryo = new Kryo();
Kryo kryo;
if (COUNT_CLASS_INSTANCES) {
kryo = new Kryo(new InstanceCountingClassResolver(), null);
} else {
kryo = new Kryo();
}
// Auto-associate classes with default serializers the first time each class is encountered.
kryo.setRegistrationRequired(false);
// Handle references and loops in the object graph, do not repeatedly serialize the same instance.
Expand All @@ -85,7 +95,7 @@ private static Kryo makeKryo () {
// The default strategy requires every class you serialize, even in your dependencies, to have a zero-arg
// constructor (which can be private). The setInstantiatorStrategy method completely replaces that default
// strategy. The nesting below specifies the Java approach as a fallback strategy to the default strategy.
kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new SerializingInstantiatorStrategy()));
kryo.setInstantiatorStrategy(new DefaultInstantiatorStrategy(new SerializingInstantiatorStrategy()));
return kryo;
}

Expand Down
4 changes: 2 additions & 2 deletions java-r5rcore/src/org/ipea/r5r/R5RCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@

public class R5RCore {

public static final String R5_VERSION = "6.9";
public static final String R5R_VERSION = "1.0.0";
public static final String R5_VERSION = "7.0";
public static final String R5R_VERSION = "1.1.0";

private int numberOfThreads;
private ForkJoinPool r5rThreadPool;
Expand Down
4 changes: 2 additions & 2 deletions r-package/R/download_r5.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
#' @examplesIf identical(tolower(Sys.getenv("NOT_CRAN")), "true")
#' library(r5r)
#'
#' download_r5(version = "6.9.0", temp_dir = TRUE)
#' download_r5(version = "7.0.0", temp_dir = TRUE)
#' @export
download_r5 <- function(version = "6.9.0",
download_r5 <- function(version = "7.0.0",
quiet = FALSE,
force_update = FALSE,
temp_dir = FALSE) {
Expand Down
10 changes: 5 additions & 5 deletions r-package/R/setup_r5.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ setup_r5 <- function(data_path,
overwrite = FALSE) {

# R5 version
version = "6.9.0"
version = "7.0.0"

# check inputs ------------------------------------------------------------

Expand All @@ -78,13 +78,13 @@ setup_r5 <- function(data_path,
rJava::.jinit()
ver <- rJava::.jcall("java.lang.System", "S", "getProperty", "java.version")
ver <- as.numeric(gsub("\\..*", "", ver))
if (ver != 11) {
if (ver != 21) {
stop(
"This package requires the Java SE Development Kit 11.\n",
"This package requires the Java SE Development Kit 21.\n",
"Please update your Java installation. ",
"The jdk 11 can be downloaded from either:\n",
" - openjdk: https://jdk.java.net/java-se-ri/11\n",
" - oracle: https://www.oracle.com/java/technologies/javase-jdk11-downloads.html"
" - openjdk: https://jdk.java.net/java-se-ri/21\n",
" - oracle: https://docs.oracle.com/en/java/javase/21/install/index.html"
)
}

Expand Down
1 change: 1 addition & 0 deletions r-package/inst/extdata/metadata_r5r.csv
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ version;release_date;download_path
6.7.0;20220509;https://github.com/conveyal/r5/releases/download/v6.7/r5-v6.7-all.jar
6.8.0;20230109;https://github.com/conveyal/r5/releases/download/v6.8/r5-v6.8-all.jar
6.9.0;20230305;https://github.com/conveyal/r5/releases/download/v6.9/r5-v6.9-all.jar
7.0.0;20231203;https://github.com/conveyal/r5/releases/download/v7.0/r5-v7.0-all.jar
Binary file modified r-package/inst/jar/r5r.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions r-package/man/download_r5.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions r-package/tests/tests_rafa/r5r_arrow.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ ttm <- travel_time_matrix(r5r_core = r5r_core,
mode = mode,
departure_datetime = departure_datetime,
max_walk_time = max_walk_time,
max_trip_duration = max_trip_duration,
output_dir = './aaaa')
max_trip_duration = max_trip_duration)#,
# output_dir = './aaaa')



Expand Down

0 comments on commit 0c7d17f

Please sign in to comment.