Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
msbarry committed Sep 17, 2023
1 parent e82126a commit a64d4db
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.atomic.LongAccumulator;
import java.util.function.Consumer;
import java.util.function.LongSupplier;
import java.util.stream.IntStream;
Expand All @@ -55,8 +54,6 @@ public class TileArchiveWriter {
private final PlanetilerConfig config;
private final Stats stats;
private final Counter.Readable[] tilesByZoom;
private final Counter.Readable[] totalTileSizesByZoom;
private final LongAccumulator[] maxTileSizesByZoom;
private final Iterable<FeatureGroup.TileFeatures> inputTiles;
private final AtomicReference<TileCoord> lastTileWritten = new AtomicReference<>();
private final TileArchiveMetadata tileArchiveMetadata;
Expand All @@ -72,12 +69,6 @@ private TileArchiveWriter(Iterable<FeatureGroup.TileFeatures> inputTiles, Writea
tilesByZoom = IntStream.rangeClosed(0, config.maxzoom())
.mapToObj(i -> Counter.newSingleThreadCounter())
.toArray(Counter.Readable[]::new);
totalTileSizesByZoom = IntStream.rangeClosed(0, config.maxzoom())
.mapToObj(i -> Counter.newMultiThreadCounter())
.toArray(Counter.Readable[]::new);
maxTileSizesByZoom = IntStream.rangeClosed(0, config.maxzoom())
.mapToObj(i -> new LongAccumulator(Long::max, 0))
.toArray(LongAccumulator[]::new);
memoizedTiles = stats.longCounter("archive_memoized_tiles");
featuresProcessed = stats.longCounter("archive_features_processed");
Map<String, LongSupplier> countsByZoom = new LinkedHashMap<>();
Expand Down Expand Up @@ -316,22 +307,18 @@ private void tileEncoderSink(Iterable<TileBatch> prev) throws IOException {
}
lastTileDataHash = tileDataHash;
}
if (skipFilled && lastIsFill) {
if ((skipFilled && lastIsFill) || encoded == null) {
continue;
}
int zoom = tileFeatures.tileCoord().z();
int encodedLength = encoded == null ? 0 : encoded.length;
totalTileSizesByZoom[zoom].incBy(encodedLength);
maxTileSizesByZoom[zoom].accumulate(encodedLength);
tileStatsUpdater.recordTile(tileFeatures.tileCoord(), bytes.length, layerStats);
tileStatsUpdater.recordTile(tileFeatures.tileCoord(), encoded.length, layerStats);
List<String> layerStatsRows = config.outputLayerStats() ?
TileSizeStats.formatOutputRows(tileFeatures.tileCoord(), bytes.length, layerStats) :
TileSizeStats.formatOutputRows(tileFeatures.tileCoord(), encoded.length, layerStats) :
List.of();
result.add(
new TileEncodingResult(
tileFeatures.tileCoord(),
bytes,
encoded == null ? 0 : encoded.length,
encoded.length,
tileDataHash == null ? OptionalLong.empty() : OptionalLong.of(tileDataHash),
layerStatsRows
)
Expand Down Expand Up @@ -372,7 +359,7 @@ private void tileWriter(Iterable<TileBatch> tileBatches) throws ExecutionExcepti
}
tileWriter.write(encodedTile);

stats.wroteTile(z, encodedTile.tileData() == null ? 0 : encodedTile.tileData().length);
stats.wroteTile(z, encodedTile.tileData().length);
tilesByZoom[z].inc();
}
lastTileWritten.set(lastTile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
import java.util.List;
import java.util.Objects;
import java.util.OptionalLong;
import javax.annotation.Nonnull;

public record TileEncodingResult(
TileCoord coord,
byte[] tileData,
@Nonnull byte[] tileData,
int rawTileSize,
/** will always be empty in non-compact mode and might also be empty in compact mode */
OptionalLong tileDataHash,
Expand Down

0 comments on commit a64d4db

Please sign in to comment.