Added zebra_meta_records_create_range
authorAdam Dickmeiss <adam@indexdata.dk>
Thu, 2 Dec 2004 17:27:03 +0000 (17:27 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Thu, 2 Dec 2004 17:27:03 +0000 (17:27 +0000)
include/idzebra/api.h
index/zebraapi.c
index/zsets.c

index 6b53295..53ae58d 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: api.h,v 1.3 2004-11-29 21:55:25 adam Exp $
+/* $Id: api.h,v 1.4 2004-12-02 17:27:03 adam Exp $
    Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
    Index Data Aps
 
@@ -149,11 +149,11 @@ YAZ_EXPORT int zebra_deleleResultSet(ZebraHandle zh, int function,
 
 /* Browse */
 YAZ_EXPORT int zebra_scan (ZebraHandle zh, ODR stream,
-                           Z_AttributesPlusTerm *zapt,
-                           oid_value attributeset,
-                           int *position, int *num_entries,
-                           ZebraScanEntry **list,
-                           int *is_partial);
+                          Z_AttributesPlusTerm *zapt,
+                          oid_value attributeset,
+                          int *position, int *num_entries,
+                          ZebraScanEntry **list,
+                          int *is_partial);
 
    
           
@@ -272,12 +272,19 @@ typedef struct {
     int score;
 } ZebraMetaRecord;
 
-YAZ_EXPORT ZebraMetaRecord *zebra_meta_records_create (ZebraHandle zh,
-                                                      const char *name,
-                                                      int num,
-                                                      zint *positions);
+YAZ_EXPORT
+ZebraMetaRecord *zebra_meta_records_create (ZebraHandle zh,
+                                           const char *name,
+                                           int num, zint *positions);
+
 
-YAZ_EXPORT void zebra_meta_records_destroy (ZebraHandle zh,
-                                           ZebraMetaRecord *records, int num);
+YAZ_EXPORT
+ZebraMetaRecord *zebra_meta_records_create_range (ZebraHandle zh,
+                                                 const char *name, 
+                                                 zint start, int num);
+
+YAZ_EXPORT
+void zebra_meta_records_destroy (ZebraHandle zh, ZebraMetaRecord *records,
+                                int num);
 YAZ_END_CDECL                                
 #endif
index 377ab7b..5861a23 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: zebraapi.c,v 1.142 2004-11-29 21:55:27 adam Exp $
+/* $Id: zebraapi.c,v 1.143 2004-12-02 17:27:03 adam Exp $
    Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
    Index Data Aps
 
@@ -847,9 +847,9 @@ int zebra_search_RPN (ZebraHandle zh, ODR o,
 }
 
 int zebra_records_retrieve (ZebraHandle zh, ODR stream,
-                            const char *setname, Z_RecordComposition *comp,
-                            oid_value input_format, int num_recs,
-                            ZebraRetrievalRecord *recs)
+                           const char *setname, Z_RecordComposition *comp,
+                           oid_value input_format, int num_recs,
+                           ZebraRetrievalRecord *recs)
 {
     ZebraMetaRecord *poset;
     int i, ret = 0;
index 6fe00c4..52cb82b 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: zsets.c,v 1.72 2004-11-29 21:55:28 adam Exp $
+/* $Id: zsets.c,v 1.73 2004-12-02 17:27:04 adam Exp $
    Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
    Index Data Aps
 
@@ -278,6 +278,31 @@ void resultSetDestroy (ZebraHandle zh, int num, char **names,int *statuses)
     }
 }
 
+ZebraMetaRecord *zebra_meta_records_create_range (ZebraHandle zh,
+                                                 const char *name, 
+                                                 zint start, int num)
+{
+    zint pos_small[10];
+    zint *pos = pos_small;
+    ZebraMetaRecord *mr;
+    int i;
+
+    if (num > 10000 || num <= 0)
+       return 0;
+
+    if (num > 10)
+       pos = xmalloc(sizeof(*pos) * num);
+    
+    for (i = 0; i<num; i++)
+       pos[i] = start+i;
+
+    mr = zebra_meta_records_create(zh, name, num, pos);
+    
+    if (num > 10)
+       xfree(pos);
+    return mr;
+}
+
 ZebraMetaRecord *zebra_meta_records_create (ZebraHandle zh, const char *name, 
                                            int num, zint *positions)
 {