Remove deprecated DB::DeleteFile API references (#13322)

Summary:
Cleanup post https://github.com/facebook/rocksdb/pull/13284.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/13322

Test Plan:
1. We did not find any evidence of breakage in internal pre-release integration pipeline runs after renaming the deprecated API in `9.10`.
2. _To the extent possible_, we manually validated partner use cases of file deletion and confirmed deprecated API is no longer in use.

Reviewed By: jaykorean

Differential Revision: D68476852

Pulled By: mszeszko-meta

fbshipit-source-id: fbe1f873e16ae7c60d7706a3c44ecc695ab86a4b
This commit is contained in:
Maciej Szeszko
2025-01-24 22:28:41 -08:00
committed by Facebook GitHub Bot
parent ac6c671308
commit 591f5b1266
12 changed files with 46 additions and 388 deletions
-19
View File
@@ -3240,25 +3240,6 @@ jlong Java_org_rocksdb_RocksDB_getUpdatesSince(JNIEnv* env, jclass,
return 0;
}
/*
* Class: org_rocksdb_RocksDB
* Method: deprecated_deleteFile
* Signature: (JLjava/lang/String;)V
*/
void Java_org_rocksdb_RocksDB_deprecated_1deleteFile(JNIEnv* env, jclass,
jlong jdb_handle,
jstring jname) {
auto* db = reinterpret_cast<ROCKSDB_NAMESPACE::DB*>(jdb_handle);
jboolean has_exception = JNI_FALSE;
std::string name =
ROCKSDB_NAMESPACE::JniUtil::copyStdString(env, jname, &has_exception);
if (has_exception == JNI_TRUE) {
// exception occurred
return;
}
db->DEPRECATED_DeleteFile(name);
}
/*
* Class: org_rocksdb_RocksDB
* Method: getLiveFilesMetaData
@@ -4419,20 +4419,6 @@ public class RocksDB extends RocksObject {
getUpdatesSince(nativeHandle_, sequenceNumber));
}
/**
* Delete the file name from the db directory and update the internal state to
* reflect that. Supports deletion of sst and log files only. 'name' must be
* path relative to the db directory. eg. 000001.sst, /archive/000003.log
*
* @param name the file name
*
* @throws RocksDBException if an error occurs whilst deleting the file
*/
@Deprecated
public void deprecated_deleteFile(final String name) throws RocksDBException {
deprecated_deleteFile(nativeHandle_, name);
}
/**
* Gets a list of all table files metadata.
*
@@ -5055,9 +5041,6 @@ public class RocksDB extends RocksObject {
private static native LogFile[] getSortedWalFiles(final long handle) throws RocksDBException;
private static native long getUpdatesSince(final long handle, final long sequenceNumber)
throws RocksDBException;
@Deprecated
private static native void deprecated_deleteFile(final long handle, final String name)
throws RocksDBException;
private static native LiveFileMetaData[] getLiveFilesMetaData(final long handle);
private static native ColumnFamilyMetaData getColumnFamilyMetaData(
final long handle, final long columnFamilyHandle);
@@ -75,20 +75,49 @@ public class EventListenerTest {
void deleteTableFile(final AbstractEventListener el, final AtomicBoolean wasCbCalled)
throws RocksDBException {
try (final Options opt =
new Options().setCreateIfMissing(true).setListeners(Collections.singletonList(el));
final int KEY_SIZE = 20;
final int VALUE_SIZE = 1000;
final int FILE_SIZE = 64000;
final int NUM_FILES = 2;
final int KEY_INTERVAL = 10000;
/*
* Intention of these options is to end up reliably with NUM_FILES files.
* we will be deleting using deleteFilesInRange.
* It is writing roughly number of keys that will fit in NUM_FILES files (target size).
* It is writing interleaved so that files from memory on L0 will overlap.
* Then compaction cleans everything, and we should end up with NUM_FILES files.
*/
try (final Options opt = new Options()
.setCreateIfMissing(true)
.setListeners(Collections.singletonList(el))
.setCompressionType(CompressionType.NO_COMPRESSION)
.setTargetFileSizeBase(FILE_SIZE)
.setWriteBufferSize(FILE_SIZE / 2)
.setDisableAutoCompactions(true)
.setLevelCompactionDynamicLevelBytes(false);
final RocksDB db = RocksDB.open(opt, dbFolder.getRoot().getAbsolutePath())) {
assertThat(db).isNotNull();
final byte[] value = new byte[24];
rand.nextBytes(value);
db.put("testKey".getBytes(), value);
final RocksDB.LiveFiles liveFiles = db.getLiveFiles();
assertThat(liveFiles).isNotNull();
assertThat(liveFiles.files).isNotNull();
assertThat(liveFiles.files.isEmpty()).isFalse();
db.deprecated_deleteFile(liveFiles.files.get(0));
assertThat(wasCbCalled.get()).isTrue();
final int records = FILE_SIZE / (KEY_SIZE + VALUE_SIZE);
// fill database with key/value pairs
final byte[] value = new byte[VALUE_SIZE];
int key_init = 0;
for (int o = 0; o < NUM_FILES; ++o) {
int int_key = key_init++;
for (int i = 0; i < records; ++i) {
int_key += KEY_INTERVAL;
rand.nextBytes(value);
db.put(String.format("%020d", int_key).getBytes(), value);
}
}
try (final FlushOptions flushOptions = new FlushOptions().setWaitForFlush(true)) {
db.flush(flushOptions);
}
db.compactRange();
db.deleteFilesInRanges(null, Arrays.asList(null, null), false /* includeEnd */);
}
assertThat(wasCbCalled.get()).isTrue();
}
@Test
@@ -1665,16 +1665,6 @@ public class RocksDBTest {
}
}
@Test
public void deprecated_deleteFile() throws RocksDBException {
try (final Options options = new Options().setCreateIfMissing(true)) {
final String dbPath = dbFolder.getRoot().getAbsolutePath();
try (final RocksDB db = RocksDB.open(options, dbPath)) {
db.deprecated_deleteFile("unknown");
}
}
}
@Test
public void getLiveFilesMetaData() throws RocksDBException {
try (final Options options = new Options().setCreateIfMissing(true)) {