[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
LMDB: Compare function implementation
- To: openldap-technical@openldap.org
- Subject: LMDB: Compare function implementation
- From: Venkat Murty <venkat.murty@gmail.com>
- Date: Sat, 23 Aug 2014 08:31:17 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-type:content-transfer-encoding:subject:message-id:date :to:mime-version; bh=miJkopbjr7bYaOBerRInOaDfAtdf6ubvrVTuGXgU0rE=; b=EWL97DYV+ZAAAPIdcBTeaxBO/R4Wtnc0Papp82Plevj/Y/I5I5caaEanAiEOLXC8yt 2WQ5jiSInfI1Iau7JjS0ZpavmDvNcCyajnU2VNerw/not7ISxvD0c/Xp+uj02BImR42b cvTDHr1bC2dChILmauDvknrWWdjQpR8dc14PNfT1718KWelEcjigZiG2OALuDDreb8q8 htUsaElaYOBJH16lOkrjelgsi9imLWVaf32mcxsGEWGj7hyaGbXAlxPfHte9dw1HstyU qzaewGorTwrX50Gwmdgmd0IcvfKI7ydxZCB1iswgZOSUwqccJLZKAiqAupusAPzhjfXK Ejqg==
Hi all,
I am inserting a non-zero length key into a database where I provide a compare function. But I am seeing that MDB_val->mv_size = 0 in the compare function. Is that possible?
More details (LMDB 0.9.11 Release):
I have a database where I want to delete all elements that have the same prefix.
void eraseElements (KeyPrefix prefix, MDB_txn *txn, MDB_dbi database)
{
MDB_val k;
k.mv_data = &prefix;
k.mv_size = sizeof (KeyPrefix);
MDB_val v;
MDB_cursor *cur;
mdb_cursor_open (txn, database, &cur);
while (! mdb_cursor_get (cur, &k, &v, MDB_SET_RANGE))
{
if (memcmp (&prefix, k.mv_data, sizeof (KeyPrefix)) != 0) break;
mdb_cursor_del (cur, 0);
k.mv_data = &prefix;
k.mv_size = sizeof (KeyPrefix);
}
mdb_cursor_close (cur);
}
Relevant stack trace
DB::compare (a, b) and b->mv_size == 0
mdb_cursor_set(mc, key, data, op=MDB_SET_RANGE, exactp=0x0) at mdb.c:5348
mdb_cursor_get(mc,key,data,op=MDB_SET_RANGE) at mdb.c:5655
eraseElements(..)