Skip to content

Commit

Permalink
Fix memoize bug (onthegomap#279)
Browse files Browse the repository at this point in the history
  • Loading branch information
msbarry authored Jun 20, 2022
1 parent 76c7880 commit 52432b8
Showing 1 changed file with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -271,36 +271,37 @@ private void tileEncoder(Iterable<TileBatch> prev, Consumer<TileBatch> next) thr
byte[] bytes, encoded;
Long tileDataHash;
if (tileFeatures.hasSameContents(last)) {
if (skipFilled && lastIsFill) {
continue;
}
bytes = lastBytes;
encoded = lastEncoded;
tileDataHash = lastTileDataHash;
memoizedTiles.inc();
} else {
VectorTile en = tileFeatures.getVectorTileEncoder();
if (skipFilled) {
lastIsFill = en.containsOnlyFills();
if (lastIsFill) {
continue;
if (skipFilled && (lastIsFill = en.containsOnlyFills())) {
encoded = null;
bytes = null;
} else {
encoded = en.encode();
bytes = gzip(encoded);
if (encoded.length > 1_000_000) {
LOGGER.warn("{} {}kb uncompressed",
tileFeatures.tileCoord(),
encoded.length / 1024);
}
}
lastEncoded = encoded = en.encode();
lastBytes = bytes = gzip(encoded);
lastEncoded = encoded;
lastBytes = bytes;
last = tileFeatures;
if (encoded.length > 1_000_000) {
LOGGER.warn("{} {}kb uncompressed",
tileFeatures.tileCoord(),
encoded.length / 1024);
}
if (compactDb && en.containsOnlyFillsOrEdges()) {
tileDataHash = tileFeatures.generateContentHash();
} else {
tileDataHash = null;
}
lastTileDataHash = tileDataHash;
}
if (skipFilled && lastIsFill) {
continue;
}
int zoom = tileFeatures.tileCoord().z();
int encodedLength = encoded == null ? 0 : encoded.length;
totalTileSizesByZoom[zoom].incBy(encodedLength);
Expand Down

0 comments on commit 52432b8

Please sign in to comment.