示例#1
0
文件: options.go 项目: C0rWin/fabric
// SetComparator sets the comparator which define the order of keys in the table.
// Default: a comparator that uses lexicographic byte-wise ordering
func (opts *Options) SetComparator(value Comparator) {
	if nc, ok := value.(nativeComparator); ok {
		opts.ccmp = nc.c
	} else {
		idx := registerComperator(value)
		opts.ccmp = C.gorocksdb_comparator_create(C.uintptr_t(idx))
	}
	C.rocksdb_options_set_comparator(opts.c, opts.ccmp)
}
示例#2
0
// Comparator used to define the order of keys in the table.
// Default: a comparator that uses lexicographic byte-wise ordering
func (self *Options) SetComparator(value Comparator) {
	if nc, ok := value.(nativeComparator); ok {
		self.ccmp = nc.c
	} else {
		h := unsafe.Pointer(&value)
		self.cmp = &value
		self.ccmp = C.gorocksdb_comparator_create(h)
	}
	C.rocksdb_options_set_comparator(self.c, self.ccmp)
}