Changes between Version 55 and Version 56 of Noeud - parcours RHT


Ignore:
Timestamp:
Jan 9, 2012 5:41:13 PM (13 years ago)
Author:
celine
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Noeud - parcours RHT

    v55 v56  
    286286}}} 
    287287 
    288 Mise à jour de la table rht_topology 
     288Mise à jour de la table rhtvs2 
    289289{{{ 
    290290#!sql 
     
    329329CREATE INDEX chemin_btee_indexvs2 ON rht.rhtvs2 USING btree(chemin); --27688 ms 
    330330VACUUM ANALYSE rht.rhtvs2; 
    331 CREATE INDEX chemin_gist_index ON rht.rht_topology USING GIST (chemin); -- fait planter mon serveur.... 
     331CREATE INDEX chemin_gist_index ON rht.rhtvs2 USING GIST (chemin); -- fait planter mon serveur.... 
    332332SELECT * from rht.rhtvs2 where chemin <@ '212340'; -- tronçon source de la Vilaine -- 35641 
    333333SELECT chemin from rht.rhtvs2 where chemin <@ '212340' limit 1 
    334334-- La distance source est la distance mer maximale de tous les chemins possibles en ne prenant que le dernier tronçon du chemin. 
    335335Select max(dmer) from rht.rhtvs2 where id_drain in ( 
    336 Select cast(ltree2text(subpath(chemin, -1, 1))as integer) as chenin_id_drain from rht.rht_topology where chemin ~ '*.212340.*'); 
     336Select cast(ltree2text(subpath(chemin, -1, 1))as integer) as chenin_id_drain from rht.rhtvs2 where chemin ~ '*.212340.*'); 
    337337--  travail sur les noeuds source et le recalcul des distances mer et source (voir fichier doc joint) 
    338338-- en pratique les distances sont calculées a partir du milieu de chaque tronçon, elles prennent par contre toute la distance des tronçons autre que le tronçon considéré. 
     
    346346); 
    347347 
    348 alter table rht.rht_topology add column dsource numeric; 
     348alter table rht.rhtvs2 add column dsource numeric; 
    349349-- voir schéma pour explications 
    350350 
     
    384384-- pour essai pour voir ce qui se passe dans la requête 
    385385-- je l'ai pas lancé ! 
    386 SELECT 212340,  MAX(dmer+length/2) as dmer FROM rht.rht_topology WHERE id_drain IN ( 
    387                         SELECT CAST(ltree2text(subpath(chemin, -1, 1))as integer) FROM rht.rht_topology where chemin ~  '*.212340.*' ) 
     386SELECT 212340,  MAX(dmer+length/2) as dmer FROM rht.rhtvs2 WHERE id_drain IN ( 
     387                        SELECT CAST(ltree2text(subpath(chemin, -1, 1))as integer) FROM rht.rhtvs2 where chemin ~  '*.212340.*' ) 
    388388-- il faudra enlever la dmer de 212340 
    389389 
     
    401401-- pour essai pour voir ce qui se passe dans la requête 
    402402 
    403 SELECT 212340,  MAX(dmer+length/2) as dmer FROM rht.rht_topology WHERE id_drain IN ( 
    404                         SELECT CAST(ltree2text(subpath(chemin, -1, 1))as integer) FROM rht.rht_topology where chemin ~  '*.212340.*' ) 
    405  
    406  
    407 select * from rht.rht_topology t join rht.distance_source s on s.id_drain=t.id_drain where distance is null; --323 
     403SELECT 212340,  MAX(dmer+length/2) as dmer FROM rht.rhtvs2 WHERE id_drain IN ( 
     404                        SELECT CAST(ltree2text(subpath(chemin, -1, 1))as integer) FROM rht.rhtvs2 where chemin ~  '*.212340.*' ) 
     405 
     406 
     407select * from rht.rhtvs2 t join rht.distance_source s on s.id_drain=t.id_drain where distance is null; --323 
    408408 
    409409-- il faudra enlever la dmer de 212340 
     
    415415-- mise à jour des distances source dans la table distance source (il faut encore enlever dmer) 
    416416update rht.distance_source d set distance_source = sub.distance_source from ( 
    417 select t.id_drain, distance-dmer as distance_source from rht.distance_source s join rht.rht_topology t on s.id_drain=t.id_drain) as sub 
     417select t.id_drain, distance-dmer as distance_source from rht.distance_source s join rht.rhtvs2 t on s.id_drain=t.id_drain) as sub 
    418418where sub.id_drain=d.id_drain; --57067 
    419419 
    420 -- copie des valeurs de distance_source dans dsource de la table rht.rht_topology 
    421 update rht.rht_topology t set dsource=distance_source 
     420-- copie des valeurs de distance_source dans dsource de la table rht.rhtvs2 
     421update rht.rhtvs2 t set dsource=distance_source 
    422422from rht.distance_source d where d.id_drain=t.id_drain; --57067 
    423423 
    424424-- mise à jour des distances_source (pour l'instant valeurs = null) pour les noeuds source (pour les derniers c'est la moitié de la longueur du segment) 
    425 update rht.rht_topology t set dsource=length/2 where noeudsource; 
     425update rht.rhtvs2 t set dsource=length/2 where noeudsource; 
    426426-- nombre de  
    427 select count(*)as count, noeudsource from rht.rht_topology where dsource is null group by noeudsource; 
     427select count(*)as count, noeudsource from rht.rhtvs2 where dsource is null group by noeudsource; 
    428428}}} 
    429429 
     
    440440SELECT regexp_split_to_array('hello.world', E'\\.+'); 
    441441*/ 
    442 SELECT regexp_split_to_array(ltree2text(chemin),E'\\.+') from rht.rht_topology where chemin <@ '212340'; 
     442SELECT regexp_split_to_array(ltree2text(chemin),E'\\.+') from rht.rhtvs2 where chemin <@ '212340'; 
    443443 
    444444/* 
     
    460460-- pour convertir un vecteur en table 
    461461select unpack(vecteurchemin) from  
    462         (SELECT regexp_split_to_array(ltree2text(chemin),E'\\.+') as vecteurchemin from rht.rht_topology where chemin <@ '212340' limit 1) as sub 
     462        (SELECT regexp_split_to_array(ltree2text(chemin),E'\\.+') as vecteurchemin from rht.rhtvs2 where chemin <@ '212340' limit 1) as sub 
    463463-- j'avais pas vu il y a déjà une fonction magique unest... 
    464464select cast(unnest(vecteurchemin) as integer) as chemin_id_drain from 
    465         (SELECT regexp_split_to_array(ltree2text(chemin),E'\\.+') as vecteurchemin from rht.rht_topology where chemin <@ '212340' limit 1) as sub 
     465        (SELECT regexp_split_to_array(ltree2text(chemin),E'\\.+') as vecteurchemin from rht.rhtvs2 where chemin <@ '212340' limit 1) as sub 
    466466-- Fonction qui renvoit les identifiants uniques des tronçons en amont d'un ouvrage 
    467467 
     
    470470RETURNS SETOF integer AS $$ 
    471471select cast(unnest(vecteurchemin) as integer) as chemin_id_drain from 
    472         (SELECT regexp_split_to_array(ltree2text(chemin),E'\\.+') as vecteurchemin from rht.rht_topology where chemin <@ text2ltree(cast ($1 as text))  limit 1) as sub; 
     472        (SELECT regexp_split_to_array(ltree2text(chemin),E'\\.+') as vecteurchemin from rht.rhtvs2 where chemin <@ text2ltree(cast ($1 as text))  limit 1) as sub; 
    473473$$ LANGUAGE sql STRICT IMMUTABLE;        
    474474