Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/cassandra/schema.py
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | CREATE TABLE IF NOT EXISTS content ( | ||||
blake2s256 blob, | blake2s256 blob, | ||||
length bigint, | length bigint, | ||||
ctime timestamp, | ctime timestamp, | ||||
-- creation time, i.e. time of (first) injection into the storage | -- creation time, i.e. time of (first) injection into the storage | ||||
status ascii, | status ascii, | ||||
PRIMARY KEY ((sha1, sha1_git, sha256, blake2s256)) | PRIMARY KEY ((sha1, sha1_git, sha256, blake2s256)) | ||||
); | ); | ||||
CREATE TABLE IF NOT EXISTS skipped_content ( | |||||
sha1 blob, | |||||
sha1_git blob, | |||||
sha256 blob, | |||||
blake2s256 blob, | |||||
length bigint, | |||||
ctime timestamp, | |||||
-- creation time, i.e. time of (first) injection into the storage | |||||
status ascii, | |||||
reason text, | |||||
origin text, | |||||
PRIMARY KEY ((sha1, sha1_git, sha256, blake2s256)) | |||||
); | |||||
CREATE TABLE IF NOT EXISTS revision ( | CREATE TABLE IF NOT EXISTS revision ( | ||||
id blob PRIMARY KEY, | id blob PRIMARY KEY, | ||||
date microtimestamp_with_timezone, | date microtimestamp_with_timezone, | ||||
committer_date microtimestamp_with_timezone, | committer_date microtimestamp_with_timezone, | ||||
type ascii, | type ascii, | ||||
directory blob, -- source code "root" directory | directory blob, -- source code "root" directory | ||||
message blob, | message blob, | ||||
author person, | author person, | ||||
▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | |||||
CONTENT_INDEX_TEMPLATE = ''' | CONTENT_INDEX_TEMPLATE = ''' | ||||
CREATE TABLE IF NOT EXISTS content_by_{main_algo} ( | CREATE TABLE IF NOT EXISTS content_by_{main_algo} ( | ||||
sha1 blob, | sha1 blob, | ||||
sha1_git blob, | sha1_git blob, | ||||
sha256 blob, | sha256 blob, | ||||
blake2s256 blob, | blake2s256 blob, | ||||
PRIMARY KEY (({main_algo}), {other_algos}) | PRIMARY KEY (({main_algo}), {other_algos}) | ||||
);''' | ); | ||||
CREATE TABLE IF NOT EXISTS skipped_content_by_{main_algo} ( | |||||
sha1 blob, | |||||
sha1_git blob, | |||||
sha256 blob, | |||||
blake2s256 blob, | |||||
PRIMARY KEY (({main_algo}), {other_algos}) | |||||
); | |||||
''' | |||||
TABLES = ('content revision revision_parent release directory ' | TABLES = ('skipped_content content revision revision_parent release ' | ||||
'directory_entry snapshot snapshot_branch origin_visit ' | 'directory directory_entry snapshot snapshot_branch ' | ||||
'origin tool_by_uuid tool object_count').split() | 'origin_visit origin tool_by_uuid tool object_count').split() | ||||
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.append(CONTENT_INDEX_TEMPLATE.format( | CREATE_TABLES_QUERIES.extend(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')) | ||||
TABLES.append('content_by_%s' % main_algo) | TABLES.append('content_by_%s' % main_algo) | ||||
TABLES.append('skipped_content_by_%s' % main_algo) |