Skip to content

Commit 29b2581

Browse files
committed
mvstore instead of mapdb
1 parent 8115985 commit 29b2581

File tree

2 files changed

+23
-29
lines changed

2 files changed

+23
-29
lines changed

build.sbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ version := "1.0"
44

55
scalaVersion := "2.12.1"
66

7-
87
scalacOptions in ThisBuild ++= Seq("-unchecked", "-deprecation")
98

109
libraryDependencies ++= Seq(
11-
// "org.mapdb" % "mapdb" % "3.0.2",
10+
"org.mapdb" % "mapdb" % "3.0.2",
11+
"com.h2database" % "h2-mvstore" % "1.4.193",
1212
"org.scorexfoundation" %% "scrypto" % "1.2.0-SNAPSHOT")

src/main/scala/benchmarks/BlockchainBench.scala

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11

22
package scorex.crypto.authds.benchmarks
33

4-
/*
54
import com.google.common.primitives.Ints
6-
import org.mapdb.DB.TreeMapMaker
7-
import org.mapdb.{BTreeMap, DBMaker, Serializer}
5+
import org.h2.mvstore.MVStore
86
import scorex.crypto.authds.TwoPartyDictionary.Label
97
import scorex.crypto.authds._
108
import scorex.crypto.authds.avltree.batch.{BatchAVLProver, BatchAVLVerifier, Insert}
@@ -30,24 +28,24 @@ trait BenchmarkCommons {
3028

3129

3230
trait TwoPartyCommons extends BenchmarkCommons with UpdateF[TreapValue] {
33-
lazy val db = DBMaker
31+
lazy val db = new MVStore.Builder().
32+
fileName("/tmp/proofs").
33+
cacheSize(1).
34+
open()
35+
36+
/*DBMaker
3437
.fileDB("/tmp/proofs")
3538
.closeOnJvmShutdown()
36-
.make()
37-
38-
lazy private val proofsMapMaker:TreeMapMaker[Integer, Array[Byte]] =
39-
db.treeMap("proofs", Serializer.INTEGER, Serializer.BYTE_ARRAY)
39+
.make()*/
4040

41-
lazy val proofsMap = proofsMapMaker.createOrOpen().asInstanceOf[BTreeMap[Integer, Array[Byte]]]
41+
lazy val proofsMap = db.openMap[Integer, Array[Byte]]("proofs")
4242

4343
def set(value: TreapValue): UpdateFunction = { oldOpt: Option[TreapValue] => Try(Some(oldOpt.getOrElse(value))) }
4444

4545
lazy val balance = Array.fill(8)(0: Byte)
4646
lazy val bfn = set(balance)
4747

48-
protected lazy val rootMap = db.treeMap("root", Serializer.STRING, Serializer.BYTE_ARRAY)
49-
.createOrOpen()
50-
.asInstanceOf[BTreeMap[String, Array[Byte]]]
48+
protected lazy val rootMap = db.openMap[String, Array[Byte]]("root")
5149

5250
def setRoot(newVal: Array[Byte]) = rootMap.put("root", newVal)
5351

@@ -117,11 +115,7 @@ class Prover extends TwoPartyCommons with Initializing {
117115

118116

119117
trait Batching extends TwoPartyCommons {
120-
lazy val rootsMap: BTreeMap[Integer, Array[Byte]] = db.treeMap("roots")
121-
.keySerializer(Serializer.INTEGER)
122-
.valueSerializer(Serializer.BYTE_ARRAY)
123-
.createOrOpen()
124-
.asInstanceOf[BTreeMap[Integer, Array[Byte]]]
118+
lazy val rootsMap = db.openMap[Int, Array[Byte]]("roots")
125119
}
126120

127121

@@ -229,13 +223,9 @@ class BatchVerifier extends TwoPartyCommons with Batching with Initializing {
229223
}
230224

231225
class FullWorker extends BenchmarkCommons with Initializing {
232-
val store = DBMaker.fileDB("/tmp/fulldb").make()
226+
val store = MVStore.open("/tmp/fulldb")
233227

234-
val map: BTreeMap[Array[Byte], Integer] = store.treeMap("proofs")
235-
.keySerializer(Serializer.BYTE_ARRAY)
236-
.valueSerializer(Serializer.INTEGER)
237-
.createOrOpen()
238-
.asInstanceOf[BTreeMap[Array[Byte], Integer]]
228+
val map = store.openMap[Array[Byte], Int]("proofs")
239229

240230

241231
override protected def initStep(i: Int) = {
@@ -360,9 +350,13 @@ trait BenchmarkLaunchers extends BenchmarkCommons {
360350
}
361351
}
362352

363-
353+
/**
354+
* Todo: describe benches
355+
* todo: launchers
356+
*/
364357
object BlockchainBench extends BenchmarkLaunchers with App {
365-
runBatchProver()
366-
//runBatchVerifier()
358+
// runBatchProver()
359+
// runBatchVerifier()
360+
361+
runFullWorker()
367362
}
368-
*/

0 commit comments

Comments
 (0)