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

Commit

Permalink
Upgrade rockdb to 5.10.3; Use DeleteFilesInRange to accelerate cleanu…
Browse files Browse the repository at this point in the history
…p process

Summary: as titled

Test Plan: unit test and test in production

Reviewers: dikang, sdev

Differential Revision: https://phabricator.intern.facebook.com/D7134922
  • Loading branch information
wpc committed Mar 3, 2018
1 parent 4dff91b commit b5a1bb5
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@
<dependency groupId="org.openjdk.jmh" artifactId="jmh-generator-annprocess"/>
<dependency groupId="net.ju-n.compile-command-annotations" artifactId="compile-command-annotations"/>
<dependency groupId="org.apache.ant" artifactId="ant-junit" version="1.9.4" />
<dependency groupId="org.rocksdb" artifactId="rocksdbjni" version="5.8.0" scope="system" systemPath="${basedir}/lib/rocksdbjni-5.8.0.jar"/>
<dependency groupId="org.rocksdb" artifactId="rocksdbjni" version="5.10.3" scope="system" systemPath="${basedir}/lib/rocksdbjni-5.10.3.jar"/>
</artifact:pom>
<!-- this build-deps-pom-sources "artifact" is the same as build-deps-pom but only with those
artifacts that have "-source.jar" files -->
Expand Down
Binary file added lib/rocksdbjni-5.10.3.jar
Binary file not shown.
Binary file removed lib/rocksdbjni-5.8.0.jar
Binary file not shown.
3 changes: 3 additions & 0 deletions src/java/org/apache/cassandra/rocksdb/RocksDBCF.java
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,10 @@ public void merge(DecoratedKey partitionKey, byte[] key, byte[] value) throws Ro
public void deleteRange(byte[] start, byte[] end) throws RocksDBException
{
for (RocksDB rocksDB : rocksDBLists)
{
rocksDB.deleteFilesInRange(start, end);
rocksDB.deleteRange(start, end);
}
}

public void compactRange() throws RocksDBException
Expand Down
27 changes: 27 additions & 0 deletions test/unit/org/apache/cassandra/rocksdb/RocksDBCFTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,33 @@ private byte[] encodeValue(ColumnFamilyStore cfs, String value)
return RowValueEncoder.encode(cfs.metadata, builder.build());
}

@Test
public void testDeleteRange() throws RocksDBException
{
createTable("CREATE TABLE %s (p text, c text, v text, PRIMARY KEY (p, c))");
ColumnFamilyStore cfs = getCurrentColumnFamilyStore();

RocksDBCF rocksDBCF = RocksDBEngine.getRocksDBCF(cfs.metadata.cfId);

byte[] a = "a".getBytes();
byte[] b = "b".getBytes();
byte[] c = "c".getBytes();
byte[] d = "d".getBytes();
byte[] value = encodeValue(cfs, "test_value");

rocksDBCF.merge(dk, a, value);
rocksDBCF.merge(dk, b, value);
rocksDBCF.merge(dk, c, value);
rocksDBCF.merge(dk, d, value);

rocksDBCF.deleteRange(b, d);
rocksDBCF.compactRange();
assertArrayEquals(value, rocksDBCF.get(dk, a));
assertNull(rocksDBCF.get(dk, b));
assertNull(rocksDBCF.get(dk, c));
assertArrayEquals(value, rocksDBCF.get(dk, d));
}

@Test
public void testTruncate() throws RocksDBException
{
Expand Down

0 comments on commit b5a1bb5

Please sign in to comment.