Update snippets handling for new store keys structure. Also omit
[idzebra-moved-to-github.git] / index / extract.c
index 2da4282..a7fd69b 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: extract.c,v 1.190 2005-08-19 09:45:24 adam Exp $
+/* $Id: extract.c,v 1.193 2005-08-26 10:13:30 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -1313,7 +1313,6 @@ void extract_flushRecordKeys (ZebraHandle zh, SYSNO sysno,
        struct it_key key_out;
        char *dst = (char*) &key_in;
        zint *keyp = key_out.mem;
-       size_t key_idx = 0;
 
        iscz1_decode(decode_handle, &dst, &src);
        assert(key_in.len == 4);
@@ -1527,13 +1526,11 @@ void extract_add_it_key (ZebraHandle zh,
 ZEBRA_RES zebra_snippets_rec_keys(ZebraHandle zh, struct recKeys *reckeys,
                                  zebra_snippets *snippets)
 {
-   void *decode_handle = iscz1_start();
+    void *decode_handle = iscz1_start();
     int off = 0;
     int seqno = 0;
     NMEM nmem = nmem_create();
 
-    yaz_log(YLOG_LOG, "zebra_rec_keys_snippets buf=%p sz=%d", reckeys->buf,
-           reckeys->buf_used);
     assert(reckeys->buf);
     while (off < reckeys->buf_used)
     {
@@ -1542,14 +1539,19 @@ ZEBRA_RES zebra_snippets_rec_keys(ZebraHandle zh, struct recKeys *reckeys,
        char *dst = (char*) &key;
        char dst_buf[IT_MAX_WORD];
        char *dst_term = dst_buf;
+       int index_type, ord;
 
        iscz1_decode(decode_handle, &dst, &src);
        assert(key.len <= 4 && key.len > 2);
 
        seqno = (int) key.mem[key.len-1];
+       ord = key.mem[0];
 
-       zebra_term_untrans_iconv(zh, nmem, src[0], &dst_term, src+1);
-       zebra_snippets_append(snippets, seqno, src[0], key.mem[0], dst_term);
+       zebraExplain_lookup_ord(zh->reg->zei, ord, &index_type,
+                               0/* db */, 0/* set */, 0/* use */);
+       zebra_term_untrans_iconv(zh, nmem, index_type,
+                                &dst_term, src);
+       zebra_snippets_append(snippets, seqno, ord, dst_term);
         while (*src++)
            ;
         off = src - reckeys->buf;
@@ -1685,9 +1687,9 @@ static void extract_add_sort_string (RecWord *p, const char *str, int length)
     {
         int set, use, slen;
 
-        off += key_SU_decode(&set, sk->buf + off);
-        off += key_SU_decode(&use, sk->buf + off);
-        off += key_SU_decode(&slen, sk->buf + off);
+        off += key_SU_decode(&set, (unsigned char *) sk->buf + off);
+        off += key_SU_decode(&use, (unsigned char *) sk->buf + off);
+        off += key_SU_decode(&slen, (unsigned char *) sk->buf + off);
         off += slen;
         if (p->attrSet == set && p->attrUse == use)
             return;
@@ -1931,9 +1933,9 @@ void extract_flushSortKeys (ZebraHandle zh, SYSNO sysno,
     {
         int set, use, slen;
         
-        off += key_SU_decode(&set, sk->buf + off);
-        off += key_SU_decode(&use, sk->buf + off);
-        off += key_SU_decode(&slen, sk->buf + off);
+        off += key_SU_decode(&set, (unsigned char *) sk->buf + off);
+        off += key_SU_decode(&use, (unsigned char *) sk->buf + off);
+        off += key_SU_decode(&slen, (unsigned char *) sk->buf + off);
         
         sortIdx_type(sortIdx, use);
         if (cmd == 1)