Rename master_index_valid_{indexes,groups} to resolved_{indexes,groups}

Signed-off-by: Graham <gpe@openrs2.org>
bzip2
Graham 4 years ago
parent 29541b03a8
commit f8c44f1de4
  1. 12
      archive/src/main/kotlin/org/openrs2/archive/cache/CacheExporter.kt
  2. 2
      archive/src/main/kotlin/org/openrs2/archive/cache/CacheImporter.kt
  3. 16
      archive/src/main/resources/org/openrs2/archive/migrations/V1__init.sql

@ -181,7 +181,7 @@ public class CacheExporter @Inject constructor(
connection.prepareStatement( connection.prepareStatement(
""" """
SELECT archive_id, group_id, data, version SELECT archive_id, group_id, data, version
FROM master_index_valid_groups FROM resolved_groups
WHERE master_index_id = ? WHERE master_index_id = ?
""".trimIndent() """.trimIndent()
).use { stmt -> ).use { stmt ->
@ -221,11 +221,11 @@ public class CacheExporter @Inject constructor(
return database.execute { connection -> return database.execute { connection ->
connection.prepareStatement( connection.prepareStatement(
""" """
SELECT v.archive_id, v.group_id, v.name_hash, n.name, (k.key).k0, (k.key).k1, (k.key).k2, (k.key).k3 SELECT g.archive_id, g.group_id, g.name_hash, n.name, (k.key).k0, (k.key).k1, (k.key).k2, (k.key).k3
FROM master_index_valid_groups v FROM resolved_groups g
JOIN keys k ON k.id = v.key_id JOIN keys k ON k.id = g.key_id
LEFT JOIN names n ON n.hash = v.name_hash AND n.name ~ '^l(?:[0-9]|[1-9][0-9])_(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$' LEFT JOIN names n ON n.hash = g.name_hash AND n.name ~ '^l(?:[0-9]|[1-9][0-9])_(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$'
WHERE v.master_index_id = ? WHERE g.master_index_id = ?
""".trimIndent() """.trimIndent()
).use { stmt -> ).use { stmt ->
stmt.setInt(1, id) stmt.setInt(1, id)

@ -276,7 +276,7 @@ public class CacheImporter @Inject constructor(
""" """
SELECT ig.group_id SELECT ig.group_id
FROM index_groups ig FROM index_groups ig
LEFT JOIN master_index_valid_indexes i ON i.master_index_id = ? AND LEFT JOIN resolved_indexes i ON i.master_index_id = ? AND
i.archive_id = ? i.archive_id = ?
LEFT JOIN index_groups ig2 ON ig2.container_id = i.container_id AND ig2.group_id = ig.group_id AND LEFT JOIN index_groups ig2 ON ig2.container_id = i.container_id AND ig2.group_id = ig.group_id AND
ig2.crc32 = ig.crc32 AND ig2.version = ig.version ig2.crc32 = ig.crc32 AND ig2.version = ig.version

@ -134,7 +134,7 @@ CREATE TABLE names (
CREATE UNIQUE INDEX ON names (hash, name); CREATE UNIQUE INDEX ON names (hash, name);
CREATE VIEW master_index_valid_indexes AS CREATE VIEW resolved_indexes AS
SELECT m.id AS master_index_id, a.archive_id, c.data, g.container_id SELECT m.id AS master_index_id, a.archive_id, c.data, g.container_id
FROM master_indexes m FROM master_indexes m
JOIN master_index_archives a ON a.master_index_id = m.id JOIN master_index_archives a ON a.master_index_id = m.id
@ -143,10 +143,10 @@ JOIN groups g ON g.archive_id = 255 AND g.group_id = a.archive_id::INTEGER AND
JOIN containers c ON c.id = g.container_id AND c.crc32 = a.crc32 JOIN containers c ON c.id = g.container_id AND c.crc32 = a.crc32
JOIN indexes i ON i.container_id = g.container_id AND i.version = a.version; JOIN indexes i ON i.container_id = g.container_id AND i.version = a.version;
CREATE VIEW master_index_valid_groups (master_index_id, archive_id, group_id, name_hash, version, data, key_id) AS CREATE VIEW resolved_groups (master_index_id, archive_id, group_id, name_hash, version, data, key_id) AS
WITH i AS NOT MATERIALIZED ( WITH i AS NOT MATERIALIZED (
SELECT master_index_id, archive_id, data, container_id SELECT master_index_id, archive_id, data, container_id
FROM master_index_valid_indexes FROM resolved_indexes
) )
SELECT i.master_index_id, 255::uint1, i.archive_id::INTEGER, NULL, NULL, i.data, NULL SELECT i.master_index_id, 255::uint1, i.archive_id::INTEGER, NULL, NULL, i.data, NULL
FROM i FROM i
@ -174,20 +174,20 @@ CREATE UNIQUE INDEX ON master_index_archive_stats (master_index_id);
CREATE MATERIALIZED VIEW master_index_group_stats (master_index_id, groups, valid_groups, keys, valid_keys) AS CREATE MATERIALIZED VIEW master_index_group_stats (master_index_id, groups, valid_groups, keys, valid_keys) AS
SELECT SELECT
v.master_index_id, i.master_index_id,
COUNT(*), COUNT(*),
COUNT(g.container_id), COUNT(g.container_id),
COUNT(*) FILTER (WHERE c.encrypted), COUNT(*) FILTER (WHERE c.encrypted),
COUNT(*) FILTER (WHERE c.key_id IS NOT NULL) COUNT(*) FILTER (WHERE c.key_id IS NOT NULL)
FROM master_index_valid_indexes v FROM resolved_indexes i
JOIN index_groups ig ON ig.container_id = v.container_id JOIN index_groups ig ON ig.container_id = i.container_id
LEFT JOIN groups g ON g.archive_id = v.archive_id AND g.group_id = ig.group_id AND ( LEFT JOIN groups g ON g.archive_id = i.archive_id AND g.group_id = ig.group_id AND (
(g.version = ig.version AND NOT g.version_truncated) OR (g.version = ig.version AND NOT g.version_truncated) OR
(g.version = ig.version & 65535 AND g.version_truncated) (g.version = ig.version & 65535 AND g.version_truncated)
) AND g.container_id IN (SELECT id FROM containers WHERE crc32 = ig.crc32) ) AND g.container_id IN (SELECT id FROM containers WHERE crc32 = ig.crc32)
LEFT JOIN containers c ON c.id = g.container_id LEFT JOIN containers c ON c.id = g.container_id
LEFT JOIN keys k ON k.id = c.key_id LEFT JOIN keys k ON k.id = c.key_id
GROUP BY v.master_index_id; GROUP BY i.master_index_id;
CREATE UNIQUE INDEX ON master_index_group_stats (master_index_id); CREATE UNIQUE INDEX ON master_index_group_stats (master_index_id);

Loading…
Cancel
Save