mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Remove get_metadata cache
This commit is contained in:
commit
bf2b051aa0
@ -19,7 +19,7 @@ from PyQt4.Qt import Qt, SIGNAL, QTimer, \
|
|||||||
QMessageBox, QHelpEvent
|
QMessageBox, QHelpEvent
|
||||||
|
|
||||||
from calibre import prints
|
from calibre import prints
|
||||||
from calibre.constants import __appname__, isosx, DEBUG
|
from calibre.constants import __appname__, isosx
|
||||||
from calibre.ptempfile import PersistentTemporaryFile
|
from calibre.ptempfile import PersistentTemporaryFile
|
||||||
from calibre.utils.config import prefs, dynamic
|
from calibre.utils.config import prefs, dynamic
|
||||||
from calibre.utils.ipc.server import Server
|
from calibre.utils.ipc.server import Server
|
||||||
@ -590,9 +590,6 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
|||||||
# Goes here, because if cf is valid, db is valid.
|
# Goes here, because if cf is valid, db is valid.
|
||||||
db.prefs['field_metadata'] = db.field_metadata.all_metadata()
|
db.prefs['field_metadata'] = db.field_metadata.all_metadata()
|
||||||
db.commit_dirty_cache()
|
db.commit_dirty_cache()
|
||||||
if DEBUG and db.gm_count > 0:
|
|
||||||
print 'get_metadata cache: {0:d} calls, {1:4.2f}% misses'.format(
|
|
||||||
db.gm_count, (db.gm_missed*100.0)/db.gm_count)
|
|
||||||
for action in self.iactions.values():
|
for action in self.iactions.values():
|
||||||
if not action.shutting_down():
|
if not action.shutting_down():
|
||||||
return
|
return
|
||||||
|
@ -598,7 +598,6 @@ class ResultCache(SearchQueryParser): # {{{
|
|||||||
|
|
||||||
def set(self, row, col, val, row_is_id=False):
|
def set(self, row, col, val, row_is_id=False):
|
||||||
id = row if row_is_id else self._map_filtered[row]
|
id = row if row_is_id else self._map_filtered[row]
|
||||||
self._data[id][self.FIELD_MAP['all_metadata']] = None
|
|
||||||
self._data[id][col] = val
|
self._data[id][col] = val
|
||||||
|
|
||||||
def get(self, row, col, row_is_id=False):
|
def get(self, row, col, row_is_id=False):
|
||||||
@ -629,7 +628,6 @@ class ResultCache(SearchQueryParser): # {{{
|
|||||||
self._data[id] = CacheRow(db, self.composites,
|
self._data[id] = CacheRow(db, self.composites,
|
||||||
db.conn.get('SELECT * from meta2 WHERE id=?', (id,))[0])
|
db.conn.get('SELECT * from meta2 WHERE id=?', (id,))[0])
|
||||||
self._data[id].append(db.book_on_device_string(id))
|
self._data[id].append(db.book_on_device_string(id))
|
||||||
self._data[id].append(None)
|
|
||||||
except IndexError:
|
except IndexError:
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
@ -646,7 +644,6 @@ class ResultCache(SearchQueryParser): # {{{
|
|||||||
self._data[id] = CacheRow(db, self.composites,
|
self._data[id] = CacheRow(db, self.composites,
|
||||||
db.conn.get('SELECT * from meta2 WHERE id=?', (id,))[0])
|
db.conn.get('SELECT * from meta2 WHERE id=?', (id,))[0])
|
||||||
self._data[id].append(db.book_on_device_string(id))
|
self._data[id].append(db.book_on_device_string(id))
|
||||||
self._data[id].append(None)
|
|
||||||
self._map[0:0] = ids
|
self._map[0:0] = ids
|
||||||
self._map_filtered[0:0] = ids
|
self._map_filtered[0:0] = ids
|
||||||
|
|
||||||
@ -671,7 +668,6 @@ class ResultCache(SearchQueryParser): # {{{
|
|||||||
for item in self._data:
|
for item in self._data:
|
||||||
if item is not None:
|
if item is not None:
|
||||||
item.append(db.book_on_device_string(item[0]))
|
item.append(db.book_on_device_string(item[0]))
|
||||||
item.append(None)
|
|
||||||
self._map = [i[0] for i in self._data if i is not None]
|
self._map = [i[0] for i in self._data if i is not None]
|
||||||
if field is not None:
|
if field is not None:
|
||||||
self.sort(field, ascending)
|
self.sort(field, ascending)
|
||||||
|
@ -298,10 +298,8 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
base,
|
base,
|
||||||
prefer_custom=True)
|
prefer_custom=True)
|
||||||
|
|
||||||
self.FIELD_MAP['ondevice'] = base+1
|
self.FIELD_MAP['ondevice'] = base = base+1
|
||||||
self.field_metadata.set_field_record_index('ondevice', base+1, prefer_custom=False)
|
self.field_metadata.set_field_record_index('ondevice', base, prefer_custom=False)
|
||||||
self.FIELD_MAP['all_metadata'] = base+2
|
|
||||||
self.field_metadata.set_field_record_index('all_metadata', base+2, prefer_custom=False)
|
|
||||||
|
|
||||||
script = '''
|
script = '''
|
||||||
DROP VIEW IF EXISTS meta2;
|
DROP VIEW IF EXISTS meta2;
|
||||||
@ -690,19 +688,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
'''
|
'''
|
||||||
row = self.data._data[idx] if index_is_id else self.data[idx]
|
row = self.data._data[idx] if index_is_id else self.data[idx]
|
||||||
fm = self.FIELD_MAP
|
fm = self.FIELD_MAP
|
||||||
|
|
||||||
self.gm_count += 1
|
|
||||||
mi = row[self.FIELD_MAP['all_metadata']]
|
|
||||||
if mi is not None:
|
|
||||||
if get_cover:
|
|
||||||
# Always get the cover, because the value can be wrong if the
|
|
||||||
# original mi was from the OPF
|
|
||||||
mi.cover = self.cover(idx, index_is_id=index_is_id, as_path=True)
|
|
||||||
return mi
|
|
||||||
|
|
||||||
self.gm_missed += 1
|
|
||||||
mi = Metadata(None)
|
mi = Metadata(None)
|
||||||
self.data.set(idx, fm['all_metadata'], mi, row_is_id = index_is_id)
|
|
||||||
|
|
||||||
aut_list = row[fm['au_map']]
|
aut_list = row[fm['au_map']]
|
||||||
aut_list = [p.split(':::') for p in aut_list.split(':#:')]
|
aut_list = [p.split(':::') for p in aut_list.split(':#:')]
|
||||||
|
@ -162,15 +162,6 @@ class FieldMetadata(dict):
|
|||||||
'search_terms':['tags', 'tag'],
|
'search_terms':['tags', 'tag'],
|
||||||
'is_custom':False,
|
'is_custom':False,
|
||||||
'is_category':True}),
|
'is_category':True}),
|
||||||
('all_metadata',{'table':None,
|
|
||||||
'column':None,
|
|
||||||
'datatype':None,
|
|
||||||
'is_multiple':None,
|
|
||||||
'kind':'field',
|
|
||||||
'name':None,
|
|
||||||
'search_terms':[],
|
|
||||||
'is_custom':False,
|
|
||||||
'is_category':False}),
|
|
||||||
('author_sort',{'table':None,
|
('author_sort',{'table':None,
|
||||||
'column':None,
|
'column':None,
|
||||||
'datatype':'text',
|
'datatype':'text',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user