def _write_batch_to_lmdb(db, batch):
 try:
  with db.begin(write=True) as lmdb_txn:
   for (key, datum) in batch:
    lmdb_txn.put(key, datum.SerializeToString())
 except lmdb.MapFullError:
  curr_limit = db.info()['map_size']
  new_limit = (curr_limit * 2)
  try:
   db.set_mapsize(new_limit)
  except AttributeError as e:
   version = tuple((int(x) for x in lmdb.__version__.split('.')))
   if (version < (0, 87)):
    raise ImportError(('py-lmdb is out of date (%s vs 0.87)' % lmdb.__version__))
   else:
    raise e
  _write_batch_to_lmdb(db, batch)

def _write_batch_to_lmdb ( db , batch ) : try : with db . begin ( write = True ) as lmdb_txn : for ( key , datum ) in batch : lmdb_txn . put ( key , datum . SerializeToString ( ) ) except lmdb . MapFullError : curr_limit = db . info ( ) [ 'map_size' ] new_limit = ( curr_limit * 2 ) try : db . set_mapsize ( new_limit ) except AttributeError as e : version = tuple ( ( int ( x ) for x in lmdb . __version__ . split ( '.' ) ) ) if ( version < ( 0 , 87 ) ) : raise ImportError ( ( 'py-lmdb is out of date (%s vs 0.87)' % lmdb . __version__ ) ) else : raise e _write_batch_to_lmdb ( db , batch )
write a batch of to db .