示例#1
0
文件: db.go 项目: tradia/gotable
func (db *DB) NewReadOptions(createSnapshot bool) *ReadOptions {
	var opt = new(ReadOptions)
	opt.rOpt = C.rocksdb_readoptions_create()
	if createSnapshot {
		opt.snap = C.rocksdb_create_snapshot(db.db)
		C.rocksdb_readoptions_set_snapshot(opt.rOpt, opt.snap)
		opt.db = db.db
	}
	return opt
}
示例#2
0
// CreateSnapshot creates a snapshot handle from engine.
func (r *RocksDB) CreateSnapshot(snapshotID string) error {
	if r.rdb == nil {
		return util.Errorf("RocksDB is not initialized yet")
	}
	_, ok := r.snapshots[snapshotID]
	if ok {
		return util.Errorf("snapshotID %s already exists", snapshotID)
	}
	snapshotHandle := C.rocksdb_create_snapshot(r.rdb)
	r.snapshots[snapshotID] = snapshotHandle
	return nil
}
示例#3
0
文件: db.go 项目: malloc-fi/vantaa
func (db *DB) NewSnapshot() (driver.ISnapshot, error) {
	snap := &Snapshot{
		db:           db,
		snap:         C.rocksdb_create_snapshot(db.db),
		readOpts:     NewReadOptions(),
		iteratorOpts: NewReadOptions(),
	}
	snap.readOpts.SetSnapshot(snap)
	snap.iteratorOpts.SetSnapshot(snap)
	snap.iteratorOpts.SetFillCache(false)

	return snap, nil
}
示例#4
0
文件: db.go 项目: rdallman/gorocksdb
// NewSnapshot creates a new snapshot of the database.
func (self *DB) NewSnapshot() *Snapshot {
	cSnap := C.rocksdb_create_snapshot(self.c)

	return NewNativeSnapshot(cSnap, self.c)
}
示例#5
0
文件: db.go 项目: cayleydb/dgraph
// NewSnapshot creates a new snapshot of the database.
//
// The snapshot, when used in a ReadOptions, provides a consistent view of
// state of the database at the the snapshot was created.
//
// To prevent memory leaks and resource strain in the database, the snapshot
// returned must be released with DB.ReleaseSnapshot method on the DB that
// created it.
//
// See the LevelDB documentation for details.
func (db *DB) NewSnapshot() *Snapshot {
	return &Snapshot{C.rocksdb_create_snapshot(db.Ldb)}
}
示例#6
0
文件: db.go 项目: C0rWin/fabric
// NewSnapshot creates a new snapshot of the database.
func (db *DB) NewSnapshot() *Snapshot {
	cSnap := C.rocksdb_create_snapshot(db.c)
	return NewNativeSnapshot(cSnap, db.c)
}