Esempio n. 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;
 }
Esempio n. 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);
        }
Esempio n. 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;
        }
Esempio n. 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);
            }
        }
Esempio n. 5
0
 public void Delete(byte[] key, WriteOptions options)
 {
     LevelDBImpl.Delete(_dbHandle, options.Handle, key);
 }
Esempio n. 6
0
 public void Put(byte[] key, byte[] value, WriteOptions options)
 {
     LevelDBImpl.Put(_dbHandle, options.Handle, key, value);
 }
Esempio n. 7
0
 public byte[] Get(byte[] key, ReadOptions options)
 {
     return(LevelDBImpl.Get(_dbHandle, options.Handle, key));
 }
Esempio n. 8
0
 public void Next()
 {
     LevelDBImpl.leveldb_iter_next(_handle);
 }
Esempio n. 9
0
 public void Previous()
 {
     LevelDBImpl.leveldb_iter_prev(_handle);
 }
Esempio n. 10
0
 public void Seek(string key)
 {
     LevelDBImpl.leveldb_iter_seek(_handle, key, key.UTF8Length());
 }
Esempio n. 11
0
 public void SeekToLast()
 {
     LevelDBImpl.leveldb_iter_seek_to_last(_handle);
 }
Esempio n. 12
0
 public void SeekToFirst()
 {
     LevelDBImpl.leveldb_iter_seek_to_first(_handle);
 }
Esempio n. 13
0
 public static Cache Create(int capacity)
 {
     return(new Cache(LevelDBImpl.leveldb_cache_create_lru((UIntPtr)capacity)));
 }
Esempio n. 14
0
 public WriteOptions()
 {
     _handle = LevelDBImpl.leveldb_writeoptions_create();
 }
Esempio n. 15
0
 public ReadOptions()
 {
     _handle = LevelDBImpl.leveldb_readoptions_create();
 }