-/* $Id: extract.c,v 1.149 2004-01-22 15:40:25 heikki Exp $
+/* $Id: extract.c,v 1.155 2004-06-03 11:45:28 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
#include <stdio.h>
#include <assert.h>
+#include <ctype.h>
#ifdef WIN32
#include <io.h>
#else
char ext[128];
char ext_res[128];
struct file_read_info *fi;
+ const char *original_record_type = 0;
if (!zh->m_group || !*zh->m_group)
*gprefix = '\0';
break;
}
/* determine file type - depending on extension */
+ original_record_type = zh->m_record_type;
if (!zh->m_record_type)
{
sprintf (ext_res, "%srecordType.%s", gprefix, ext);
if ((fd = open (full_rep, O_BINARY|O_RDONLY)) == -1)
{
logf (LOG_WARN|LOG_ERRNO, "open %s", full_rep);
+ zh->m_record_type = original_record_type;
return 0;
}
}
file_read_stop (fi);
if (fd != -1)
close (fd);
+ zh->m_record_type = original_record_type;
return r;
}
if (zh->reg->key_buf_used + 1024 >
(zh->reg->ptr_top -zh->reg->ptr_i)*sizeof(char*))
extract_flushWriteKeys (zh,0);
+ assert(zh->reg->ptr_i >= 0);
++(zh->reg->ptr_i);
+ assert(zh->reg->ptr_i > 0);
(zh->reg->key_buf)[zh->reg->ptr_top - zh->reg->ptr_i] =
(char*)zh->reg->key_buf + zh->reg->key_buf_used;
#if SU_SCHEME
qsort (zh->reg->key_buf + zh->reg->ptr_top - ptr_i, ptr_i,
sizeof(char*), key_qsort_compare);
- /* Case 1: always use temp files (old way) */
- /* Case 2: use temp files, if more than one (auto) */
- /* = if this is both the last and the first */
- /* Case 3: never bother with temp files (new) */
- temp_policy=2;
- /* FIXME - will come from config file into zh */
+ /* zebra.cfg: tempfiles:
+ Y: always use temp files (old way)
+ A: use temp files, if more than one (auto)
+ = if this is both the last and the first
+ N: never bother with temp files (new) */
- if ( ( temp_policy ==3 ) || /* always from memory */
- ( ( temp_policy ==2 ) && /* automatic */
+ temp_policy=toupper(res_get_def(zh->res,"tempfiles","auto")[0]);
+ if (temp_policy != 'Y' && temp_policy != 'N' && temp_policy != 'A') {
+ logf (LOG_WARN, "Illegal tempfiles setting '%c'. using 'Auto' ",
+ temp_policy);
+ temp_policy='A';
+ }
+
+ if ( ( temp_policy =='N' ) || /* always from memory */
+ ( ( temp_policy =='A' ) && /* automatic */
(zh->reg->key_file_no == 1) && /* this is first time */
(final) ) ) /* and last (=only) time */
{ /* go directly from memory */
zebra_index_merge(zh);
zh->reg->ptr_i = 0;
zh->reg->key_buf_used = 0;
- return; /*!*/
+ return;
}
/* Not doing directly from memory, write into a temp file */
}
dst = keys->buf + keys->buf_used;
+ /* leader byte is encoded as follows:
+ bit 0 : 1 if attrset is unchanged; 0 if attrset is changed
+ bit 1 : 1 if attruse is unchanged; 0 if attruse is changed
+ */
attrSet = p->attrSet;
if (keys->buf_used > 0 && keys->prevAttrSet == attrSet)
lead |= 1;