projects
/
idzebra-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Updates YAZ m4 macros.
[idzebra-moved-to-github.git]
/
index
/
extract.c
diff --git
a/index/extract.c
b/index/extract.c
index
044a225
..
1b8fdb7
100644
(file)
--- a/
index/extract.c
+++ b/
index/extract.c
@@
-1,4
+1,4
@@
-/* $Id: extract.c,v 1.151 2004-01-29 13:11:01 adam Exp $
+/* $Id: extract.c,v 1.157.2.1 2004-09-16 14:07:50 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
@@
-756,6
+756,7
@@
int fileExtract (ZebraHandle zh, SYSNO *sysno, const char *fname,
char ext[128];
char ext_res[128];
struct file_read_info *fi;
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';
if (!zh->m_group || !*zh->m_group)
*gprefix = '\0';
@@
-775,6
+776,7
@@
int fileExtract (ZebraHandle zh, SYSNO *sysno, const char *fname,
break;
}
/* determine file type - depending on extension */
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 (!zh->m_record_type)
{
sprintf (ext_res, "%srecordType.%s", gprefix, ext);
@@
-812,6
+814,7
@@
int fileExtract (ZebraHandle zh, SYSNO *sysno, const char *fname,
if ((fd = open (full_rep, O_BINARY|O_RDONLY)) == -1)
{
logf (LOG_WARN|LOG_ERRNO, "open %s", full_rep);
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;
}
}
return 0;
}
}
@@
-824,6
+827,7
@@
int fileExtract (ZebraHandle zh, SYSNO *sysno, const char *fname,
file_read_stop (fi);
if (fd != -1)
close (fd);
file_read_stop (fi);
if (fd != -1)
close (fd);
+ zh->m_record_type = original_record_type;
return r;
}
return r;
}
@@
-1028,7
+1032,7
@@
int buffer_extract_record (ZebraHandle zh,
extract_flushSortKeys (zh, *sysno, -1, &zh->reg->sortKeys);
rec_rm (&rec);
logRecord(zh);
extract_flushSortKeys (zh, *sysno, -1, &zh->reg->sortKeys);
rec_rm (&rec);
logRecord(zh);
- return 0;
+ return -1;
}
}
}
}
@@
-1284,7
+1288,9
@@
void extract_flushRecordKeys (ZebraHandle zh, SYSNO sysno,
if (zh->reg->key_buf_used + 1024 >
(zh->reg->ptr_top -zh->reg->ptr_i)*sizeof(char*))
extract_flushWriteKeys (zh,0);
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);
++(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
(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
@@
-1479,6
+1485,10
@@
void extract_add_index_string (RecWord *p, const char *string,
}
dst = keys->buf + keys->buf_used;
}
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;
attrSet = p->attrSet;
if (keys->buf_used > 0 && keys->prevAttrSet == attrSet)
lead |= 1;
@@
-1592,7
+1602,7
@@
static void extract_add_incomplete_field (RecWord *p)
const char **map = 0;
if (remain > 0)
const char **map = 0;
if (remain > 0)
- map = zebra_maps_input(p->zebra_maps, p->reg_type, &b, remain);
+ map = zebra_maps_input(p->zebra_maps, p->reg_type, &b, remain, 0);
while (map)
{
while (map)
{
@@
-1604,7
+1614,7
@@
static void extract_add_incomplete_field (RecWord *p)
{
remain = p->length - (b - p->string);
if (remain > 0)
{
remain = p->length - (b - p->string);
if (remain > 0)
- map = zebra_maps_input(p->zebra_maps, p->reg_type, &b, remain);
+ map = zebra_maps_input(p->zebra_maps, p->reg_type, &b, remain, 0);
else
map = 0;
}
else
map = 0;
}
@@
-1619,7
+1629,7
@@
static void extract_add_incomplete_field (RecWord *p)
buf[i++] = *(cp++);
remain = p->length - (b - p->string);
if (remain > 0)
buf[i++] = *(cp++);
remain = p->length - (b - p->string);
if (remain > 0)
- map = zebra_maps_input(p->zebra_maps, p->reg_type, &b, remain);
+ map = zebra_maps_input(p->zebra_maps, p->reg_type, &b, remain, 0);
else
map = 0;
}
else
map = 0;
}
@@
-1636,17
+1646,24
@@
static void extract_add_complete_field (RecWord *p)
char buf[IT_MAX_WORD+1];
const char **map = 0;
int i = 0, remain = p->length;
char buf[IT_MAX_WORD+1];
const char **map = 0;
int i = 0, remain = p->length;
+ int first; /* first position */
+
+yaz_log(LOG_DEBUG, "Complete field, w='%s'", p->string);
if (remain > 0)
if (remain > 0)
- map = zebra_maps_input (p->zebra_maps, p->reg_type, &b, remain);
+ map = zebra_maps_input (p->zebra_maps, p->reg_type, &b, remain, 1);
while (remain > 0 && i < IT_MAX_WORD)
{
while (map && *map && **map == *CHR_SPACE)
{
remain = p->length - (b - p->string);
while (remain > 0 && i < IT_MAX_WORD)
{
while (map && *map && **map == *CHR_SPACE)
{
remain = p->length - (b - p->string);
+
if (remain > 0)
if (remain > 0)
- map = zebra_maps_input(p->zebra_maps, p->reg_type, &b, remain);
+ {
+ first = i ? 0 : 1;
+ map = zebra_maps_input(p->zebra_maps, p->reg_type, &b, remain, first);
+ }
else
map = 0;
}
else
map = 0;
}
@@
-1659,14
+1676,24
@@
static void extract_add_complete_field (RecWord *p)
{
const char *cp = *map;
{
const char *cp = *map;
- if (i >= IT_MAX_WORD)
- break;
- while (i < IT_MAX_WORD && *cp)
- buf[i++] = *(cp++);
+ if (**map == *CHR_CUT)
+ {
+ i = 0;
+ }
+ else
+ {
+ if (i >= IT_MAX_WORD)
+ break;
+yaz_log(LOG_DEBUG, "Adding string to index '%d'", *map);
+ while (i < IT_MAX_WORD && *cp)
+ buf[i++] = *(cp++);
+ }
remain = p->length - (b - p->string);
if (remain > 0)
remain = p->length - (b - p->string);
if (remain > 0)
+ {
map = zebra_maps_input (p->zebra_maps, p->reg_type, &b,
map = zebra_maps_input (p->zebra_maps, p->reg_type, &b,
- remain);
+ remain, 0);
+ }
else
map = 0;
}
else
map = 0;
}