Esempio 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)));
     }
 }
Esempio 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));
        }
Esempio 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));
            }
        }
Esempio 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);
     }
 }
Esempio 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));
 }
Esempio n. 6
0
 public static int mdb_cursor_renew(IntPtr txn, IntPtr cursor)
 {
     return(check(LmdbMethods.mdb_cursor_renew(txn, cursor)));
 }
Esempio n. 7
0
 public static int mdb_txn_renew(IntPtr txn)
 {
     return(check(LmdbMethods.mdb_txn_renew(txn)));
 }
Esempio n. 8
0
 public static int mdb_stat(IntPtr txn, uint dbi, out MDBStat stat)
 {
     return(check(LmdbMethods.mdb_stat(txn, dbi, out stat)));
 }
Esempio n. 9
0
 public static int mdb_set_dupsort(IntPtr txn, uint dbi, CompareFunction cmp)
 {
     return(check(LmdbMethods.mdb_set_dupsort(txn, dbi, cmp)));
 }
Esempio 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)));
 }
Esempio 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)));
 }
Esempio n. 12
0
 public static int mdb_env_stat(IntPtr env, out MDBStat stat)
 {
     return(check(LmdbMethods.mdb_env_stat(env, out stat)));
 }
Esempio n. 13
0
 public static int mdb_env_sync(IntPtr env, bool force)
 {
     return(check(LmdbMethods.mdb_env_sync(env, force)));
 }
Esempio n. 14
0
 public static int mdb_env_info(IntPtr env, out MDBEnvInfo stat)
 {
     return(check(LmdbMethods.mdb_env_info(env, out stat)));
 }
Esempio n. 15
0
 public static int mdb_env_copy2(IntPtr env, string path, EnvironmentCopyFlags copyFlags)
 {
     return(check(LmdbMethods.mdb_env_copy2(env, path, copyFlags)));
 }
Esempio n. 16
0
 public static int mdb_env_copy(IntPtr env, string path)
 {
     return(check(LmdbMethods.mdb_env_copy(env, path)));
 }
Esempio 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)));
 }
Esempio 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)));
 }
Esempio 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)));
 }
Esempio 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)));
 }
Esempio 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)));
 }
Esempio n. 22
0
 public static void mdb_env_close(IntPtr env)
 {
     LmdbMethods.mdb_env_close(env);
 }
Esempio n. 23
0
 public static int mdb_cursor_del(IntPtr cursor, CursorDeleteOption flags)
 {
     return(check(LmdbMethods.mdb_cursor_del(cursor, flags)));
 }
Esempio 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))));
 }
Esempio n. 25
0
 public static int mdb_env_create(out IntPtr env)
 {
     return(check(LmdbMethods.mdb_env_create(out env)));
 }
Esempio n. 26
0
        public static string mdb_strerror(int err)
        {
            var ptr = LmdbMethods.mdb_strerror(err);

            return(Marshal.PtrToStringAnsi(ptr));
        }
Esempio 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)));
 }
Esempio 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)));
 }
Esempio 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)));
 }
Esempio n. 30
0
 public static void mdb_cursor_close(IntPtr cursor)
 {
     LmdbMethods.mdb_cursor_close(cursor);
 }