Arrays : no viable alternative error

Hello ,

I’m trying to insert values in Array and attach it to vertex set. But I get no viable alternative at input error.

Example:

ArrayAccum<SumAccum<double>> @@squares[5][10];

ArrayAccum<SumAccum<double>> @@norm[5];

SumAccum<double> @@value;

Start={Person.*}

CV = SELECT p FROM Start:p

FOREACH i IN RANGE [0,5] DO

    @@value=0;

         FOREACH j in RANGE [0,9] DO  

              @@value=(i*i) + (j*j);

              p.@@squares[i][j]=(i*j);

         END;

     p.@norm[i]=sqrt(@@value);

END;

I tried using ACCUM and POST-ACCUM but I got an error NO VIABLE ALTERNATIVE AT INPUT error.

Hi Meghana,

There are a few things you can change in the query.

Start={Person.*} missing semicolon at the end

CV = select p from start:p missing semicolon at the end

p.@@squares[i][j]=(i*j) the line that returns the error you mentioned.

This is because @@squares, which you defined in the first line, is a global accumulator. Global accumulators are not attached to vertices.

To access it, just use this:

@@squares[i][j]=(i*j)

p.@norm[i]=sqrt(@@value); local accumulator can’t be updated unless within a select statement.

Thanks,

Kevin