当前位置: 首页>>代码示例>>Golang>>正文


Golang gorocksdb.NewDefaultReadOptions函数代码示例

本文整理汇总了Golang中github.com/tecbot/gorocksdb.NewDefaultReadOptions函数的典型用法代码示例。如果您正苦于以下问题:Golang NewDefaultReadOptions函数的具体用法?Golang NewDefaultReadOptions怎么用?Golang NewDefaultReadOptions使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了NewDefaultReadOptions函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: read_multi_cfs

func read_multi_cfs() error {
	dbOpts := gorocksdb.NewDefaultOptions()
	defaultRO := gorocksdb.NewDefaultReadOptions()
	db, handles, err := gorocksdb.OpenDbColumnFamilies(
		dbOpts,
		"/tmp/multicf_db",
		[]string{"default", "0", "1", "2", "3"},
		[]*gorocksdb.Options{dbOpts, dbOpts, dbOpts, dbOpts, dbOpts},
	)
	iters, err := gorocksext.NewIterators(defaultRO, db, handles)
	if err != nil {
		return err
	}
	for i, iter := range iters {
		fmt.Printf("COUTING FOR ITER: %d\n", i)
		iter.SeekToFirst()
		for iter.Valid() {
			fmt.Println(string(iter.Key().Data()))
			defer iter.Key().Free()
			iter.Next()
		}
	}
	db.Close()
	return nil
}
开发者ID:pavanka,项目名称:gorocksext_test,代码行数:25,代码来源:gorocksext.go

示例2: NewRocksdbStorage

func NewRocksdbStorage(dbfname string, dbtype string, mergeOp gorocksdb.MergeOperator) (*RocksdbStorage, error) {
	var sto *RocksdbStorage

	if dbtype != "kv" && dbtype != "json" {
		return sto, fmt.Errorf("Unkown db type")
	}

	opts := gorocksdb.NewDefaultOptions()

	if mergeOp != nil {
		opts.SetMergeOperator(mergeOp)
	}
	// opts.IncreaseParallelism(runtime.NumCPU())
	// opts.OptimizeLevelStyleCompaction(0)
	opts.SetCreateIfMissing(true)

	db, err := gorocksdb.OpenDb(opts, dbfname)
	if err != nil {
		return sto, err
	}
	ro := gorocksdb.NewDefaultReadOptions()
	wo := gorocksdb.NewDefaultWriteOptions()

	sto = &RocksdbStorage{
		dbfname: dbfname,
		db:      db,
		ro:      ro,
		wo:      wo,
	}
	return sto, nil
}
开发者ID:yuyang0,项目名称:gkv,代码行数:31,代码来源:rocksdb.go

示例3: RedisKeys

// Only support key prefix or all keys, e.g. "KEYS *" or "KEYS test*"
func (rh *RocksDBHandler) RedisKeys(pattern []byte) ([][]byte, error) {
	if rh.db == nil {
		return nil, ErrRocksIsDead
	}
	if pattern == nil || len(pattern) == 0 {
		return nil, ErrWrongArgumentsCount
	}
	if pattern[len(pattern)-1] == '*' {
		pattern = pattern[:len(pattern)-1]
	}

	options := rocks.NewDefaultReadOptions()
	defer options.Destroy()
	options.SetFillCache(false)

	data := make([][]byte, 0)
	it := rh.db.NewIterator(options)
	defer it.Close()
	it.Seek(pattern)
	for ; it.Valid(); it.Next() {
		key := it.Key()
		dKey := rh.copySlice(key, false)
		if bytes.HasPrefix(dKey, kTypeKeyPrefix) {
			continue
		}
		if !bytes.HasPrefix(dKey, pattern) {
			break
		}
		data = append(data, dKey)
	}
	if err := it.Err(); err != nil {
		return nil, err
	}
	return data, nil
}
开发者ID:ngaut,项目名称:gorockdis,代码行数:36,代码来源:rocks_keys.go

示例4: RedisDel

func (rh *RocksDBHandler) RedisDel(key []byte, keys ...[]byte) (int, error) {
	if rh.db == nil {
		return 0, ErrRocksIsDead
	}
	if key == nil || len(key) == 0 {
		return 0, ErrWrongArgumentsCount
	}

	keyData := append([][]byte{key}, keys...)
	count := 0
	readOptions := rocks.NewDefaultReadOptions()
	writeOptions := rocks.NewDefaultWriteOptions()
	defer readOptions.Destroy()
	defer writeOptions.Destroy()

	for _, dKey := range keyData {
		_, err := rh.loadRedisObject(readOptions, dKey)
		if err == nil {
			batch := rocks.NewWriteBatch()
			batch.Delete(rh.getTypeKey(dKey))
			batch.Delete(dKey)
			if err := rh.db.Write(writeOptions, batch); err == nil {
				count++
			}
			batch.Destroy()
		}
	}
	return count, nil
}
开发者ID:ngaut,项目名称:gorockdis,代码行数:29,代码来源:rocks_keys.go

示例5: Iterate

func (r *RocksDB) Iterate(key []byte) Iter {
	ro := gorocksdb.NewDefaultReadOptions()
	ro.SetFillCache(false)
	it := r.db.NewIterator(ro)
	it.Seek(key)
	return &rocksIter{iter: it}
}
开发者ID:sheki,项目名称:rocksiterbench,代码行数:7,代码来源:rocks.go

示例6: getSnapshotIterator

func (openchainDB *OpenchainDB) getSnapshotIterator(snapshot *gorocksdb.Snapshot, cfHandler *gorocksdb.ColumnFamilyHandle) *gorocksdb.Iterator {
	opt := gorocksdb.NewDefaultReadOptions()
	defer opt.Destroy()
	opt.SetSnapshot(snapshot)
	iter := openchainDB.DB.NewIteratorCF(opt, cfHandler)
	return iter
}
开发者ID:butine,项目名称:research,代码行数:7,代码来源:db.go

示例7: New

func New(rdb *gorocksdb.DB) *DB {
	db := &DB{rdb: rdb}
	db.wo = gorocksdb.NewDefaultWriteOptions()
	db.ro = gorocksdb.NewDefaultReadOptions()
	db.caches = lru.New(1000)
	db.RawSet([]byte{MAXBYTE}, nil) // for Enumerator seek to last
	return db
}
开发者ID:CowLeo,项目名称:GoRedis,代码行数:8,代码来源:db.go

示例8: RangeEnumerate

func (d *DB) RangeEnumerate(min, max []byte, direction IterDirection, fn func(i int, key, value []byte, quit *bool)) {
	opts := gorocksdb.NewDefaultReadOptions()
	opts.SetFillCache(false)
	defer opts.Destroy()
	iter := d.rdb.NewIterator(opts)
	defer iter.Close()
	d.Enumerate(iter, min, max, direction, fn)
}
开发者ID:CowLeo,项目名称:GoRedis,代码行数:8,代码来源:db.go

示例9: get

func (openchainDB *OpenchainDB) get(cfHandler *gorocksdb.ColumnFamilyHandle, key []byte) ([]byte, error) {
	opt := gorocksdb.NewDefaultReadOptions()
	slice, err := openchainDB.DB.GetCF(opt, cfHandler, key)
	if err != nil {
		fmt.Println("Error while trying to retrieve key:", key)
		return nil, err
	}
	return slice.Data(), nil
}
开发者ID:tenc,项目名称:obc-peer-pre-public,代码行数:9,代码来源:db.go

示例10: GetFromDB

// GetFromDB gets the value for the given key from default column-family
func (testDB *TestDBWrapper) GetFromDB(t testing.TB, key []byte) []byte {
	db := GetDBHandle().DB
	opt := gorocksdb.NewDefaultReadOptions()
	defer opt.Destroy()
	slice, err := db.Get(opt, key)
	defer slice.Free()
	if err != nil {
		t.Fatalf("Error while getting key-value from DB: %s", err)
	}
	value := append([]byte(nil), slice.Data()...)
	return value
}
开发者ID:C0rWin,项目名称:fabric,代码行数:13,代码来源:db_test_exports.go

示例11: get

func (openchainDB *OpenchainDB) get(cfHandler *gorocksdb.ColumnFamilyHandle, key []byte) ([]byte, error) {
	opt := gorocksdb.NewDefaultReadOptions()
	defer opt.Destroy()
	slice, err := openchainDB.DB.GetCF(opt, cfHandler, key)
	if err != nil {
		fmt.Println("Error while trying to retrieve key:", key)
		return nil, err
	}
	defer slice.Free()
	data := append([]byte(nil), slice.Data()...)
	return data, nil
}
开发者ID:butine,项目名称:research,代码行数:12,代码来源:db.go

示例12: getFromSnapshot

func (openchainDB *OpenchainDB) getFromSnapshot(snapshot *gorocksdb.Snapshot, cfHandler *gorocksdb.ColumnFamilyHandle, key []byte) ([]byte, error) {
	opt := gorocksdb.NewDefaultReadOptions()
	defer opt.Destroy()
	opt.SetSnapshot(snapshot)
	slice, err := openchainDB.DB.GetCF(opt, cfHandler, key)
	if err != nil {
		dbLogger.Errorf("Error while trying to retrieve key: %s", key)
		return nil, err
	}
	defer slice.Free()
	data := append([]byte(nil), slice.Data()...)
	return data, nil
}
开发者ID:yoshiharay,项目名称:fabric,代码行数:13,代码来源:db.go

示例13: GetSnapshot

func (db *rocksDB) GetSnapshot() (engine.Snapshot, error) {
	snap := db.rkdb.NewSnapshot()

	ropt := gorocksdb.NewDefaultReadOptions()
	ropt.SetFillCache(db.snapshotFillCache)
	ropt.SetSnapshot(snap)

	return &snapshot{
		db:   db,
		snap: snap,
		ropt: ropt,
	}, nil
}
开发者ID:pingcap,项目名称:tidbrocks,代码行数:13,代码来源:db.go

示例14: _list_getData

func (rh *RocksDBHandler) _list_getData(key []byte) ([][]byte, error) {
	options := rocks.NewDefaultReadOptions()
	defer options.Destroy()
	if obj, err := rh.loadRedisObject(options, key); err != nil {
		if err == ErrDoesNotExist {
			return [][]byte{}, nil
		}
		return nil, err
	} else {
		if obj.Type != kRedisList {
			return nil, ErrWrongTypeRedisObject
		}
		return obj.Data.([][]byte), nil
	}
}
开发者ID:ngaut,项目名称:gorockdis,代码行数:15,代码来源:rocks_lists.go

示例15: newReadOptions

func (s *Store) newReadOptions() *gorocksdb.ReadOptions {
	ro := gorocksdb.NewDefaultReadOptions()

	if s.roptVerifyChecksumsUse {
		ro.SetVerifyChecksums(s.roptVerifyChecksums)
	}
	if s.roptFillCacheUse {
		ro.SetFillCache(s.roptFillCache)
	}
	if s.roptReadTierUse {
		ro.SetReadTier(gorocksdb.ReadTier(s.roptReadTier))
	}

	return ro
}
开发者ID:blevesearch,项目名称:blevex,代码行数:15,代码来源:config.go


注:本文中的github.com/tecbot/gorocksdb.NewDefaultReadOptions函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。