Skip to content

Commit

Permalink
Revert "Compatible with RocksDB v6.16, tecbot#203"
Browse files Browse the repository at this point in the history
This reverts commit 9decd5d.
  • Loading branch information
roysc committed Jul 1, 2021
1 parent 8e10788 commit 2224ff8
Show file tree
Hide file tree
Showing 10 changed files with 128 additions and 374 deletions.
67 changes: 0 additions & 67 deletions .github/workflows/ci.yml

This file was deleted.

2 changes: 1 addition & 1 deletion checkpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ func TestCheckpoint(t *testing.T) {
opts := NewDefaultOptions()
opts.SetCreateIfMissing(true)
dbCheck, err = OpenDb(opts, dir)
ensure.Nil(t, err)
defer dbCheck.Close()
ensure.Nil(t, err)

// test keys
var value *Slice
Expand Down
83 changes: 83 additions & 0 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,89 @@ func (db *DB) DropColumnFamily(c *ColumnFamilyHandle) error {
return nil
}

// GetApproximateSizes returns the approximate number of bytes of file system
// space used by one or more key ranges.
//
// The keys counted will begin at Range.Start and end on the key before
// Range.Limit.
func (db *DB) GetApproximateSizes(ranges []Range) []uint64 {
sizes := make([]uint64, len(ranges))
if len(ranges) == 0 {
return sizes
}

cStarts := make([]*C.char, len(ranges))
cLimits := make([]*C.char, len(ranges))
cStartLens := make([]C.size_t, len(ranges))
cLimitLens := make([]C.size_t, len(ranges))
for i, r := range ranges {
cStarts[i] = (*C.char)(C.CBytes(r.Start))
cStartLens[i] = C.size_t(len(r.Start))
cLimits[i] = (*C.char)(C.CBytes(r.Limit))
cLimitLens[i] = C.size_t(len(r.Limit))
}

defer func() {
for i := range ranges {
C.free(unsafe.Pointer(cStarts[i]))
C.free(unsafe.Pointer(cLimits[i]))
}
}()

C.rocksdb_approximate_sizes(
db.c,
C.int(len(ranges)),
&cStarts[0],
&cStartLens[0],
&cLimits[0],
&cLimitLens[0],
(*C.uint64_t)(&sizes[0]))

return sizes
}

// GetApproximateSizesCF returns the approximate number of bytes of file system
// space used by one or more key ranges in the column family.
//
// The keys counted will begin at Range.Start and end on the key before
// Range.Limit.
func (db *DB) GetApproximateSizesCF(cf *ColumnFamilyHandle, ranges []Range) []uint64 {
sizes := make([]uint64, len(ranges))
if len(ranges) == 0 {
return sizes
}

cStarts := make([]*C.char, len(ranges))
cLimits := make([]*C.char, len(ranges))
cStartLens := make([]C.size_t, len(ranges))
cLimitLens := make([]C.size_t, len(ranges))
for i, r := range ranges {
cStarts[i] = (*C.char)(C.CBytes(r.Start))
cStartLens[i] = C.size_t(len(r.Start))
cLimits[i] = (*C.char)(C.CBytes(r.Limit))
cLimitLens[i] = C.size_t(len(r.Limit))
}

defer func() {
for i := range ranges {
C.free(unsafe.Pointer(cStarts[i]))
C.free(unsafe.Pointer(cLimits[i]))
}
}()

C.rocksdb_approximate_sizes_cf(
db.c,
cf.c,
C.int(len(ranges)),
&cStarts[0],
&cStartLens[0],
&cLimits[0],
&cLimitLens[0],
(*C.uint64_t)(&sizes[0]))

return sizes
}

// SetOptions dynamically changes options through the SetOptions API.
func (db *DB) SetOptions(keys, values []string) error {
num_keys := len(keys)
Expand Down
91 changes: 0 additions & 91 deletions db_6.go

This file was deleted.

108 changes: 0 additions & 108 deletions db_6_16.go

This file was deleted.

Loading

0 comments on commit 2224ff8

Please sign in to comment.