Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt RocksDB 8.5.3 #126

Merged
merged 1 commit into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions array_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
)

func TestBytesToCSlice(t *testing.T) {
t.Parallel()

v, err := byteSlicesToCSlices(nil)
require.Nil(t, v)
require.Nil(t, err)
Expand Down
18 changes: 10 additions & 8 deletions backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
)

func TestBackupEngine(t *testing.T) {
t.Parallel()

db := newTestDB(t, nil)
defer db.Close()

Expand Down Expand Up @@ -63,7 +65,7 @@ func TestBackupEngine(t *testing.T) {
opts.Destroy()
}()

t.Run("createBackupAndVerify", func(t *testing.T) {
{
infos := engine.GetInfo()
require.Empty(t, infos)

Expand All @@ -80,25 +82,25 @@ func TestBackupEngine(t *testing.T) {
require.True(t, infos[i].Size > 0)
require.True(t, infos[i].NumFiles > 0)
}
})
}

t.Run("purge", func(t *testing.T) {
{
require.Nil(t, engine.PurgeOldBackups(1))

infos := engine.GetInfo()
require.Equal(t, 1, len(infos))
})
}

t.Run("restoreFromLatest", func(t *testing.T) {
{
dir := t.TempDir()

ro := NewRestoreOptions()
defer ro.Destroy()
require.Nil(t, engine.RestoreDBFromLatestBackup(dir, dir, ro))
require.Nil(t, engine.RestoreDBFromLatestBackup(dir, dir, ro))
})
}

t.Run("restoreFromBackup", func(t *testing.T) {
{
infos := engine.GetInfo()
require.Equal(t, 1, len(infos))

Expand Down Expand Up @@ -127,5 +129,5 @@ func TestBackupEngine(t *testing.T) {
require.False(t, v4.Exists())
v4.Destroy()
}
})
}
}
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ cd $BUILD_PATH && wget https://github.com/facebook/zstd/archive/v${zstd_version}

# Note: if you don't have a good reason, please do not set -DPORTABLE=ON
# This one is set here on purpose of compatibility with github action runtime processor
rocksdb_version="8.4.4"
rocksdb_version="8.5.3"
cd $BUILD_PATH && wget https://github.com/facebook/rocksdb/archive/v${rocksdb_version}.tar.gz && tar xzf v${rocksdb_version}.tar.gz && cd rocksdb-${rocksdb_version}/ && \
mkdir -p build_place && cd build_place && cmake -DCMAKE_BUILD_TYPE=Release $CMAKE_REQUIRED_PARAMS -DCMAKE_PREFIX_PATH=$INSTALL_PREFIX -DWITH_TESTS=OFF -DWITH_GFLAGS=OFF \
-DWITH_BENCHMARK_TOOLS=OFF -DWITH_TOOLS=OFF -DWITH_MD_LIBRARY=OFF -DWITH_RUNTIME_DEBUG=OFF -DROCKSDB_BUILD_SHARED=OFF -DWITH_SNAPPY=ON -DWITH_LZ4=ON -DWITH_ZLIB=ON -DWITH_LIBURING=OFF \
Expand Down
19 changes: 18 additions & 1 deletion c.h
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,16 @@ rocksdb_create_column_family(rocksdb_t* db,
const rocksdb_options_t* column_family_options,
const char* column_family_name, char** errptr);

extern ROCKSDB_LIBRARY_API rocksdb_column_family_handle_t**
rocksdb_create_column_families(rocksdb_t* db,
const rocksdb_options_t* column_family_options,
int num_column_families,
const char* const* column_family_names,
size_t* lencfs, char** errptr);

extern ROCKSDB_LIBRARY_API void rocksdb_create_column_families_destroy(
rocksdb_column_family_handle_t** list);

extern ROCKSDB_LIBRARY_API rocksdb_column_family_handle_t*
rocksdb_create_column_family_with_ttl(
rocksdb_t* db, const rocksdb_options_t* column_family_options,
Expand Down Expand Up @@ -1518,7 +1528,8 @@ extern ROCKSDB_LIBRARY_API void rocksdb_options_set_hash_skip_list_rep(
extern ROCKSDB_LIBRARY_API void rocksdb_options_set_hash_link_list_rep(
rocksdb_options_t*, size_t);
extern ROCKSDB_LIBRARY_API void rocksdb_options_set_plain_table_factory(
rocksdb_options_t*, uint32_t, int, double, size_t);
rocksdb_options_t*, uint32_t, int, double, size_t, size_t, char,
unsigned char, unsigned char);

extern ROCKSDB_LIBRARY_API void rocksdb_options_set_min_level_to_compress(
rocksdb_options_t* opt, int level);
Expand Down Expand Up @@ -2446,6 +2457,12 @@ extern ROCKSDB_LIBRARY_API char* rocksdb_transactiondb_property_value(
extern ROCKSDB_LIBRARY_API int rocksdb_transactiondb_property_int(
rocksdb_transactiondb_t* db, const char* propname, uint64_t* out_val);

extern ROCKSDB_LIBRARY_API rocksdb_t* rocksdb_transactiondb_get_base_db(
rocksdb_transactiondb_t* txn_db);

extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_close_base_db(
rocksdb_t* base_db);

extern ROCKSDB_LIBRARY_API rocksdb_transaction_t* rocksdb_transaction_begin(
rocksdb_transactiondb_t* txn_db,
const rocksdb_writeoptions_t* write_options,
Expand Down
8 changes: 8 additions & 0 deletions cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
)

func TestLRUCache(t *testing.T) {
t.Parallel()

cache := NewLRUCache(19)
defer cache.Destroy()

Expand All @@ -18,6 +20,8 @@ func TestLRUCache(t *testing.T) {
}

func TestHyperClockCache(t *testing.T) {
t.Parallel()

cache := NewHyperClockCache(100, 10)
defer cache.Destroy()

Expand All @@ -29,6 +33,8 @@ func TestHyperClockCache(t *testing.T) {
}

func TestLRUCacheWithOpts(t *testing.T) {
t.Parallel()

opts := NewLRUCacheOptions()
opts.SetCapacity(19)
opts.SetNumShardBits(2)
Expand All @@ -45,6 +51,8 @@ func TestLRUCacheWithOpts(t *testing.T) {
}

func TestHyperClockCacheWithOpts(t *testing.T) {
t.Parallel()

opts := NewHyperClockCacheOptions(100, 10)
opts.SetCapacity(19)
opts.SetEstimatedEntryCharge(10)
Expand Down
22 changes: 19 additions & 3 deletions cf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
)

func TestColumnFamilyOpen(t *testing.T) {
t.Parallel()

dir := t.TempDir()

givenNames := []string{"default", "guide"}
Expand All @@ -22,12 +24,18 @@ func TestColumnFamilyOpen(t *testing.T) {
cfh[0].Destroy()
cfh[1].Destroy()

actualNames, err := ListColumnFamilies(opts, dir)
require.Nil(t, err)
require.EqualValues(t, actualNames, givenNames)
for i := 0; i < 10; i++ {
actualNames, err := ListColumnFamilies(opts, dir)
require.Nil(t, err)
require.EqualValues(t, actualNames, givenNames)

runtime.GC()
}
}

func TestColumnFamilyCreateDrop(t *testing.T) {
t.Parallel()

dir := t.TempDir()

opts := NewDefaultOptions()
Expand All @@ -53,6 +61,8 @@ func TestColumnFamilyCreateDrop(t *testing.T) {
}

func TestColumnFamilyBatchPutGet(t *testing.T) {
t.Parallel()

dir := t.TempDir()

givenNames := []string{"default", "guide"}
Expand Down Expand Up @@ -139,6 +149,8 @@ func TestColumnFamilyBatchPutGet(t *testing.T) {
}

func TestColumnFamilyPutGetDelete(t *testing.T) {
t.Parallel()

dir := t.TempDir()

givenNames := []string{"default", "guide"}
Expand Down Expand Up @@ -244,6 +256,8 @@ func newTestDBCF(t *testing.T) (db *DB, cfh []*ColumnFamilyHandle, cleanup func(
}

func TestColumnFamilyMultiGet(t *testing.T) {
t.Parallel()

db, cfh, cleanup := newTestDBCF(t)
defer cleanup()

Expand Down Expand Up @@ -314,6 +328,8 @@ func TestColumnFamilyMultiGet(t *testing.T) {
}

func TestCFMetadata(t *testing.T) {
t.Parallel()

db := newTestDB(t, nil)
defer db.Close()
meta := db.GetColumnFamilyMetadata()
Expand Down
4 changes: 4 additions & 0 deletions cf_ts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
)

func TestColumnFamilyPutGetDeleteWithTS(t *testing.T) {
t.Parallel()

dir := t.TempDir()

givenNames := []string{"default", "guide"}
Expand Down Expand Up @@ -96,6 +98,8 @@ func TestColumnFamilyPutGetDeleteWithTS(t *testing.T) {
}

func TestColumnFamilyMultiGetWithTS(t *testing.T) {
t.Parallel()

db, cfh, cleanup := newTestDBMultiCF(t, []string{"default", "custom"}, func(opts *Options) {
opts.SetComparator(newDefaultComparatorWithTS())
})
Expand Down
1 change: 1 addition & 0 deletions checkpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
)

func TestCheckpoint(t *testing.T) {
t.Parallel()

dir := t.TempDir()
err := os.RemoveAll(dir)
Expand Down
2 changes: 2 additions & 0 deletions compaction_filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
)

func TestCompactionFilter(t *testing.T) {
t.Parallel()

var (
changeKey = []byte("change")
changeValOld = []byte("old")
Expand Down
2 changes: 2 additions & 0 deletions comparator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
)

func TestComparator(t *testing.T) {
t.Parallel()

db, opts := newTestDBAndOpts(t, func(opts *Options) {
opts.SetComparator(NewComparator("rev", func(a, b []byte) int {
return bytes.Compare(a, b) * -1
Expand Down
2 changes: 2 additions & 0 deletions comparator_ts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
)

func TestComparatorWithTS(t *testing.T) {
t.Parallel()

db, opts := newTestDBAndOpts(t, func(opts *Options) {
comp := newComparatorWithTimeStamp(
"rev",
Expand Down
4 changes: 4 additions & 0 deletions cow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
)

func TestCOWList(t *testing.T) {
t.Parallel()

cl := NewCOWList()
cl.Append("hello")
cl.Append("world")
Expand All @@ -19,6 +21,8 @@ func TestCOWList(t *testing.T) {
}

func TestCOWListMT(t *testing.T) {
t.Parallel()

cl := NewCOWList()
expectedRes := make([]int, 3)
var wg sync.WaitGroup
Expand Down
33 changes: 33 additions & 0 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -1269,6 +1269,39 @@ func (db *DB) CreateColumnFamily(opts *Options, name string) (handle *ColumnFami
return
}

// CreateColumnFamilies creates new column families.
func (db *DB) CreateColumnFamilies(opts *Options, names []string) (handles []*ColumnFamilyHandle, err error) {
if len(names) == 0 {
return nil, nil
}

var cErr *C.char

n := len(names)
cNames := make([]*C.char, 0, n)
cSizes := make([]C.size_t, 0, n)
for i := range names {
cNames = append(cNames, C.CString(names[i]))
cSizes = append(cSizes, C.size_t(len(names[i])))
}

cHandles := C.rocksdb_create_column_families(db.c, opts.c, C.int(n), &cNames[0], &cSizes[0], &cErr)
if err = fromCError(cErr); err == nil {
tmp := unsafe.Slice(cHandles, n)

handles = make([]*ColumnFamilyHandle, 0, n)
for i := range tmp {
handles = append(handles, newNativeColumnFamilyHandle(tmp[i]))
}
}

for i := range cNames {
C.free(unsafe.Pointer(cNames[i]))
}

return
}

// CreateColumnFamilyWithTTL create a new column family along with its ttl.
//
// BEHAVIOUR:
Expand Down
4 changes: 4 additions & 0 deletions db_external_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
)

func TestExternalFile(t *testing.T) {
t.Parallel()

db := newTestDB(t, nil)
defer db.Close()

Expand Down Expand Up @@ -56,6 +58,8 @@ func TestExternalFile(t *testing.T) {
}

func TestExternalFileWithTS(t *testing.T) {
t.Parallel()

db := newTestDB(t, func(opts *Options) {
opts.SetComparator(newDefaultComparatorWithTS())
})
Expand Down
Loading