Skip to content

Commit a76eb09

Browse files
author
Youri K
committed
add sst writer
1 parent 0f6c94c commit a76eb09

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,28 @@ class RocksDBManager(dataDir: Path, columnFamilies: List[String], optionsFilePat
7474
def compactAllData() = {
7575
logger.info("Compacting all data")
7676
RocksDB.loadLibrary()
77-
db.compactRange()
77+
//db.compactRange()
78+
writeAllSSts()
7879
logger.info("All data has been compacted to last level containing data")
7980
}
8081

8182
def close(): Future[Unit] = {
8283
logger.info("Closing RocksDB handle")
8384
Future.successful(db.close())
8485
}
86+
87+
def writeAllSSts() = {
88+
val dbOptions = new DBOptions().setCreateIfMissing(true)
89+
val envOptions = new EnvOptions()
90+
val options = new Options(dbOptions, new ColumnFamilyOptions())
91+
val writer = new SstFileWriter(envOptions, options)
92+
writer.open("data/test.sst")
93+
val store = getStoreForColumnFamily(columnFamilies.head)
94+
val it = store.get.scan("", None)
95+
it.foreach(el => writer.put(el.key.getBytes, el.value))
96+
writer.finish()
97+
//db.ingestExternalFile()
98+
}
8599
}
86100

87101
class RocksDBKeyIterator(it: RocksIterator, prefix: Option[String]) extends Iterator[String] {

0 commit comments

Comments
 (0)