* Sebastian Hammer, Adam Dickmeiss
*
* $Log: extract.c,v $
- * Revision 1.12 1995-09-28 14:22:56 adam
+ * Revision 1.13 1995-09-29 14:01:39 adam
+ * Bug fixes.
+ *
+ * Revision 1.12 1995/09/28 14:22:56 adam
* Sort uses smaller temporary files.
*
* Revision 1.11 1995/09/28 12:10:31 adam
static size_t kused;
static int key_file_no;
-static int sort_compare (const void *p1, const void *p2)
-{
- int r;
- size_t l;
- char *cp1 = *(char**) p1;
- char *cp2 = *(char**) p2;
-
- if ((r = strcmp (cp1, cp2)))
- return r;
- l = strlen(cp1);
- if ((r = key_compare (cp1+l, cp2+l)))
- return r;
- return cp1[l+sizeof(struct it_key)] -
- cp2[l+sizeof(struct it_key)];
-}
-
void key_open (int mem)
{
void *file_key;
key_file_no++;
logf (LOG_LOG, "sorting section %d", key_file_no);
- qsort (key_buf + ptr_top-ptr_i, ptr_i, sizeof(char*), sort_compare);
+ qsort (key_buf + ptr_top-ptr_i, ptr_i, sizeof(char*), key_qsort_compare);
sprintf (out_fname, TEMP_FNAME, key_file_no);
-
if (!(outf = fopen (out_fname, "w")))
{
logf (LOG_FATAL|LOG_ERRNO, "fopen (4) %s", out_fname);
default:
return ;
}
+ ((char*) key_buf)[kused++] = ((key_cmd == 'a') ? 1 : 0);
key.sysno = key_sysno;
key.seqno = p->seqno;
memcpy ((char*)key_buf + kused, &key, sizeof(key));
kused += sizeof(key);
-
- ((char*) key_buf)[kused++] = ((key_cmd == 'a') ? 1 : 0);
}
void file_extract (int cmd, const char *fname, const char *kname)
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: index.h,v $
- * Revision 1.13 1995-09-28 14:22:56 adam
+ * Revision 1.14 1995-09-29 14:01:40 adam
+ * Bug fixes.
+ *
+ * Revision 1.13 1995/09/28 14:22:56 adam
* Sort uses smaller temporary files.
*
* Revision 1.12 1995/09/28 12:10:32 adam
int key_close (void);
void key_write (int cmd, struct it_key *k, const char *str);
int key_compare (const void *p1, const void *p2);
+int key_qsort_compare (const void *p1, const void *p2);
void key_logdump (int mask, const void *p);
void key_input (const char *dict_fname, const char *isam_fname,
const char *key_fname, int cache);
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: kcompare.c,v $
- * Revision 1.9 1995-09-28 12:10:32 adam
+ * Revision 1.10 1995-09-29 14:01:41 adam
+ * Bug fixes.
+ *
+ * Revision 1.9 1995/09/28 12:10:32 adam
* Bug fixes. Field prefix used in queries.
*
* Revision 1.8 1995/09/28 09:19:42 adam
return 0;
}
+int key_qsort_compare (const void *p1, const void *p2)
+{
+ int r;
+ size_t l;
+ char *cp1 = *(char **) p1;
+ char *cp2 = *(char **) p2;
+
+ if ((r = strcmp (cp1, cp2)))
+ return r;
+ l = strlen(cp1)+1;
+ if ((r = key_compare (cp1+l+1, cp2+l+1)))
+ return r;
+ return cp1[l] - cp2[l];
+}
+
int index_char_cvt (int c)
{
return tolower (c);
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: kdump.c,v $
- * Revision 1.5 1995-09-11 13:09:35 adam
+ * Revision 1.6 1995-09-29 14:01:42 adam
+ * Bug fixes.
+ *
+ * Revision 1.5 1995/09/11 13:09:35 adam
* More work on relevance feedback.
*
* Revision 1.4 1995/09/08 14:52:27 adam
{
int c;
int i = 0;
- name[0] = 0;
do
{
if ((c=getc(inf)) == EOF)
while (read_one (inf, key_string, key_info))
{
struct it_key k;
+ int op;
- memcpy (&k, key_info+1, sizeof(k));
+ op = key_info[0];
+ memcpy (&k, 1+key_info, sizeof(k));
#if IT_KEY_HAVE_SEQNO
- printf ("%7d op=%d s=%-5d %s\n", k.sysno, *key_info, k.seqno,
+ printf ("%7d op=%d s=%-5d %s\n", k.sysno, op, k.seqno,
key_string);
#else
- printf ("%7d op=%d f=%-3d %s\n", k.sysno, *key_info, k.freq,
+ printf ("%7d op=%d f=%-3d %s\n", k.sysno, op, k.freq,
key_string);
#endif
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: kinput.c,v $
- * Revision 1.4 1995-09-28 14:22:57 adam
+ * Revision 1.5 1995-09-29 14:01:43 adam
+ * Bug fixes.
+ *
+ * Revision 1.4 1995/09/28 14:22:57 adam
* Sort uses smaller temporary files.
*
* Revision 1.3 1995/09/06 16:11:17 adam
{
int c;
int i = 0;
- name[0] = 0;
do
{
if ((c=getc(inf)) == EOF)
int key_buf_ptr;
char *next_key;
char *key_buf;
+ int more;
next_key = xmalloc (KEY_SIZE);
key_buf = xmalloc (key_buf_size * (KEY_SIZE));
logf (LOG_FATAL|LOG_ERRNO, "cannot open `%s'", name);
exit (1);
}
- read_one (inf, cur_name, key_buf);
- while (cur_name[0]) /* EOF ? */
+ more = read_one (inf, cur_name, key_buf);
+ while (more) /* EOF ? */
{
int nmemb;
key_buf_ptr = KEY_SIZE;
while (1)
{
- if (!read_one (inf, next_name, next_key))
+ if (!(more = read_one (inf, next_name, next_key)))
break;
if (*next_name && strcmp (next_name, cur_name))
break;
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: main.c,v $
- * Revision 1.10 1995-09-28 14:22:57 adam
+ * Revision 1.11 1995-09-29 14:01:45 adam
+ * Bug fixes.
+ *
+ * Revision 1.10 1995/09/28 14:22:57 adam
* Sort uses smaller temporary files.
*
* Revision 1.9 1995/09/14 07:48:24 adam
#include "index.h"
char *prog;
+size_t mem_max = 4*1024*1024;
int main (int argc, char **argv)
{
char **mbuf;
prog = *argv;
- while ((ret = options ("r:v:", argv, argc, &arg)) != -2)
+ while ((ret = options ("r:v:m:", argv, argc, &arg)) != -2)
{
if (ret == 0)
{
else
{
unlink ("keys.tmp");
- key_open (3000000);
+ key_open (mem_max);
repository (cmd, arg, base_path);
cmd = 0;
}
{
base_path = arg;
}
+ else if (ret == 'm')
+ {
+ mem_max = 1024*1024*atoi(arg);
+ }
else
{
logf (LOG_FATAL, "Unknown option '-%s'", arg);
logf (LOG_LOG, "Merge sorting");
mbuf = xmalloc (100000);
merge_sort (mbuf, 1, nsections+1);
+ xfree (mbuf);
logf (LOG_LOG, "Input");
key_input (FNAME_WORD_DICT, FNAME_WORD_ISAM, "keys1.tmp", 60);
exit (0);