Skip to content

Commit d8bbab2

Browse files
committed
Fast fix fox calling OrientDB for every parent recalculation
Long-term solutions should be separating creation and storage time (using temporary ids before confirmation is received from storage engine)
1 parent e38a984 commit d8bbab2

3 files changed

Lines changed: 28 additions & 5 deletions

File tree

  • auginte-desktop/src/main/scala/com/auginte/desktop
  • auginte-distribution/src/main/scala/com/auginte/distribution/orientdb

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,10 @@ Known Issues
7878
* After gen-idea, no compiler library found
7979
- Project settings -> Libraries -> *scala-library* -> Classes: Add from ~/.sbt/boot/*/scala-*
8080
- Project settings -> Facets -> Compiler library: Choose *scaka-library*
81-
* `JavaFx` runtime is only in `Oracle JRE 1.7+`, not in OpenJRE.
81+
* `JavaFx` runtime is only in `Oracle JRE 1.7+`, in OpenJRE it must installed separately
8282
- Internet is full of [examples](https://www.digitalocean.com/community/tutorials/how-to-install-java-on-ubuntu-with-apt-get)
8383
how to install Oracle Java and make it as default.
84+
- For Ubuntu and OpenJRE: `sudo apt-get install default-jre openjfx`
8485

8586
Useful links (for developers)
8687
-----------------------------

auginte-desktop/src/main/scala/com/auginte/desktop/View.scala

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,19 @@ with Saving[jp] with Loading[jp] with WithFileChooser {
4545
// Infinity zooming and refresh
4646
//
4747

48+
@volatile var coordinatesInProgress = false
49+
4850
private val grid2absoluteCron = new Timeline {
4951
cycleCount = Timeline.Indefinite
5052
keyFrames = Seq(
5153
jfxKeyFrame2sfx(new KeyFrame(
52-
Duration(10),
53-
(e: ActionEvent) => absoluteToCachedCoordinates()
54+
Duration(40),
55+
(e: ActionEvent) =>
56+
if (!coordinatesInProgress) {
57+
coordinatesInProgress = true
58+
absoluteToCachedCoordinates()
59+
coordinatesInProgress = false
60+
}
5461
))
5562
)
5663
}
@@ -134,4 +141,4 @@ with Saving[jp] with Loading[jp] with WithFileChooser {
134141
case e: Exception => println(s"Saving failed: $e")
135142
}
136143
}
137-
}
144+
}

auginte-distribution/src/main/scala/com/auginte/distribution/orientdb/Node.scala

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ class Node(val _x: Byte = 0, val _y: Byte = 0, protected val cache: Cache[Node]
2929

3030
private[auginte] val checkParentsConsistency = false // Useful for testing, but disabled in production
3131

32+
private var loaded = false
33+
private var cachedParent: Option[zooming.Node] = None
34+
3235
//
3336
// Structure
3437
//
@@ -51,7 +54,19 @@ class Node(val _x: Byte = 0, val _y: Byte = 0, protected val cache: Cache[Node]
5154

5255
override def y: Byte = get[Byte]("y", _y)
5356

54-
override def parent: Option[zooming.Node] = if (isPersisted) cache(edge("out_Parent")) else super.parent
57+
58+
override def parent: Option[zooming.Node] = if (loaded) {
59+
cachedParent
60+
} else {
61+
if (isPersisted) {
62+
val rez = cache(edge("out_Parent"))
63+
cachedParent = rez
64+
if (rez.isDefined) {
65+
loaded = true
66+
}
67+
rez
68+
} else super.parent
69+
}
5570

5671
override def children: List[zooming.Node] = if (isPersisted) cache(edges("in_Parent")).toList else super.children
5772

0 commit comments

Comments
 (0)