/[pgestraier]/trunk/pgest.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/pgest.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 48 by dpavlin, Thu Oct 20 16:24:26 2005 UTC revision 51 by dpavlin, Tue May 9 22:55:42 2006 UTC
# Line 359  char *attr2text(ESTDOC *doc, char *attr) Line 359  char *attr2text(ESTDOC *doc, char *attr)
359  #define _arg_node_uri 0  #define _arg_node_uri 0
360  #define _arg_login 1  #define _arg_login 1
361  #define _arg_passwd 2  #define _arg_passwd 2
362  #define _arg_query 3  #define _arg_depth 3
363  #define _arg_attr 4  #define _arg_query 4
364  #define _arg_order 5  #define _arg_attr 5
365  #define _arg_limit 6  #define _arg_order 6
366  #define _arg_offset 7  #define _arg_limit 7
367  #define _arg_attr_array 8  #define _arg_offset 8
368    #define _arg_attr_array 9
369  /* as (foo text, ... ); */  /* as (foo text, ... ); */
370    
371    
# Line 402  Datum pgest_node(PG_FUNCTION_ARGS) Line 403  Datum pgest_node(PG_FUNCTION_ARGS)
403          int resnum = 0;          int resnum = 0;
404          int limit = 0;          int limit = 0;
405          int offset = 0;          int offset = 0;
406            int depth = 0;
407    
408          char            *node_url;          char            *node_url;
409          char            *user, *passwd;          char            *user, *passwd;
# Line 479  Datum pgest_node(PG_FUNCTION_ARGS) Line 481  Datum pgest_node(PG_FUNCTION_ARGS)
481          user = _textout(PG_GETARG_TEXT_P(_arg_login));          user = _textout(PG_GETARG_TEXT_P(_arg_login));
482          passwd = _textout(PG_GETARG_TEXT_P(_arg_passwd));          passwd = _textout(PG_GETARG_TEXT_P(_arg_passwd));
483    
484            /* depth of search */
485            if (PG_ARGISNULL(_arg_depth)) {
486                    depth = 0;
487            } else {
488                    depth = PG_GETARG_INT32(_arg_depth);
489            }
490    
491          /* query string */          /* query string */
492          if (PG_ARGISNULL(_arg_query)) {          if (PG_ARGISNULL(_arg_query)) {
493                  query = "";                  query = "";
# Line 526  Datum pgest_node(PG_FUNCTION_ARGS) Line 535  Datum pgest_node(PG_FUNCTION_ARGS)
535          node = est_node_new(node_url);          node = est_node_new(node_url);
536          est_node_set_auth(node, user, passwd);          est_node_set_auth(node, user, passwd);
537    
538          elog(DEBUG1, "pgest_node: query[%s] attr[%s] limit %d offset %d", query, (PG_ARGISNULL(_arg_attr) ? "NULL" : attr), limit, offset);          elog(DEBUG1, "pgest_node: node: %s (d:%d) query[%s] attr[%s] limit %d offset %d", node_url, depth, query, (PG_ARGISNULL(_arg_attr) ? "NULL" : attr), limit, offset);
539                    
540          /* create a search condition object */          /* create a search condition object */
541          if (!(cond = est_cond_new())) {          if (!(cond = est_cond_new())) {
# Line 561  Datum pgest_node(PG_FUNCTION_ARGS) Line 570  Datum pgest_node(PG_FUNCTION_ARGS)
570                  est_cond_set_max(cond, limit + offset);                  est_cond_set_max(cond, limit + offset);
571          }          }
572    
573            if (offset) {
574                    elog(DEBUG1,"est_cond_set_skip(%d)", offset);
575                    est_cond_set_skip(cond, offset);
576            }
577    
578          /* get the result of search */          /* get the result of search */
579          /* FIXME: allow user to specify depath of search */          nres = est_node_search(node, cond, depth);
         nres = est_node_search(node, cond, 0);  
580    
581          if (! nres) {          if (! nres) {
582                  int status = est_node_status(node);                  int status = est_node_status(node);
# Line 589  Datum pgest_node(PG_FUNCTION_ARGS) Line 602  Datum pgest_node(PG_FUNCTION_ARGS)
602                  nrows = resnum - offset;                  nrows = resnum - offset;
603          }          }
604    
   
605          elog(DEBUG1, "pgest_node: found %d hits for %s", resnum, query);          elog(DEBUG1, "pgest_node: found %d hits for %s", resnum, query);
606    
607    
# Line 599  Datum pgest_node(PG_FUNCTION_ARGS) Line 611  Datum pgest_node(PG_FUNCTION_ARGS)
611          {          {
612    
613                  /* get result from estraier */                  /* get result from estraier */
614                  if (! ( rdoc = est_noderes_get_doc(nres, i + offset) )) {                  if (! ( rdoc = est_noderes_get_doc(nres, i) )) {
615                          elog(INFO, "pgest_node: can't find result %d", i + offset);                          elog(INFO, "pgest_node: can't find result %d", i + offset);
616                  } else {                  } else {
617                          elog(DEBUG1, "URI: %s\n Title: %s\n",                          elog(DEBUG1, "URI: %s\n Title: %s\n",

Legend:
Removed from v.48  
changed lines
  Added in v.51

  ViewVC Help
Powered by ViewVC 1.1.26