-
-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pull in pbf parsing to give more control over threading model and performance.
- Loading branch information
Showing
34 changed files
with
1,840 additions
and
726 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...tiler-benchmarks/src/main/java/com/onthegomap/planetiler/benchmarks/BenchmarkOsmRead.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.onthegomap.planetiler.benchmarks; | ||
|
||
import com.onthegomap.planetiler.Profile; | ||
import com.onthegomap.planetiler.collection.LongLongMap; | ||
import com.onthegomap.planetiler.config.Arguments; | ||
import com.onthegomap.planetiler.config.PlanetilerConfig; | ||
import com.onthegomap.planetiler.reader.osm.OsmInputFile; | ||
import com.onthegomap.planetiler.reader.osm.OsmReader; | ||
import com.onthegomap.planetiler.stats.Stats; | ||
import com.onthegomap.planetiler.stats.Timer; | ||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
|
||
public class BenchmarkOsmRead { | ||
|
||
public static void main(String[] args) throws IOException { | ||
OsmInputFile file = new OsmInputFile(Path.of("data/sources/northeast.osm.pbf"), true); | ||
var profile = new Profile.NullProfile(); | ||
var stats = Stats.inMemory(); | ||
var config = PlanetilerConfig.from(Arguments.of()); | ||
|
||
while (true) { | ||
Timer timer = Timer.start(); | ||
try ( | ||
var nodes = LongLongMap.noop(); | ||
var reader = new OsmReader("osm", file, nodes, profile, stats) | ||
) { | ||
reader.pass1(config); | ||
} | ||
System.err.println(timer.stop()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 0 additions & 13 deletions
13
planetiler-core/src/main/java/com/graphhopper/reader/ReaderElementUtils.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
planetiler-core/src/main/java/com/onthegomap/planetiler/reader/osm/OsmBlockSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.onthegomap.planetiler.reader.osm; | ||
|
||
import java.io.Closeable; | ||
import java.util.function.Consumer; | ||
|
||
/** | ||
* An osm.pbf input file that iterates through {@link Block Blocks} of raw bytes that can be decompressed/parsed in | ||
* worker threads using {@link Block#decodeElements()}. | ||
*/ | ||
public interface OsmBlockSource extends Closeable { | ||
|
||
/** Calls {@code consumer} for each block from the input file sequentially in a single thread. */ | ||
void forEachBlock(Consumer<Block> consumer); | ||
|
||
@Override | ||
default void close() { | ||
} | ||
|
||
/** | ||
* An individual block of raw bytes from an osm.pbf file that can be decompressed/parsed with {@link | ||
* #decodeElements()}. | ||
*/ | ||
interface Block { | ||
|
||
/** Create a fake block from existing elements - useful for tests. */ | ||
static Block of(Iterable<? extends OsmElement> items) { | ||
return () -> items; | ||
} | ||
|
||
/** Decompress and parse OSM elements from this block. */ | ||
Iterable<? extends OsmElement> decodeElements(); | ||
|
||
default int id() { | ||
return -1; | ||
} | ||
} | ||
} |
Oops, something went wrong.