[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: (ITS#8908) LMDB Documentation for MDB_XXX_MULTIPLE



--000000000000a517d40574956804
Content-Type: text/plain; charset="UTF-8"

Thanks!

On Wed, Aug 29, 2018, 12:05 Howard Chu, <hyc@symas.com> wrote:

> karl@waclawek.net wrote:
> > --00000000000018b43a057492d87f
> > Content-Type: text/plain; charset="UTF-8"
> >
> > As far as point 2 is concerned I was basing it on this piece of code,
> where
> > it looks like MDB_GET_MULTIPLE just checks some flags and then goes to
> the
> > fetchm label where the code does nothing but retrieve data:
>
> You're not reading the code correctly. See below.
> >
> > case MDB_GET_MULTIPLE:
> > if (data == NULL || !(mc->mc_flags & C_INITIALIZED)) {
> > rc = EINVAL;
> > break;
> > }
> > if (!(mc->mc_db->md_flags & MDB_DUPFIXED)) {
> > rc = MDB_INCOMPATIBLE;
> > break;
> > }
> > rc = MDB_SUCCESS;
> > if (!(mc->mc_xcursor->mx_cursor.mc_flags & C_INITIALIZED) ||
> > (mc->mc_xcursor->mx_cursor.mc_flags & C_EOF))
> > break;
> > goto fetchm;
> > case MDB_NEXT_MULTIPLE:
> > if (data == NULL) {
> > rc = EINVAL;
> > break;
> > }
> > if (!(mc->mc_db->md_flags & MDB_DUPFIXED)) {
> > rc = MDB_INCOMPATIBLE;
> > break;
> > }
> > rc = mdb_cursor_next(mc, key, data, MDB_NEXT_DUP);
> > if (rc == MDB_SUCCESS) {
> > if (mc->mc_xcursor->mx_cursor.mc_flags & C_INITIALIZED) {
> > MDB_cursor *mx;
> > fetchm:
> > mx = &mc->mc_xcursor->mx_cursor;
> > data->mv_size = NUMKEYS(mx->mc_pg[mx->mc_top]) *
> > mx->mc_db->md_pad;
> > data->mv_data = METADATA(mx->mc_pg[mx->mc_top]);
> > mx->mc_ki[mx->mc_top] = NUMKEYS(mx->mc_pg[mx->mc_top])-1;
>
> ^^^ this line advances the cursor.
>
> > } else {
> > rc = MDB_NOTFOUND;
> > }
> > }
> > break;
> >
> >
> > On Tue, Aug 28, 2018 at 8:26 PM Howard Chu <openldap-its@openldap.org>
> > wrote:
> >
> >>> Full_Name: Karl Waclawek
> >>> Version: LMDB 0.9.22
> >>> OS: Windows 10
> >>> URL: ftp://ftp.openldap.org/incoming/
> >>> Submission from: (NULL) (2607:fea8:7a80:814:3ca9:e8f6:801c:d6f8)
> >>>
> >>>
> >>> The documentation in lmdb.h for MDB_GET_MULTIPLE, MDB_NEXT_MULTIPLE and
> >>> MDB_PREV_MULTIPLE seems to have two issues:
> >>>
> >>> 1) The documentation indicates that both, the key and data, are
> >> returned, but
> >> in
> >>> reality only the data is returned.
> >>
> >> Looks like you're right. Since these are DUPs the key would be the same
> >> every time so there's no need to return it on each call.
> >> Doc fixed in git mdb.master.
> >>
> >>> 2) The documentation states that MDB_GET_MULTIPLE moves the cursor.
> This
> >> does
> >>> not seem to be true.
> >>
> >> The doc is correct here. The cursor is advanced far enough that a
> >> MDB_NEXT_MULTIPLE will return the following data, as opposed to just
> >> returning the same data again.
> >>
> >
>
>
>
> --
>    -- Howard Chu
>    CTO, Symas Corp.           http://www.symas.com
>    Director, Highland Sun     http://highlandsun.com/hyc/
>    Chief Architect, OpenLDAP  http://www.openldap.org/project/
>

--000000000000a517d40574956804
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto">Thanks!</div><br><div class=3D"gmail_quote"><div dir=3D"l=
tr">On Wed, Aug 29, 2018, 12:05 Howard Chu, &lt;<a href=3D"mailto:hyc@symas=
.com">hyc@symas.com</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quot=
e" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">=
<a href=3D"mailto:karl@waclawek.net"; target=3D"_blank" rel=3D"noreferrer">k=
arl@waclawek.net</a> wrote:<br>
&gt; --00000000000018b43a057492d87f<br>
&gt; Content-Type: text/plain; charset=3D&quot;UTF-8&quot;<br>
&gt; <br>
&gt; As far as point 2 is concerned I was basing it on this piece of code, =
where<br>
&gt; it looks like MDB_GET_MULTIPLE just checks some flags and then goes to=
 the<br>
&gt; fetchm label where the code does nothing but retrieve data:<br>
<br>
You&#39;re not reading the code correctly. See below.<br>
&gt; <br>
&gt; case MDB_GET_MULTIPLE:<br>
&gt; if (data =3D=3D NULL || !(mc-&gt;mc_flags &amp; C_INITIALIZED)) {<br>
&gt; rc =3D EINVAL;<br>
&gt; break;<br>
&gt; }<br>
&gt; if (!(mc-&gt;mc_db-&gt;md_flags &amp; MDB_DUPFIXED)) {<br>
&gt; rc =3D MDB_INCOMPATIBLE;<br>
&gt; break;<br>
&gt; }<br>
&gt; rc =3D MDB_SUCCESS;<br>
&gt; if (!(mc-&gt;mc_xcursor-&gt;mx_cursor.mc_flags &amp; C_INITIALIZED) ||=
<br>
&gt; (mc-&gt;mc_xcursor-&gt;mx_cursor.mc_flags &amp; C_EOF))<br>
&gt; break;<br>
&gt; goto fetchm;<br>
&gt; case MDB_NEXT_MULTIPLE:<br>
&gt; if (data =3D=3D NULL) {<br>
&gt; rc =3D EINVAL;<br>
&gt; break;<br>
&gt; }<br>
&gt; if (!(mc-&gt;mc_db-&gt;md_flags &amp; MDB_DUPFIXED)) {<br>
&gt; rc =3D MDB_INCOMPATIBLE;<br>
&gt; break;<br>
&gt; }<br>
&gt; rc =3D mdb_cursor_next(mc, key, data, MDB_NEXT_DUP);<br>
&gt; if (rc =3D=3D MDB_SUCCESS) {<br>
&gt; if (mc-&gt;mc_xcursor-&gt;mx_cursor.mc_flags &amp; C_INITIALIZED) {<br=
>
&gt; MDB_cursor *mx;<br>
&gt; fetchm:<br>
&gt; mx =3D &amp;mc-&gt;mc_xcursor-&gt;mx_cursor;<br>
&gt; data-&gt;mv_size =3D NUMKEYS(mx-&gt;mc_pg[mx-&gt;mc_top]) *<br>
&gt; mx-&gt;mc_db-&gt;md_pad;<br>
&gt; data-&gt;mv_data =3D METADATA(mx-&gt;mc_pg[mx-&gt;mc_top]);<br>
&gt; mx-&gt;mc_ki[mx-&gt;mc_top] =3D NUMKEYS(mx-&gt;mc_pg[mx-&gt;mc_top])-1=
;<br>
<br>
^^^ this line advances the cursor.<br>
<br>
&gt; } else {<br>
&gt; rc =3D MDB_NOTFOUND;<br>
&gt; }<br>
&gt; }<br>
&gt; break;<br>
&gt; <br>
&gt; <br>
&gt; On Tue, Aug 28, 2018 at 8:26 PM Howard Chu &lt;<a href=3D"mailto:openl=
dap-its@openldap.org" target=3D"_blank" rel=3D"noreferrer">openldap-its@ope=
nldap.org</a>&gt;<br>
&gt; wrote:<br>
&gt; <br>
&gt;&gt;&gt; Full_Name: Karl Waclawek<br>
&gt;&gt;&gt; Version: LMDB 0.9.22<br>
&gt;&gt;&gt; OS: Windows 10<br>
&gt;&gt;&gt; URL: <a href=3D"ftp://ftp.openldap.org/incoming/"; rel=3D"noref=
errer noreferrer" target=3D"_blank">ftp://ftp.openldap.org/incoming/</a><br=
>
&gt;&gt;&gt; Submission from: (NULL) (2607:fea8:7a80:814:3ca9:e8f6:801c:d6f=
8)<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; The documentation in lmdb.h for MDB_GET_MULTIPLE, MDB_NEXT_MUL=
TIPLE and<br>
&gt;&gt;&gt; MDB_PREV_MULTIPLE seems to have two issues:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; 1) The documentation indicates that both, the key and data, ar=
e<br>
&gt;&gt; returned, but<br>
&gt;&gt; in<br>
&gt;&gt;&gt; reality only the data is returned.<br>
&gt;&gt;<br>
&gt;&gt; Looks like you&#39;re right. Since these are DUPs the key would be=
 the same<br>
&gt;&gt; every time so there&#39;s no need to return it on each call.<br>
&gt;&gt; Doc fixed in git mdb.master.<br>
&gt;&gt;<br>
&gt;&gt;&gt; 2) The documentation states that MDB_GET_MULTIPLE moves the cu=
rsor. This<br>
&gt;&gt; does<br>
&gt;&gt;&gt; not seem to be true.<br>
&gt;&gt;<br>
&gt;&gt; The doc is correct here. The cursor is advanced far enough that a<=
br>
&gt;&gt; MDB_NEXT_MULTIPLE will return the following data, as opposed to ju=
st<br>
&gt;&gt; returning the same data again.<br>
&gt;&gt;<br>
&gt; <br>
<br>
<br>
<br>
-- <br>
=C2=A0 =C2=A0-- Howard Chu<br>
=C2=A0 =C2=A0CTO, Symas Corp.=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0<a hr=
ef=3D"http://www.symas.com"; rel=3D"noreferrer noreferrer" target=3D"_blank"=
>http://www.symas.com</a><br>
=C2=A0 =C2=A0Director, Highland Sun=C2=A0 =C2=A0 =C2=A0<a href=3D"http://hi=
ghlandsun.com/hyc/" rel=3D"noreferrer noreferrer" target=3D"_blank">http://=
highlandsun.com/hyc/</a><br>
=C2=A0 =C2=A0Chief Architect, OpenLDAP=C2=A0 <a href=3D"http://www.openldap=
.org/project/" rel=3D"noreferrer noreferrer" target=3D"_blank">http://www.o=
penldap.org/project/</a><br>
</blockquote></div>

--000000000000a517d40574956804--