Skip to content

Commit

Permalink
fix agg hash calc
Browse files Browse the repository at this point in the history
  • Loading branch information
nyurik committed Oct 8, 2023
1 parent f549a9f commit 0bce261
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
6 changes: 4 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ serde = { version = "1", features = ["derive"] }
serde_json = "1"
serde_yaml = "0.9"
spreet = { version = "0.8", default-features = false }
sqlite-hashes = "0.3"
sqlite-hashes = "0.4"
sqlx = { version = "0.7", features = ["sqlite", "runtime-tokio"] }
subst = { version = "0.3", features = ["yaml"] }
thiserror = "1"
Expand Down
26 changes: 10 additions & 16 deletions martin-mbtiles/src/mbtiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -640,27 +640,21 @@ where
// Note that ORDER BY controls the output ordering, which is important for the hash value,
// and having it at the top level would not order values properly.
// See https://sqlite.org/forum/forumpost/228bb96e12a746ce
// Sadly, this is still not a guaranteed solution as it is possible, in the future, for the optimizer to change.
"SELECT
hex(
coalesce(
md5_concat(
"
SELECT coalesce(
(SELECT md5_concat_hex(
cast(zoom_level AS text),
cast(tile_column AS text),
cast(tile_row AS text),
tile_data
),
md5('')
)
)
FROM (
SELECT zoom_level,
tile_column,
tile_row,
tile_data
FROM tiles
ORDER BY zoom_level, tile_column, tile_row
);",
OVER (ORDER BY zoom_level, tile_column, tile_row ROWS
BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
FROM tiles
LIMIT 1),
md5_hex('')
);
",
);
Ok(query.fetch_one(conn).await?.get::<String, _>(0))
}
Expand Down

0 comments on commit 0bce261

Please sign in to comment.