Ejemplo n.º 1
0
// destroyOptions destroys the options used for creating, reading, and writing
// from the db. It is meant to be used in conjunction with createOptions.
func (r *RocksDB) destroyOptions() {
	C.rocksdb_options_destroy(r.opts)
	C.rocksdb_readoptions_destroy(r.rOpts)
	C.rocksdb_writeoptions_destroy(r.wOpts)
	r.opts = nil
	r.rOpts = nil
	r.wOpts = nil
}
Ejemplo n.º 2
0
// destroyOptions destroys the options used for creating, reading, and writing
// from the db. It is meant to be used in conjunction with createOptions.
func (r *RocksDB) destroyOptions() {
	// The merge operator is stored inside of r.opts as a std::shared_ptr,
	// so it will actually be freed automatically.
	// Calling rocksdb_mergeoperator_destroy will ignore that shared_ptr,
	// and a subsequent rocksdb_options_destroy would segfault.
	// The following line zeroes the shared_ptr instead, effectively
	// deallocating the merge operator if one is set.
	C.rocksdb_options_set_merge_operator(r.opts, nil)
	C.rocksdb_options_destroy(r.opts)
	C.rocksdb_readoptions_destroy(r.rOpts)
	C.rocksdb_writeoptions_destroy(r.wOpts)
	r.mergeOperator = nil
	r.opts = nil
	r.rOpts = nil
	r.wOpts = nil
}
Ejemplo n.º 3
0
// Destroy deallocates the Options object.
func (opts *Options) Destroy() {
	C.rocksdb_options_destroy(opts.c)
	if opts.ccmp != nil {
		C.rocksdb_comparator_destroy(opts.ccmp)
	}
	if opts.cmo != nil {
		C.rocksdb_mergeoperator_destroy(opts.cmo)
	}
	if opts.cst != nil {
		C.rocksdb_slicetransform_destroy(opts.cst)
	}
	if opts.ccf != nil {
		C.rocksdb_compactionfilter_destroy(opts.ccf)
	}
	opts.c = nil
	opts.env = nil
	opts.bbto = nil
}
Ejemplo n.º 4
0
// destroyOptions destroys the options used for creating, reading, and writing
// from the db. It is meant to be used in conjunction with createOptions.
func (r *RocksDB) destroyOptions() {
	// The merge operator and compaction filter are stored inside of
	// r.opts using std::shared_ptrs, so they'll be freed
	// automatically. Calling the *_destroy methods directly would
	// ignore the shared_ptrs, and a subsequent rocksdb_options_destroy
	// would segfault. The following lines zero the shared_ptrs instead,
	// which deletes the underlying values.
	C.rocksdb_options_set_merge_operator(r.opts, nil)
	C.rocksdb_options_set_compaction_filter_factory(r.opts, nil)
	C.rocksdb_options_destroy(r.opts)
	C.rocksdb_readoptions_destroy(r.rOpts)
	C.rocksdb_writeoptions_destroy(r.wOpts)
	r.mergeOperator = nil
	r.compactionFilterFactory = nil
	r.opts = nil
	r.rOpts = nil
	r.wOpts = nil
}
Ejemplo n.º 5
0
// Destroy deallocates the Options object.
func (self *Options) Destroy() {
	C.rocksdb_options_destroy(self.c)
	if self.ccmp != nil {
		C.rocksdb_comparator_destroy(self.ccmp)
	}
	if self.cmo != nil {
		C.rocksdb_mergeoperator_destroy(self.cmo)
	}
	if self.cst != nil {
		C.rocksdb_slicetransform_destroy(self.cst)
	}
	if self.ccf != nil {
		C.rocksdb_compactionfilter_destroy(self.ccf)
	}
	self.c = nil
	self.cmp = nil
	self.mo = nil
	self.env = nil
	self.st = nil
	self.cf = nil
	self.bbto = nil
}
Ejemplo n.º 6
0
Archivo: db.go Proyecto: tradia/gotable
func (db *DB) Close() {
	if db.db != nil {
		C.rocksdb_close(db.db)
		db.db = nil

		if db.opt != nil {
			C.rocksdb_options_destroy(db.opt)
		}
		if db.rOpt != nil {
			C.rocksdb_readoptions_destroy(db.rOpt)
		}
		if db.wOpt != nil {
			C.rocksdb_writeoptions_destroy(db.wOpt)
		}
		if db.cache != nil {
			C.rocksdb_cache_destroy(db.cache)
		}
		if db.fp != nil {
			C.rocksdb_filterpolicy_destroy(db.fp)
		}
	}
}
Ejemplo n.º 7
0
// Close deallocates the Options, freeing its underlying C struct.
func (o *Options) Close() {
	C.rocksdb_options_destroy(o.Opt)
}
Ejemplo n.º 8
0
// Close deallocates the Options, freeing its underlying C struct.
func (o *Options) Close() {
	C.rocksdb_options_destroy(o.Opt)
	C.rocksdb_block_based_options_destroy(o.Bopt)
}