aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Topolnik <marko.topolnik@gmail.com>2024-01-06 10:19:13 +0100
committerGunnar Morling <gunnar.morling@googlemail.com>2024-01-06 10:35:44 +0100
commit35b90992aaae06f3a301b07335e1fad71ad1ae38 (patch)
treec0728c83f0e9f65f2505fc20a75dc282a9001e0d
parent7ec968d3bbab75737ab4a16861c8529fccb049ce (diff)
More detailed attribution
-rw-r--r--data/weather_stations.csv1
-rw-r--r--src/main/java/dev/morling/onebrc/CreateMeasurements3.java9
2 files changed, 8 insertions, 2 deletions
diff --git a/data/weather_stations.csv b/data/weather_stations.csv
index 4822109..c685915 100644
--- a/data/weather_stations.csv
+++ b/data/weather_stations.csv
@@ -1,4 +1,5 @@
# Adapted from https://simplemaps.com/data/world-cities
+# Licensed under Creative Commons Attribution 4.0 (https://creativecommons.org/licenses/by/4.0/
Tokyo;35.6897
Jakarta;-6.1750
Delhi;28.6100
diff --git a/src/main/java/dev/morling/onebrc/CreateMeasurements3.java b/src/main/java/dev/morling/onebrc/CreateMeasurements3.java
index 0b3f9c3..fb3a97d 100644
--- a/src/main/java/dev/morling/onebrc/CreateMeasurements3.java
+++ b/src/main/java/dev/morling/onebrc/CreateMeasurements3.java
@@ -71,7 +71,7 @@ public class CreateMeasurements3 {
// which we'll use as a "source of city name randomness"
var bigName = new StringBuilder(1 << 20);
try (var rows = new BufferedReader(new FileReader("data/weather_stations.csv"));) {
- rows.readLine(); // Skip the attribution line
+ skipComments(rows);
while (true) {
var row = rows.readLine();
if (row == null) {
@@ -85,7 +85,7 @@ public class CreateMeasurements3 {
var minLen = Integer.MAX_VALUE;
var maxLen = Integer.MIN_VALUE;
try (var rows = new BufferedReader(new FileReader("data/weather_stations.csv"))) {
- rows.readLine(); // Skip the attribution line
+ skipComments(rows);
final var nameSource = new StringReader(bigName.toString());
final var buf = new char[MAX_NAME_LEN];
final var rnd = ThreadLocalRandom.current();
@@ -146,6 +146,11 @@ public class CreateMeasurements3 {
return weatherStations;
}
+ private static void skipComments(BufferedReader rows) throws IOException {
+ while (rows.readLine().startsWith("#")) {
+ }
+ }
+
private static char readNonSpace(StringReader nameSource) throws IOException {
while (true) {
var n = nameSource.read();