public MarshalMultipleValueStructure(byte[] key, byte[][] values)
        {
            if (values == null)
                throw new ArgumentNullException(nameof(values));

            _size = GetSize(values);
            _count = GetCount(values);
            _flattened = values.SelectMany(x => x).ToArray();
            _valuesHandle = GCHandle.Alloc(_flattened, GCHandleType.Pinned);

            _key = key;
            _keyHandle = GCHandle.Alloc(_key, GCHandleType.Pinned);

            Values = new[]
            {
                new ValueStructure
                {
                    size = new IntPtr(_size),
                    data = _valuesHandle.AddrOfPinnedObject()
                },
                new ValueStructure
                {
                    size = new IntPtr(_count)
                }
            };

            Key = new ValueStructure
            {
                size = new IntPtr(_key.Length),
                data = _keyHandle.AddrOfPinnedObject()
            };
        }
        public MarshalValueStructure(byte[] key)
        {
            if (key == null)
                throw new ArgumentNullException(nameof(key));

            _key = key;
            _keyHandle = GCHandle.Alloc(_key, GCHandleType.Pinned);
            Key = new ValueStructure
            {
                size = new IntPtr(_key.Length),
                data = _keyHandle.AddrOfPinnedObject()
            };
        }
        public MarshalValueStructure(byte[] key, byte[] value) : this(key)
        {
            if (value == null)
                throw new ArgumentNullException(nameof(value));

            _value = value;
            _valueHandle = GCHandle.Alloc(_value, GCHandleType.Pinned);
            Value = new ValueStructure
            {
                size = new IntPtr(_value.Length),
                data = _valueHandle.AddrOfPinnedObject()
            };
        }
Exemplo n.º 4
0
        public static unsafe int mdb_get(IntPtr txn, uint dbi, ReadOnlySpan <byte> key, out Span <byte> data)
        {
            fixed(byte *addKey = &key.GetPinnableReference())
            {
                var keyVs = new ValueStructure
                {
                    size = new IntPtr(key.Length),
                    data = new IntPtr(addKey),
                };

                ValueStructure value;
                var            result = checkRead(LmdbMethods.mdb_get(txn, dbi, ref keyVs, out value));

                if (result == MDB_NOTFOUND)
                {
                    data = Span <byte> .Empty;
                    return(result);
                }
                data = new Span <byte>(value.data.ToPointer(), value.size.ToInt32());
                return(result);
            }
        }
Exemplo n.º 5
0
 int INativeLibraryFacade.mdb_cursor_put(IntPtr cursor, ref ValueStructure key, ValueStructure[] data, CursorPutOptions flags)
 {
     return FallbackLibraryFacade.mdb_cursor_put(cursor, ref key, data, flags);
 }
Exemplo n.º 6
0
 int INativeLibraryFacade.mdb_put(IntPtr txn, uint dbi, ref ValueStructure key, ref ValueStructure data, PutOptions flags)
 {
     return FallbackLibraryFacade.mdb_put(txn, dbi, ref key, ref data, flags);
 }
Exemplo n.º 7
0
 private static extern int mdb_put(IntPtr txn, UInt32 dbi, ref ValueStructure key, ref ValueStructure data, PutOptions flags);
Exemplo n.º 8
0
 private static extern int mdb_cursor_get(IntPtr cursor, ref ValueStructure key, ref ValueStructure data, CursorOperation op);
Exemplo n.º 9
0
 private static extern int mdb_get(IntPtr txn, UInt32 dbi, ref ValueStructure key, out ValueStructure data);
Exemplo n.º 10
0
 public static extern int mdb_cursor_get(IntPtr cursor, ref ValueStructure key, ref ValueStructure data, CursorOperation op);
Exemplo n.º 11
0
 int INativeLibraryFacade.mdb_del(IntPtr txn, uint dbi, ref ValueStructure key, ref ValueStructure data)
 {
     return Native64BitLibraryFacade.mdb_del(txn, dbi, ref key, ref data);
 }
 int INativeLibraryFacade.mdb_cursor_put(IntPtr cursor, ref ValueStructure key, ref ValueStructure data, PutOptions flags)
 {
     return(FallbackLibraryFacade.mdb_cursor_put(cursor, ref key, ref data, flags));
 }
 private static extern int mdb_del(IntPtr txn, UInt32 dbi, ref ValueStructure key, IntPtr data);
 int INativeLibraryFacade.mdb_cursor_get(IntPtr cursor, ref ValueStructure key, ref ValueStructure data, CursorOperation op)
 {
     return(FallbackLibraryFacade.mdb_cursor_get(cursor, ref key, ref data, op));
 }
 private static extern int mdb_put(IntPtr txn, UInt32 dbi, ref ValueStructure key, ref ValueStructure data, PutOptions flags);
 int INativeLibraryFacade.mdb_del(IntPtr txn, uint dbi, ref ValueStructure key, IntPtr data)
 {
     return(FallbackLibraryFacade.mdb_del(txn, dbi, ref key, data));
 }
 private static extern int mdb_get(IntPtr txn, UInt32 dbi, ref ValueStructure key, out ValueStructure data);
 int INativeLibraryFacade.mdb_put(IntPtr txn, uint dbi, ref ValueStructure key, ref ValueStructure data, PutOptions flags)
 {
     return(FallbackLibraryFacade.mdb_put(txn, dbi, ref key, ref data, flags));
 }
Exemplo n.º 19
0
 public static int mdb_cursor_get(IntPtr cursor, byte[] key, out ValueStructure keyStructure, out ValueStructure valueStructure, CursorOperation op)
 {
     valueStructure = default(ValueStructure);
     using (var marshal = new MarshalValueStructure(key))
     {
         keyStructure = marshal.Key;
         return(checkRead(LmdbMethods.mdb_cursor_get(cursor, ref keyStructure, ref valueStructure, op)));
     }
 }
 private static extern int mdb_cursor_put(IntPtr cursor, ref ValueStructure key, ref ValueStructure data, PutOptions flags);
 int INativeLibraryFacade.mdb_get(IntPtr txn, uint dbi, ref ValueStructure key, out ValueStructure data)
 {
     return(FallbackLibraryFacade.mdb_get(txn, dbi, ref key, out data));
 }
Exemplo n.º 22
0
 public static int mdb_cursor_get_multiple(IntPtr cursor, ref ValueStructure key, ref ValueStructure value, CursorOperation op)
 {
     return(checkRead(LmdbMethods.mdb_cursor_get(cursor, ref key, ref value, op)));
 }
Exemplo n.º 23
0
 public static extern int mdb_cursor_put(IntPtr cursor, ref ValueStructure key, ref ValueStructure value, CursorPutOptions flags);
Exemplo n.º 24
0
 public static int mdb_cursor_get(IntPtr cursor, byte[] key, out ValueStructure keyStructure, out ValueStructure valueStructure, CursorOperation op)
 {
     valueStructure = default(ValueStructure);
     using (var marshal = new MarshalValueStructure(key))
     {
         keyStructure = marshal.Key;
         return checkRead(LmdbMethods.mdb_cursor_get(cursor, ref keyStructure, ref valueStructure, op));
     }
 }
Exemplo n.º 25
0
 int INativeLibraryFacade.mdb_cursor_put(IntPtr cursor, ref ValueStructure key, ref ValueStructure data, CursorPutOptions flags)
 {
     return Native64BitLibraryFacade.mdb_cursor_put(cursor, ref key, ref data, flags);
 }
Exemplo n.º 26
0
 public static int mdb_cursor_get(IntPtr cursor, out ValueStructure key, out ValueStructure value, CursorOperation op)
 {
     key = value = default(ValueStructure);
     return checkRead(LmdbMethods.mdb_cursor_get(cursor, ref key, ref value, op));
 }
Exemplo n.º 27
0
 private static extern int mdb_cursor_put(IntPtr cursor, ref ValueStructure key, ValueStructure[] data, CursorPutOptions flags);
Exemplo n.º 28
0
 public static int mdb_cursor_get(IntPtr cursor, out byte[] key, out byte[] value, ref ValueStructure keyStructure, ref ValueStructure valueStructure, CursorOperation op)
 {
     key = value = null;
     var result = checkRead(LmdbMethods.mdb_cursor_get(cursor, ref keyStructure, ref valueStructure, op));
     if (result == 0)
     {
         key = keyStructure.GetBytes();
         value = valueStructure.GetBytes();
     }
     return result;
 }
Exemplo n.º 29
0
 int INativeLibraryFacade.mdb_get(IntPtr txn, uint dbi, ref ValueStructure key, out ValueStructure data)
 {
     return FallbackLibraryFacade.mdb_get(txn, dbi, ref key, out data);
 }
Exemplo n.º 30
0
 public static int mdb_cursor_put(IntPtr cursor, ref ValueStructure key, ValueStructure[] data, CursorPutOptions flags)
 {
     return check(LmdbMethods.Overloads.mdb_cursor_put(cursor, ref key, data, flags));
 }
Exemplo n.º 31
0
 int INativeLibraryFacade.mdb_del(IntPtr txn, uint dbi, ref ValueStructure key, IntPtr data)
 {
     return FallbackLibraryFacade.mdb_del(txn, dbi, ref key, data);
 }
Exemplo n.º 32
0
        public static int mdb_cursor_get(IntPtr cursor, out byte[] key, out byte[] value, ref ValueStructure keyStructure, ref ValueStructure valueStructure, CursorOperation op)
        {
            key = value = null;
            var result = checkRead(LmdbMethods.mdb_cursor_get(cursor, ref keyStructure, ref valueStructure, op));

            if (result == 0)
            {
                key   = keyStructure.GetBytes();
                value = valueStructure.GetBytes();
            }
            return(result);
        }
Exemplo n.º 33
0
 int INativeLibraryFacade.mdb_cursor_get(IntPtr cursor, ref ValueStructure key, ref ValueStructure data, CursorOperation op)
 {
     return FallbackLibraryFacade.mdb_cursor_get(cursor, ref key, ref data, op);
 }
Exemplo n.º 34
0
 public static int mdb_cursor_get_multiple(IntPtr cursor, ref ValueStructure key, ref ValueStructure value, CursorOperation op)
 {
     return checkRead(LmdbMethods.mdb_cursor_get(cursor, ref key, ref value, op));
 }
Exemplo n.º 35
0
 private static extern int mdb_del(IntPtr txn, UInt32 dbi, ref ValueStructure key, IntPtr data);
Exemplo n.º 36
0
 public static extern int mdb_del(IntPtr txn, uint dbi, ref ValueStructure key, ref ValueStructure data);
Exemplo n.º 37
0
 public static int mdb_cursor_get(IntPtr cursor, out ValueStructure key, out ValueStructure value, CursorOperation op)
 {
     key = value = default(ValueStructure);
     return(checkRead(LmdbMethods.mdb_cursor_get(cursor, ref key, ref value, op)));
 }
 int INativeLibraryFacade.mdb_del(IntPtr txn, uint dbi, ref ValueStructure key, ref ValueStructure data)
 {
     return(Native64BitLibraryFacade.mdb_del(txn, dbi, ref key, ref data));
 }
Exemplo n.º 39
0
 public static int mdb_cursor_put(IntPtr cursor, ref ValueStructure key, ValueStructure[] data, CursorPutOptions flags)
 {
     return(check(LmdbMethods.mdb_cursor_put(cursor, ref key, data, flags)));
 }
Exemplo n.º 40
0
 public static extern int mdb_put(IntPtr txn, uint dbi, ref ValueStructure key, ref ValueStructure data, PutOptions flags);