CheckError() public static method

public static CheckError ( IntPtr error ) : void
error IntPtr
return void
コード例 #1
0
        private void CheckError()
        {
            IntPtr error;

            leveldb_iter_get_error(handle, out error);
            NativeHelper.CheckError(error);
        }
コード例 #2
0
        public void Put(WriteOptions options, Slice key, Slice value)
        {
            IntPtr error;

            leveldb_put(handle, options.handle, key.buffer, (UIntPtr)key.buffer.Length, value.buffer, (UIntPtr)value.buffer.Length, out error);
            NativeHelper.CheckError(error);
        }
コード例 #3
0
        public void Delete(WriteOptions options, Slice key)
        {
            IntPtr error;

            leveldb_delete(handle, options.handle, key.buffer, (UIntPtr)key.buffer.Length, out error);
            NativeHelper.CheckError(error);
        }
コード例 #4
0
        public void Write(WriteOptions options, WriteBatch write_batch)
        {
            // There's a bug in .Net Core.
            // When calling DB.Write(), it will throw LevelDbException sometimes.
            // But when you try to catch the exception, the bug disappears.
            // We shall remove the "try...catch" clause when Microsoft fix the bug.
            byte retry = 0;

            while (true)
            {
                try
                {
                    IntPtr error;
                    leveldb_write(handle, options.handle, write_batch.Handle, out error);
                    NativeHelper.CheckError(error);
                    break;
                }
                catch (LevelDbException ex)
                {
                    if (++retry >= 4)
                    {
                        throw;
                    }
                    System.IO.File.AppendAllText("leveldb.log", ex.Message + "\r\n");
                }
            }
        }
コード例 #5
0
        public static DatabaseContext Open(string name, Options options)
        {
            IntPtr error;
            IntPtr handle = leveldb_open(options.Handle, name, out error);

            NativeHelper.CheckError(error);
            return(new DatabaseContext(handle));
        }
コード例 #6
0
        public Slice Get(ReadOptions options, Slice key)
        {
            UIntPtr length;
            IntPtr  error;
            IntPtr  value = leveldb_get(handle, options.handle, key.buffer, (UIntPtr)key.buffer.Length, out length, out error);

            try
            {
                NativeHelper.CheckError(error);
                if (value == IntPtr.Zero)
                {
                    throw new LevelDbException("not found");
                }
                return(new Slice(value, length));
            }
            finally
            {
                if (value != IntPtr.Zero)
                {
                    leveldb_free(value);
                }
            }
        }