Skip to content
Snippets Groups Projects
Commit eaf88265 authored by Chad Hanna's avatar Chad Hanna
Browse files

ll_simplify: add sql script for online processing

parent 9ee9b7e5
No related branches found
No related tags found
No related merge requests found
dist_pkgdata_DATA = \
ll_simplify_and_cluster.sql
ll_simplify.sql
Makefile.triggers_example \
Makefile.non_spinning_NSBH \
Makefile.non_spinning_BNS \
......
-- Copyright (C) 2011--2012,2014,2015 Kipp Cannon, Chad Hanna
--
-- This program is free software; you can redistribute it and/or modify it
-- under the terms of the GNU General Public License as published by the
-- Free Software Foundation; either version 2 of the License, or (at your
-- option) any later version.
--
-- This program is distributed in the hope that it will be useful, but
-- WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-- Public License for more details.
--
-- You should have received a copy of the GNU General Public License along
-- with this program; if not, write to the Free Software Foundation, Inc.,
-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
--
-- coinc_definer clean up
--
CREATE TEMPORARY TABLE _idmap_ AS
SELECT
old.coinc_def_id AS old,
MIN(new.coinc_def_id) AS new
FROM
coinc_definer AS old
JOIN coinc_definer AS new ON (
new.search == old.search
AND new.search_coinc_type == old.search_coinc_type
)
GROUP BY
old.coinc_def_id;
CREATE INDEX tmpindex ON _idmap_ (old);
UPDATE coinc_event SET coinc_def_id = (SELECT new FROM _idmap_ WHERE old == coinc_def_id);
DELETE FROM coinc_definer WHERE coinc_def_id IN (SELECT old FROM _idmap_ WHERE old != new);
DROP INDEX tmpindex;
DROP TABLE _idmap_;
--
-- segment_definer clean up. NOTE; this assumes no meaningful information
-- is stored in the version and comment columns, and will scramble it if
-- there is. that is, two segment_definer rows are considered to be
-- equivalent even if their version and comment values differ, and the one
-- with the higher ID will be discarded.
--
CREATE TEMPORARY TABLE _idmap_ AS
SELECT
old.segment_def_id AS old,
MIN(new.segment_def_id) AS new
FROM
segment_definer AS old
JOIN segment_definer AS new ON (
new.ifos == old.ifos
AND new.name == old.name
)
GROUP BY
old.segment_def_id;
CREATE INDEX tmpindex ON _idmap_ (old);
UPDATE segment_summary SET segment_def_id = (SELECT new FROM _idmap_ WHERE old == segment_def_id);
UPDATE segment SET segment_def_id = (SELECT new FROM _idmap_ WHERE old == segment_def_id);
DELETE FROM segment_definer WHERE segment_def_id IN (SELECT old FROM _idmap_ WHERE old != new);
DROP INDEX tmpindex;
DROP TABLE _idmap_;
--
-- time_slide clean up
--
CREATE TEMPORARY TABLE _idmap_ AS
SELECT
time_slide_id AS old,
(SELECT group_concat(instrument || "=" || offset) FROM time_slide AS time_slide_a WHERE time_slide_a.time_slide_id == time_slide.time_slide_id ORDER BY instrument) AS repr,
NULL AS new
FROM
time_slide
GROUP BY
time_slide_id;
CREATE INDEX tmpindex ON _idmap_ (repr, old);
UPDATE _idmap_ SET new = (SELECT MIN(old) FROM _idmap_ AS a WHERE a.repr == _idmap_.repr);
DROP INDEX tmpindex;
CREATE INDEX tmpindex ON _idmap_ (old);
UPDATE coinc_event SET time_slide_id = (SELECT _idmap_.new FROM _idmap_ WHERE _idmap_.old == time_slide_id);
DELETE FROM time_slide WHERE time_slide_id IN (SELECT old FROM _idmap_ WHERE old != new);
DROP INDEX tmpindex;
DROP TABLE _idmap_;
VACUUM;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment