diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
index 1d2b54d7..65cb4b6e 100644
--- a/.idea/codeStyles/Project.xml
+++ b/.idea/codeStyles/Project.xml
@@ -54,6 +54,8 @@
+
+
@@ -578,9 +580,7 @@
-
-
diff --git a/src/main/java/com/onthegomap/flatmap/MbtilesWriter.java b/src/main/java/com/onthegomap/flatmap/MbtilesWriter.java
index d256cf64..adfd5aef 100644
--- a/src/main/java/com/onthegomap/flatmap/MbtilesWriter.java
+++ b/src/main/java/com/onthegomap/flatmap/MbtilesWriter.java
@@ -18,6 +18,8 @@ import org.slf4j.LoggerFactory;
public class MbtilesWriter {
+ private static final Logger LOGGER = LoggerFactory.getLogger(MbtilesWriter.class);
+
private final AtomicLong featuresProcessed = new AtomicLong(0);
private final AtomicLong memoizedTiles = new AtomicLong(0);
private final AtomicLong tiles = new AtomicLong(0);
@@ -27,8 +29,6 @@ public class MbtilesWriter {
this.stats = stats;
}
- private static final Logger LOGGER = LoggerFactory.getLogger(MbtilesWriter.class);
-
private static record RenderedTile(TileCoord tile, byte[] contents) {
}
@@ -39,7 +39,7 @@ public class MbtilesWriter {
MbtilesWriter writer = new MbtilesWriter(config.stats());
var topology = Topology.start("mbtiles", stats)
- .readFromIterator("reader", features.getAll())
+ .readFrom("reader", features)
.addBuffer("reader_queue", 50_000, 1_000)
.addWorker("encoder", config.threads(), writer::tileEncoder)
.addBuffer("writer_queue", 50_000, 1_000)
diff --git a/src/main/java/com/onthegomap/flatmap/collections/MergeSortFeatureMap.java b/src/main/java/com/onthegomap/flatmap/collections/MergeSortFeatureMap.java
index 62ad2bae..a6e3966a 100644
--- a/src/main/java/com/onthegomap/flatmap/collections/MergeSortFeatureMap.java
+++ b/src/main/java/com/onthegomap/flatmap/collections/MergeSortFeatureMap.java
@@ -3,6 +3,7 @@ package com.onthegomap.flatmap.collections;
import com.carrotsearch.hppc.LongArrayList;
import com.onthegomap.flatmap.RenderedFeature;
import com.onthegomap.flatmap.VectorTileEncoder;
+import com.onthegomap.flatmap.collections.MergeSortFeatureMap.TileFeatures;
import com.onthegomap.flatmap.geo.TileCoord;
import com.onthegomap.flatmap.monitoring.Stats;
import java.nio.file.Path;
@@ -11,7 +12,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.function.Consumer;
-public class MergeSortFeatureMap implements Consumer {
+public class MergeSortFeatureMap implements Consumer, Iterable {
private volatile boolean prepared = false;
@@ -34,7 +35,8 @@ public class MergeSortFeatureMap implements Consumer {
return 0;
}
- public Iterator getAll() {
+ @Override
+ public Iterator iterator() {
if (!prepared) {
throw new IllegalStateException("Attempting to iterate over features but not prepared yet");
}
diff --git a/src/main/java/com/onthegomap/flatmap/worker/Topology.java b/src/main/java/com/onthegomap/flatmap/worker/Topology.java
index 9311a828..73e7bbe7 100644
--- a/src/main/java/com/onthegomap/flatmap/worker/Topology.java
+++ b/src/main/java/com/onthegomap/flatmap/worker/Topology.java
@@ -91,7 +91,8 @@ public record Topology(
return fromGenerator(name, producer, 1);
}
- public Bufferable, T> readFromIterator(String name, Iterator iter) {
+ public Bufferable, T> readFrom(String name, Iterable iterable) {
+ Iterator iter = iterable.iterator();
return fromGenerator(name, next -> {
while (iter.hasNext()) {
next.accept(iter.next());
diff --git a/src/test/java/com/onthegomap/flatmap/collections/MergeSortFeatureMapTest.java b/src/test/java/com/onthegomap/flatmap/collections/MergeSortFeatureMapTest.java
index a626c031..98fa29ff 100644
--- a/src/test/java/com/onthegomap/flatmap/collections/MergeSortFeatureMapTest.java
+++ b/src/test/java/com/onthegomap/flatmap/collections/MergeSortFeatureMapTest.java
@@ -18,14 +18,14 @@ public class MergeSortFeatureMapTest {
public void testEmpty() {
var features = new MergeSortFeatureMap(tmpDir, new InMemory());
features.sort();
- assertFalse(features.getAll().hasNext());
+ assertFalse(features.iterator().hasNext());
}
@Test
public void testThrowsWhenPreparedOutOfOrder() {
var features = new MergeSortFeatureMap(tmpDir, new InMemory());
features.accept(new RenderedFeature(1, new byte[]{}));
- assertThrows(IllegalStateException.class, features::getAll);
+ assertThrows(IllegalStateException.class, features::iterator);
features.sort();
assertThrows(IllegalStateException.class, () -> features.accept(new RenderedFeature(1, new byte[]{})));
}
diff --git a/src/test/java/com/onthegomap/flatmap/worker/TopologyTest.java b/src/test/java/com/onthegomap/flatmap/worker/TopologyTest.java
index e826a9da..fed6e0a1 100644
--- a/src/test/java/com/onthegomap/flatmap/worker/TopologyTest.java
+++ b/src/test/java/com/onthegomap/flatmap/worker/TopologyTest.java
@@ -71,7 +71,7 @@ public class TopologyTest {
public void testTopologyFromIterator() {
Set result = Collections.synchronizedSet(new TreeSet<>());
var topology = Topology.start("test", stats)
- .readFromIterator("reader", List.of(0, 1).iterator())
+ .readFrom("reader", List.of(0, 1))
.addBuffer("reader_queue", 1)
.addWorker("process", 1, (prev, next) -> {
Integer item;