diff options
author | George Hazan <ghazan@miranda.im> | 2018-09-19 14:57:27 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-09-19 14:57:27 +0300 |
commit | 8dd934a1e0e80b1c14194195f4664bc9a6e685cc (patch) | |
tree | 0f0264a4d3c9848ea64e2dabb1969bd78d1300eb /plugins/Dbx_mdbx/src | |
parent | d5c92952533f3e1bfb06ad7f231dacc03e6a260b (diff) |
eventids table added for message keys
Diffstat (limited to 'plugins/Dbx_mdbx/src')
-rw-r--r-- | plugins/Dbx_mdbx/src/dbintf.cpp | 2 | ||||
-rw-r--r-- | plugins/Dbx_mdbx/src/dbintf.h | 31 | ||||
-rw-r--r-- | plugins/Dbx_mdbx/src/dbutils.cpp | 16 |
3 files changed, 33 insertions, 16 deletions
diff --git a/plugins/Dbx_mdbx/src/dbintf.cpp b/plugins/Dbx_mdbx/src/dbintf.cpp index efe6ba1559..51b0c04c60 100644 --- a/plugins/Dbx_mdbx/src/dbintf.cpp +++ b/plugins/Dbx_mdbx/src/dbintf.cpp @@ -84,6 +84,7 @@ int CDbxMDBX::Load() mdbx_dbi_open(trnlck, "modules", defFlags | MDBX_INTEGERKEY, &m_dbModules);
mdbx_dbi_open(trnlck, "events", defFlags | MDBX_INTEGERKEY, &m_dbEvents);
+ mdbx_dbi_open_ex(trnlck, "eventids", defFlags, &m_dbEventIds, DBEventIdKey::Compare, nullptr);
mdbx_dbi_open_ex(trnlck, "eventsrt", defFlags, &m_dbEventsSort, DBEventSortingKey::Compare, nullptr);
mdbx_dbi_open_ex(trnlck, "settings", defFlags, &m_dbSettings, DBSettingKey::Compare, nullptr);
@@ -115,6 +116,7 @@ int CDbxMDBX::Load() mdbx_txn_begin(m_env, nullptr, MDBX_RDONLY, &m_txn_ro);
mdbx_cursor_open(m_txn_ro, m_dbEvents, &m_curEvents);
+ mdbx_cursor_open(m_txn_ro, m_dbEventIds, &m_curEventIds);
mdbx_cursor_open(m_txn_ro, m_dbEventsSort, &m_curEventsSort);
mdbx_cursor_open(m_txn_ro, m_dbSettings, &m_curSettings);
mdbx_cursor_open(m_txn_ro, m_dbModules, &m_curModules);
diff --git a/plugins/Dbx_mdbx/src/dbintf.h b/plugins/Dbx_mdbx/src/dbintf.h index 73fb14e36b..fceabaf5f8 100644 --- a/plugins/Dbx_mdbx/src/dbintf.h +++ b/plugins/Dbx_mdbx/src/dbintf.h @@ -39,30 +39,29 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <pshpack1.h>
-#define DBHEADER_VERSION MAKELONG(1, 4)
-
+#define DBHEADER_VERSION MAKELONG(1, 4)
#define DBHEADER_SIGNATURE 0x40DECADEu
struct DBHeader
{
uint32_t dwSignature;
- uint32_t dwVersion; // database format version
+ uint32_t dwVersion; // database format version
};
struct DBContact
{
- uint32_t dwEventCount; // number of events in the chain for this contact
+ uint32_t dwEventCount; // number of events in the chain for this contact
MEVENT evFirstUnread;
uint64_t tsFirstUnread;
};
struct DBEvent
{
- MCONTACT contactID; // a contact this event belongs to
+ MCONTACT contactID; // a contact this event belongs to
uint32_t iModuleId; // offset to a DBModuleName struct of the name of
- uint64_t timestamp; // seconds since 00:00:00 01/01/1970
- uint32_t flags; // see m_database.h, db/event/add
- uint16_t wEventType; // module-defined event type
- uint16_t cbBlob; // number of bytes in the blob
+ uint64_t timestamp; // seconds since 00:00:00 01/01/1970
+ uint32_t flags; // see m_database.h, db/event/add
+ uint16_t wEventType; // module-defined event type
+ uint16_t cbBlob; // number of bytes in the blob
bool __forceinline markedRead() const
{
@@ -76,7 +75,15 @@ struct DBEventSortingKey MEVENT hEvent;
uint64_t ts;
- static int Compare(const MDBX_val* a, const MDBX_val* b);
+ static int Compare(const MDBX_val*, const MDBX_val*);
+};
+
+struct DBEventIdKey
+{
+ uint32_t iModuleId; // offset to a DBModuleName struct of the name of
+ char szEventId[256]; // string id
+
+ static int Compare(const MDBX_val*, const MDBX_val*);
};
struct DBSettingKey
@@ -186,8 +193,8 @@ class CDbxMDBX : public MDatabaseCommon, public MZeroedObject ////////////////////////////////////////////////////////////////////////////
// events
- MDBX_dbi m_dbEvents, m_dbEventsSort;
- MDBX_cursor *m_curEvents, *m_curEventsSort;
+ MDBX_dbi m_dbEvents, m_dbEventsSort, m_dbEventIds;
+ MDBX_cursor *m_curEvents, *m_curEventsSort, *m_curEventIds;
MEVENT m_dwMaxEventId;
HANDLE hEventAddedEvent, hEventDeletedEvent, hEventFilterAddedEvent;
diff --git a/plugins/Dbx_mdbx/src/dbutils.cpp b/plugins/Dbx_mdbx/src/dbutils.cpp index e3d125d302..1cb253dccb 100644 --- a/plugins/Dbx_mdbx/src/dbutils.cpp +++ b/plugins/Dbx_mdbx/src/dbutils.cpp @@ -25,10 +25,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define CMP_UINT(x, y) { if ((x) != (y)) return (x) < (y) ? -1 : 1; }
+int DBEventIdKey::Compare(const MDBX_val *ax, const MDBX_val *bx)
+{
+ const DBEventIdKey *a = (DBEventIdKey*)ax->iov_base;
+ const DBEventIdKey *b = (DBEventIdKey*)bx->iov_base;
+ CMP_UINT(a->iModuleId, b->iModuleId);
+ return strcmp(a->szEventId, b->szEventId);
+}
+
int DBEventSortingKey::Compare(const MDBX_val *ax, const MDBX_val *bx)
{
- const DBEventSortingKey *a = (DBEventSortingKey *)ax->iov_base;
- const DBEventSortingKey *b = (DBEventSortingKey *)bx->iov_base;
+ const DBEventSortingKey *a = (DBEventSortingKey*)ax->iov_base;
+ const DBEventSortingKey *b = (DBEventSortingKey*)bx->iov_base;
CMP_UINT(a->hContact, b->hContact);
CMP_UINT(a->ts, b->ts);
@@ -38,8 +46,8 @@ int DBEventSortingKey::Compare(const MDBX_val *ax, const MDBX_val *bx) int DBSettingKey::Compare(const MDBX_val *ax, const MDBX_val *bx)
{
- const DBSettingKey *a = (DBSettingKey *)ax->iov_base;
- const DBSettingKey *b = (DBSettingKey *)bx->iov_base;
+ const DBSettingKey *a = (DBSettingKey*)ax->iov_base;
+ const DBSettingKey *b = (DBSettingKey*)bx->iov_base;
CMP_UINT(a->hContact, b->hContact);
CMP_UINT(a->dwModuleId, b->dwModuleId);
|