forked from facebook/rocksdb
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add deletion-triggered compaction to RocksJava (facebook#12028)
Summary: Pull Request resolved: facebook#12028 Reviewed By: akankshamahajan15 Differential Revision: D52264983 Pulled By: ajkr fbshipit-source-id: 02d08015b4bffac06d889dc1be50a51d03f891b3
- Loading branch information
1 parent
66ef68b
commit f7486ff
Showing
8 changed files
with
199 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// Created by rhubner on 23-Oct-23. | ||
// | ||
|
||
#include "java/rocksjni/table_properties_collector_factory.h" | ||
|
||
#include "java/include/org_rocksdb_TablePropertiesCollectorFactory.h" | ||
#include "java/rocksjni/cplusplus_to_java_convert.h" | ||
#include "rocksdb/db.h" | ||
#include "rocksdb/utilities/table_properties_collectors.h" | ||
|
||
/* | ||
* Class: org_rocksdb_TablePropertiesCollectorFactory | ||
* Method: newCompactOnDeletionCollectorFactory | ||
* Signature: (JJD)J | ||
*/ | ||
jlong Java_org_rocksdb_TablePropertiesCollectorFactory_newCompactOnDeletionCollectorFactory( | ||
JNIEnv *, jclass, jlong sliding_window_size, jlong deletion_trigger, | ||
jdouble deletion_ratio) { | ||
auto *wrapper = new TablePropertiesCollectorFactoriesJniWrapper(); | ||
wrapper->table_properties_collector_factories = | ||
ROCKSDB_NAMESPACE::NewCompactOnDeletionCollectorFactory( | ||
sliding_window_size, deletion_trigger, deletion_ratio); | ||
return GET_CPLUSPLUS_POINTER(wrapper); | ||
} | ||
|
||
/* | ||
* Class: org_rocksdb_TablePropertiesCollectorFactory | ||
* Method: deleteCompactOnDeletionCollectorFactory | ||
* Signature: (J)J | ||
*/ | ||
void Java_org_rocksdb_TablePropertiesCollectorFactory_deleteCompactOnDeletionCollectorFactory( | ||
JNIEnv *, jclass, jlong jhandle) { | ||
auto instance = | ||
reinterpret_cast<TablePropertiesCollectorFactoriesJniWrapper *>(jhandle); | ||
delete instance; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// Created by rhubner on 24-Oct-23. | ||
// | ||
|
||
#include "rocksdb/table_properties.h" | ||
#include "rocksdb/utilities/table_properties_collectors.h" | ||
|
||
#ifndef ROCKSDB_TABLE_PROPERTIES_COLLECTOR_FACTORY_H | ||
#define ROCKSDB_TABLE_PROPERTIES_COLLECTOR_FACTORY_H | ||
|
||
struct TablePropertiesCollectorFactoriesJniWrapper { | ||
std::shared_ptr<rocksdb::TablePropertiesCollectorFactory> | ||
table_properties_collector_factories; | ||
}; | ||
#endif // ROCKSDB_TABLE_PROPERTIES_COLLECTOR_FACTORY_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
java/src/main/java/org/rocksdb/TablePropertiesCollectorFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.rocksdb; | ||
|
||
public abstract class TablePropertiesCollectorFactory extends RocksObject { | ||
private TablePropertiesCollectorFactory(final long nativeHandle) { | ||
super(nativeHandle); | ||
} | ||
|
||
public static TablePropertiesCollectorFactory NewCompactOnDeletionCollectorFactory( | ||
final long sliding_window_size, final long deletion_trigger, final double deletion_ratio) { | ||
long handle = | ||
newCompactOnDeletionCollectorFactory(sliding_window_size, deletion_trigger, deletion_ratio); | ||
return new TablePropertiesCollectorFactory(handle) { | ||
@Override | ||
protected void disposeInternal(long handle) { | ||
TablePropertiesCollectorFactory.deleteCompactOnDeletionCollectorFactory(handle); | ||
} | ||
}; | ||
} | ||
|
||
/** | ||
* Internal API. Do not use. | ||
* @param nativeHandle | ||
* @return | ||
*/ | ||
static TablePropertiesCollectorFactory newWrapper(final long nativeHandle) { | ||
return new TablePropertiesCollectorFactory(nativeHandle) { | ||
@Override | ||
protected void disposeInternal(long handle) { | ||
TablePropertiesCollectorFactory.deleteCompactOnDeletionCollectorFactory(handle); | ||
} | ||
}; | ||
} | ||
|
||
private static native long newCompactOnDeletionCollectorFactory( | ||
final long slidingWindowSize, final long deletionTrigger, final double deletionRatio); | ||
|
||
private static native void deleteCompactOnDeletionCollectorFactory(final long handle); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters