Update of /cvsroot/monetdb/pathfinder/modules/pftijah
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv30711
Modified Files:
nexi.c nexi_generate_mil.c nexi_generate_plan.c pftijah.mx
serialize_pftijah.mx termdb.mx
Log Message:
* Fixed big startNodes problem. Startnodes in combination with multiple
docmument collections should work now.
* Improve GDKmalloc error handling and changed all calloc's from Vojkans
code into GDKmalloc. There are still a couple of OS malloc/calloc left
in the lex and snowball code.
partially fixes [monetdb-bug# #1725352]
Index: serialize_pftijah.mx
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/modules/pftijah/serialize_pftijah.mx,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- serialize_pftijah.mx 24 May 2007 19:43:39 -0000 1.47
+++ serialize_pftijah.mx 25 May 2007 12:34:24 -0000 1.48
@@ -953,14 +953,20 @@
} else {
//if (*res) GDKfree(*res);
*res = GDKmalloc( strlen(stemmed)+1 );
- assert(*res); /* FIXME: properly handle failing alloc() */
+ if ( !res ) {
+ stream_printf(GDKout,"CMDtj_normalizeTerm: GDKmalloc()
failed.\n");
+ return GDK_FAIL;
+ }
strcpy( *res, stemmed );
}
//if ( stemCtx->clear ) stemCtx->clear( stemCtx );
} else {
//if (*res) GDKfree(*res);
*res = GDKmalloc( strlen(term)+1 );
- assert(*res); /* FIXME: properly handle failing alloc() */
+ if ( !res ) {
+ stream_printf(GDKout,"CMDtj_normalizeTerm: GDKmalloc() failed.\n");
+ return GDK_FAIL;
+ }
strcpy( *res, term );
}
return GDK_SUCCEED;
Index: nexi.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/modules/pftijah/nexi.c,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -d -r1.60 -r1.61
--- nexi.c 24 May 2007 19:43:38 -0000 1.60
+++ nexi.c 25 May 2007 12:34:23 -0000 1.61
@@ -197,12 +197,14 @@
[EMAIL PROTECTED] (2006-12-15):
This bug should be fixed now, with the cleanup of nexi_rewriter.c
*/
- txt_retr_model = calloc(MAX_QUERIES, sizeof(struct_RMT));
- assert(txt_retr_model); /* FIXME: properly handle failing alloc() */
- img_retr_model = calloc(MAX_QUERIES, sizeof(struct_RMI));
- assert(img_retr_model); /* FIXME: properly handle failing alloc() */
- rel_feedback = calloc(MAX_QUERIES, sizeof(struct_RF));
- assert(rel_feedback); /* FIXME: properly handle failing alloc() */
+ txt_retr_model = GDKmalloc(MAX_QUERIES*sizeof(struct_RMT));
+ img_retr_model = GDKmalloc(MAX_QUERIES*sizeof(struct_RMI));
+ rel_feedback = GDKmalloc(MAX_QUERIES*sizeof(struct_RF));
+ if ( !txt_retr_model || !img_retr_model || !rel_feedback ) {
+ stream_printf(GDKout,"nexi.c:old_main: GDKmalloc failed.\n");
+ return 0;
+ }
+
/*** Set default configuration values here: ***/
@@ -646,13 +648,13 @@
/* memory cleaning */
p_command_array = NULL;
- free(p_command_array); /* NONSENSE */
+ GDKfree(p_command_array); /* NONSENSE */
txt_retr_model = NULL;
img_retr_model = NULL;
- free(txt_retr_model);
- free(img_retr_model); /* NONSENSE */
+ GDKfree(txt_retr_model);
+ GDKfree(img_retr_model); /* NONSENSE */
rel_feedback = NULL;
- free(rel_feedback); /* NONSENSE */
+ GDKfree(rel_feedback); /* NONSENSE */
return 1;
}
@@ -673,7 +675,7 @@
tsl->cnt = 0;
tsl->max = max;
tsl->val = GDKmalloc( tsl->max * sizeof(char*) );
- assert(tsl->val); /* FIXME: properly handle failing alloc() */
+ assert(tsl->val);
return 1;
}
@@ -703,7 +705,7 @@
if ( tsl->cnt >= tsl->max) {
tsl->max *= 2;
tsl->val = GDKrealloc(tsl->val,(tsl->max * sizeof(char*)));
- assert(tsl->val); /* FIXME: properly handle failing alloc() */
+ assert(tsl->val);
}
#ifdef DEBUG_LIST
stream_printf(GDKout,"# appending \"%s\" to LIST[%s].\n",v,tsl->label);
@@ -726,7 +728,7 @@
tnl->cnt = 0;
tnl->max = max;
tnl->val = GDKmalloc( tnl->max * sizeof(int) );
- assert(tnl->val); /* FIXME: properly handle failing alloc() */
+ assert(tnl->val);
return 1;
}
@@ -750,7 +752,7 @@
if ( tnl->cnt >= tnl->max) {
tnl->max *= 2;
tnl->val = GDKrealloc(tnl->val,tnl->max * sizeof(int));
- assert(tnl->val); /* FIXME: properly handle failing alloc() */
+ assert(tnl->val);
}
#ifdef DEBUG_LIST
stream_printf(GDKout,"# appending (%d) to LIST[%s].\n",v,tnl->label);
Index: termdb.mx
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/modules/pftijah/termdb.mx,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- termdb.mx 24 May 2007 19:43:39 -0000 1.9
+++ termdb.mx 25 May 2007 12:34:24 -0000 1.10
@@ -514,11 +514,17 @@
*
*/
tdb->hashbat= GDKrealloc(tdb->hashbat,1+(int)tdb->curFrag* sizeof(BAT*));
- assert(tdb->hashbat); /* FIXME: properly handle failing alloc() */
+ if ( !tdb->hashbat ) {
+ stream_printf(GDKout,"tdb_splitBucket: realloc fails.\n");
+ return 0;
+ }
tdb->hashbat[new_fragIdx] = 0;
if (tdb->hashbatSize) {
tdb->hashbatSize = GDKrealloc(tdb->hashbatSize,1+(int)tdb->curFrag*
sizeof(size_t));
- assert(tdb->hashbatSize); /* FIXME: properly handle failing alloc() */
+ if ( !tdb->hashbatSize ) {
+ stream_printf(GDKout,"tdb_splitBucket: realloc fails.\n");
+ return 0;
+ }
tdb->hashbatSize[frag] = 0;
tdb->hashbatSize[new_fragIdx] = 0;
}
Index: nexi_generate_plan.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/modules/pftijah/nexi_generate_plan.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- nexi_generate_plan.c 24 May 2007 19:43:39 -0000 1.7
+++ nexi_generate_plan.c 25 May 2007 12:34:23 -0000 1.8
@@ -35,6 +35,9 @@
#include <ctype.h>
#include <string.h>
#include <assert.h>
+
+#include <gdk.h>
+
#include "nexi.h"
#include "nexi_generate_plan.h"
@@ -177,11 +180,13 @@
/* initialization for query plan trees */
- p_command_array = calloc(MAX_QUERIES, sizeof(command_tree*));
- assert(p_command_array); /* FIXME: properly handle failing alloc() */
+ p_command_array = GDKmalloc(MAX_QUERIES * sizeof(command_tree*));
p_command_start = p_command_array;
- p_command = calloc(MAX_QUERIES*OPERAND_MAX, sizeof(command_tree));
- assert(p_command); /* FIXME: properly handle failing alloc() */
+ p_command = GDKmalloc(MAX_QUERIES*OPERAND_MAX * sizeof(command_tree));
+ if ( !p_command_array || !p_command ) {
+ stream_printf(GDKout,"CAS_plan_gen: GDKmalloc failed.\n");
+ return 0;
+ }
/* printf("%d\n",p_command_array); */
/* printf("%d\n",p_command); */
Index: nexi_generate_mil.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/modules/pftijah/nexi_generate_mil.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- nexi_generate_mil.c 24 May 2007 19:43:39 -0000 1.30
+++ nexi_generate_mil.c 25 May 2007 12:34:23 -0000 1.31
@@ -37,6 +37,7 @@
#include <strings.h>
#include <assert.h>
+#include <gdk.h>
#include "pftijah.h"
#include "nexi.h"
#include "nexi_generate_mil.h"
@@ -206,12 +207,13 @@
bool set_reset;
/* memory allocation for string manipulation */
- argument1 = calloc(TERM_LENGTH, sizeof(char));
- assert(argument1); /* FIXME: properly handle failing alloc() */
- term_cut = calloc(TERM_LENGTH, sizeof(char));
- assert(term_cut); /* FIXME: properly handle failing alloc() */
- unq_term = calloc(ADJ_TERM_MAX * TERM_LENGTH, sizeof(char));
- assert(unq_term); /* FIXME: properly handle failing alloc() */
+ argument1 = GDKmalloc(TERM_LENGTH * sizeof(char));
+ term_cut = GDKmalloc(TERM_LENGTH * sizeof(char));
+ unq_term = GDKmalloc(ADJ_TERM_MAX * TERM_LENGTH* sizeof(char));
+ if ( !argument1 || !term_cut || !unq_term ) {
+ stream_printf(GDKout,"SRA_to_MIL: GDKmalloc failed.\n");
+ return 0;
+ }
/* formating the mil header */
@@ -439,7 +441,7 @@
/*printf("ZX1:%s\n",argument); */
adj_arg++;
- free(argument1);
+ GDKfree(argument1);
}
@@ -1072,9 +1074,9 @@
}
- free(term_cut);
- free(unq_term);
- free(argument1);
+ GDKfree(term_cut);
+ GDKfree(unq_term);
+ GDKfree(argument1);
return 1;
}
Index: pftijah.mx
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/modules/pftijah/pftijah.mx,v
retrieving revision 1.122
retrieving revision 1.123
diff -u -d -r1.122 -r1.123
--- pftijah.mx 24 May 2007 19:43:39 -0000 1.122
+++ pftijah.mx 25 May 2007 12:34:24 -0000 1.123
@@ -3183,7 +3183,11 @@
{
int sz = strlen(arg);
char* buf = GDKmalloc(sz + 1);
- assert(buf); /* FIXME: properly handle failing alloc() */
+
+ if (!buf) {
+ GDKerror("CMDtijah_tokenize: GDKmalloc() failed.\n");
+ return GDK_FAIL;
+ }
buf[0] = 0;
*res = tijah_tokenize_string(arg,sz,buf);
@@ -3196,7 +3200,10 @@
int nDocs = BATcount(doc_loaded);
BAT **rangeBAT = (BAT**)GDKmalloc(nDocs*sizeof(BAT*));
- assert(rangeBAT); /* FIXME: properly handle failing alloc() */
+ if (!rangeBAT) {
+ GDKerror("CMDpf2tijah_node: GDKmalloc() failed.\n");
+ return GDK_FAIL;
+ }
for(int i=0; i<nDocs; i++) {
rangeBAT[i] = NULL;
}
@@ -3204,7 +3211,7 @@
*res = BATnew(TYPE_void, TYPE_oid, BATcount(item));
if ( debug ) stream_printf(GDKout,"* Start of CMDpf2tijah_node():\n");
- if ( 1 && debug ) {
+ if ( 0 && debug ) {
BATprintf(GDKout,item);
BATprintf(GDKout,kind);
BATprintf(GDKout,doc_loaded);
@@ -3238,18 +3245,19 @@
int myindex = container - 1;
/* make it a switch */
if ( rangeBAT[myindex] == NULL ) {
+
+ BAT* docs_in_cont =
BATselect(BATmirror(doc_loaded),&container,&container);
+ int x_dic;
+ BUN p_dic,q_dic;
+ BATloopFast(docs_in_cont, p_dic, q_dic, x_dic) {
oid doc_start;
oid doc_end;
- BUN xbun = BUNfnd(doc_loaded,&container);
- if ( ! xbun ) {
- stream_printf(GDKout,"Cannot find cont %d.\n",container);
- return GDK_FAIL;
- }
- str docname = (str)BUNtail(doc_loaded,xbun);
+ str docname = (str) BUNhead(docs_in_cont, p_dic);
BAT* b = BATmirror(doc_name);
BUN yy = BUNfnd(b,docname);
if ( yy ) {
+ if ( debug ) stream_printf(GDKout,"* pf2tijah_index:
preparing doc(%s)[] nodes for translation\n",docname);
oid tj_docIndex = *(oid*)BUNtail(b,yy);
BUN r;
@@ -3271,11 +3279,17 @@
} else {
doc_end = oid_nil;
}
- rangeBAT[myindex] =
BATselect(BATmirror(doc_pfpre),(ptr)&doc_start,(ptr)&doc_end);
- if ( 0 && debug ) BATprintf(GDKout,rangeBAT[myindex]);
+ BAT* ds =
BATselect(BATmirror(doc_pfpre),(ptr)&doc_start,(ptr)&doc_end);
+ if ( rangeBAT[myindex] == NULL ) {
+ rangeBAT[myindex] = BATsetaccess(ds, BAT_WRITE);
+ } else {
+ if ( !BATins(rangeBAT[myindex],ds,1) ) {
+ stream_printf(GDKout,"CMDpf2tijah_node: BATins in
rangeBAT fails.\n");
+ return GDK_FAIL;
+ }
+ }
} {
- /* else skip */
- } }
+ } } }
if ( rangeBAT[myindex] ) {
BUN range_bun = BUNfnd(rangeBAT[myindex],&pfpre);
if ( range_bun ) {
@@ -3652,11 +3666,10 @@
BAT** bats = (BAT**) GDKmalloc(term_cnt * sizeof(BAT*));
BUN* dsts = (BUN*) GDKmalloc(term_cnt * sizeof(BUN));
int* bfrees = (int*) GDKmalloc(term_cnt * sizeof(int));
- assert(terms); /* FIXME: properly handle failing alloc() */
- assert(facs); /* FIXME: properly handle failing alloc() */
- assert(bats); /* FIXME: properly handle failing alloc() */
- assert(dsts); /* FIXME: properly handle failing alloc() */
- assert(bfrees); /* FIXME: properly handle failing alloc() */
+ if (!terms || !facs || !bats || !dsts || !bfrees ) {
+ GDKerror("CMDscore_NLLR: GDKmalloc() failed.\n");
+ return GDK_FAIL;
+ }
/* --------------------------- checks
---------------------------------- */
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins