gstlal-inspiral  1.9.3
 All Classes Namespaces Files Functions
simplify_proc_table_in_inj_file.sql
1 -- Copyright (C) 2011--2012,2014,2015 Kipp Cannon, Chad Hanna
2 --
3 -- This program is free software; you can redistribute it and/or modify it
4 -- under the terms of the GNU General Public License as published by the
5 -- Free Software Foundation; either version 2 of the License, or (at your
6 -- option) any later version.
7 --
8 -- This program is distributed in the hope that it will be useful, but
9 -- WITHOUT ANY WARRANTY; without even the implied warranty of
10 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
11 -- Public License for more details.
12 --
13 -- You should have received a copy of the GNU General Public License along
14 -- with this program; if not, write to the Free Software Foundation, Inc.,
15 -- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 
17 --
18 -- process clean up. same computer, unix process ID, and start time =
19 -- same process
20 --
21 
22 CREATE INDEX tmpindex ON process (node, unix_procid, start_time);
23 CREATE TEMPORARY TABLE _idmap_ AS
24  SELECT
25  old.process_id AS old,
26  MIN(new.process_id) AS new
27  FROM
28  process AS old
29  JOIN process AS new ON (
30  new.node == old.node
31  AND new.unix_procid == old.unix_procid
32  AND new.start_time == old.start_time
33  )
34  GROUP BY
35  old.process_id;
36 DROP INDEX tmpindex;
37 CREATE INDEX tmpindex ON _idmap_ (old);
38 
39 UPDATE sim_inspiral SET process_id = (SELECT new FROM _idmap_ WHERE old == process_id);
40 
41 DELETE FROM process WHERE process_id IN (SELECT old FROM _idmap_ WHERE old != new);
42 DELETE FROM process_params WHERE process_id NOT IN (SELECT process_id FROM process);
43 
44 DROP INDEX tmpindex;
45 DROP TABLE _idmap_;
46 
47 VACUUM;