forked from facebook/rocksdb
-
Notifications
You must be signed in to change notification settings - Fork 0
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
- Loading branch information
Showing
8 changed files
with
206 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,14 @@ | ||
// | ||
// Created by rhubner on 24-Oct-23. | ||
// | ||
|
||
#include "rocksdb/utilities/table_properties_collectors.h" | ||
#include "rocksdb/table_properties.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
45 changes: 45 additions & 0 deletions
45
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,45 @@ | ||
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) { | ||
|
||
//TODO - Call native method to create instance of deletion factory and get pointer. | ||
|
||
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 sliding_window_size, | ||
final long deletion_trigger, | ||
final double deletion_ratio); | ||
|
||
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