[fti] backout 166c6f7b1be4
authorRémi Cardona <remi.cardona@logilab.fr>
Thu, 19 Nov 2015 16:48:55 +0100
changeset 10846 d186820c5f7a
parent 10845 75c60e58ce6b
child 10847 ce5403611cbe
[fti] backout 166c6f7b1be4 * breaks tests * see next commit for a better solution
entities/__init__.py
server/checkintegrity.py
--- a/entities/__init__.py	Thu Nov 19 17:16:19 2015 +0100
+++ b/entities/__init__.py	Thu Nov 19 16:48:55 2015 +0100
@@ -20,7 +20,6 @@
 __docformat__ = "restructuredtext en"
 
 from six import text_type, string_types
-from six.moves import range
 
 from logilab.common.decorators import classproperty
 
@@ -28,12 +27,6 @@
 from cubicweb.entity import Entity
 
 
-def chunks(seq, step):
-    """See http://stackoverflow.com/questions/312443/how-do-you-split-a-list-into-evenly-sized-chunks-in-python)"""
-    return (seq[i:i+step]
-            for i in range(0, len(seq), step))
-
-
 class AnyEntity(Entity):
     """an entity instance has e_schema automagically set on the class and
     instances have access to their issuing cursor
@@ -52,25 +45,21 @@
 
     @classmethod
     def cw_fti_index_rql_queries(cls, req):
-        """return an iterator on rql queries to fetch entities to FT-index
+        """return the list of rql queries to fetch entities to FT-index
 
-        The default is to fetch entities 1000 per 1000 and to prefetch
-        indexable attributes, but one could imagine iterating over
+        The default is to fetch all entities at once and to prefetch
+        indexable attributes but one could imagine iterating over
         "smaller" resultsets if the table is very big or returning
         a subset of entities that match some business-logic condition.
         """
-        restrictions = []
+        restrictions = ['X is %s' % cls.__regid__]
         selected = ['X']
         for attrschema in sorted(cls.e_schema.indexable_attributes()):
             varname = attrschema.type.upper()
             restrictions.append('X %s %s' % (attrschema, varname))
             selected.append(varname)
-        rset = req.execute('Any EID WHERE X eid EID, X is %s' % cls.__regid__)
-        for rows in chunks(rset.rows, 1000):
-            q_restrictions = restrictions + [
-                'X eid IN (%s)' % ', '.join(str(r[0]) for r in rows)]
-            yield 'Any %s WHERE %s' % (', '.join(selected),
-                                       ', '.join(q_restrictions))
+        return ['Any %s WHERE %s' % (', '.join(selected),
+                                     ', '.join(restrictions))]
 
     # meta data api ###########################################################
 
--- a/server/checkintegrity.py	Thu Nov 19 17:16:19 2015 +0100
+++ b/server/checkintegrity.py	Thu Nov 19 16:48:55 2015 +0100
@@ -124,10 +124,7 @@
     source = repo.system_source
     for eschema in etypes:
         etype_class = cnx.vreg['etypes'].etype_class(str(eschema))
-        queries = list(etype_class.cw_fti_index_rql_queries(cnx))
-        for i, fti_rql in enumerate(queries):
-            if withpb:
-                pb.text = "%s: %s%%" % (str(eschema), i * 100 / len(queries))
+        for fti_rql in etype_class.cw_fti_index_rql_queries(cnx):
             rset = cnx.execute(fti_rql)
             source.fti_index_entities(cnx, rset.entities())
             # clear entity cache to avoid high memory consumption on big tables