-
Notifications
You must be signed in to change notification settings - Fork 68
/
cf_handle.go
44 lines (36 loc) · 1.19 KB
/
cf_handle.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package grocksdb
// #include <stdlib.h>
// #include "rocksdb/c.h"
import "C"
// ColumnFamilyHandle represents a handle to a ColumnFamily.
type ColumnFamilyHandle struct {
c *C.rocksdb_column_family_handle_t
}
// NewNativeColumnFamilyHandle creates a ColumnFamilyHandle object.
func newNativeColumnFamilyHandle(c *C.rocksdb_column_family_handle_t) *ColumnFamilyHandle {
return &ColumnFamilyHandle{c: c}
}
// ID returned id of Column family.
func (h *ColumnFamilyHandle) ID() uint32 {
return uint32(C.rocksdb_column_family_handle_get_id(h.c))
}
// Name returned name of Column family.
func (h *ColumnFamilyHandle) Name() string {
var len C.size_t
cValue := C.rocksdb_column_family_handle_get_name(h.c, &len)
return toString(cValue, C.int(len))
}
// Destroy calls the destructor of the underlying column family handle.
func (h *ColumnFamilyHandle) Destroy() {
C.rocksdb_column_family_handle_destroy(h.c)
h.c = nil
}
// ColumnFamilyHandles represents collection of multiple column family handle.
type ColumnFamilyHandles []*ColumnFamilyHandle
func (cfs ColumnFamilyHandles) toCSlice() columnFamilySlice {
cCFs := make(columnFamilySlice, len(cfs))
for i, cf := range cfs {
cCFs[i] = cf.c
}
return cCFs
}