#include "vocab.h"
#include "mlparse.h"
#include "str.h"
-#include "ndocmap.h"
+#include "docmap.h"
/*
* Utility function forward declarations.
*/
static PyObject * index_result_to_PyObject(struct index_result * result);
static PyObject * index_results_to_PyObject(struct index_result * results,
- unsigned int num_results, unsigned long int total_results);
+ unsigned int num_results, double/*unsigned long int*/ total_results);
/* *****************************************************************
*
*/
typedef struct {
PyObject_HEAD
- unsigned long int total_results;
+ double/*unsigned long int*/ total_results;
PyObject * results;
} zet_SearchResultsObject;
* Members as visible from Python.
*/
static PyMemberDef SearchResults_members[] = {
- {"total_results", T_ULONG, offsetof(zet_SearchResultsObject,
+ {"total_results", T_DOUBLE/*T_ULONG*/, offsetof(zet_SearchResultsObject,
total_results), 0, "total results"},
{"results", T_OBJECT_EX, offsetof(zet_SearchResultsObject,
results), 0, "results" },
vec.pos = self->postings->vec + self->vec_offset;
vec.end = vec.pos + self->postings->size;
- vec_vbyte_read_unchecked(&vec, &docno_d);
+ vec_vbyte_read/*unchecked*/(&vec, &docno_d);
if (self->last_docno == (unsigned long) -1)
posting->docno = docno_d;
else
posting->docno = self->last_docno + docno_d + 1;
- vec_vbyte_read_unchecked(&vec, &f_dt);
+ vec_vbyte_read/*unchecked*/(&vec, &f_dt);
posting->f_dt = f_dt;
posting->offsets = PyTuple_New(f_dt);
if (posting->offsets == NULL) {
for (i = 0; i < f_dt; i++) {
unsigned long int offset_d;
PyObject * pyOffset;
- vec_vbyte_read_unchecked(&vec, &offset_d);
+ vec_vbyte_read/*unchecked*/(&vec, &offset_d);
if (i == 0)
offset = offset_d;
else
unsigned long vec_save_pos;
vec_save_pos = vec.pos - iterator->postings->vec;
- vec_vbyte_read_unchecked(&vec, &docno_d);
+ vec_vbyte_read/*unchecked*/(&vec, &docno_d);
prev_docno = curr_docno;
if (curr_docno == (unsigned long) -1)
curr_docno = docno_d;
/* skip the offsets */
unsigned long f_dt;
unsigned int scanned;
- vec_vbyte_read_unchecked(&vec, &f_dt);
- vec_vbyte_scan_unchecked(&vec, f_dt, &scanned);
+ vec_vbyte_read/*unchecked*/(&vec, &f_dt);
+ vec_vbyte_scan/*_unchecked*/(&vec, f_dt, &scanned);
} else {
vec.pos = iterator->postings->vec + vec_save_pos;
}
static PyObject * Index_vocab_iterator(PyObject * self, PyObject * args);
static PyObject * Index_num_docs(PyObject * self, PyObject * args);
static PyObject * Index_vocab_size(PyObject * self, PyObject * args);
-static PyObject * Index_doc_aux(PyObject * self, PyObject * args);
+static PyObject * Index_doc_trecno/*Index_doc_aux*/(PyObject * self, PyObject * args);
/*
* Object methods as visible from Python.
"Get the total number of documents in the indexed collection"},
{"vocab_size", Index_vocab_size, METH_NOARGS,
"Get the number of terms in the index vocab" },
- {"doc_aux", Index_doc_aux, METH_VARARGS,
+ {"doc_trecno"/*"doc_aux"*/, Index_doc_trecno/*Index_doc_aux*/, METH_VARARGS,
"Get the auxiliary information for a document."},
{NULL}
};
zet_IndexObject * Index = (zet_IndexObject *) self;
struct index_result * result;
unsigned int results;
- unsigned long int total_results;
+ double/*unsigned long int*/ total_results;
+ int est;
unsigned int accumulator_limit = 0;
int opts = INDEX_SEARCH_NOOPT;
struct index_search_opt opt;
if (optArgsTuple == NULL) {
PyErr_SetString(PyExc_StandardError, "Must supply args to "
"search type");
+ free(result);
return NULL;
}
opts = INDEX_SEARCH_OKAPI_RANK;
if (!PyArg_ParseTuple(optArgsTuple, "ddd",
&opt.u.okapi_k3.k1, &opt.u.okapi_k3.k3, &opt.u.okapi_k3.b)) {
+ free(result);
return NULL;
}
} else if (strcmp(optType, "HAWKAPI") == 0) {
if (optArgsTuple == NULL) {
PyErr_SetString(PyExc_StandardError, "Must supply args to "
"search type");
+ free(result);
return NULL;
}
opts = INDEX_SEARCH_HAWKAPI_RANK;
if (!PyArg_ParseTuple(optArgsTuple, "dd", &opt.u.hawkapi.alpha,
&opt.u.hawkapi.k3)) {
+ free(result);
return NULL;
}
} else if (strcmp(optType, "DIRICHLET") == 0) {
opt.u.dirichlet.mu = 2500.0;
} else if (!PyArg_ParseTuple(optArgsTuple, "f",
&opt.u.dirichlet.mu)) {
+ free(result);
return NULL;
}
} else {
opt.accumulator_limit = accumulator_limit;
}
if (!index_search(Index->idx, query, startdoc, len,
- result, &results, &total_results, opts, &opt)) {
+ result, &results, &total_results, &est, opts, &opt)) {
char err_buf[1024];
snprintf(err_buf, 1024, "Unable to perform search for query '%s'; "
"system error is '%s'\n", query, strerror(errno));
struct index * idx = Index->idx;
unsigned long num_docs;
- num_docs = ndocmap_entries(idx->map);
+ num_docs = docmap_entries(idx->map);
return Py_BuildValue("k", num_docs);
}
#define AUX_BUF_LEN 1024
-static PyObject * Index_doc_aux(PyObject * self, PyObject * args) {
+static PyObject * Index_doc_trecno/*Index_doc_aux*/(PyObject * self, PyObject * args) {
zet_IndexObject * Index = (zet_IndexObject *) self;
struct index * idx = Index->idx;
- struct ndocmap * docmap = idx->map;
+ struct docmap * docmap = idx->map;
char aux_buf[AUX_BUF_LEN];
unsigned aux_len;
unsigned long int docno;
- enum ndocmap_ret ret;
+ enum docmap_ret ret;
if (!PyArg_ParseTuple(args, "k", &docno))
return NULL;
- ret = ndocmap_get_aux(docmap, docno, aux_buf, AUX_BUF_LEN, &aux_len);
- if (ret != NDOCMAP_OK) {
- /* error might be NDOCMAP_BUFSIZE_ERROR, but life is too short... */
+ ret = docmap_get_trecno/*docmap_get_aux*/(docmap, docno, aux_buf, AUX_BUF_LEN, &aux_len);
+ if (ret != DOCMAP_OK) {
+ /* error might be DOCMAP_BUFSIZE_ERROR, but life is too short... */
PyErr_SetString(PyExc_IOError, "Unable to read aux info");
return NULL;
}
}
static PyObject * index_results_to_PyObject(struct index_result * results,
- unsigned int num_results, unsigned long int total_results) {
+ unsigned int num_results, double/*unsigned long int*/ total_results) {
int i;
zet_SearchResultsObject * pyResult = PyObject_New(zet_SearchResultsObject,
&zet_SearchResultsType);
struct index * idx;
struct index_result * result;
unsigned int results;
- unsigned long int total_results;
+ double/*unsigned long int*/ total_results;
+ int est;
int opts = INDEX_SEARCH_NOOPT;
struct index_search_opt opt;
return NULL;
}
if (!index_search(idx, query, startdoc, len, result,
- &results, &total_results, opts, &opt)) {
+ &results, &total_results, &est, opts, &opt)) {
PyErr_SetString(PyExc_StandardError, "Unable to perform search");
free(result);
index_delete(idx);