-/* $Id: extract.c,v 1.200 2005-12-09 10:45:04 adam Exp $
+/* $Id: extract.c,v 1.203 2006-02-20 18:39:43 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
#include <fcntl.h>
#include "index.h"
+#include "orddict.h"
#include <direntz.h>
#include <charmap.h>
}
}
+#define FILE_MATCH_BLANK "\t "
+
static char *fileMatchStr (ZebraHandle zh,
zebra_rec_keys_t reckeys,
const char *fname, const char *spec)
while (1)
{
- while (*s == ' ' || *s == '\t')
- s++;
+ for (; *s && strchr(FILE_MATCH_BLANK, *s); s++)
+ ;
if (!*s)
break;
if (*s == '(')
char attset_str[64], attname_str[64];
data1_attset *attset;
int i;
- char matchFlag[32];
int attSet = 1, attUse = 1;
int first = 1;
-
- s++;
- for (i = 0; *s && *s != ',' && *s != ')'; s++)
- if (i < 63)
+
+ for (s++; strchr(FILE_MATCH_BLANK, *s); s++)
+ ;
+ for (i = 0; *s && *s != ',' && *s != ')' &&
+ !strchr(FILE_MATCH_BLANK, *s); s++)
+ if (i+1 < sizeof(attset_str))
attset_str[i++] = *s;
attset_str[i] = '\0';
-
+
+ for (; strchr(FILE_MATCH_BLANK, *s); s++)
+ ;
if (*s == ',')
{
- s++;
- for (i = 0; *s && *s != ')'; s++)
- if (i < 63)
+ for (s++; strchr(FILE_MATCH_BLANK, *s); s++)
+ ;
+ for (i = 0; *s && *s != ')' &&
+ !strchr(FILE_MATCH_BLANK, *s); s++)
+ if (i+1 < sizeof(attname_str))
attname_str[i++] = *s;
attname_str[i] = '\0';
}
}
searchRecordKey (zh, reckeys, attSet, attUse, ws, 32);
- if (*s == ')')
- {
- for (i = 0; i<32; i++)
- matchFlag[i] = 1;
- }
- else
+ if (*s != ')')
{
yaz_log (YLOG_WARN, "Missing ) in match criteria %s in group %s",
spec, zh->m_group ? zh->m_group : "none");
s++;
for (i = 0; i<32; i++)
- if (matchFlag[i] && ws[i])
+ if (ws[i])
{
if (first)
{
char special[64];
const char *spec_src = NULL;
const char *s1 = ++s;
- while (*s1 && *s1 != ' ' && *s1 != '\t')
+ while (*s1 && !strchr(FILE_MATCH_BLANK, *s1))
s1++;
spec_len = s1 - s;
- if (spec_len > 63)
- spec_len = 63;
+ if (spec_len > sizeof(special)-1)
+ spec_len = sizeof(special)-1;
memcpy (special, s, spec_len);
special[spec_len] = '\0';
s = s1;
while (*s && *s != stopMarker)
{
- if (i < 63)
+ if (i+1 < sizeof(tmpString))
tmpString[i++] = *s++;
}
if (*s)
}
if (matchStr)
{
- char *rinfo = dict_lookup (zh->reg->matchDict, matchStr);
+ int db_ord = zebraExplain_get_database_ord(zh->reg->zei);
+ char *rinfo = dict_lookup_ord(zh->reg->matchDict, db_ord,
+ matchStr);
if (rinfo)
{
assert(*rinfo == sizeof(*sysno));
if (matchStr)
{
- dict_insert (zh->reg->matchDict, matchStr, sizeof(*sysno), sysno);
+ int db_ord = zebraExplain_get_database_ord(zh->reg->zei);
+ dict_insert_ord(zh->reg->matchDict, db_ord, matchStr,
+ sizeof(*sysno), sysno);
}
#if NATTR
extract_flushSortKeys (zh, *sysno, 1, zh->reg->sortKeys);
zh->m_record_type, fname, recordOffset);
zh->records_deleted++;
if (matchStr)
- dict_delete (zh->reg->matchDict, matchStr);
+ {
+ int db_ord = zebraExplain_get_database_ord(zh->reg->zei);
+ dict_delete_ord(zh->reg->matchDict, db_ord, matchStr);
+ }
rec_del (zh->reg->records, &rec);
}
rec_rm (&rec);
}
}
}
- if (matchStr) {
- char *rinfo = dict_lookup (zh->reg->matchDict, matchStr);
+ if (matchStr)
+ {
+ int db_ord = zebraExplain_get_database_ord(zh->reg->zei);
+ char *rinfo = dict_lookup_ord(zh->reg->matchDict, db_ord,
+ matchStr);
if (rinfo)
{
assert(*rinfo == sizeof(*sysno));
if (matchStr)
{
- dict_insert (zh->reg->matchDict, matchStr,
- sizeof(*sysno), sysno);
+ int db_ord = zebraExplain_get_database_ord(zh->reg->zei);
+ dict_insert_ord(zh->reg->matchDict, db_ord, matchStr,
+ sizeof(*sysno), sysno);
}
#if NATTR
extract_flushSortKeys (zh, *sysno, 1, zh->reg->sortKeys);
pr_fname, (long) recordOffset);
zh->records_deleted++;
if (matchStr)
- dict_delete (zh->reg->matchDict, matchStr);
+ {
+ int db_ord = zebraExplain_get_database_ord(zh->reg->zei);
+ dict_delete_ord(zh->reg->matchDict, db_ord, matchStr);
+ }
rec_del (zh->reg->records, &rec);
}
rec_rm (&rec);
if (zh->m_staticrank) /* rank config enabled ? */
{
+ if (staticrank < 0)
+ {
+ yaz_log(YLOG_WARN, "staticrank = %d. Setting to 0",
+ staticrank);
+ staticrank = 0;
+ }
*keyp++ = staticrank;
key_out.len = 4;
}
i->prevcmd=-1;
i->keylen=0;
i->encode_handle = iscz1_start();
+ i->decode_handle = iscz1_start();
}
#define OLDENCODE 1
/* and copy & align key so we can mangle */
memcpy (&key, k+1, sizeof(struct it_key)); /* *k is insert/delete */
+#if 0
+ /* debugging */
+ key_logdump_txt(YLOG_LOG, &key, *k ? "i" : "d");
+#endif
+ assert(key.mem[0] >= 0);
+
bp0 = bp++;
iscz1_encode(i->encode_handle, &bp, &src);
+
*bp0 = (*k * 128) + bp - bp0 - 1; /* length and insert/delete combined */
if (fwrite (i->buf, bp - i->buf, 1, outf) != 1)
{
yaz_log (YLOG_FATAL|YLOG_ERRNO, "fwrite");
exit (1);
}
+
+#if 0
+ /* debugging */
+ if (1)
+ {
+ struct it_key key2;
+ const char *src = bp0+1;
+ char *dst = (char*) &key2;
+ iscz1_decode(i->decode_handle, &dst, &src);
+
+ key_logdump_txt(YLOG_LOG, &key2, *k ? "i" : "d");
+
+ assert(key2.mem[1]);
+ }
+#endif
}
void encode_key_flush (struct encode_info *i, FILE *outf)
-{ /* dummy routine */
+{
iscz1_stop(i->encode_handle);
+ iscz1_stop(i->decode_handle);
}
#else