Loading file_catalog/00-init.sql +3 −1 Original line number Diff line number Diff line Loading @@ -34,7 +34,9 @@ CREATE TYPE NodeType AS ENUM ('container', 'data', 'link'); CREATE TABLE Node ( node_id BIGSERIAL NOT NULL, parent_path LTREE default NULL, parent_relative_path LTREE default NULL, name VARCHAR NOT NULL, os_name VARCHAR default NULL, type NodeType NOT NULL, format VARCHAR default NULL, -- format serve per distinguere unstuctured (format=NULL) da structured che hanno un formato noto Loading file_catalog/02-indexes.sql +2 −2 Original line number Diff line number Diff line Loading @@ -12,5 +12,5 @@ ALTER TABLE Node ADD COLUMN path ltree GENERATED ALWAYS AS (path(parent_path, no CREATE INDEX file_path_gist_idx ON Node USING GIST(path); CREATE UNIQUE INDEX file_path_idx ON Node USING btree(path); --ALTER TABLE Node ADD COLUMN os_path varchar GENERATED ALWAYS AS (get_os_path(parent_path, name)) STORED; --CREATE UNIQUE INDEX file_os_path_idx ON Node(os_path); ALTER TABLE Node ADD COLUMN relative_path ltree GENERATED ALWAYS AS (path(parent_relative_path, node_id)) STORED; CREATE INDEX file_rel_path_gist_idx ON Node USING GIST(relative_path); file_catalog/03-os_path_view.sql +23 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,22 @@ CREATE VIEW node_os_path AS SELECT node_id, '/' AS os_path FROM Node WHERE path = '' UNION SELECT node_id, '/' || string_agg(name, '/') AS os_path FROM ( SELECT (CASE WHEN os_name IS NOT NULL THEN os_name ELSE name END) AS name, p.node_id FROM Node n JOIN ( SELECT UNNEST(string_to_array(relative_path::varchar, '.')) AS rel_id, node_id FROM Node ) AS p ON n.node_id::varchar = p.rel_id ORDER BY p.node_id, nlevel(n.path) ) AS j GROUP BY node_id; -- View that maps node_id to vos_path CREATE VIEW node_vos_path AS SELECT node_id, '/' AS vos_path FROM Node WHERE path = '' UNION SELECT node_id, '/' || string_agg(name, '/') AS os_path FROM ( SELECT name, p.node_id FROM Node n Loading @@ -20,3 +36,10 @@ FROM ( ) AS p ON n.node_id::varchar = p.rel_id ORDER BY p.node_id, nlevel(n.path) ) AS j GROUP BY node_id; -- This view allows to obtain the the os_path from the vos_path CREATE VIEW node_path AS SELECT v.node_id, vos_path, os_path FROM node_vos_path v LEFT JOIN node_os_path o ON o.node_id = v.node_id; file_catalog/05-data.sql +14 −9 Original line number Diff line number Diff line Loading @@ -2,14 +2,19 @@ Initialization test for vospace Node table; for now owner_id and group_id are set equal to the rap_id */ INSERT INTO Node (parent_path, name, type, owner_id, creator_id) VALUES (NULL, '', 'container', '0', '0'); -- / INSERT INTO Node (parent_path, name, type, owner_id, creator_id) VALUES ('', 'curban', 'container', '3354', '3354'); -- /curban INSERT INTO Node (parent_path, name, type, owner_id, creator_id) VALUES ('2', 'store', 'container', '3354', '3354'); -- /curban/store INSERT INTO Node (parent_path, name, type, owner_id, creator_id) VALUES ('', 'sbertocco', 'container', '2048', '2048'); -- /sbertocco INSERT INTO Node (parent_path, name, type, owner_id, creator_id) VALUES ('4', 'store', 'container', '2048', '2048'); -- /sbertocco/store INSERT INTO Node (parent_path, name, type, owner_id, creator_id) VALUES ('', 'szorba', 'container', '2386', '2386'); -- /szorba INSERT INTO Node (parent_path, name, type, owner_id, creator_id) VALUES ('6', 'store', 'container', '2386', '2386'); -- /szorba/store -- parent_path = parent_relative_path INSERT INTO Node (parent_path, parent_relative_path, name, type, owner_id, creator_id) VALUES (NULL, NULL, '', 'container', '0', '0'); -- / INSERT INTO Node (parent_path, parent_relative_path, name, type, owner_id, creator_id) VALUES ('', '', 'curban', 'container', '3354', '3354'); -- /curban INSERT INTO Node (parent_path, parent_relative_path, name, type, owner_id, creator_id) VALUES ('2', '2', 'store', 'container', '3354', '3354'); -- /curban/store INSERT INTO Node (parent_path, parent_relative_path, name, type, owner_id, creator_id) VALUES ('', '', 'sbertocco', 'container', '2048', '2048'); -- /sbertocco INSERT INTO Node (parent_path, parent_relative_path, name, type, owner_id, creator_id) VALUES ('4', '4', 'store', 'container', '2048', '2048'); -- /sbertocco/store INSERT INTO Node (parent_path, parent_relative_path, name, type, owner_id, creator_id) VALUES ('', '', 'szorba', 'container', '2386', '2386'); -- /szorba INSERT INTO Node (parent_path, parent_relative_path, name, type, owner_id, creator_id) VALUES ('6', '6', 'store', 'container', '2386', '2386'); -- /szorba/store -- parent_path <> parent_relative_path INSERT INTO Node (parent_path, parent_relative_path, name, type, owner_id, creator_id) VALUES ('', NULL, 'test', 'container', '2386', '2386'); -- /test INSERT INTO Node (parent_path, parent_relative_path, name, type, owner_id, creator_id) VALUES ('8', '', 'f1', 'container', '2386', '2386'); -- /test/f1 (rel: /f1) INSERT INTO Node (parent_path, parent_relative_path, name, os_name, type, owner_id, creator_id) VALUES ('8.9', '9', 'f2_renamed', 'f2', 'container', '2386', '2386'); -- /test/f1/f2_renamed (rel: /f1/f2) INSERT INTO Node (parent_path, parent_relative_path, name, type, owner_id, creator_id) VALUES ('8.9.10', '9.10', 'f3', 'container', '2386', '2386'); -- /test/f1/f2_renamed/f3 (rel: /f1/f2/f3) /* Initialization test for vospace Users table Loading Loading
file_catalog/00-init.sql +3 −1 Original line number Diff line number Diff line Loading @@ -34,7 +34,9 @@ CREATE TYPE NodeType AS ENUM ('container', 'data', 'link'); CREATE TABLE Node ( node_id BIGSERIAL NOT NULL, parent_path LTREE default NULL, parent_relative_path LTREE default NULL, name VARCHAR NOT NULL, os_name VARCHAR default NULL, type NodeType NOT NULL, format VARCHAR default NULL, -- format serve per distinguere unstuctured (format=NULL) da structured che hanno un formato noto Loading
file_catalog/02-indexes.sql +2 −2 Original line number Diff line number Diff line Loading @@ -12,5 +12,5 @@ ALTER TABLE Node ADD COLUMN path ltree GENERATED ALWAYS AS (path(parent_path, no CREATE INDEX file_path_gist_idx ON Node USING GIST(path); CREATE UNIQUE INDEX file_path_idx ON Node USING btree(path); --ALTER TABLE Node ADD COLUMN os_path varchar GENERATED ALWAYS AS (get_os_path(parent_path, name)) STORED; --CREATE UNIQUE INDEX file_os_path_idx ON Node(os_path); ALTER TABLE Node ADD COLUMN relative_path ltree GENERATED ALWAYS AS (path(parent_relative_path, node_id)) STORED; CREATE INDEX file_rel_path_gist_idx ON Node USING GIST(relative_path);
file_catalog/03-os_path_view.sql +23 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,22 @@ CREATE VIEW node_os_path AS SELECT node_id, '/' AS os_path FROM Node WHERE path = '' UNION SELECT node_id, '/' || string_agg(name, '/') AS os_path FROM ( SELECT (CASE WHEN os_name IS NOT NULL THEN os_name ELSE name END) AS name, p.node_id FROM Node n JOIN ( SELECT UNNEST(string_to_array(relative_path::varchar, '.')) AS rel_id, node_id FROM Node ) AS p ON n.node_id::varchar = p.rel_id ORDER BY p.node_id, nlevel(n.path) ) AS j GROUP BY node_id; -- View that maps node_id to vos_path CREATE VIEW node_vos_path AS SELECT node_id, '/' AS vos_path FROM Node WHERE path = '' UNION SELECT node_id, '/' || string_agg(name, '/') AS os_path FROM ( SELECT name, p.node_id FROM Node n Loading @@ -20,3 +36,10 @@ FROM ( ) AS p ON n.node_id::varchar = p.rel_id ORDER BY p.node_id, nlevel(n.path) ) AS j GROUP BY node_id; -- This view allows to obtain the the os_path from the vos_path CREATE VIEW node_path AS SELECT v.node_id, vos_path, os_path FROM node_vos_path v LEFT JOIN node_os_path o ON o.node_id = v.node_id;
file_catalog/05-data.sql +14 −9 Original line number Diff line number Diff line Loading @@ -2,14 +2,19 @@ Initialization test for vospace Node table; for now owner_id and group_id are set equal to the rap_id */ INSERT INTO Node (parent_path, name, type, owner_id, creator_id) VALUES (NULL, '', 'container', '0', '0'); -- / INSERT INTO Node (parent_path, name, type, owner_id, creator_id) VALUES ('', 'curban', 'container', '3354', '3354'); -- /curban INSERT INTO Node (parent_path, name, type, owner_id, creator_id) VALUES ('2', 'store', 'container', '3354', '3354'); -- /curban/store INSERT INTO Node (parent_path, name, type, owner_id, creator_id) VALUES ('', 'sbertocco', 'container', '2048', '2048'); -- /sbertocco INSERT INTO Node (parent_path, name, type, owner_id, creator_id) VALUES ('4', 'store', 'container', '2048', '2048'); -- /sbertocco/store INSERT INTO Node (parent_path, name, type, owner_id, creator_id) VALUES ('', 'szorba', 'container', '2386', '2386'); -- /szorba INSERT INTO Node (parent_path, name, type, owner_id, creator_id) VALUES ('6', 'store', 'container', '2386', '2386'); -- /szorba/store -- parent_path = parent_relative_path INSERT INTO Node (parent_path, parent_relative_path, name, type, owner_id, creator_id) VALUES (NULL, NULL, '', 'container', '0', '0'); -- / INSERT INTO Node (parent_path, parent_relative_path, name, type, owner_id, creator_id) VALUES ('', '', 'curban', 'container', '3354', '3354'); -- /curban INSERT INTO Node (parent_path, parent_relative_path, name, type, owner_id, creator_id) VALUES ('2', '2', 'store', 'container', '3354', '3354'); -- /curban/store INSERT INTO Node (parent_path, parent_relative_path, name, type, owner_id, creator_id) VALUES ('', '', 'sbertocco', 'container', '2048', '2048'); -- /sbertocco INSERT INTO Node (parent_path, parent_relative_path, name, type, owner_id, creator_id) VALUES ('4', '4', 'store', 'container', '2048', '2048'); -- /sbertocco/store INSERT INTO Node (parent_path, parent_relative_path, name, type, owner_id, creator_id) VALUES ('', '', 'szorba', 'container', '2386', '2386'); -- /szorba INSERT INTO Node (parent_path, parent_relative_path, name, type, owner_id, creator_id) VALUES ('6', '6', 'store', 'container', '2386', '2386'); -- /szorba/store -- parent_path <> parent_relative_path INSERT INTO Node (parent_path, parent_relative_path, name, type, owner_id, creator_id) VALUES ('', NULL, 'test', 'container', '2386', '2386'); -- /test INSERT INTO Node (parent_path, parent_relative_path, name, type, owner_id, creator_id) VALUES ('8', '', 'f1', 'container', '2386', '2386'); -- /test/f1 (rel: /f1) INSERT INTO Node (parent_path, parent_relative_path, name, os_name, type, owner_id, creator_id) VALUES ('8.9', '9', 'f2_renamed', 'f2', 'container', '2386', '2386'); -- /test/f1/f2_renamed (rel: /f1/f2) INSERT INTO Node (parent_path, parent_relative_path, name, type, owner_id, creator_id) VALUES ('8.9.10', '9.10', 'f3', 'container', '2386', '2386'); -- /test/f1/f2_renamed/f3 (rel: /f1/f2/f3) /* Initialization test for vospace Users table Loading