public void Test3() { string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "mdbx2"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } using (MdbxEnvironment env = new MdbxEnvironment()) { EnvironmentFlag flags = EnvironmentFlag.NoTLS | EnvironmentFlag.NoMetaSync | EnvironmentFlag.Coalesce | EnvironmentFlag.LifoReclaim; env.SetMaxDatabases(20) .SetMaxReaders(128) .SetMapSize(10485760 * 10) .Open(path, flags, Convert.ToInt32("666", 8)); DatabaseOption option = DatabaseOption.Create | DatabaseOption.IntegerKey; // add some values using (MdbxTransaction tran = env.BeginTransaction()) { MdbxDatabase db = tran.OpenDatabase("cursor_test3", option); for (long i = 0; i < 1000000; i++) { db.Put(i, Guid.NewGuid().ToByteArray()); } tran.Commit(); } using (MdbxTransaction tran = env.BeginTransaction(TransactionOption.ReadOnly)) { MdbxDatabase db = tran.OpenDatabase("cursor_test3", option); using (MdbxCursor cursor = db.OpenCursor()) { long key = 0; byte[] value = null; cursor.Get(ref key, ref value, CursorOp.First); long index = 0; Assert.Equal(index, key); key = 0; value = null; while (cursor.Get(ref key, ref value, CursorOp.Next)) { index++; Assert.Equal(index, key); } } } env.Close(); } }
public static void Open(IntPtr env, string path, EnvironmentFlag flags, int mode) { int err = _openDelegate(env, path, (int)flags, mode); if (err != 0) { throw new MdbxException("mdbx_env_open", err); } }
public static void SetFlags(IntPtr env, EnvironmentFlag flags, bool onoff) { int err = _setFlagsDelegate(env, (uint)flags, onoff ? 1 : 0); if (err != 0) { throw new MdbxException("mdbx_env_set_flags", err); } }
public void SetFlags(EnvironmentFlag flags, SetOption option = SetOption.Add) { if (!closed && _envPtr != IntPtr.Zero) { Env.SetFlags(_envPtr, flags, option == SetOption.Add); } else { throw new InvalidOperationException("MDBX environment is not open."); } }
public IHost BuildHost() #endif { // SAMPLE: what-the-cli-is-doing // The --log-level flag value overrides your application's // LogLevel if (LogLevelFlag.HasValue) { Console.WriteLine($"Overwriting the minimum log level to {LogLevelFlag.Value}"); HostBuilder.ConfigureLogging(x => x.SetMinimumLevel(LogLevelFlag.Value)); } if (VerboseFlag) { Console.WriteLine("Verbose flag is on."); // The --verbose flag adds console and // debug logging, as well as setting // the minimum logging level down to debug HostBuilder.ConfigureLogging(x => { x.SetMinimumLevel(LogLevel.Debug); }); } // The --environment flag is used to set the environment // property on the IHostedEnvironment within your system if (EnvironmentFlag.IsNotEmpty()) { Console.WriteLine($"Overwriting the environment to `{EnvironmentFlag}`"); HostBuilder.UseEnvironment(EnvironmentFlag); } if (ConfigFlag.Any()) { HostBuilder.ConfigureAppConfiguration(c => c.AddInMemoryCollection(ConfigFlag)); } // ENDSAMPLE return(HostBuilder.Build()); }
public void Test3() { string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "mdbx"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } using (MdbxEnvironment env = new MdbxEnvironment()) { env.Open(path, EnvironmentFlag.NoTLS, Convert.ToInt32("666", 8)); EnvironmentFlag flags = env.GetFlags(); env.SetFlags(EnvironmentFlag.NoSync); env.Close(); } }
public JasperRuntime BuildRuntime() { // SAMPLE: what-the-cli-is-doing // The --log-level flag value overrides your application's // LogLevel if (LogLevelFlag.HasValue) { Registry.ConfigureLogging(x => x.SetMinimumLevel(LogLevelFlag.Value)); } if (VerboseFlag) { Console.WriteLine("Verbose flag is on."); // The --verbose flag adds console and // debug logging, as well as setting // the minimum logging level down to debug Registry.ConfigureLogging(x => { x.SetMinimumLevel(LogLevel.Debug); x.AddConsole(); x.AddDebug(); }); } // The --environment flag is used to set the environment // property on the IHostedEnvironment within your system if (EnvironmentFlag.IsNotEmpty()) { Registry.UseEnvironment(EnvironmentFlag); } // ENDSAMPLE return(JasperRuntime.For(Registry)); }
/// <summary> /// Open an environment handle. /// /// This function allocates memory for a MDBX_env structure. To release /// the allocated memory and discard the handle, call mdbx_env_close(). /// possible exceptions are: /// - MDBX_VERSION_MISMATCH - the version of the MDBX library doesn't match the /// version that created the database environment. /// - MDBX_INVALID - the environment file headers are corrupted. /// - MDBX_ENOENT - the directory specified by the path parameter /// doesn't exist. /// - MDBX_EACCES - the user didn't have permission to access /// the environment files. /// - MDBX_EAGAIN - the environment was locked by another process. /// </summary> /// <param name="path"></param> /// <param name="flags"></param> /// <param name="mode"></param> public void Open(string path, EnvironmentFlag flags, int mode) { Env.Open(_envPtr, path, flags, mode); }