Example #1
0
File: db.go Project: 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
}
Example #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
}
Example #3
0
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
}
Example #4
0
// 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)
}
Example #5
0
// 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)}
}
Example #6
0
File: db.go Project: 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)
}