Python module: do not limit result fetching to the Xapian result count: it may be underestimated
This commit is contained in:
parent
652b29eb56
commit
3af31612d5
1 changed files with 8 additions and 11 deletions
|
@ -1035,13 +1035,12 @@ Query_fetchone(PyObject *_self)
|
||||||
PyErr_SetString(PyExc_EnvironmentError, "doc create failed");
|
PyErr_SetString(PyExc_EnvironmentError, "doc create failed");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (self->next >= self->rowcount) {
|
|
||||||
PyErr_SetNone(PyExc_StopIteration);
|
// We used to check against rowcount here, but this was wrong:
|
||||||
return 0;
|
// xapian result count estimate are sometimes wrong, we must go on
|
||||||
}
|
// fetching until we fail
|
||||||
if (!self->query->getDoc(self->next, *result->doc)) {
|
if (!self->query->getDoc(self->next, *result->doc)) {
|
||||||
PyErr_SetString(PyExc_EnvironmentError, "query: cant fetch result");
|
PyErr_SetNone(PyExc_StopIteration);
|
||||||
self->next = -1;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
self->next++;
|
self->next++;
|
||||||
|
@ -1081,8 +1080,7 @@ Query_fetchmany(recoll_QueryObject* self, PyObject *args, PyObject *kwargs)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *reslist = PyList_New(0);
|
PyObject *reslist = PyList_New(0);
|
||||||
int howmany = MIN(self->rowcount - self->next, size);
|
for (int i = 0; i < size; i++) {
|
||||||
for (int i = 0; i < howmany; i++) {
|
|
||||||
recoll_DocObject *docobj = (recoll_DocObject *)
|
recoll_DocObject *docobj = (recoll_DocObject *)
|
||||||
PyObject_CallObject((PyObject *)&recoll_DocType, 0);
|
PyObject_CallObject((PyObject *)&recoll_DocType, 0);
|
||||||
if (!docobj) {
|
if (!docobj) {
|
||||||
|
@ -1090,9 +1088,8 @@ Query_fetchmany(recoll_QueryObject* self, PyObject *args, PyObject *kwargs)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!self->query->getDoc(self->next, *docobj->doc)) {
|
if (!self->query->getDoc(self->next, *docobj->doc)) {
|
||||||
PyErr_SetString(PyExc_EnvironmentError, "can't fetch");
|
PyErr_SetNone(PyExc_StopIteration);
|
||||||
self->next = -1;
|
break;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
self->next++;
|
self->next++;
|
||||||
movedocfields(docobj->doc);
|
movedocfields(docobj->doc);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue