@@ -205,15 +205,16 @@ def set(self, traj_info):
205
205
206
206
self ._update_time_stamp (hash_value = traj_info .hash_value )
207
207
208
- current_size = os .stat (self .filename ).st_size
209
- if (self .num_entries >= config .traj_info_max_entries or
210
- # current_size is in bytes, while traj_info_max_size is in MB
211
- 1. * current_size / 1024 ** 2 >= config .traj_info_max_size ):
212
- logger .info ("Cleaning database because it has too much entries or is too large.\n "
213
- "Entries: %s. Size: %.2fMB. Configured max_entires: %s. Max_size: %sMB"
214
- % (self .num_entries , (current_size * 1.0 / 1024 ** 2 ),
215
- config .traj_info_max_entries , config .traj_info_max_size ))
216
- self ._clean (n = self .clean_n_entries )
208
+ if self .filename is not None :
209
+ current_size = os .stat (self .filename ).st_size
210
+ if (self .num_entries >= config .traj_info_max_entries or
211
+ # current_size is in bytes, while traj_info_max_size is in MB
212
+ 1. * current_size / 1024 ** 2 >= config .traj_info_max_size ):
213
+ logger .info ("Cleaning database because it has too much entries or is too large.\n "
214
+ "Entries: %s. Size: %.2fMB. Configured max_entires: %s. Max_size: %sMB"
215
+ % (self .num_entries , (current_size * 1.0 / 1024 ** 2 ),
216
+ config .traj_info_max_entries , config .traj_info_max_size ))
217
+ self ._clean (n = self .clean_n_entries )
217
218
218
219
def get (self , key ):
219
220
cursor = self ._database .execute ("SELECT * FROM traj_info WHERE hash=?" , (key ,))
@@ -231,12 +232,15 @@ def _database_from_key(self, key):
231
232
database has to be locked for updates and multiple processes want to write,
232
233
each process has to wait until the lock has been released.
233
234
234
- By default the LRU databases will be stored in a sub directory "tra_info_usage "
235
+ By default the LRU databases will be stored in a sub directory "traj_info_usage "
235
236
lying next to the main database.
236
237
237
238
:param key: hash of the TrajInfo instance
238
239
:return: str, database path
239
240
"""
241
+ if not self .filename :
242
+ return None
243
+
240
244
from pyemma .util .files import mkdir_p
241
245
hash_value_long = int (key , 16 )
242
246
# bin hash to one of either 10 different databases
@@ -250,6 +254,9 @@ def _update_time_stamp(self, hash_value):
250
254
""" timestamps are being stored distributed over several lru databases.
251
255
The timestamp is a time.time() snapshot (float), which are seconds since epoch."""
252
256
db_name = self ._database_from_key (hash_value )
257
+ if not db_name :
258
+ db_name = ':memory:'
259
+
253
260
import sqlite3
254
261
255
262
with sqlite3 .connect (db_name ) as conn :
0 commit comments