Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/cassandra/schema.py
| Show First 20 Lines • Show All 215 Lines • ▼ Show 20 Lines | |||||
| );""", | );""", | ||||
| """ | """ | ||||
| CREATE TABLE IF NOT EXISTS object_count ( | CREATE TABLE IF NOT EXISTS object_count ( | ||||
| partition_key smallint, -- Constant, must always be 0 | partition_key smallint, -- Constant, must always be 0 | ||||
| object_type ascii, | object_type ascii, | ||||
| count counter, | count counter, | ||||
| PRIMARY KEY ((partition_key), object_type) | PRIMARY KEY ((partition_key), object_type) | ||||
| );""", | );""", | ||||
| """ | |||||
| CREATE TABLE IF NOT EXISTS extid ( | |||||
| extid_type ascii, | |||||
| extid blob, | |||||
| target_type ascii, | |||||
| target blob, | |||||
olasd: If you switch this to `((target, target_type), extid, extid_type)` | |||||
| PRIMARY KEY ((target, target_type, extid, extid_type)) | |||||
| );""", | |||||
| """ | |||||
| CREATE TABLE IF NOT EXISTS extid_by_extid ( | |||||
| extid_type ascii, | |||||
| extid blob, | |||||
| target_token bigint, -- value of token(pk) on the "primary" table | |||||
| PRIMARY KEY ((extid_type, extid), target_token) | |||||
| );""", | |||||
| """ | |||||
| CREATE TABLE IF NOT EXISTS extid_by_target ( | |||||
| target_type ascii, | |||||
| target blob, | |||||
| target_token bigint, -- value of token(pk) on the "primary" table | |||||
| PRIMARY KEY ((target_type, target), target_token) | |||||
| );""", | |||||
Not Done Inline ActionsThen I don't think this index is needed? olasd: Then I don't think this index is needed? | |||||
| ] | ] | ||||
| CONTENT_INDEX_TEMPLATE = """ | CONTENT_INDEX_TEMPLATE = """ | ||||
| -- Secondary table, used for looking up "content" from a single hash | -- Secondary table, used for looking up "content" from a single hash | ||||
| CREATE TABLE IF NOT EXISTS content_by_{main_algo} ( | CREATE TABLE IF NOT EXISTS content_by_{main_algo} ( | ||||
| {main_algo} blob, | {main_algo} blob, | ||||
| target_token bigint, -- value of token(pk) on the "primary" table | target_token bigint, -- value of token(pk) on the "primary" table | ||||
| PRIMARY KEY (({main_algo}), target_token) | PRIMARY KEY (({main_algo}), target_token) | ||||
| Show All 18 Lines | TABLES = [ | ||||
| "snapshot_branch", | "snapshot_branch", | ||||
| "origin_visit", | "origin_visit", | ||||
| "origin", | "origin", | ||||
| "raw_extrinsic_metadata", | "raw_extrinsic_metadata", | ||||
| "object_count", | "object_count", | ||||
| "origin_visit_status", | "origin_visit_status", | ||||
| "metadata_authority", | "metadata_authority", | ||||
| "metadata_fetcher", | "metadata_fetcher", | ||||
| "extid", | |||||
| "extid_by_extid", | |||||
| "extid_by_target", | |||||
| ] | ] | ||||
| HASH_ALGORITHMS = ["sha1", "sha1_git", "sha256", "blake2s256"] | HASH_ALGORITHMS = ["sha1", "sha1_git", "sha256", "blake2s256"] | ||||
| for main_algo in HASH_ALGORITHMS: | for main_algo in HASH_ALGORITHMS: | ||||
| CREATE_TABLES_QUERIES.extend( | CREATE_TABLES_QUERIES.extend( | ||||
| CONTENT_INDEX_TEMPLATE.format( | CONTENT_INDEX_TEMPLATE.format( | ||||
| main_algo=main_algo, | main_algo=main_algo, | ||||
| other_algos=", ".join( | other_algos=", ".join( | ||||
| [algo for algo in HASH_ALGORITHMS if algo != main_algo] | [algo for algo in HASH_ALGORITHMS if algo != main_algo] | ||||
| ), | ), | ||||
| ).split("\n\n") | ).split("\n\n") | ||||
| ) | ) | ||||
| TABLES.append("content_by_%s" % main_algo) | TABLES.append("content_by_%s" % main_algo) | ||||
| TABLES.append("skipped_content_by_%s" % main_algo) | TABLES.append("skipped_content_by_%s" % main_algo) | ||||
If you switch this to ((target, target_type), extid, extid_type)