@@ -381,16 +381,18 @@ public void flushToDisk() throws RocksDBException {
381381 try {
382382 try (WriteBatch batch = new WriteBatch ()) {
383383 //Clear old metadata from disk
384- try (RocksIterator iterator = db .newIterator (metaDataHandle )) {
385- iterator .seekToFirst ();
386- while (iterator .isValid ()) {
387- batch .delete (metaDataHandle , iterator .key ());
388- iterator .next ();
389- }
390- }
384+ // try (RocksIterator iterator = db.newIterator(metaDataHandle)) {
385+ // iterator.seekToFirst();
386+ // while (iterator.isValid()) {
387+ // batch.delete(metaDataHandle, iterator.key());
388+ // iterator.next();
389+ // }
390+ // }
391391
392392 if (rootHash != null ) {
393393 batch .put (metaDataHandle , KEY_ROOT_HASH .getBytes (), rootHash );
394+ } else {
395+ batch .delete (metaDataHandle , KEY_ROOT_HASH .getBytes ());
394396 }
395397 batch .put (metaDataHandle , KEY_NUM_LEAVES .getBytes (), ByteBuffer .allocate (4 ).putInt (numLeaves ).array ());
396398 batch .put (metaDataHandle , KEY_DEPTH .getBytes (), ByteBuffer .allocate (4 ).putInt (depth ).array ());
@@ -417,10 +419,6 @@ public void flushToDisk() throws RocksDBException {
417419 db .write (writeOptions , batch );
418420 }
419421
420- db .compactRange (metaDataHandle );
421- db .compactRange (nodesHandle );
422- db .compactRange (keyDataHandle );
423-
424422 nodesCache .clear ();
425423 keyDataCache .clear ();
426424 hasUnsavedChanges .set (false );
@@ -698,7 +696,7 @@ private void initializeDb() throws RocksDBException {
698696 .setAllowMmapReads (false )
699697 .setUseDirectIoForFlushAndCompaction (true )
700698 .setMaxOpenFiles (100 )
701- .setMaxBackgroundJobs (1 )
699+ .setMaxBackgroundJobs (4 )
702700 .setInfoLogLevel (InfoLogLevel .FATAL_LEVEL )
703701 .setMaxManifestFileSize (64L * 1024 * 1024 ) // e.g. 64 MB
704702 .setMaxTotalWalSize (250L * 1024 * 1024 ) // total WAL across all CFs ≤ 250 MB
0 commit comments