Exemplo n.º 1
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.º 2
0
        public static int mdb_dbi_open(IntPtr txn, string name, DatabaseOpenFlags flags, out uint db)
        {
            var statusCode = LmdbMethods.mdb_dbi_open(txn, name, flags, out db);

            if (statusCode == MDB_NOTFOUND)
            {
                throw new LightningException($"Error opening database {name}: {mdb_strerror(statusCode)}", statusCode);
            }
            return(check(statusCode));
        }
Exemplo n.º 3
0
        public static int mdb_del(IntPtr txn, uint dbi, byte[] key)
        {
            ValueStructure val = default(ValueStructure);

            using (var marshal = new MarshalValueStructure(key)) {
                var code = LmdbMethods.mdb_del(txn, dbi, ref marshal.Key, ref val);
                // not found is not an error
                if (code == 0 || code == MDB_NOTFOUND)
                {
                    return(code);
                }
                // throw exception otherwise
                return(check(code));
            }
        }
Exemplo n.º 4
0
 public static int mdb_get(IntPtr txn, uint dbi, byte[] key, out byte[] data)
 {
     using (var marshal = new MarshalValueStructure(key))
     {
         ValueStructure value;
         var            result = checkRead(LmdbMethods.mdb_get(txn, dbi, ref marshal.Key, out value));
         if (result == MDB_NOTFOUND)
         {
             data = null;
             return(result);
         }
         data = value.GetBytes();
         return(result);
     }
 }
Exemplo n.º 5
0
 public static IntPtr mdb_version(out int major, out int minor, out int patch)
 {
     return(LmdbMethods.mdb_version(out major, out minor, out patch));
 }
Exemplo n.º 6
0
 public static int mdb_cursor_renew(IntPtr txn, IntPtr cursor)
 {
     return(check(LmdbMethods.mdb_cursor_renew(txn, cursor)));
 }
Exemplo n.º 7
0
 public static int mdb_txn_renew(IntPtr txn)
 {
     return(check(LmdbMethods.mdb_txn_renew(txn)));
 }
Exemplo n.º 8
0
 public static int mdb_stat(IntPtr txn, uint dbi, out MDBStat stat)
 {
     return(check(LmdbMethods.mdb_stat(txn, dbi, out stat)));
 }
Exemplo n.º 9
0
 public static int mdb_set_dupsort(IntPtr txn, uint dbi, CompareFunction cmp)
 {
     return(check(LmdbMethods.mdb_set_dupsort(txn, dbi, cmp)));
 }
Exemplo n.º 10
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.º 11
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.º 12
0
 public static int mdb_env_stat(IntPtr env, out MDBStat stat)
 {
     return(check(LmdbMethods.mdb_env_stat(env, out stat)));
 }
Exemplo n.º 13
0
 public static int mdb_env_sync(IntPtr env, bool force)
 {
     return(check(LmdbMethods.mdb_env_sync(env, force)));
 }
Exemplo n.º 14
0
 public static int mdb_env_info(IntPtr env, out MDBEnvInfo stat)
 {
     return(check(LmdbMethods.mdb_env_info(env, out stat)));
 }
Exemplo n.º 15
0
 public static int mdb_env_copy2(IntPtr env, string path, EnvironmentCopyFlags copyFlags)
 {
     return(check(LmdbMethods.mdb_env_copy2(env, path, copyFlags)));
 }
Exemplo n.º 16
0
 public static int mdb_env_copy(IntPtr env, string path)
 {
     return(check(LmdbMethods.mdb_env_copy(env, path)));
 }
Exemplo n.º 17
0
 public static int mdb_cursor_get(IntPtr cursor, byte[] key, byte[] value, CursorOperation op)
 {
     using (var marshal = new MarshalValueStructure(key, value))
         return(checkRead(LmdbMethods.mdb_cursor_get(cursor, ref marshal.Key, ref marshal.Value, op)));
 }
Exemplo n.º 18
0
 public static int mdb_put(IntPtr txn, uint dbi, byte[] key, byte[] value, PutOptions flags)
 {
     using (var marshal = new MarshalValueStructure(key, value))
         return(check(LmdbMethods.mdb_put(txn, dbi, ref marshal.Key, ref marshal.Value, flags)));
 }
Exemplo n.º 19
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.º 20
0
 public static int mdb_del(IntPtr txn, uint dbi, byte[] key, byte[] value)
 {
     using (var marshal = new MarshalValueStructure(key, value))
         return(check(LmdbMethods.mdb_del(txn, dbi, ref marshal.Key, ref marshal.Value)));
 }
Exemplo n.º 21
0
 public static int mdb_cursor_put(IntPtr cursor, byte[] key, byte[] value, CursorPutOptions flags)
 {
     using (var marshal = new MarshalValueStructure(key, value))
         return(check(LmdbMethods.mdb_cursor_put(cursor, ref marshal.Key, ref marshal.Value, flags)));
 }
Exemplo n.º 22
0
 public static void mdb_env_close(IntPtr env)
 {
     LmdbMethods.mdb_env_close(env);
 }
Exemplo n.º 23
0
 public static int mdb_cursor_del(IntPtr cursor, CursorDeleteOption flags)
 {
     return(check(LmdbMethods.mdb_cursor_del(cursor, flags)));
 }
Exemplo n.º 24
0
 public static int mdb_env_set_mapsize(IntPtr env, long size)
 {
     return(check(LmdbMethods.mdb_env_set_mapsize(env, new IntPtr(size))));
 }
Exemplo n.º 25
0
 public static int mdb_env_create(out IntPtr env)
 {
     return(check(LmdbMethods.mdb_env_create(out env)));
 }
Exemplo n.º 26
0
        public static string mdb_strerror(int err)
        {
            var ptr = LmdbMethods.mdb_strerror(err);

            return(Marshal.PtrToStringAnsi(ptr));
        }
Exemplo n.º 27
0
 public static int mdb_env_open(IntPtr env, string path, EnvironmentOpenFlags flags, UnixAccessMode mode)
 {
     return(check(LmdbMethods.mdb_env_open(env, path, flags, mode)));
 }
Exemplo n.º 28
0
 public static int mdb_cursor_open(IntPtr txn, uint dbi, out IntPtr cursor)
 {
     return(check(LmdbMethods.mdb_cursor_open(txn, dbi, out cursor)));
 }
Exemplo n.º 29
0
 public static int mdb_env_get_maxreaders(IntPtr env, out uint readers)
 {
     return(check(LmdbMethods.mdb_env_get_maxreaders(env, out readers)));
 }
Exemplo n.º 30
0
 public static void mdb_cursor_close(IntPtr cursor)
 {
     LmdbMethods.mdb_cursor_close(cursor);
 }