dataimport/massive_store.py
changeset 11028 66f94d7f9ca7
parent 11027 ec5eeb08f2e8
child 11033 63d860a14a17
equal deleted inserted replaced
11027:ec5eeb08f2e8 11028:66f94d7f9ca7
    80        store.convert_relations('Person', 'lives_in', 'Location', 'cwuri', 'uri')
    80        store.convert_relations('Person', 'lives_in', 'Location', 'cwuri', 'uri')
    81        ...
    81        ...
    82        store.commit()
    82        store.commit()
    83        store.finish()
    83        store.finish()
    84     """
    84     """
    85     # size of eid range reserved by the store for each batch
       
    86     eids_seq_range = 10000
       
    87     # max size of the iid, used to create the iid_eid conversion table
    85     # max size of the iid, used to create the iid_eid conversion table
    88     iid_maxsize = 1024
    86     iid_maxsize = 1024
    89 
    87 
    90     def __init__(self, cnx,
    88     def __init__(self, cnx,
    91                  on_commit_callback=None, on_rollback_callback=None,
    89                  on_commit_callback=None, on_rollback_callback=None,
    92                  slave_mode=False,
    90                  slave_mode=False,
    93                  source=None):
    91                  source=None,
       
    92                  eids_seq_range=10000):
    94         """ Create a MassiveObject store, with the following attributes:
    93         """ Create a MassiveObject store, with the following attributes:
    95 
    94 
    96         - cnx: CubicWeb cnx
    95         - cnx: CubicWeb cnx
       
    96         - eids_seq_range: size of eid range reserved by the store for each batch
    97         """
    97         """
    98         super(MassiveObjectStore, self).__init__(cnx)
    98         super(MassiveObjectStore, self).__init__(cnx)
    99         self.logger = logging.getLogger('dataimport.massive_store')
    99         self.logger = logging.getLogger('dataimport.massive_store')
   100         self._cnx = cnx
   100         self._cnx = cnx
   101         self.sql = cnx.system_sql
   101         self.sql = cnx.system_sql
   102         self._data_uri_relations = defaultdict(list)
   102         self._data_uri_relations = defaultdict(list)
       
   103         self.eids_seq_range = eids_seq_range
   103 
   104 
   104         # etypes for which we have a uri_eid_%(etype)s table
   105         # etypes for which we have a uri_eid_%(etype)s table
   105         self._init_uri_eid = set()
   106         self._init_uri_eid = set()
   106         # etypes for which we have a uri_eid_%(e)s_idx index
   107         # etypes for which we have a uri_eid_%(e)s_idx index
   107         self._uri_eid_inserted = set()
   108         self._uri_eid_inserted = set()