diff options
Diffstat (limited to 'plugins/Dbx_kyoto')
-rw-r--r-- | plugins/Dbx_kyoto/src/dbevents.cpp | 2 | ||||
-rw-r--r-- | plugins/Dbx_kyoto/src/dbintf.cpp | 76 | ||||
-rw-r--r-- | plugins/Dbx_kyoto/src/dbintf.h | 20 |
3 files changed, 87 insertions, 11 deletions
diff --git a/plugins/Dbx_kyoto/src/dbevents.cpp b/plugins/Dbx_kyoto/src/dbevents.cpp index ec4c562751..c39848241b 100644 --- a/plugins/Dbx_kyoto/src/dbevents.cpp +++ b/plugins/Dbx_kyoto/src/dbevents.cpp @@ -314,6 +314,7 @@ STDMETHODIMP_(MEVENT) CDbxKV::FindNextEvent(MCONTACT contactID, MEVENT hDbEvent) DBEventSortingKey keyVal = { contactID, ts, hDbEvent+1 };
cursor_ptr cursor(m_dbEventsSort);
cursor->jump((LPCSTR)&keyVal, sizeof(keyVal));
+ cursor->step();
size_t size;
DBEventSortingKey *pKey = (DBEventSortingKey*)cursor->get_key(&size);
@@ -343,6 +344,7 @@ STDMETHODIMP_(MEVENT) CDbxKV::FindPrevEvent(MCONTACT contactID, MEVENT hDbEvent) DBEventSortingKey keyVal = { contactID, ts, hDbEvent-1 };
cursor_ptr cursor(m_dbEventsSort);
cursor->jump_back((LPCSTR)&keyVal, sizeof(keyVal));
+ cursor->step_back();
size_t size;
DBEventSortingKey *pKey = (DBEventSortingKey*)cursor->get_key(&size);
diff --git a/plugins/Dbx_kyoto/src/dbintf.cpp b/plugins/Dbx_kyoto/src/dbintf.cpp index cbed2eb648..4b3859eb63 100644 --- a/plugins/Dbx_kyoto/src/dbintf.cpp +++ b/plugins/Dbx_kyoto/src/dbintf.cpp @@ -23,6 +23,53 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "commonheaders.h"
+struct SettingsComparator : public Comparator
+{
+ SettingsComparator() {}
+ virtual int32_t compare(const char *akbuf, size_t, const char *bkbuf, size_t) + { + DBSettingSortingKey *k1 = (DBSettingSortingKey*)akbuf, *k2 = (DBSettingSortingKey*)bkbuf;
+ if (k1->dwContactID < k2->dwContactID) return -1;
+ if (k1->dwContactID > k2->dwContactID) return 1;
+
+ if (k1->dwOfsModule < k2->dwOfsModule) return -1;
+ if (k1->dwOfsModule > k2->dwOfsModule) return 1;
+
+ return strcmp(k1->szSettingName, k2->szSettingName);
+ } +}
+static _settingsComparator;
+
+struct EventsComparator : public Comparator
+{
+ EventsComparator() {}
+ virtual int32_t compare(const char *akbuf, size_t, const char *bkbuf, size_t) + { + DBEventSortingKey *k1 = (DBEventSortingKey*)akbuf, *k2 = (DBEventSortingKey*)bkbuf;
+ if (k1->dwContactId < k2->dwContactId) return -1;
+ if (k1->dwContactId > k2->dwContactId) return 1;
+
+ if (k1->ts < k2->ts) return -1;
+ if (k1->ts > k2->ts) return 1;
+
+ if (k1->dwEventId < k2->dwEventId) return -1;
+ if (k1->dwEventId > k2->dwEventId) return 1;
+
+ return 0;
+ }
+}
+static _eventsComparator;
+
+struct LongComparator : public Comparator
+{
+ LongComparator() {}
+ virtual int32_t compare(const char *akbuf, size_t, const char *bkbuf, size_t) + {
+ return *(LONG*)akbuf - *(LONG*)bkbuf;
+ } +} +static _longComparator;
+
static int ModCompare(const ModuleName *mn1, const ModuleName *mn2)
{
return strcmp(mn1->name, mn2->name);
@@ -87,12 +134,29 @@ int CDbxKV::Load(bool bSkipInit) iFlags |= TreeDB::OWRITER;
std::string szFilename((char*)_T2A(m_tszProfileName));
- if (!m_dbGlobal.open(szFilename, iFlags)) return EGROKPRF_DAMAGED;
- if (!m_dbContacts.open(szFilename + ".cnt", iFlags)) return EGROKPRF_DAMAGED;
- if (!m_dbModules.open(szFilename + ".mod", iFlags)) return EGROKPRF_DAMAGED;
- if (!m_dbEvents.open(szFilename + ".evt", iFlags)) return EGROKPRF_DAMAGED;
- if (!m_dbEventsSort.open(szFilename + ".evs", iFlags)) return EGROKPRF_DAMAGED;
- if (!m_dbSettings.open(szFilename + ".set", iFlags)) return EGROKPRF_DAMAGED;
+ m_dbGlobal.tune_map(16384);
+ if (!m_dbGlobal.open(szFilename, iFlags))
+ return EGROKPRF_DAMAGED;
+
+ m_dbContacts.tune_map(256 * 1024);
+ if (!m_dbContacts.open(szFilename + ".cnt", iFlags))
+ return EGROKPRF_DAMAGED;
+
+ m_dbModules.tune_comparator(&_longComparator);
+ if (!m_dbModules.open(szFilename + ".mod", iFlags))
+ return EGROKPRF_DAMAGED;
+
+ m_dbEvents.tune_comparator(&_longComparator);
+ if (!m_dbEvents.open(szFilename + ".evt", iFlags))
+ return EGROKPRF_DAMAGED;
+
+ m_dbEventsSort.tune_comparator(&_eventsComparator);
+ if (!m_dbEventsSort.open(szFilename + ".evs", iFlags))
+ return EGROKPRF_DAMAGED;
+
+ m_dbSettings.tune_comparator(&_settingsComparator);
+ if (!m_dbSettings.open(szFilename + ".set", iFlags))
+ return EGROKPRF_DAMAGED;
DWORD keyVal = 1;
if (-1 != m_dbGlobal.get((LPCSTR)&keyVal, sizeof(keyVal), (LPSTR)&m_header, sizeof(m_header))) {
diff --git a/plugins/Dbx_kyoto/src/dbintf.h b/plugins/Dbx_kyoto/src/dbintf.h index cfde9f33b4..cbf2510f19 100644 --- a/plugins/Dbx_kyoto/src/dbintf.h +++ b/plugins/Dbx_kyoto/src/dbintf.h @@ -123,6 +123,16 @@ struct DBCachedContact : public DBCachedContactBase DBContact dbc;
};
+struct CTable : public TreeDB
+{
+ CTable()
+ {
+ tune_options(TLINEAR | TCOMPRESS);
+ tune_alignment(3);
+ tune_map(1024 * 1024);
+ }
+};
+
struct CDbxKV : public MIDatabase, public MIDatabaseChecker, public MZeroedObject
{
CDbxKV(const TCHAR *tszFileName, int mode);
@@ -217,7 +227,7 @@ public: MICryptoEngine *m_crypto;
protected:
- TreeDB m_dbGlobal;
+ CTable m_dbGlobal;
DBHeader m_header;
HANDLE hSettingChangeEvent, hContactDeletedEvent, hContactAddedEvent, hEventMarkedRead;
@@ -229,14 +239,14 @@ protected: ////////////////////////////////////////////////////////////////////////////
// settings
- TreeDB m_dbSettings;
+ CTable m_dbSettings;
int m_codePage;
HANDLE hService, hHook;
////////////////////////////////////////////////////////////////////////////
// contacts
- TreeDB m_dbContacts;
+ CTable m_dbContacts;
int m_contactCount, m_dwMaxContactId;
int WipeContactHistory(DBContact *dbc);
@@ -244,7 +254,7 @@ protected: ////////////////////////////////////////////////////////////////////////////
// events
- TreeDB m_dbEvents, m_dbEventsSort;
+ CTable m_dbEvents, m_dbEventsSort;
DWORD m_dwMaxEventId, m_tsLast;
MEVENT m_evLast;
@@ -253,7 +263,7 @@ protected: ////////////////////////////////////////////////////////////////////////////
// modules
- TreeDB m_dbModules;
+ CTable m_dbModules;
HANDLE m_hModHeap;
LIST<ModuleName> m_lMods, m_lOfs;
LIST<char> m_lResidentSettings;
|