Create OPERATOR BUG
Create OPERATOR BUG
I want to create en OPERATOR:
OPERATOR DISTANCE(i1 INTEGER, i2 INTEGER) RETURNS INTEGER Java FOREIGN
int[][] T = new int[32][32];
for (int i=1; i<33; i++)
{
for(int j=1;j<33;j++)
{ T[j]=0;
}
}
T[1][2]=4;
T[1][3]=4;
T[1][4]=3;
T[1][5]=7;
T[1][6]=14;
T[1][8]=6;
T[1][11]=7;
T[1][14]=9;
T[1][15]=10;
T[1][16]=7;
T[1][17]=7;
T[1][18]=8;
T[1][21]=9;
T[1][25]=10;
T[1][26]=14;
T[1][27]=6;
T[1][28]=2;
T[1][29]=10;
T[1][30]=12;
T[1][32]=14;
T[2][3]=3;
T[2][4]=2;
T[2][5]=9;
T[2][6]=14;
T[2][8]=5;
T[2][11]=5;
T[2][14]=7;
T[2][15]=8;
T[2][16]=6;
T[2][17]=7;
T[2][18]=5;
T[2][21]=10;
T[2][25]=9;
T[2][26]=14;
T[2][27]=2;
T[2][28]=4;
T[2][29]=6;
T[2][30]=9;
T[2][32]=9;
T[3][4]=1;
T[3][5]=7;
T[3][6]=12;
T[3][8]=2;
T[3][11]=3;
T[3][14]=6;
T[3][15]=8;
T[3][16]=7;
T[3][17]=3;
T[3][18]=9;
T[3][21]=4;
T[3][25]=7;
T[3][26]=9;
T[3][27]=4;
T[3][28]=2;
T[3][29]=5;
T[3][30]=7;
T[3][32]=9;
T[4][5]=8;
T[4][6]=12;
T[4][8]=3;
T[4][11]=4;
T[4][14]=6;
T[4][15]=8;
T[4][16]=7;
T[4][17]=3;
T[4][18]=10;
T[4][21]=4;
T[4][25]=7;
T[4][26]=9;
T[4][27]=5;
T[4][28]=1;
T[4][29]=5;
T[4][30]=7;
T[4][32]=9;
T[5][6]=8;
T[5][8]=8;
T[5][11]=8;
T[5][14]=10;
T[5][15]=11;
T[5][16]=8;
T[5][17]=5;
T[5][18]=14;
T[5][21]=6;
T[5][25]=12;
T[5][26]=14;
T[5][27]=10;
T[5][28]=4;
T[5][29]=6;
T[5][30]=4;
T[5][32]=13;
T[6][8]=11;
T[6][11]=10;
T[6][14]=5;
T[6][15]=6;
T[6][16]=14;
T[6][17]=8;
T[6][18]=12;
T[6][21]=4;
T[6][25]=6;
T[6][26]=10;
T[6][27]=7;
T[6][28]=4;
T[6][29]=2;
T[6][30]=4;
T[6][32]=9;
T[8][11]=2;
T[8][14]=8;
T[8][15]=9;
T[8][16]=12;
T[8][17]=5;
T[8][18]=6;
T[8][21]=6;
T[8][25]=4;
T[8][26]=7;
T[8][27]=2;
T[8][28]=5;
T[8][29]=4;
T[8][30]=9;
T[8][32]=6;
T[11][14]=4;
T[11][15]=5;
T[11][16]=8;
T[11][17]=5;
T[11][18]=5;
T[11][21]=5;
T[11][25]=3;
T[11][26]=7;
T[11][27]=3;
T[11][28]=4;
T[11][29]=3;
T[11][30]=6;
T[11][32]=5;
T[14][15]=2;
T[14][16]=11;
T[14][17]=6;
T[14][18]=6;
T[14][21]=6;
T[14][25]=1;
T[14][26]=7;
T[14][27]=4;
T[14][28]=1;
T[14][29]=2;
T[14][30]=8;
T[14][32]=4;
T[15][16]=12;
T[15][17]=7;
T[15][18]=7;
T[15][21]=7;
T[15][25]=0;
T[15][26]=5;
T[15][27]=4;
T[15][28]=3;
T[15][29]=3;
T[15][30]=10;
T[15][32]=3;
T[16][17]=13;
T[16][18]=3;
T[16][21]=14;
T[16][25]=12;
T[16][26]=14;
T[16][27]=0;
T[16][28]=13;
T[16][29]=10;
T[16][30]=14;
T[16][32]=11;
T[17][18]=10;
T[17][21]=3;
T[17][25]=9;
T[17][26]=11;
T[17][27]=6;
T[17][28]=0;
T[17][29]=3;
T[17][30]=1;
T[17][32]=10;
for (int i=1; i<33; i++)
{
T[7]=T[2];
T[9]=T[4];
T[10]=T[3];
T[12]=T[11];
T[13]=T[6][i];
T[19][i]=T[4][i];
T[20][i]=T[5][i];
T[22][i]=T[6][i];
T[23][i]=T[11][i];
T[24][i]=T[15][i];
T[31][i]=T[8][i];
}
for (int i=1; i<33; i++)
{
for(int j=1 ; j<33; j++)
{
T[j][i]=T[i][j];
}
}
int a= T[i1][i2];
return a ;
END OPERATOR;
I have This ERROR MESSAGE:
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.
I want to understand where is the problem?
OPERATOR DISTANCE(i1 INTEGER, i2 INTEGER) RETURNS INTEGER Java FOREIGN
int[][] T = new int[32][32];
for (int i=1; i<33; i++)
{
for(int j=1;j<33;j++)
{ T[j]=0;
}
}
T[1][2]=4;
T[1][3]=4;
T[1][4]=3;
T[1][5]=7;
T[1][6]=14;
T[1][8]=6;
T[1][11]=7;
T[1][14]=9;
T[1][15]=10;
T[1][16]=7;
T[1][17]=7;
T[1][18]=8;
T[1][21]=9;
T[1][25]=10;
T[1][26]=14;
T[1][27]=6;
T[1][28]=2;
T[1][29]=10;
T[1][30]=12;
T[1][32]=14;
T[2][3]=3;
T[2][4]=2;
T[2][5]=9;
T[2][6]=14;
T[2][8]=5;
T[2][11]=5;
T[2][14]=7;
T[2][15]=8;
T[2][16]=6;
T[2][17]=7;
T[2][18]=5;
T[2][21]=10;
T[2][25]=9;
T[2][26]=14;
T[2][27]=2;
T[2][28]=4;
T[2][29]=6;
T[2][30]=9;
T[2][32]=9;
T[3][4]=1;
T[3][5]=7;
T[3][6]=12;
T[3][8]=2;
T[3][11]=3;
T[3][14]=6;
T[3][15]=8;
T[3][16]=7;
T[3][17]=3;
T[3][18]=9;
T[3][21]=4;
T[3][25]=7;
T[3][26]=9;
T[3][27]=4;
T[3][28]=2;
T[3][29]=5;
T[3][30]=7;
T[3][32]=9;
T[4][5]=8;
T[4][6]=12;
T[4][8]=3;
T[4][11]=4;
T[4][14]=6;
T[4][15]=8;
T[4][16]=7;
T[4][17]=3;
T[4][18]=10;
T[4][21]=4;
T[4][25]=7;
T[4][26]=9;
T[4][27]=5;
T[4][28]=1;
T[4][29]=5;
T[4][30]=7;
T[4][32]=9;
T[5][6]=8;
T[5][8]=8;
T[5][11]=8;
T[5][14]=10;
T[5][15]=11;
T[5][16]=8;
T[5][17]=5;
T[5][18]=14;
T[5][21]=6;
T[5][25]=12;
T[5][26]=14;
T[5][27]=10;
T[5][28]=4;
T[5][29]=6;
T[5][30]=4;
T[5][32]=13;
T[6][8]=11;
T[6][11]=10;
T[6][14]=5;
T[6][15]=6;
T[6][16]=14;
T[6][17]=8;
T[6][18]=12;
T[6][21]=4;
T[6][25]=6;
T[6][26]=10;
T[6][27]=7;
T[6][28]=4;
T[6][29]=2;
T[6][30]=4;
T[6][32]=9;
T[8][11]=2;
T[8][14]=8;
T[8][15]=9;
T[8][16]=12;
T[8][17]=5;
T[8][18]=6;
T[8][21]=6;
T[8][25]=4;
T[8][26]=7;
T[8][27]=2;
T[8][28]=5;
T[8][29]=4;
T[8][30]=9;
T[8][32]=6;
T[11][14]=4;
T[11][15]=5;
T[11][16]=8;
T[11][17]=5;
T[11][18]=5;
T[11][21]=5;
T[11][25]=3;
T[11][26]=7;
T[11][27]=3;
T[11][28]=4;
T[11][29]=3;
T[11][30]=6;
T[11][32]=5;
T[14][15]=2;
T[14][16]=11;
T[14][17]=6;
T[14][18]=6;
T[14][21]=6;
T[14][25]=1;
T[14][26]=7;
T[14][27]=4;
T[14][28]=1;
T[14][29]=2;
T[14][30]=8;
T[14][32]=4;
T[15][16]=12;
T[15][17]=7;
T[15][18]=7;
T[15][21]=7;
T[15][25]=0;
T[15][26]=5;
T[15][27]=4;
T[15][28]=3;
T[15][29]=3;
T[15][30]=10;
T[15][32]=3;
T[16][17]=13;
T[16][18]=3;
T[16][21]=14;
T[16][25]=12;
T[16][26]=14;
T[16][27]=0;
T[16][28]=13;
T[16][29]=10;
T[16][30]=14;
T[16][32]=11;
T[17][18]=10;
T[17][21]=3;
T[17][25]=9;
T[17][26]=11;
T[17][27]=6;
T[17][28]=0;
T[17][29]=3;
T[17][30]=1;
T[17][32]=10;
for (int i=1; i<33; i++)
{
T[7]=T[2];
T[9]=T[4];
T[10]=T[3];
T[12]=T[11];
T[13]=T[6][i];
T[19][i]=T[4][i];
T[20][i]=T[5][i];
T[22][i]=T[6][i];
T[23][i]=T[11][i];
T[24][i]=T[15][i];
T[31][i]=T[8][i];
}
for (int i=1; i<33; i++)
{
for(int j=1 ; j<33; j++)
{
T[j][i]=T[i][j];
}
}
int a= T[i1][i2];
return a ;
END OPERATOR;
I have This ERROR MESSAGE:
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.
I want to understand where is the problem?
Re: Create OPERATOR BUG
How can I define an Operator who compare two Ids of 2 relations like this:
OPERATOR COMPARE(RELATION {id INTEGER}, RELATION{id INTEGER}) RETURNS INTEGER Java FOREIGN
RETURN id;
END OPERATOR;
??
OPERATOR COMPARE(RELATION {id INTEGER}, RELATION{id INTEGER}) RETURNS INTEGER Java FOREIGN
RETURN id;
END OPERATOR;
??
Re: Create OPERATOR BUG
The Tutorial D INTEGER type is not directly compatible with the Java int type.katoussa wrote: I want to understand where is the problem?
To convert a Java int (or long) 'x' to an INTEGER (which is represented by ValueInteger in Java):
Code: Select all
ValueInteger.select(context.getGenerator(), x)
Code: Select all
x.longValue()
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.
Re: Create OPERATOR BUG
I don't know what you're trying to do. Sorry.katoussa wrote:How can I define an Operator who compare two Ids of 2 relations like this:
OPERATOR COMPARE(RELATION {id INTEGER}, RELATION{id INTEGER}) RETURNS INTEGER Java FOREIGN
RETURN id;
END OPERATOR;
??
Re: Create OPERATOR BUG
OPERATOR COMPARE(RELATION {id1 INTEGER}, RELATION{id2 INTEGER}) RETURNS INTEGER Java FOREIGN
IF (id1>id2) RETURN id1;
ELSE RETURN id2;
END OPERATOR;
I want to compare two ids of relations.
IF (id1>id2) RETURN id1;
ELSE RETURN id2;
END OPERATOR;
I want to compare two ids of relations.
Re: Create OPERATOR BUG
Dave wrote:The Tutorial D INTEGER type is not directly compatible with the Java int type.katoussa wrote: I want to understand where is the problem?
To convert a Java int (or long) 'x' to an INTEGER (which is represented by ValueInteger in Java):To convert a ValueInteger 'x' to a Java long:Code: Select all
ValueInteger.select(context.getGenerator(), x)
See the OperatorsChar.d and OperatorsMath.d scripts in the Scripts subdirectory of a Rel installation for examples of Java-based user-defined OPERATORs.Code: Select all
x.longValue()
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.
Re: Create OPERATOR BUG
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:OPERATOR COMPARE(RELATION {id1 INTEGER}, RELATION{id2 INTEGER}) RETURNS INTEGER Java FOREIGN
IF (id1>id2) RETURN id1;
ELSE RETURN id2;
END OPERATOR;
I want to compare two ids of relations.
Re: Create OPERATOR BUG
Using your original example as a guideline (and with no guarantee that your original was correct!) I would do something like the following.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.
Code: Select all
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;
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!
Re: Create OPERATOR BUG
No I'm From Sherbrooke University.Dave wrote:Using your original example as a guideline (and with no guarantee that your original was correct!) I would do something like the following.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.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.Code: Select all
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;
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!
Re: Create OPERATOR BUG
I have this Relation:
VAR Batiments REAL RELATION {Id integer, Nom char, Polygon Polygon} KEY {Id};
How Can I have the minimum of values of Id of Batiments?
And How Can I have the minimum Of Distance between some value (for example 1) and the values of Id of the relation Batiments?
SOME THING LIKE : (Batiments WHERE Min DISTANCE (1, Id)) !!!!!! ("I want to have the nearest Batiment of the element who have id=1").
VAR Batiments REAL RELATION {Id integer, Nom char, Polygon Polygon} KEY {Id};
How Can I have the minimum of values of Id of Batiments?
And How Can I have the minimum Of Distance between some value (for example 1) and the values of Id of the relation Batiments?
SOME THING LIKE : (Batiments WHERE Min DISTANCE (1, Id)) !!!!!! ("I want to have the nearest Batiment of the element who have id=1").
Re: Create OPERATOR BUG
katoussa wrote:How Can I have the minimum of values of Id of Batiments?
Code: Select all
MIN(Batiments, Id)
Is this what you have in mind?katoussa wrote:And How Can I have the minimum Of Distance between some value (for example 1) and the values of Id of the relation Batiments?
Code: Select all
MIN(EXTEND Batiments ADD (DISTANCE(1, Id) AS Distance), Distance)
Re: Create OPERATOR BUG
Dave wrote:katoussa wrote:How Can I have the minimum of values of Id of Batiments?Code: Select all
MIN(Batiments, Id)
Is this what you have in mind?katoussa wrote:And How Can I have the minimum Of Distance between some value (for example 1) and the values of Id of the relation Batiments?Code: Select all
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.
Re: Create OPERATOR BUG
Sorry, I don't know what you mean.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.
Re: Create OPERATOR BUG
I want to have the persons who have encountered the greatest number of people FROM RELATION (Suivi_Personnes).
I wrote this:
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.
Thanks.
I wrote this:
Code: Select all
(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}))
)
I sent you all declarations of relations in message.
Thanks.