Exemple #1
0
 internal Iterator(DB db, ReadOptions opt)
 {
     _db = db;
     if (opt == null)
     {
         opt = new ReadOptions();
     }
     _handle     = LevelDBImpl.leveldb_create_iterator(db._dbHandle, opt.Handle);
     IsFirstMove = true;
 }
Exemple #2
0
        private void OpenImpl(string name)
        {
            if (_optionsHandle == IntPtr.Zero)
            {
                SetOptions();
            }
            IntPtr err;

            _dbHandle = LevelDBImpl.leveldb_open(_optionsHandle, name, out err);
            LevelDBImpl.ThrowError(err);
        }
Exemple #3
0
        private void SetOptions(bool createIfMissing = false, bool errorIfExists = false, bool paranoidChecks = false, int writeBufferSize = 0, int maxOpenFile = 0, Cache blockCache = null, int blockSize = 0, int blockRestartInterval = 0, CompressionType compressionType = CompressionType.NoCompression)
        {
            IntPtr handle = LevelDBImpl.leveldb_options_create();

            if (createIfMissing)
            {
                LevelDBImpl.leveldb_options_set_create_if_missing(handle, true);
            }

            if (errorIfExists)
            {
                LevelDBImpl.leveldb_options_set_error_if_exists(handle, true);
            }

            if (paranoidChecks)
            {
                LevelDBImpl.leveldb_options_set_paranoid_checks(handle, true);
            }

            if (writeBufferSize > 0)
            {
                LevelDBImpl.leveldb_options_set_write_buffer_size(handle, (UIntPtr)writeBufferSize);
            }

            if (maxOpenFile > 0)
            {
                LevelDBImpl.leveldb_options_set_max_open_files(handle, maxOpenFile);
            }

            if (blockCache != null)
            {
                LevelDBImpl.leveldb_options_set_cache(handle, blockCache.Handle);
            }

            if (blockSize > 0)
            {
                LevelDBImpl.leveldb_options_set_block_size(handle, (UIntPtr)blockSize);
            }

            if (blockRestartInterval > 0)
            {
                LevelDBImpl.leveldb_options_set_block_restart_interval(handle, blockRestartInterval);
            }

            LevelDBImpl.leveldb_options_set_compression(handle, (int)compressionType);

            _optionsHandle = handle;
        }
Exemple #4
0
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
            }

            if (_optionsHandle != IntPtr.Zero)
            {
                LevelDBImpl.leveldb_options_destroy(_optionsHandle);
            }

            if (_dbHandle != IntPtr.Zero)
            {
                LevelDBImpl.leveldb_close(_dbHandle);
            }
        }
Exemple #5
0
 public void Delete(byte[] key, WriteOptions options)
 {
     LevelDBImpl.Delete(_dbHandle, options.Handle, key);
 }
Exemple #6
0
 public void Put(byte[] key, byte[] value, WriteOptions options)
 {
     LevelDBImpl.Put(_dbHandle, options.Handle, key, value);
 }
Exemple #7
0
 public byte[] Get(byte[] key, ReadOptions options)
 {
     return(LevelDBImpl.Get(_dbHandle, options.Handle, key));
 }
Exemple #8
0
 public void Next()
 {
     LevelDBImpl.leveldb_iter_next(_handle);
 }
Exemple #9
0
 public void Previous()
 {
     LevelDBImpl.leveldb_iter_prev(_handle);
 }
Exemple #10
0
 public void Seek(string key)
 {
     LevelDBImpl.leveldb_iter_seek(_handle, key, key.UTF8Length());
 }
Exemple #11
0
 public void SeekToLast()
 {
     LevelDBImpl.leveldb_iter_seek_to_last(_handle);
 }
Exemple #12
0
 public void SeekToFirst()
 {
     LevelDBImpl.leveldb_iter_seek_to_first(_handle);
 }
Exemple #13
0
 public static Cache Create(int capacity)
 {
     return(new Cache(LevelDBImpl.leveldb_cache_create_lru((UIntPtr)capacity)));
 }
Exemple #14
0
 public WriteOptions()
 {
     _handle = LevelDBImpl.leveldb_writeoptions_create();
 }
Exemple #15
0
 public ReadOptions()
 {
     _handle = LevelDBImpl.leveldb_readoptions_create();
 }