Skip to content

Commit

Permalink
Fixes to LightDB upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
darkfrog26 committed Nov 20, 2024
1 parent df0ce64 commit 235c381
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 23 deletions.
14 changes: 5 additions & 9 deletions core/src/main/scala/lightdb/LightDB.scala
Original file line number Diff line number Diff line change
Expand Up @@ -166,22 +166,18 @@ trait LightDB extends Initializable with FeatureSupport[DBFeatureKey] {
dbInitialized: Boolean,
stillBlocking: Boolean): Unit = upgrades.headOption match {
case Some(upgrade) =>
val continueBlocking = upgrades.exists(_.blockStartup)
if (!dbInitialized && !upgrade.applyToNew) {
appliedUpgrades.modify { set =>
set + upgrade.label
}
doUpgrades(upgrades.tail, dbInitialized, continueBlocking)
} else if (stillBlocking && !continueBlocking) {
val runUpgrade = dbInitialized || upgrade.applyToNew
val continueBlocking = upgrades.exists(u => u.blockStartup && (dbInitialized || u.applyToNew))
if (stillBlocking && !continueBlocking) {
scribe.Platform.executionContext.execute(() => {
upgrade.upgrade(this)
if (runUpgrade) upgrade.upgrade(this)
appliedUpgrades.modify { set =>
set + upgrade.label
}
doUpgrades(upgrades.tail, dbInitialized, continueBlocking)
})
} else {
upgrade.upgrade(this)
if (runUpgrade) upgrade.upgrade(this)
appliedUpgrades.modify { set =>
set + upgrade.label
}
Expand Down
14 changes: 0 additions & 14 deletions rocksdb/src/main/scala/lightdb/rocksdb/RocksDBStore.scala
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,6 @@ class RocksDBStore[Doc <: Document[Doc], Model <: DocumentModel[Doc]](directory:
db.close()
}

private def iteratorOld(rocksIterator: RocksIterator, value: Boolean = true): Iterator[Array[Byte]] = new Iterator[Array[Byte]] {
override def hasNext: Boolean = rocksIterator.isValid

override def next(): Array[Byte] = try {
if (value) {
rocksIterator.value()
} else {
rocksIterator.key()
}
} finally {
rocksIterator.next()
}
}

private def iterator(rocksIterator: RocksIterator, value: Boolean = true): Iterator[Array[Byte]] = new Iterator[Array[Byte]] {
// Initialize the iterator to the first position
rocksIterator.seekToFirst()
Expand Down

0 comments on commit 235c381

Please sign in to comment.