Skip to content

Commit

Permalink
#989 Made viewport keys iterable.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjstevo committed Jan 4, 2024
1 parent 857a681 commit 913510b
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ class VirtualizedViewPortKeys(tablePrimaryKeys: TablePrimaryKeys) extends ViewPo
override def create(tableKeys: TablePrimaryKeys): ViewPortKeys = ???

override def get(index: Int): String = tablePrimaryKeys.get(index)
override def slice(from: Int, to: Int): Array[String] = tablePrimaryKeys.sliceTableKeys(from, to).toArray
override def sliceToArray(from: Int, to: Int): Array[String] = tablePrimaryKeys.sliceTableKeys(from, to).toArray
override def sliceToKeys(from: Int, to: Int): ViewPortKeys = ???
override def length: Int = tablePrimaryKeys.length
override def toArray(): Array[String] = tablePrimaryKeys.toArray
def setDataInRange(from: Int, to: Int, data: Array[String]): Unit = ???
override def iterator: Iterator[String] = tablePrimaryKeys.iterator
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ trait DataTable extends KeyedObservable[RowKeyUpdate] with RowSource {
val columns = getTableDef.columns
val keys = primaryKeys

val selectedKeys = keys.toArray.slice(start, end) //.slice(start, end)//drop(start).take(end - start)
val selectedKeys = keys.toArray.slice(start, end) //.sliceToArray(start, end)//drop(start).take(end - start)

val rows = selectedKeys.map(key => pullRowAsArray(key, ViewPortColumnCreator.create(this, columns.map(_.name).toList)))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import org.finos.vuu.feature.inmem.InMemViewPortKeys

object EmptyViewPortKeys extends ViewPortKeys {
override def create(immutableArray: TablePrimaryKeys): ViewPortKeys = InMemViewPortKeys(immutableArray)
override def slice(from: Int, to: Int): Array[String] = Array()
override def sliceToArray(from: Int, to: Int): Array[String] = Array()
override def get(index: Int): String = null
override def sliceToKeys(from: Int, to: Int): ViewPortKeys = EmptyViewPortKeys
override def toArray(): Array[String] = Array()
override def length: Int = 0
}
override def iterator: Iterator[String] = Array().iterator
}
4 changes: 2 additions & 2 deletions vuu/src/main/scala/org/finos/vuu/feature/ViewPortKeys.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package org.finos.vuu.feature
import org.finos.toolbox.collection.array.ImmutableArray
import org.finos.vuu.core.table.TablePrimaryKeys

trait ViewPortKeys {
trait ViewPortKeys extends Iterable[String] {
def create(tableKeys: TablePrimaryKeys): ViewPortKeys
def get(index: Int): String
def slice(from: Int, to: Int): Array[String]
def sliceToArray(from: Int, to: Int): Array[String]
def sliceToKeys(from: Int, to: Int): ViewPortKeys
def length: Int
def toArray(): Array[String]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import org.finos.vuu.feature.ViewPortKeys
case class InMemViewPortKeys(keys: TablePrimaryKeys) extends ViewPortKeys{
override def create(immutableArray: TablePrimaryKeys): ViewPortKeys = InMemViewPortKeys(immutableArray)
override def get(index: Int): String = keys.get(index)
override def slice(from: Int, to: Int): Array[String] = keys.slice(from, to).toArray
override def sliceToArray(from: Int, to: Int): Array[String] = keys.slice(from, to).toArray
override def sliceToKeys(from: Int, to: Int): ViewPortKeys = InMemViewPortKeys(keys.sliceTableKeys(from, to))
override def length: Int = keys.length
override def toArray(): Array[String] = keys.toArray
override def iterator: Iterator[String] = keys.iterator
}
2 changes: 1 addition & 1 deletion vuu/src/main/scala/org/finos/vuu/viewport/ViewPort.scala
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ class ViewPortImpl(val id: String,
val from = currentRange.from
val to = currentRange.to

val inrangeKeys = keys.slice(from, to)
val inrangeKeys = keys.sliceToArray(from, to)

logger.info(s"Sending updates on ${inrangeKeys.length} inrangeKeys")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ class ViewPortContainer(val tableContainer: TableContainer, val providerContaine
val columns = vp.getColumns
val keys = vp.getKeysInRange

val rows = keys.toArray.map(key => vp.table.pullRowAsArray(key, columns))
val rows = keys.map(key => vp.table.pullRowAsArray(key, columns)).toArray

val headers = if (vp.hasGroupBy)
Array[String]("depth", "isOpen", "key", "isLeaf") ++ columns.getColumns().map(_.name).toArray[String]
Expand Down

0 comments on commit 913510b

Please sign in to comment.