C:\Program Files\Rel\Database\RelUserCode\op_DISTANCE__INTEGER_INTEGER.java:229: incompatible types found : ca.mb.armchair.rel3.values.ValueInteger required: int int a= T[i1][i2];
^ C:\Program Files\Rel\Database\RelUserCode\op_DISTANCE__INTEGER_INTEGER.java:229: incompatible types found : ca.mb.armchair.rel3.values.ValueInteger required: int int a= T[i1][i2];
^ C:\Program Files\Rel\Database\RelUserCode\op_DISTANCE__INTEGER_INTEGER.java:230: incompatible types found : int required: ca.mb.armchair.rel3.values.ValueInteger return a ;
^ 3 errors
ERROR: ca.mb.armchair.rel3.exceptions.ExceptionSemantic: Java compilation failed due to errors.
See the OperatorsChar.d and OperatorsMath.d scripts in the Scripts subdirectory of a Rel installation for examples of Java-based user-defined OPERATORs.
By the way, I'm not sure what you're trying to achieve with your DISTANCE operator, but I suspect it can be done better with a Tutorial D operator rather than a Java-based FOREIGN operator.
See the OperatorsChar.d and OperatorsMath.d scripts in the Scripts subdirectory of a Rel installation for examples of Java-based user-defined OPERATORs.
By the way, I'm not sure what you're trying to achieve with your DISTANCE operator, but I suspect it can be done better with a Tutorial D operator rather than a Java-based FOREIGN operator.
I have to define an array with all distances between two things. Then by giving two ids as parameters the operator returns the distance between this two things through ids. I don't know haw to write it.
Thanks.
Sorry, that doesn't make sense. Relations don't have IDs. A relation has a heading that defines 0 or more attributes, and a body containing 0 or more tuples. I've tried to guess what you might have in mind but I'm afraid it defeats me.
katoussa wrote:
I have to define an array with all distances between two things. Then by giving two ids as parameters the operator returns the distance between this two things through ids. I don't know haw to write it.
Thanks.
Using your original example as a guideline (and with no guarantee that your original was correct!) I would do something like the following.
OPERATOR DISTANCE(i1 INTEGER, i2 INTEGER) RETURNS INTEGER;
BEGIN;
VAR T PRIVATE RELATION {x INTEGER, y INTEGER, distance INTEGER} KEY {x, y};
T := RELATION {
TUPLE {x 1, y 1, distance 0},
TUPLE {x 1, y 2, distance 4},
TUPLE {x 1, y 3, distance 3},
... etc. ...
};
RETURN distance FROM TUPLE FROM (T WHERE x = i1 AND y = i2);
END;
END OPERATOR;
NOTE: I haven't tested it, so there may be syntax errors and obviously it is incomplete.
By the way, are these questions related to university or college coursework? If so, I'm happy to provide general suggestions but of course I can't give you the answers!
katoussa wrote:
I have to define an array with all distances between two things. Then by giving two ids as parameters the operator returns the distance between this two things through ids. I don't know haw to write it.
Thanks.
Using your original example as a guideline (and with no guarantee that your original was correct!) I would do something like the following.
OPERATOR DISTANCE(i1 INTEGER, i2 INTEGER) RETURNS INTEGER;
BEGIN;
VAR T PRIVATE RELATION {x INTEGER, y INTEGER, distance INTEGER} KEY {x, y};
T := RELATION {
TUPLE {x 1, y 1, distance 0},
TUPLE {x 1, y 2, distance 4},
TUPLE {x 1, y 3, distance 3},
... etc. ...
};
RETURN distance FROM TUPLE FROM (T WHERE x = i1 AND y = i2);
END;
END OPERATOR;
NOTE: I haven't tested it, so there may be syntax errors and obviously it is incomplete. There aren't Syntax errors I have tested it. Thanks.
By the way, are these questions related to university or college coursework? If so, I'm happy to provide general suggestions but of course I can't give you the answers!
MIN(EXTEND Batiments ADD (DISTANCE(1, Id) AS Distance), Distance)
Thank you for your answers.
If I want to make the minimum of distance with Ids of Two relations. In other words I want to replace 1 in last code with Id of RELATION (Personnes) FOR Example. How to do this? I have to compare two EXTEND RELATION.
katoussa wrote:
If I want to make the minimum of distance with Ids of Two relations. In other words I want to replace 1 in last code with Id of RELATION (Personnes) FOR Example. How to do this? I have to compare two EXTEND RELATION.
(Suivi_Personnes WHERE
MAX (EXTEND Suivi ADD
(WITH ((Suivi WHERE DISTANCE (Id_S, Id_Personnes)<10 and Heure_S=Heure and Id_Personnes_S<>Id_Personnes
){Id_S} ) AS T : COUNT (T {Id_S})
AS N),N) = ( WITH ((Suivi WHERE DISTANCE (Id_S, Id_Personnes)<10 and Heure_S=Heure and Id_Personnes_S<>Id_Personnes
){Id_S} ) AS T : COUNT (T {Id_S}))
)
It's runing but dont't stop and don't give a response. I dont't know where is the problem why the runing take so time.
I sent you all declarations of relations in message.