Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

limitation on graph traversal

1) in model.sql, fcreate_tmp()
	The yflow_status(pat)!=3 in the WITH statement is removed,
and a DELETE .. where yflow_status(pat)!=3; is added.
This way, the maximum number of paths fetched by the WITH statement is limited by
_MAXORDERFETCH

2) in _yflow_follow(), a condition is added so that the path is not followed when
the initial path is draft. It was already done but it is faster like this.

3) _MAXORDERFETCH is set to 10 000
this modifies expected/*
  • Loading branch information...
commit 236919f792976a991506dc34a8bd517012489e80 1 parent 7bf7361
@olivierch authored
View
40 src/expected/testflow_2.out
@@ -134,25 +134,25 @@ select id,qtt from tquality;
(3 rows)
select * from fgetstats(true);
- _name | cnt
-------------------------------+-----
- number of qualities | 3
- number of owners | 3
- number of orders | 7
- number of movements | 8
- number of orders removed | 7
- number of movements removed | 8
- total number of agreements | 3
- errors on quantities in mvts | 0
- errors on agreements in mvts | 0
- MAXCYCLE | 8
- VERSION | 31
- INSERT_OWN_UNKNOWN | 1
- CHECK_QUALITY_OWNERSHIP | 0
- MAXORDERFETCH | 100
- MARKET_OPENED | 1
- MARKET_SESSION | 1
- agreements with 2 partners | 1
- agreements with 3 partners | 2
+ _name | cnt
+------------------------------+-------
+ number of qualities | 3
+ number of owners | 3
+ number of orders | 7
+ number of movements | 8
+ number of orders removed | 7
+ number of movements removed | 8
+ total number of agreements | 3
+ errors on quantities in mvts | 0
+ errors on agreements in mvts | 0
+ MAXCYCLE | 8
+ VERSION | 31
+ INSERT_OWN_UNKNOWN | 1
+ CHECK_QUALITY_OWNERSHIP | 0
+ MAXORDERFETCH | 10000
+ MARKET_OPENED | 1
+ MARKET_SESSION | 1
+ agreements with 2 partners | 1
+ agreements with 3 partners | 2
(18 rows)
View
40 src/expected/testflow_5.out
@@ -216,26 +216,26 @@ select id,qtt from tquality;
(3 rows)
select * from fgetstats(true);
- _name | cnt
-------------------------------+-----
- number of qualities | 3
- number of owners | 3
- number of orders | 7
- number of movements | 8
- number of orders removed | 7
- number of movements removed | 8
- total number of agreements | 3
- errors on quantities in mvts | 0
- errors on agreements in mvts | 0
- MAXCYCLE | 8
- VERSION | 31
- INSERT_OWN_UNKNOWN | 1
- CHECK_QUALITY_OWNERSHIP | 0
- MAXORDERFETCH | 100
- MARKET_OPENED | 0
- MARKET_SESSION | 2
- agreements with 2 partners | 1
- agreements with 3 partners | 2
+ _name | cnt
+------------------------------+-------
+ number of qualities | 3
+ number of owners | 3
+ number of orders | 7
+ number of movements | 8
+ number of orders removed | 7
+ number of movements removed | 8
+ total number of agreements | 3
+ errors on quantities in mvts | 0
+ errors on agreements in mvts | 0
+ MAXCYCLE | 8
+ VERSION | 31
+ INSERT_OWN_UNKNOWN | 1
+ CHECK_QUALITY_OWNERSHIP | 0
+ MAXORDERFETCH | 10000
+ MARKET_OPENED | 0
+ MARKET_SESSION | 2
+ agreements with 2 partners | 1
+ agreements with 3 partners | 2
(18 rows)
select id,sess,action from fprepare();
View
40 src/expected/testflow_6.out
@@ -88,25 +88,25 @@ select id,qtt from tquality;
(3 rows)
select * from fgetstats(true);
- _name | cnt
-------------------------------+-----
- number of qualities | 3
- number of owners | 4
- number of orders | 4
- number of movements | 5
- number of orders removed | 4
- number of movements removed | 0
- total number of agreements | 2
- errors on quantities in mvts | 0
- errors on agreements in mvts | 0
- MAXCYCLE | 8
- VERSION | 31
- INSERT_OWN_UNKNOWN | 1
- CHECK_QUALITY_OWNERSHIP | 0
- MAXORDERFETCH | 100
- MARKET_OPENED | 1
- MARKET_SESSION | 3
- agreements with 2 partners | 1
- agreements with 3 partners | 1
+ _name | cnt
+------------------------------+-------
+ number of qualities | 3
+ number of owners | 4
+ number of orders | 4
+ number of movements | 5
+ number of orders removed | 4
+ number of movements removed | 0
+ total number of agreements | 2
+ errors on quantities in mvts | 0
+ errors on agreements in mvts | 0
+ MAXCYCLE | 8
+ VERSION | 31
+ INSERT_OWN_UNKNOWN | 1
+ CHECK_QUALITY_OWNERSHIP | 0
+ MAXORDERFETCH | 10000
+ MARKET_OPENED | 1
+ MARKET_SESSION | 3
+ agreements with 2 partners | 1
+ agreements with 3 partners | 1
(18 rows)
View
24 src/sql/model.sql
@@ -26,8 +26,8 @@ INSERT INTO tconst (name,value) VALUES
('CHECK_QUALITY_OWNERSHIP',0),
-- !=0, quality = user_name/quality_name prefix must match session_user
-- ==0, the name of quality can be any string
- ('MAXORDERFETCH',100);
- -- maximum number of agreements of the set on which the competition occurs
+ ('MAXORDERFETCH',10000);
+ -- maximum number of paths of the set on which the competition occurs
--------------------------------------------------------------------------------
-- fetch a constant, and verify consistancy
CREATE FUNCTION fgetconst(_name text) RETURNS int AS $$
@@ -661,9 +661,6 @@ END;
$$ LANGUAGE PLPGSQL SECURITY DEFINER;
GRANT EXECUTE ON FUNCTION finsertorder(text,text,int8,int8,text) TO market_open_role;
-CREATE VIEW vorderinsert AS
- SELECT id,yorder_get(id,own,nr,qtt_requ,np,qtt_prov,qtt) as ord,np,nr
- FROM torder ORDER BY id ASC;
--------------------------------------------------------------------------------
-- finsert_order_int
@@ -710,7 +707,7 @@ BEGIN
*/
LOOP
_cnt := _cnt + 1;
- SELECT yflow_max(pat) INTO _patmax FROM _tmp;
+ SELECT yflow_max(pat) INTO _patmax FROM _tmp ;
IF (yflow_status(_patmax)!=3) THEN
EXIT; -- from LOOP
END IF;
@@ -741,7 +738,10 @@ BEGIN
RETURN;
END;
$$ LANGUAGE PLPGSQL;
-
+--------------------------------------------------------------------------------
+CREATE VIEW vorderinsert AS
+ SELECT id,yorder_get(id,own,nr,qtt_requ,np,qtt_prov,qtt) as ord,np,nr
+ FROM torder ORDER BY id ASC ;
--------------------------------------------------------------------------------
CREATE FUNCTION fcreate_tmp(_id int,_ord yorder,_np int,_nr int) RETURNS int AS $$
DECLARE
@@ -760,9 +760,8 @@ BEGIN
SELECT X.id,X.ord,
yflow_get(X.ord,Y.pat), -- add the order at the begin of the yflow
X.np,X.nr
- FROM vorderinsert X, search_backward Y
- WHERE X.np = yorder_nr(Y.ord) -- use of indexe
- AND yflow_follow(_MAXCYCLE,X.ord,Y.pat)
+ FROM search_backward Y,vorderinsert X
+ WHERE yflow_follow(_MAXCYCLE,X.ord,Y.pat)
-- X->Y === X.qtt>0 and X.np=Y[0].nr
-- Y.pat does not contain X.ord
-- len(X.ord+Y.path) <= _MAXCYCLE
@@ -770,10 +769,11 @@ BEGIN
)
SELECT id,ord,nr,pat
- FROM search_backward where yflow_status(pat)=3 LIMIT _MAXORDERFETCH --draft
+ FROM search_backward LIMIT _MAXORDERFETCH --draft
);
+ DELETE FROM _tmp WHERE yflow_status(pat)!=3;
SELECT COUNT(*) INTO _cnt FROM _tmp;
-
+
RETURN _cnt;
END;
$$ LANGUAGE PLPGSQL;
View
3  src/yflow.c
@@ -314,6 +314,9 @@ static bool _yflow_follow(int32 maxlen,Torder *o,Tflow *f, bool before) {
if(globales.warning_follow)
elog(WARNING,"_yflow_follow %s",yflow_pathToStr(f));
+ if(f->status == draft)
+ return false;
+
if((dim >=maxlen) || (dim >= FLOW_MAX_DIM))
return false;
Please sign in to comment.
Something went wrong with that request. Please try again.