Skip to content

Commit

Permalink
#989 Added more detail to VirtualizedSessionTable
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjstevo committed Dec 29, 2023
1 parent e8c5a7f commit 1e9ca7b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ object IgniteLocalConfig {

cfg.setClientMode(clientMode)
cfg.setPeerClassLoadingEnabled(true)
cfg.setWorkDirectory("./target/ignite")

cfg.setCacheConfiguration(
createParentOrderCacheConfig(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ class VirtualizedSessionTable(clientSessionId: ClientSessionId, sessionTableDef:
case Some(r) => r.size
case None => 0
}

override def primaryKeys: TablePrimaryKeys = super.primaryKeys
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import org.finos.vuu.core.table.{RowData, RowWithData, TableData, TablePrimaryKe

class VirtualizedSessionTableData extends TableData {

private val primaryKeys: VirtualizedTableKeys = new VirtualizedTableKeys(10_000)
private val primaryKeys: VirtualizedTableKeys = VirtualizedTableKeys(VirtualizedRange(0, 0, 0), Array())

override def dataByKey(key: String): RowData = ???

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
package org.finos.vuu.table.virtualized

import org.finos.toolbox.collection.window.ArrayBackedMovingWindow
import org.finos.vuu.core.table.TablePrimaryKeys

class VirtualizedTableKeys(cacheSize: Int) {
private val window = new ArrayBackedMovingWindow[String](cacheSize)
@volatile private var internalLength = 0
case class VirtualizedTableKeys(range: VirtualizedRange, data: Array[String], cacheSize: Int = 10_000) extends TablePrimaryKeys{

def setDataInRange(length: Int, from: Int, to: Int, data: Array[String]): Unit = {
window.setRange(from, to)
(from until to).foreach(i => window.setAtIndex(i, data(i)))
internalLength = length
}
def length: Int = internalLength
def getAtIndex(index:Int): Option[String] = window.getAtIndex(index)
private val window = new ArrayBackedMovingWindow[String](10_000)

}
window.setRange(range.from, range.to)

case class VirtualizedDataTableData() {
(range.from until range.to).foreach(i => window.setAtIndex(i, data(i)))

def length: Int = range.size
def getAtIndex(index:Int): Option[String] = window.getAtIndex(index)
override def add(key: String): TablePrimaryKeys = ???
override def +(key: String): TablePrimaryKeys = ???
override def remove(key: String): TablePrimaryKeys = ???
override def -(key: String): TablePrimaryKeys = ???
override def sliceTableKeys(from: Int, until: Int): TablePrimaryKeys = ???
override def get(index: Int): String = ???
override def iterator: Iterator[String] = ???
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ class VirtualizedTableKeysTest extends AnyFeatureSpec with Matchers with GivenWh

Scenario("test creating and populating virtualized viewport keys") {

val keys = new VirtualizedTableKeys(10)
val data = Array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J")

When("We create a list of keys that we have loaded from our virtualized data source")
keys.setDataInRange(100, 0, 10, Array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J"))
val keys = VirtualizedTableKeys(VirtualizedRange(0, 10, 100), data)

Then("we check if the length is correct")
keys.length should equal(100)
Expand All @@ -25,7 +25,6 @@ class VirtualizedTableKeysTest extends AnyFeatureSpec with Matchers with GivenWh
keys.getAtIndex(9) should equal(Some("J"))
keys.getAtIndex(10) should equal(None)
keys.getAtIndex(99) should equal(None)

}
}

Expand Down

0 comments on commit 1e9ca7b

Please sign in to comment.