X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fextract.c;h=de9e04ff9d105b5e0e9e151afa836b2ac876fd4b;hb=98a65c4df19ff025d24167f425610d809a93bf80;hp=b12769c6b7a0a54e5ad10f9154f962281e65c2cf;hpb=48d26dcea283f57c49f77b82d6a987e41d775749;p=idzebra-moved-to-github.git diff --git a/index/extract.c b/index/extract.c index b12769c..de9e04f 100644 --- a/index/extract.c +++ b/index/extract.c @@ -1,10 +1,29 @@ /* - * Copyright (C) 1994-1998, Index Data I/S + * Copyright (C) 1994-1998, Index Data * All rights reserved. * Sebastian Hammer, Adam Dickmeiss * * $Log: extract.c,v $ - * Revision 1.83 1998-06-08 14:43:10 adam + * Revision 1.88 1998-10-16 08:14:29 adam + * Updated record control system. + * + * Revision 1.87 1998/10/15 13:10:33 adam + * Fixed bug in Zebra that caused it to stop indexing when empty + * record was read. + * + * Revision 1.86 1998/10/13 20:33:53 adam + * Fixed one log message and change use ordinal to be an unsigned char. + * + * Revision 1.85 1998/09/22 10:03:41 adam + * Changed result sets to be persistent in the sense that they can + * be re-searched if needed. + * Fixed memory leak in rsm_or. + * + * Revision 1.84 1998/06/11 15:42:22 adam + * Changed the way use attributes are specified in the recordId + * specification. + * + * Revision 1.83 1998/06/08 14:43:10 adam * Added suport for EXPLAIN Proxy servers - added settings databasePath * and explainDatabase to facilitate this. Increased maximum number * of databases and attributes in one register. @@ -603,8 +622,8 @@ static struct recKeys { static void addIndexString (RecWord *p, const char *string, int length) { char *dst; - char attrSet; - short attrUse; + unsigned char attrSet; + unsigned short attrUse; int lead = 0; int diff = 0; int *pseqno = &p->seqnos[p->reg_type]; @@ -678,9 +697,10 @@ static void addSortString (RecWord *p, const char *string, int length) sk->next = sortKeys; sortKeys = sk; - sk->string = xmalloc (p->length); - sk->length = p->length; - memcpy (sk->string, p->string, p->length); + sk->string = xmalloc (length); + sk->length = length; + memcpy (sk->string, string, length); + sk->attrSet = p->attrSet; sk->attrUse = p->attrUse; } @@ -811,8 +831,8 @@ static void flushSortKeys (SYSNO sysno, int cmd) static void flushRecordKeys (SYSNO sysno, int cmd, struct recKeys *reckeys) { - char attrSet = -1; - short attrUse = -1; + unsigned char attrSet = (unsigned char) -1; + unsigned short attrUse = (unsigned short) -1; int seqno = 0; int off = 0; @@ -999,26 +1019,13 @@ static void file_end (void *handle, off_t offset) p->file_moffset = offset; } -static int atois (const char **s) -{ - int val = 0, c; - while ( (c=**s) >= '0' && c <= '9') - { - val = val*10 + c - '0'; - ++(*s); - } - return val; -} - static char *fileMatchStr (struct recKeys *reckeys, struct recordGroup *rGroup, - const char *fname, - const char *spec) + const char *fname, const char *spec) { static char dstBuf[2048]; char *dst = dstBuf; const char *s = spec; static const char **w; - int i; while (1) { @@ -1028,21 +1035,39 @@ static char *fileMatchStr (struct recKeys *reckeys, struct recordGroup *rGroup, break; if (*s == '(') { + char attset_str[64], attname_str[64]; + data1_attset *attset; + int i; char matchFlag[32]; - int attrSet, attrUse; + int attSet = 1, attUse = 1; int first = 1; s++; - attrSet = atois (&s); - if (*s != ',') - { - logf (LOG_WARN, "Missing , in match criteria %s in group %s", - spec, rGroup->groupName ? rGroup->groupName : "none"); - return NULL; - } - s++; - attrUse = atois (&s); - w = searchRecordKey (reckeys, attrSet, attrUse); + for (i = 0; *s && *s != ',' && *s != ')'; s++) + if (i < 63) + attset_str[i++] = *s; + attset_str[i] = '\0'; + + if (*s == ',') + { + s++; + for (i = 0; *s && *s != ')'; s++) + if (i < 63) + attname_str[i++] = *s; + attname_str[i] = '\0'; + } + + if ((attset = data1_get_attset (rGroup->dh, attset_str))) + { + data1_att *att; + attSet = attset->reference; + att = data1_getattbyname(rGroup->dh, attset, attname_str); + if (att) + attUse = att->value; + else + attUse = atoi (attname_str); + } + w = searchRecordKey (reckeys, attSet, attUse); assert (w); if (*s == ')') @@ -1072,7 +1097,7 @@ static char *fileMatchStr (struct recKeys *reckeys, struct recordGroup *rGroup, if (first) { logf (LOG_WARN, "Record didn't contain match" - " fields in (%d,%d)", attrSet, attrUse); + " fields in (%s,%s)", attset_str, attname_str); return NULL; } } @@ -1239,7 +1264,7 @@ static int recordExtract (SYSNO *sysno, const char *fname, return 1; logf (LOG_WARN, "No keys generated for file %s", fname); logf (LOG_WARN, " The file is probably empty"); - return 0; + return 1; } } @@ -1412,8 +1437,8 @@ static int recordExtract (SYSNO *sysno, const char *fname, rec->info[recInfo_storeData] = xmalloc (recordAttr->recordSize); if (lseek (fi->fd, recordOffset, SEEK_SET) < 0) { - logf (LOG_ERRNO|LOG_FATAL, "seek to %ld in %s", fname, - (long) recordOffset); + logf (LOG_ERRNO|LOG_FATAL, "seek to %ld in %s", + (long) recordOffset, fname); exit (1); } if (read (fi->fd, rec->info[recInfo_storeData], recordAttr->recordSize) @@ -1493,7 +1518,8 @@ int fileExtract (SYSNO *sysno, const char *fname, } if (!*rGroup->recordType) return 0; - if (!(recType = recType_byName (rGroup->recordType, subType))) + if (!(recType = + recType_byName (rGroup->recTypes, rGroup->recordType, subType))) { logf (LOG_WARN, "No such record type: %s", rGroup->recordType); return 0;