本文整理汇总了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
}
示例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
}
示例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
}
示例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
}
示例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}
}
示例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
}
示例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
}
示例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)
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
}
示例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
}