示例#1
0
        private static EJDB_OPTS MapOptions(EJDB2Options options, Utf8StringPool pool)
        {
            var result = new EJDB_OPTS();

            result.no_wal                         = !options.UseWAL;
            result.sort_buffer_sz                 = options.SortBufferSize;
            result.document_buffer_sz             = options.DocumentBufferSize;
            result.kv.random_seed                 = options.IWKVOptions.RandomSeed;
            result.kv.oflags                      = options.IWKVOptions.OpenFlags;
            result.kv.file_lock_fail_fast         = options.IWKVOptions.FileLockFailFast;
            result.kv.path                        = pool.GetString(options.IWKVOptions.Path);
            result.kv.wal.check_crc_on_checkpoint = options.IWKVOptions.WALOptions.CheckCRCOnCheckpoint;
            result.kv.wal.savepoint_timeout_sec   = options.IWKVOptions.WALOptions.SavePointTimeoutSec;
            result.kv.wal.checkpoint_timeout_sec  = options.IWKVOptions.WALOptions.CheckPointTimeoutSec;
            result.kv.wal.wal_buffer_sz           = new UIntPtr(options.IWKVOptions.WALOptions.BufferSize);
            result.kv.wal.checkpoint_buffer_sz    = options.IWKVOptions.WALOptions.CheckpointBufferSize;
            result.http.enabled                   = options.HttpOptions.Enabled;
            result.http.port                      = options.HttpOptions.Port;
            result.http.bind                      = options.HttpOptions.Bind;
            result.http.access_token              = options.HttpOptions.AccessToken;
            result.http.access_token_len          = new UIntPtr((uint)(options.HttpOptions.AccessToken?.Length ?? 0));
            result.http.read_anon                 = options.HttpOptions.ReadAnon;
            result.http.max_body_size             = new UIntPtr(options.HttpOptions.MaxBodySize);

            return(result);
        }
示例#2
0
        public EJDB2Handle Open(EJDB2Options options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            IntPtr handle;
            ulong  rc;

            using (var pool = new Utf8StringPool())
            {
                EJDB_OPTS opts = MapOptions(options, pool);
                rc = _helper.ejdb_open(ref opts, out handle);
            }

            if (rc != 0)
            {
                throw _e.CreateException(rc);
            }

            return(new EJDB2Handle(handle));
        }