Remove redundant flags complete_logic_tree_gmf and complete_logic_tree_ses
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenQuake (deprecated) |
Fix Committed
|
Undecided
|
Michele Simionato |
Bug Description
Such flags appear as fields in four tables: gmf_collection, gmf_set,
ses_collection and ses. They are redundant, because the check constraints
fully specify them. This can be seen directly from the table definitions::
CREATE TABLE hzrdr.gmf_
id SERIAL PRIMARY KEY,
output_id INTEGER NOT NULL, -- FK to output.id
-- FK to lt_realization.id
lt_
CHECK(
-- Case 1: Normal GMF collection
-- Case 2: GMF collection containing all ground motion fields for the entire
-- logic tree.
OR ((lt_realization_id IS NULL) AND (complete_
-- A flag to indicate that this is a `complete logic
-- tree` GMF collection.
complete_
) TABLESPACE hzrdr_ts;
CREATE TABLE hzrdr.gmf_set (
id SERIAL PRIMARY KEY,
gmf_
investigati
-- Keep track of the stochastic event set which this GMF set is associated with
ses_ordinal INTEGER CONSTRAINT gmf_set_
CHECK(
-- Case 1: Normal GMF set
-- Case 2: GMF set containing all ground motion fields for the entire
-- logic tree.
OR ((ses_ordinal IS NULL) AND (complete_
complete_
) TABLESPACE hzrdr_ts;
CREATE TABLE hzrdr.ses_
id SERIAL PRIMARY KEY,
output_id INTEGER NOT NULL,
-- If `lt_realization_id` is NULL, this is a `complete logic tree`
-- Stochastic Event Set Collection, containing a single stochastic
-- event set containing all of the ruptures from the entire
-- calculation.
lt_
CHECK(
-- Case 1: Normal stochastic event set
-- Case 2: Stochastic event set containing all ruptures for the entire
-- logic tree.
OR ((lt_realization_id IS NULL) AND (complete_
-- A flag to indicate that this is a `complete logic
-- tree` SES collection.
complete_
) TABLESPACE hzrdr_ts;
-- Stochastic Event Set: A container for 1 or more ruptures associated with a
-- specific investigation time span.
CREATE TABLE hzrdr.ses (
id SERIAL PRIMARY KEY,
ses_
investigati
-- Order number of this Stochastic Event Set in a series of SESs
-- (for a given logic tree realization).
ordinal INTEGER CONSTRAINT ses_ordinal_check
CHECK(
-- Case 1: Normal stochastic event set
-- Case 2: Stochastic event set containing all ruptures for the entire
-- logic tree.
OR (ordinal IS NULL) AND (complete_
-- A flag to indicate that this is a `complete logic
-- tree` SES.
-- If `true`, there should be no `ordinal` specified.
complete_
) TABLESPACE hzrdr_ts;
After two minutes to parse the above definitions, one sees that
- gmf_collection.
- gmf_set.
- ses_collection.
- ses.complete_
(and false means NOT NULL)
Therefore one can avoid storing such flags, since their value can be inferred with a
IS NULL check on the corresponding fields (gmf_collection
gmf_set.
Changed in openquake: | |
assignee: | nobody → Michele Simionato (michele-simionato) |
milestone: | none → 1.0.0 |
status: | New → In Progress |
Changed in openquake: | |
status: | In Progress → Fix Committed |
Has this been resolved? The status is fix committed, but there is no link to a patch.