Skip to content

Commit a7a5478

Browse files
author
Youri K
committed
create new db
1 parent 8060219 commit a7a5478

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/main/scala/com/scalableminds/fossildb/db/RocksDBStore.scala

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
package com.scalableminds.fossildb.db
55

6-
import java.nio.file.{Files, Path}
6+
import java.nio.file.{Files, Path, Paths}
77
import java.util
88

99
import com.typesafe.scalalogging.LazyLogging
@@ -83,6 +83,7 @@ class RocksDBManager(dataDir: Path, columnFamilies: List[String], optionsFilePat
8383
case 1 => writeAllSSts()
8484
case 2 => ingestFiles()
8585
case 3 => db.compactRange(false, -1, 0)
86+
case 4 => writeToNewDB()
8687
}
8788
logger.info("All data has been compacted to last level containing data")
8889
}
@@ -116,6 +117,13 @@ class RocksDBManager(dataDir: Path, columnFamilies: List[String], optionsFilePat
116117
}
117118
}
118119

120+
def writeToNewDB() = {
121+
val manager = new RocksDBManager(Paths.get("data_new"), columnFamilies, Some("config/options.ini"))
122+
val skeletonHandle = manager.columnFamilyHandles("skeletons")
123+
val it = getStoreForColumnFamily("skeletons").get.scan("", None).take(100000)
124+
it.foreach {el => manager.db.put(skeletonHandle, el.key.getBytes, el.value)}
125+
}
126+
119127
def loadOptions(optionFilepath: String) = {
120128
val options = new DBOptions()
121129
val cfListRef: mutable.Buffer[ColumnFamilyDescriptor] = mutable.Buffer()

0 commit comments

Comments
 (0)