Thread: problem with realizing gist index

problem with realizing gist index

From
Sergej Galkin
Date:
Hello all, <br />I'm creating gist index for testing purpuses :)<br /><br />I created index element structure:<br /><br
style="font-family:courier new,monospace;" /><div style="margin-left: 40px;"><span style="font-family: courier
new,monospace;">typedefstruct moving_object </span><br style="font-family: courier new,monospace;" /><span
style="font-family:courier new,monospace;">{</span><br style="font-family: courier new,monospace;" /><span
style="font-family:courier new,monospace;">    double x_high;</span><br style="font-family: courier new,monospace;"
/><spanstyle="font-family: courier new,monospace;">    double y_high;</span><br style="font-family: courier
new,monospace;"/><span style="font-family: courier new,monospace;">    double x_low;</span><br style="font-family:
couriernew,monospace;" /><span style="font-family: courier new,monospace;">    double y_low;</span><br
style="font-family:courier new,monospace;" /><span style="font-family: courier new,monospace;">    time_t
mov_time;</span><brstyle="font-family: courier new,monospace;" /><span style="font-family: courier new,monospace;">   
doublex_plus;</span><br style="font-family: courier new,monospace;" /><span style="font-family: courier
new,monospace;">   double y_plus;</span><br style="font-family: courier new,monospace;" /><span style="font-family:
couriernew,monospace;">    double x_minus;</span><br style="font-family: courier new,monospace;" /><span
style="font-family:courier new,monospace;">    double y_minus;</span><br style="font-family: courier new,monospace;"
/><spanstyle="font-family: courier new,monospace;">} moving_object;</span><br /></div><br />And defined macros that
returnpointer to this structure:<br /><br /><span style="font-family: courier new,monospace;">#define DatumGetMovP(x)
((moving_object*)DatumGetPointer(x))</span><br /><br /><br />but index interface function gives me error: Incompatible
typein assignment<br />Error line I style - bold<br /><br style="font-family: courier new,monospace;" /><div
style="margin-left:40px;"><span style="font-family: courier new,monospace;">Datum
gist_mov_union(PG_FUNCTION_ARGS)</span><brstyle="font-family: courier new,monospace;" /><span style="font-family:
couriernew,monospace;">{</span><br style="font-family: courier new,monospace;" /><span style="font-family: courier
new,monospace;">   GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);         int *sizep = (int *)
PG_GETARG_POINTER(1);</span><brstyle="font-family: courier new,monospace;" /><span style="font-family: courier
new,monospace;">   int num_obj;</span><br style="font-family: courier new,monospace;" /><span style="font-family:
couriernew,monospace;">    moving_object *pageunion, curr;</span><br style="font-family: courier new,monospace;"
/><spanstyle="font-family: courier new,monospace;">    </span><br style="font-family: courier new,monospace;" /><span
style="font-family:courier new,monospace;">    num_obj = entryvec->n;</span><br style="font-family: courier
new,monospace;"/><span style="font-family: courier new,monospace;">    </span><br style="font-family: courier
new,monospace;"/><span style="font-family: courier new,monospace;">    pageunion = (moving_object*)
palloc(sizeof(moving_object));</span><br/>         // THIS IS THE ERROR LINE<br style="font-family: courier
new,monospace;"/><span style="font-family: courier new,monospace;">   <font size="2"><b> curr =
DatumGetMovP(entryvec->vector[0].key);</b></font></span><brstyle="font-family: courier new,monospace;" /><span
style="font-family:courier new,monospace;">    make_now(curr);</span><br style="font-family: courier new,monospace;"
/><spanstyle="font-family: courier new,monospace;">    memcpy((void *) pageunion, (void *) curr,
sizeof(moving_object));</span><brstyle="font-family: courier new,monospace;" /><span style="font-family: courier
new,monospace;">   </span><br style="font-family: courier new,monospace;" /><span style="font-family: courier
new,monospace;">   for(int i = 1; i < num_obj; i++)</span><br style="font-family: courier new,monospace;" /><span
style="font-family:courier new,monospace;">    {</span><br style="font-family: courier new,monospace;" /><span
style="font-family:courier new,monospace;">        curr = DatumGetMovP(entryvec->vector[i].key);</span><br
style="font-family:courier new,monospace;" /><span style="font-family: courier new,monospace;">       
make_now(curr);</span><brstyle="font-family: courier new,monospace;" /><span style="font-family: courier
new,monospace;">       if (pageunion->x_high > curr->x_high)</span><br style="font-family: courier
new,monospace;"/><span style="font-family: courier new,monospace;">            pageunion->x_high =
curr->x_high;</span><brstyle="font-family: courier new,monospace;" /><span style="font-family: courier
new,monospace;">       if (pageunion->y_high < curr->y_high)</span><br style="font-family: courier
new,monospace;"/><span style="font-family: courier new,monospace;">            pageunion->y_high =
curr->y_high;</span><brstyle="font-family: courier new,monospace;" /><span style="font-family: courier
new,monospace;">       if (pageunion->x_low < curr->x_low)</span><br style="font-family: courier
new,monospace;"/><span style="font-family: courier new,monospace;">            pageunion->x_low =
curr->x_low;</span><brstyle="font-family: courier new,monospace;" /><span style="font-family: courier
new,monospace;">       if (pageunion->y_low > curr->y_low)</span><br style="font-family: courier
new,monospace;"/><span style="font-family: courier new,monospace;">            pageunion->y_low =
curr->y_low;</span><brstyle="font-family: courier new,monospace;" /><span style="font-family: courier
new,monospace;">      }</span><br style="font-family: courier new,monospace;" /><span style="font-family: courier
new,monospace;">   </span><br style="font-family: courier new,monospace;" /><span style="font-family: courier
new,monospace;">   *sizep = sizeof(moving_object);</span><br style="font-family: courier new,monospace;" /><span
style="font-family:courier new,monospace;">    PG_RETURN_POINTER(pageunion);</span><br style="font-family: courier
new,monospace;"/><span style="font-family: courier new,monospace;">}</span><b><br /></b></div><br />Can anybody know
whatthe problem ? I imagine that my defined function returns not pointer, but stucture (??) ?<br /><br />Best
regards,<br/>Sergej Galkin<br /> 

Re: problem with realizing gist index

From
Nicolas Barbier
Date:
2009/12/31 Sergej Galkin <sergej.galkin@gmail.com>:

> typedef struct moving_object
> {
>     double x_high;
>     double y_high;
>     double x_low;
>     double y_low;
>     time_t mov_time;
>     double x_plus;
>     double y_plus;
>     double x_minus;
>     double y_minus;
> } moving_object;

[..]

> #define DatumGetMovP(x) ((moving_object*)DatumGetPointer(x))

[..]

> but index interface function gives me error: Incompatible type in assignment

[..]

>     moving_object *pageunion, curr;

Note that curr is not defined as a pointer.

>         // THIS IS THE ERROR LINE
>     curr = DatumGetMovP(entryvec->vector[0].key);

But here you want to assign a pointer to it.

Nicolas