--- trunk/pgest.c 2006/05/11 15:52:50 56 +++ trunk/pgest.c 2006/05/11 16:19:38 57 @@ -42,6 +42,7 @@ #endif #define ATTR_DELIMITER "{{!}}" +#define HINTS_PREFIX "HINTS." /* prototype */ char *attr2text(ESTDOC *doc, char *attr); @@ -394,6 +395,7 @@ ESTCOND *cond; ESTNODERES *nres; ESTRESDOC *rdoc; + CBMAP *hints; int resnum = 0; int limit = 0; int offset = 0; @@ -590,6 +592,9 @@ nrows = resnum - offset; } + /* get hints */ + hints = est_noderes_hints(nres); + elog(DEBUG1, "pgest_node: found %d hits for %s", resnum, query); @@ -612,17 +617,31 @@ for (j = 0; j < ncols; j++) { bool isnull; + char *attr; /* current attribute name */ + char *hint; /* position of current hint in attribute */ + char *hint_val; /* array value of this position */ indx[0] = j + attr_dim_lower_bounds[0]; dvalue = array_ref(attr_arr, attr_ndims, indx, -1, attr_len, attr_byval, attr_align, &isnull); + attr = (char *)DirectFunctionCall1(textout, dvalue); - if (!isnull && rdoc) - values[j] = DatumGetCString( - node_attr2text(rdoc, - (char *)DirectFunctionCall1(textout, dvalue) - )); + if (!isnull && (hint = strstr(attr, HINTS_PREFIX)) != NULL) { + /* skip HINTS. prefix */ + hint += strlen(HINTS_PREFIX); + + hint_val = cbmapget(hints, hint, -1, NULL); + elog(DEBUG2, "hint %s = %s", hint, hint_val); + + if (hint_val != NULL) { + values[j] = DatumGetCString( hint_val ); + } else { + elog(INFO, "can't get hint in results: %s", hint); + values[j] = NULL; + } + } else if (!isnull && rdoc) + values[j] = DatumGetCString( node_attr2text(rdoc, attr) ); else values[j] = NULL; }