Sequence number incremented after each incomplete-field.
[idzebra-moved-to-github.git] / index / extract.c
index 4309b60..fa7f652 100644 (file)
@@ -4,7 +4,17 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: extract.c,v $
- * Revision 1.96  1999-05-26 07:49:13  adam
+ * Revision 1.99  2000-02-24 10:57:02  adam
+ * Sequence number incremented after each incomplete-field.
+ *
+ * Revision 1.98  1999/09/07 07:19:21  adam
+ * Work on character mapping. Implemented replace rules.
+ *
+ * Revision 1.97  1999/07/06 12:28:04  adam
+ * Updated record index structure. Format includes version ID. Compression
+ * algorithm ID is stored for each record block.
+ *
+ * Revision 1.96  1999/05/26 07:49:13  adam
  * C++ compilation.
  *
  * Revision 1.95  1999/05/21 12:00:17  adam
@@ -406,6 +416,8 @@ int key_open (struct recordGroup *rGroup, int mem)
     BFiles bfs = rGroup->bfs;
     int rw = rGroup->flagRw;
     data1_handle dh = rGroup->dh;
+    char *recordCompression;
+    int record_compression = REC_COMPRESS_NONE;
     if (!mem)
         mem = atoi(res_get_def (common_resource, "memMax", "4"))*1024*1024;
     if (mem < 50000)
@@ -423,7 +435,13 @@ int key_open (struct recordGroup *rGroup, int mem)
        return -1;
     }
     assert (!records);
-    records = rec_open (bfs, rw);
+    recordCompression = res_get_def (common_resource,
+                                    "recordCompression", "none");
+    if (!strcmp (recordCompression, "none"))
+       record_compression = REC_COMPRESS_NONE;
+    if (!strcmp (recordCompression, "bzip2"))
+       record_compression = REC_COMPRESS_BZIP2;
+    records = rec_open (bfs, rw, record_compression);
     if (!records)
     {
        dict_close (matchDict);
@@ -637,6 +655,7 @@ static void wordInit (struct recExtractCtrl *p, RecWord *w)
     w->attrSet = VAL_BIB1;
     w->attrUse = 1016;
     w->reg_type = 'w';
+    w->extractCtrl = p;
 }
 
 static struct sortKey {
@@ -794,6 +813,7 @@ static void addIncompleteField (RecWord *p)
            return;
        addString (p, buf, i);
     }
+    (p->seqnos[p->reg_type])++; /* to separate this from next one  */
 }
 
 static void addCompleteField (RecWord *p)
@@ -844,6 +864,13 @@ static void addCompleteField (RecWord *p)
 
 static void addRecordKey (RecWord *p)
 {
+    WRBUF wrbuf;
+    if ((wrbuf = zebra_replace(p->zebra_maps, p->reg_type, 0,
+                              p->string, p->length)))
+    {
+       p->string = wrbuf_buf(wrbuf);
+       p->length = wrbuf_len(wrbuf);
+    }
     if (zebra_maps_is_complete (p->zebra_maps, p->reg_type))
        addCompleteField (p);
     else
@@ -1279,8 +1306,8 @@ static int recordExtract (SYSNO *sysno, const char *fname,
        extractCtrl.fh = fi;
        extractCtrl.subType = subType;
        extractCtrl.init = wordInit;
-       extractCtrl.addWord = addRecordKey;
-       extractCtrl.addSchema = addSchema;
+       extractCtrl.tokenAdd = addRecordKey;
+       extractCtrl.schemaAdd = addSchema;
        extractCtrl.dh = rGroup->dh;
        for (i = 0; i<256; i++)
        {
@@ -1620,7 +1647,7 @@ int fileExtract (SYSNO *sysno, const char *fname,
     {
         if (zebraExplain_newDatabase (zti, rGroup->databaseName,
                                      rGroup->explainDatabase))
-            abort ();
+           return 0;
     }
 
     if (rGroup->flagStoreData == -1)
@@ -1748,8 +1775,8 @@ static int explain_extract (void *handle, Record rec, data1_node *n)
     reckeys.prevSeqNo = 0;
     
     extractCtrl.init = wordInit;
-    extractCtrl.addWord = addRecordKey;
-    extractCtrl.addSchema = addSchema;
+    extractCtrl.tokenAdd = addRecordKey;
+    extractCtrl.schemaAdd = addSchema;
     extractCtrl.dh = rGroup->dh;
     for (i = 0; i<256; i++)
        extractCtrl.seqno[i] = 0;