Search in sources :

Example 1 with EntityConsumerAdapter

use of com.baremaps.osm.function.EntityConsumerAdapter in project baremaps by baremaps.

the class OpenStreetMapBenchmark method entityStream.

@Benchmark
@BenchmarkMode(Mode.SingleShotTime)
@Warmup(iterations = 2)
@Measurement(iterations = 5)
public void entityStream() throws IOException {
    AtomicLong nodes = new AtomicLong(0);
    AtomicLong ways = new AtomicLong(0);
    AtomicLong relations = new AtomicLong(0);
    try (InputStream inputStream = new BufferedInputStream(Files.newInputStream(path))) {
        new OsmPbfParser().entities(inputStream).forEach(new EntityConsumerAdapter() {

            @Override
            public void match(Node node) {
                nodes.incrementAndGet();
            }

            @Override
            public void match(Way way) {
                ways.incrementAndGet();
            }

            @Override
            public void match(Relation relation) {
                relations.incrementAndGet();
            }
        });
    }
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) Relation(com.baremaps.osm.domain.Relation) BufferedInputStream(java.io.BufferedInputStream) BufferedInputStream(java.io.BufferedInputStream) InputStream(java.io.InputStream) Node(com.baremaps.osm.domain.Node) EntityConsumerAdapter(com.baremaps.osm.function.EntityConsumerAdapter) Way(com.baremaps.osm.domain.Way) OsmPbfParser(com.baremaps.osm.pbf.OsmPbfParser) Measurement(org.openjdk.jmh.annotations.Measurement) Warmup(org.openjdk.jmh.annotations.Warmup) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 2 with EntityConsumerAdapter

use of com.baremaps.osm.function.EntityConsumerAdapter in project baremaps by baremaps.

the class OpenStreetMapGeometriesBenchmark method store.

@Benchmark
@BenchmarkMode(Mode.SingleShotTime)
@Warmup(iterations = 0)
@Measurement(iterations = 1)
public void store() throws IOException {
    Path directory = Files.createTempDirectory(Paths.get("."), "benchmark_");
    LongDataMap<Coordinate> coordinates = new LongDataOpenHashMap<>(new DataStore<>(new CoordinateDataType(), new OnDiskMemory(directory)));
    LongDataMap<List<Long>> references = new LongDataOpenHashMap<>(new DataStore<>(new LongListDataType(), new OnHeapMemory()));
    AtomicLong nodes = new AtomicLong(0);
    AtomicLong ways = new AtomicLong(0);
    AtomicLong relations = new AtomicLong(0);
    try (InputStream inputStream = new BufferedInputStream(Files.newInputStream(path))) {
        new OsmPbfParser().coordinates(coordinates).references(references).projection(4326).entities(inputStream).forEach(new EntityConsumerAdapter() {

            @Override
            public void match(Node node) {
                nodes.incrementAndGet();
            }

            @Override
            public void match(Way way) {
                ways.incrementAndGet();
            }

            @Override
            public void match(Relation relation) {
                relations.incrementAndGet();
            }
        });
    }
}
Also used : Path(java.nio.file.Path) LongListDataType(com.baremaps.store.type.LongListDataType) BufferedInputStream(java.io.BufferedInputStream) InputStream(java.io.InputStream) Node(com.baremaps.osm.domain.Node) OnDiskMemory(com.baremaps.store.memory.OnDiskMemory) EntityConsumerAdapter(com.baremaps.osm.function.EntityConsumerAdapter) Way(com.baremaps.osm.domain.Way) AtomicLong(java.util.concurrent.atomic.AtomicLong) Relation(com.baremaps.osm.domain.Relation) Coordinate(org.locationtech.jts.geom.Coordinate) BufferedInputStream(java.io.BufferedInputStream) CoordinateDataType(com.baremaps.store.type.CoordinateDataType) List(java.util.List) LongDataOpenHashMap(com.baremaps.store.LongDataOpenHashMap) OnHeapMemory(com.baremaps.store.memory.OnHeapMemory) OsmPbfParser(com.baremaps.osm.pbf.OsmPbfParser) Measurement(org.openjdk.jmh.annotations.Measurement) Warmup(org.openjdk.jmh.annotations.Warmup) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Aggregations

Node (com.baremaps.osm.domain.Node)2 Relation (com.baremaps.osm.domain.Relation)2 Way (com.baremaps.osm.domain.Way)2 EntityConsumerAdapter (com.baremaps.osm.function.EntityConsumerAdapter)2 OsmPbfParser (com.baremaps.osm.pbf.OsmPbfParser)2 BufferedInputStream (java.io.BufferedInputStream)2 InputStream (java.io.InputStream)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 Benchmark (org.openjdk.jmh.annotations.Benchmark)2 BenchmarkMode (org.openjdk.jmh.annotations.BenchmarkMode)2 Measurement (org.openjdk.jmh.annotations.Measurement)2 Warmup (org.openjdk.jmh.annotations.Warmup)2 LongDataOpenHashMap (com.baremaps.store.LongDataOpenHashMap)1 OnDiskMemory (com.baremaps.store.memory.OnDiskMemory)1 OnHeapMemory (com.baremaps.store.memory.OnHeapMemory)1 CoordinateDataType (com.baremaps.store.type.CoordinateDataType)1 LongListDataType (com.baremaps.store.type.LongListDataType)1 Path (java.nio.file.Path)1 List (java.util.List)1 Coordinate (org.locationtech.jts.geom.Coordinate)1