aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGunnar Morling <gunnar.morling@googlemail.com>2023-12-28 22:33:15 +0100
committerGunnar Morling <gunnar.morling@googlemail.com>2023-12-28 22:33:15 +0100
commit3854500520dec78e5b386b6533404d6f6373f907 (patch)
tree4f46249e33d30d9cd0c5c4cd43c2d8a449eed90f
parentfd9a5f97998c7e3c609517ac28a3132d58b402ce (diff)
📈 More stations
-rw-r--r--README.md22
-rwxr-xr-xevaluate.sh22
-rw-r--r--src/main/java/dev/morling/onebrc/CreateMeasurements.java22
3 files changed, 55 insertions, 11 deletions
diff --git a/README.md b/README.md
index 4c418c3..9b97336 100644
--- a/README.md
+++ b/README.md
@@ -8,22 +8,22 @@ Each row is one measurement in the format `<string: station id>;<double: measure
The following shows ten rows as an example:
```
-hamburg;11.0
-hammerfest;-12.7
-auckland;5.3
-lima;6.6
-concordia;-42.5
-hammerfest;-6.7
-hamburg;9.0
-hammerfest;-11.9
-hamburg;-0.7
-concordia;-48.5
+Hamburg;12.0
+Bulawayo;8.9
+Palembang;38.8
+St. John's;15.2
+Cracow;12.6
+Bridgetown;26.9
+Istanbul;6.2
+Roseau;34.4
+Conakry;31.2
+Istanbul;23.0
```
The task is to write a Java program which reads the file, calculates the average temperature value per weather station, and emits the result on stdout like this:
```
-{auckland=5.3, concordia=-45.5, hamburg=6.4, hammerfest=-10.4, lima=6.6}
+{Abha=18.0, Abidjan=26.0, Abéché=29.4, Accra=26.4, Addis Ababa=16.0, Adelaide=17.3, ...}
```
Submit your implementation by Jan 31 2024 and become part of the leaderboard!
diff --git a/evaluate.sh b/evaluate.sh
new file mode 100755
index 0000000..78b4183
--- /dev/null
+++ b/evaluate.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+#
+# Copyright 2023 The original authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+
+for i in {1..5}
+do
+ time ./calculate_average.sh
+done
diff --git a/src/main/java/dev/morling/onebrc/CreateMeasurements.java b/src/main/java/dev/morling/onebrc/CreateMeasurements.java
index ff4b7d7..5f1fdae 100644
--- a/src/main/java/dev/morling/onebrc/CreateMeasurements.java
+++ b/src/main/java/dev/morling/onebrc/CreateMeasurements.java
@@ -52,6 +52,28 @@ public class CreateMeasurements {
System.exit(1);
}
+ // data from https://en.wikipedia.org/wiki/List_of_cities_by_average_temperature;
+ // converted using https://wikitable2csv.ggor.de/
+ // brought to form using DuckDB:
+ // D copy (
+ // select City, regexp_extract(Year,'(.*)\n.*', 1) as AverageTemp
+ // from (
+ // select City,Year
+ // from read_csv_auto('List_of_cities_by_average_temperature_1.csv', header = true)
+ // union
+ // select City,Year
+ // from read_csv_auto('List_of_cities_by_average_temperature_2.csv', header = true)
+ // union
+ // select City,Year
+ // from read_csv_auto('List_of_cities_by_average_temperature_3.csv', header = true)
+ // union
+ // select City,Year
+ // from read_csv_auto('List_of_cities_by_average_temperature_4.csv', header = true)
+ // union
+ // select City,Year
+ // from read_csv_auto('List_of_cities_by_average_temperature_5.csv', header = true)
+ // )
+ // ) TO 'output.csv' (HEADER, DELIMITER ',');
List<WeatherStation> stations = Arrays.asList(
new WeatherStation("Adelaide", 17.3),
new WeatherStation("Melbourne", 15.1),