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 9.6.1 #165

Merged
merged 4 commits into from
Oct 21, 2024
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
6 changes: 3 additions & 3 deletions backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ func TestBackupEngine(t *testing.T) {

// retrieve
v1, err := db.Get(ro, givenKey)
defer v1.Free()
require.Nil(t, err)
require.EqualValues(t, v1.Data(), givenVal1)
v1.Free()

// retrieve bytes
_v1, err := db.GetBytes(ro, givenKey)
Expand All @@ -39,15 +39,15 @@ func TestBackupEngine(t *testing.T) {
// update
require.Nil(t, db.Put(wo, givenKey, givenVal2))
v2, err := db.Get(ro, givenKey)
defer v2.Free()
require.Nil(t, err)
require.EqualValues(t, v2.Data(), givenVal2)
v2.Free()

// retrieve pinned
v3, err := db.GetPinned(ro, givenKey)
defer v3.Destroy()
require.Nil(t, err)
require.EqualValues(t, v3.Data(), givenVal2)
v3.Destroy()

engine, err := CreateBackupEngine(db)
require.Nil(t, err)
Expand Down
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="9.5.2"
rocksdb_version="9.6.1"
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
16 changes: 8 additions & 8 deletions cf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,18 @@ func TestColumnFamilyBatchPutGet(t *testing.T) {
b0.PutCF(cfh[0], givenKey0, givenVal0)
require.Nil(t, db.Write(wo, b0))
actualVal0, err := db.GetCF(ro, cfh[0], givenKey0)
defer actualVal0.Free()
require.Nil(t, err)
require.EqualValues(t, actualVal0.Data(), givenVal0)
actualVal0.Free()

b1 := NewWriteBatch()
defer b1.Destroy()
b1.PutCF(cfh[1], givenKey1, givenVal1)
require.Nil(t, db.Write(wo, b1))
actualVal1, err := db.GetCF(ro, cfh[1], givenKey1)
defer actualVal1.Free()
require.Nil(t, err)
require.EqualValues(t, actualVal1.Data(), givenVal1)
actualVal1.Free()

actualVal, err := db.GetCF(ro, cfh[0], givenKey1)
require.Nil(t, err)
Expand All @@ -113,8 +113,8 @@ func TestColumnFamilyBatchPutGet(t *testing.T) {

{
v := db.KeyMayExistsCF(ro, cfh[0], givenKey0, "")
defer v.Free()
require.True(t, v.Size() > 0)
v.Free()
}

// trigger flush
Expand Down Expand Up @@ -178,15 +178,15 @@ func TestColumnFamilyPutGetDelete(t *testing.T) {
{
require.Nil(t, db.PutCF(wo, cfh[0], givenKey0, givenVal0))
actualVal0, err := db.GetCF(ro, cfh[0], givenKey0)
defer actualVal0.Free()
require.Nil(t, err)
require.EqualValues(t, actualVal0.Data(), givenVal0)
actualVal0.Free()

require.Nil(t, db.PutCF(wo, cfh[1], givenKey1, givenVal1))
actualVal1, err := db.GetCF(ro, cfh[1], givenKey1)
defer actualVal1.Free()
require.Nil(t, err)
require.EqualValues(t, actualVal1.Data(), givenVal1)
actualVal1.Free()

actualVal, err := db.GetCF(ro, cfh[0], givenKey1)
require.Nil(t, err)
Expand All @@ -202,26 +202,26 @@ func TestColumnFamilyPutGetDelete(t *testing.T) {

{
v := db.KeyMayExistsCF(ro, cfh[0], givenKey0, "")
defer v.Free()
v.Free()
}
}

{
require.Nil(t, db.PutCF(wo, cfh[0], givenKey0, givenVal0))
actualVal0, err := db.GetCF(ro, cfh[0], givenKey0)
defer actualVal0.Free()
require.Nil(t, err)
require.EqualValues(t, actualVal0.Data(), givenVal0)
actualVal0.Free()

require.Nil(t, db.DeleteRangeCF(wo, cfh[0], givenKey0, givenKey1))
actualVal, err := db.GetCF(ro, cfh[0], givenKey0)
require.Nil(t, err)
require.EqualValues(t, actualVal.Size(), 0)

actualVal1, err := db.GetCF(ro, cfh[1], givenKey1)
defer actualVal1.Free()
require.Nil(t, err)
require.EqualValues(t, actualVal1.Data(), givenVal1)
actualVal1.Free()
}
}

Expand Down
49 changes: 22 additions & 27 deletions cf_ts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,58 +42,58 @@ func TestColumnFamilyPutGetDeleteWithTS(t *testing.T) {

require.Nil(t, db.PutCFWithTS(wo, cfh[0], givenKey0, givenTs0, givenVal0))
actualVal0, actualTs0, err := db.GetCFWithTS(ro, cfh[0], givenKey0)
defer actualVal0.Free()
defer actualTs0.Free()
require.Nil(t, err)
require.EqualValues(t, actualVal0.Data(), givenVal0)
require.EqualValues(t, actualTs0.Data(), givenTs0)
actualVal0.Free()
actualTs0.Free()

require.Nil(t, db.PutCFWithTS(wo, cfh[1], givenKey1, givenTs1, givenVal1))
actualVal1, actualTs1, err := db.GetCFWithTS(ro, cfh[1], givenKey1)
defer actualVal1.Free()
defer actualTs1.Free()
require.Nil(t, err)
require.EqualValues(t, actualVal1.Data(), givenVal1)
require.EqualValues(t, actualTs1.Data(), givenTs1)
actualVal1.Free()
actualTs1.Free()

actualVal, actualTs, err := db.GetCFWithTS(ro, cfh[0], givenKey1)
defer actualVal.Free()
defer actualTs.Free()
require.Nil(t, err)
require.EqualValues(t, actualVal.Size(), 0)
require.EqualValues(t, actualTs.Size(), 0)
actualVal.Free()
actualTs.Free()

actualVal, actualTs, err = db.GetCFWithTS(ro, cfh[1], givenKey0)
defer actualVal.Free()
defer actualTs.Free()
require.Nil(t, err)
require.EqualValues(t, actualVal.Size(), 0)
require.EqualValues(t, actualTs.Size(), 0)
actualVal.Free()
actualTs.Free()

require.Nil(t, db.DeleteCFWithTS(wo, cfh[0], givenKey0, givenTs2))
actualVal, actualTs, err = db.GetCFWithTS(ro, cfh[0], givenKey0)
defer actualVal.Free()
defer actualTs.Free()
require.Nil(t, err)
require.EqualValues(t, actualVal.Size(), 0)
require.EqualValues(t, actualTs.Size(), 0)
actualVal.Free()
actualTs.Free()
}

{
require.Nil(t, db.PutCFWithTS(wo, cfh[0], givenKey0, givenTs2, givenVal0))
actualVal0, actualTs0, err := db.GetCFWithTS(ro, cfh[0], givenKey0)
defer actualVal0.Free()
defer actualTs0.Free()
require.Nil(t, err)
require.EqualValues(t, actualVal0.Data(), givenVal0)
require.EqualValues(t, actualTs0.Data(), givenTs2)
actualVal0.Free()
actualTs0.Free()

actualVal1, actualTs1, err := db.GetCFWithTS(ro, cfh[1], givenKey1)
defer actualVal1.Free()
defer actualTs1.Free()
require.Nil(t, err)
require.EqualValues(t, actualVal1.Data(), givenVal1)
require.EqualValues(t, actualTs1.Data(), givenTs1)
actualVal1.Free()
actualTs1.Free()
}
}

Expand Down Expand Up @@ -131,11 +131,8 @@ func TestColumnFamilyMultiGetWithTS(t *testing.T) {

// column family 0 only has givenKey1
values, times, err := db.MultiGetCFWithTS(ro, cfh[0], []byte("noexist"), givenKey1, givenKey2, givenKey3)
defer values.Destroy()
defer times.Destroy()
require.Nil(t, err)
require.EqualValues(t, len(values), 4)

require.EqualValues(t, values[0].Data(), []byte(nil))
require.EqualValues(t, values[1].Data(), givenVal1)
require.EqualValues(t, values[2].Data(), []byte(nil))
Expand All @@ -145,39 +142,37 @@ func TestColumnFamilyMultiGetWithTS(t *testing.T) {
require.EqualValues(t, times[1].Data(), givenTs1)
require.EqualValues(t, times[2].Data(), []byte(nil))
require.EqualValues(t, times[3].Data(), []byte(nil))
values.Destroy()
times.Destroy()

// column family 1 only has givenKey2 and givenKey3
values, times, err = db.MultiGetCFWithTS(ro, cfh[1], []byte("noexist"), givenKey1, givenKey2, givenKey3)
defer values.Destroy()
defer times.Destroy()
require.Nil(t, err)
require.EqualValues(t, len(values), 4)

require.EqualValues(t, values[0].Data(), []byte(nil))
require.EqualValues(t, values[1].Data(), []byte(nil))
require.EqualValues(t, values[2].Data(), givenVal2)
require.EqualValues(t, values[3].Data(), givenVal3)

require.EqualValues(t, times[0].Data(), []byte(nil))
require.EqualValues(t, times[1].Data(), []byte(nil))
require.EqualValues(t, times[2].Data(), givenTs2)
require.EqualValues(t, times[3].Data(), givenTs3)
values.Destroy()
times.Destroy()

// getting them all from the right CF should return them all
// getting them all from the right CF
values, times, err = db.MultiGetMultiCFWithTS(ro,
ColumnFamilyHandles{cfh[0], cfh[1], cfh[1]},
[][]byte{givenKey1, givenKey2, givenKey3},
)
defer values.Destroy()
defer times.Destroy()
require.Nil(t, err)
require.EqualValues(t, len(values), 3)

require.EqualValues(t, values[0].Data(), givenVal1)
require.EqualValues(t, values[1].Data(), givenVal2)
require.EqualValues(t, values[2].Data(), givenVal3)

require.EqualValues(t, times[0].Data(), []byte{})
require.EqualValues(t, times[0].Data(), []byte{0, 0, 0, 0, 0, 0, 0, 0})
require.EqualValues(t, times[1].Data(), givenTs2)
require.EqualValues(t, times[2].Data(), givenTs3)
values.Destroy()
times.Destroy()
}
16 changes: 8 additions & 8 deletions db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ func TestDBCRUD(t *testing.T) {

// retrieve
v1, err := db.Get(ro, givenKey)
defer v1.Free()
require.Nil(t, err)
require.EqualValues(t, v1.Data(), givenVal1)
v1.Free()

{
_v1, err := db.GetCF(ro, df, givenKey)
defer _v1.Free()
require.Nil(t, err)
require.EqualValues(t, _v1.Data(), givenVal1)
_v1.Free()
}

// retrieve bytes
Expand All @@ -86,9 +86,9 @@ func TestDBCRUD(t *testing.T) {
// update
require.Nil(t, db.Put(wo, givenKey, givenVal2))
v2, err := db.Get(ro, givenKey)
defer v2.Free()
require.Nil(t, err)
require.EqualValues(t, v2.Data(), givenVal2)
v2.Free()

// retrieve pinned
for i := 0; i < 1000; i++ {
Expand Down Expand Up @@ -153,40 +153,40 @@ func TestDBCRUDDBPaths(t *testing.T) {

// retrieve
v1, err := db.Get(ro, givenKey)
defer v1.Free()
require.Nil(t, err)
require.True(t, v1.Exists())
require.EqualValues(t, v1.Data(), givenVal1)
v1.Free()

// update
require.Nil(t, db.Put(wo, givenKey, givenVal2))
v2, err := db.Get(ro, givenKey)
defer v2.Free()
require.Nil(t, err)
require.True(t, v2.Exists())
require.EqualValues(t, v2.Data(), givenVal2)
v2.Free()

// update
require.Nil(t, db.Put(wo, givenKey, givenVal3))
v3, err := db.Get(ro, givenKey)
defer v3.Free()
require.Nil(t, err)
require.True(t, v3.Exists())
require.EqualValues(t, v3.Data(), givenVal3)
v3.Free()

{
v4 := db.KeyMayExists(ro, givenKey, "")
defer v4.Free()
require.True(t, v4.Size() > 0)
v4.Free()
}

// delete
require.Nil(t, db.SingleDelete(wo, givenKey))
v4, err := db.Get(ro, givenKey)
defer v4.Free()
require.Nil(t, err)
require.False(t, v4.Exists())
require.EqualValues(t, v4.Data(), []byte(nil))
v4.Free()
}

func newTestDB(t *testing.T, applyOpts func(opts *Options)) *DB {
Expand Down
20 changes: 10 additions & 10 deletions db_ts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ func TestDBCRUDWithTS(t *testing.T) {

// retrieve
v1, t1, err := db.GetWithTS(ro, givenKey)
defer v1.Free()
defer t1.Free()
require.Nil(t, err)
require.EqualValues(t, v1.Data(), givenVal1)
require.EqualValues(t, t1.Data(), givenTs1)
v1.Free()
t1.Free()

// retrieve bytes
_v1, _ts1, err := db.GetBytesWithTS(ro, givenKey)
Expand All @@ -51,39 +51,39 @@ func TestDBCRUDWithTS(t *testing.T) {
require.Nil(t, db.PutWithTS(wo, givenKey, givenTs2, givenVal2))
ro.SetTimestamp(givenTs2)
v2, t2, err := db.GetWithTS(ro, givenKey)
defer v2.Free()
defer t2.Free()
require.Nil(t, err)
require.EqualValues(t, v2.Data(), givenVal2)
require.EqualValues(t, t2.Data(), givenTs2)
v2.Free()
t2.Free()

// delete
require.Nil(t, db.DeleteWithTS(wo, givenKey, givenTs3))
ro.SetTimestamp(givenTs3)
v3, t3, err := db.GetWithTS(ro, givenKey)
defer v3.Free()
defer t3.Free()
require.Nil(t, err)
require.True(t, v3.Data() == nil)
require.True(t, t3.Data() == nil)
v3.Free()
t3.Free()

// ts2 should read deleted data
ro.SetTimestamp(givenTs2)
v2, t2, err = db.GetWithTS(ro, givenKey)
defer v2.Free()
defer t2.Free()
require.Nil(t, err)
require.EqualValues(t, v2.Data(), givenVal2)
require.EqualValues(t, t2.Data(), givenTs2)
v2.Free()
t2.Free()

// ts1 should read old data
ro.SetTimestamp(givenTs1)
v1, t1, err = db.GetWithTS(ro, givenKey)
defer v1.Free()
defer t1.Free()
require.Nil(t, err)
require.EqualValues(t, v1.Data(), givenVal1)
require.EqualValues(t, t1.Data(), givenTs1)
v1.Free()
t1.Free()
}

func TestDBMultiGetWithTS(t *testing.T) {
Expand Down
Loading
Loading