Skip to content
This repository was archived by the owner on Sep 28, 2023. It is now read-only.

Commit b5a1bb5

Browse files
committed
Upgrade rockdb to 5.10.3; Use DeleteFilesInRange to accelerate cleanup process
Summary: as titled Test Plan: unit test and test in production Reviewers: dikang, sdev Differential Revision: https://phabricator.intern.facebook.com/D7134922
1 parent 4dff91b commit b5a1bb5

File tree

5 files changed

+31
-1
lines changed

5 files changed

+31
-1
lines changed

build.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@
479479
<dependency groupId="org.openjdk.jmh" artifactId="jmh-generator-annprocess"/>
480480
<dependency groupId="net.ju-n.compile-command-annotations" artifactId="compile-command-annotations"/>
481481
<dependency groupId="org.apache.ant" artifactId="ant-junit" version="1.9.4" />
482-
<dependency groupId="org.rocksdb" artifactId="rocksdbjni" version="5.8.0" scope="system" systemPath="${basedir}/lib/rocksdbjni-5.8.0.jar"/>
482+
<dependency groupId="org.rocksdb" artifactId="rocksdbjni" version="5.10.3" scope="system" systemPath="${basedir}/lib/rocksdbjni-5.10.3.jar"/>
483483
</artifact:pom>
484484
<!-- this build-deps-pom-sources "artifact" is the same as build-deps-pom but only with those
485485
artifacts that have "-source.jar" files -->

lib/rocksdbjni-5.10.3.jar

5.23 MB
Binary file not shown.

lib/rocksdbjni-5.8.0.jar

-5.54 MB
Binary file not shown.

src/java/org/apache/cassandra/rocksdb/RocksDBCF.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,10 @@ public void merge(DecoratedKey partitionKey, byte[] key, byte[] value) throws Ro
325325
public void deleteRange(byte[] start, byte[] end) throws RocksDBException
326326
{
327327
for (RocksDB rocksDB : rocksDBLists)
328+
{
329+
rocksDB.deleteFilesInRange(start, end);
328330
rocksDB.deleteRange(start, end);
331+
}
329332
}
330333

331334
public void compactRange() throws RocksDBException

test/unit/org/apache/cassandra/rocksdb/RocksDBCFTest.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,33 @@ private byte[] encodeValue(ColumnFamilyStore cfs, String value)
7070
return RowValueEncoder.encode(cfs.metadata, builder.build());
7171
}
7272

73+
@Test
74+
public void testDeleteRange() throws RocksDBException
75+
{
76+
createTable("CREATE TABLE %s (p text, c text, v text, PRIMARY KEY (p, c))");
77+
ColumnFamilyStore cfs = getCurrentColumnFamilyStore();
78+
79+
RocksDBCF rocksDBCF = RocksDBEngine.getRocksDBCF(cfs.metadata.cfId);
80+
81+
byte[] a = "a".getBytes();
82+
byte[] b = "b".getBytes();
83+
byte[] c = "c".getBytes();
84+
byte[] d = "d".getBytes();
85+
byte[] value = encodeValue(cfs, "test_value");
86+
87+
rocksDBCF.merge(dk, a, value);
88+
rocksDBCF.merge(dk, b, value);
89+
rocksDBCF.merge(dk, c, value);
90+
rocksDBCF.merge(dk, d, value);
91+
92+
rocksDBCF.deleteRange(b, d);
93+
rocksDBCF.compactRange();
94+
assertArrayEquals(value, rocksDBCF.get(dk, a));
95+
assertNull(rocksDBCF.get(dk, b));
96+
assertNull(rocksDBCF.get(dk, c));
97+
assertArrayEquals(value, rocksDBCF.get(dk, d));
98+
}
99+
73100
@Test
74101
public void testTruncate() throws RocksDBException
75102
{

0 commit comments

Comments
 (0)