Skip to content

Commit

Permalink
#989 adding tables to the container in the plugin table factory metho…
Browse files Browse the repository at this point in the history
…ds to be consistent
  • Loading branch information
naleeha authored and chrisjstevo committed Feb 16, 2024
1 parent 0a47602 commit d130fc3
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.finos.vuu.feature.ignite.table

import org.finos.vuu.api.TableDef
import org.finos.vuu.core.table.DataTable
import org.finos.vuu.core.table.{DataTable, TableContainer}
import org.finos.vuu.feature.TableFactory
import org.finos.vuu.provider.JoinTableProvider

class IgniteTableFactory extends TableFactory {
override def createTable(tableDef: TableDef, joinTableProvider: JoinTableProvider): DataTable = ???
override def createTable(tableDef: TableDef, tableContainer: TableContainer, joinTableProvider: JoinTableProvider): DataTable = ???
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package org.finos.vuu.plugin.virtualized

import org.finos.toolbox.jmx.MetricsProvider
import org.finos.vuu.api.TableDef
import org.finos.vuu.core.table.InMemDataTable
import org.finos.vuu.core.table.{InMemDataTable, TableContainer}
import org.finos.vuu.feature.{FilterFactory, JoinTableFactory, SessionTableFactory, SortFactory, TableFactory, ViewPortCallableFactory, ViewPortFactory, ViewPortKeysCreator, ViewPortTableCreator, ViewPortTreeCallableFactory}
import org.finos.vuu.plugin.virtualized.plugin.ViewPortVirtualizedTableCreator
import org.finos.vuu.plugin.virtualized.viewport.VirtualizedViewPortCallableFactory
Expand All @@ -14,8 +14,10 @@ object VirtualizedTablePlugin extends DefaultPlugin {

final val callableFactory = new VirtualizedViewPortCallableFactory

override def tableFactory(implicit metrics: MetricsProvider): TableFactory = (tableDef: TableDef, joinTableProvider: JoinTableProvider) => {
new InMemDataTable(tableDef, joinTableProvider)
override def tableFactory(implicit metrics: MetricsProvider): TableFactory = (tableDef: TableDef, tableContainer: TableContainer, joinTableProvider: JoinTableProvider) => {
val table = new InMemDataTable(tableDef, joinTableProvider)
tableContainer.addTable(table)
table
}

override def pluginType: PluginType = VirtualizedTablePluginType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,22 @@ import org.finos.vuu.plugin.virtualized.api.VirtualizedSessionTableDef
import org.finos.vuu.plugin.virtualized.table.VirtualizedSessionTable
import org.finos.vuu.viewport.{GroupBy, RowSource}

object ViewPortVirtualizedTableCreator extends ViewPortTableCreator{
object ViewPortVirtualizedTableCreator extends ViewPortTableCreator {

override def create(table: RowSource, clientSession: ClientSessionId, groupBy: GroupBy, tableContainer: TableContainer)(implicit metrics: MetricsProvider, clock: Clock): RowSource = {
override def create(table: RowSource, clientSession: ClientSessionId, groupBy: GroupBy, tableContainer: TableContainer)(implicit metrics: MetricsProvider, clock: Clock): RowSource = {

assert(table.asTable.getTableDef.isInstanceOf[VirtualizedSessionTableDef])

val sessionTableDef = table.asTable.getTableDef.asInstanceOf[VirtualizedSessionTableDef]

createSessionTable(clientSession, sessionTableDef, tableContainer)
}

private def createSessionTable(clientSession: ClientSessionId, sessionTableDef: VirtualizedSessionTableDef, tableContainer: TableContainer) (implicit metrics: MetricsProvider, clock: Clock) : RowSource= {
val sessionTable = new VirtualizedSessionTable(clientSession, sessionTableDef, tableContainer.joinTableProvider, cacheSize = 20_000)

val archetypeTable = tableContainer.getTable(sessionTableDef.name)

val provider = archetypeTable.getProvider

sessionTable.setProvider(provider)

tableContainer.addTable(sessionTable)
Expand Down
12 changes: 4 additions & 8 deletions vuu/src/main/scala/org/finos/vuu/core/VuuServer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,17 @@ class VuuServer(config: VuuServerConfig)(implicit lifecycle: LifecycleContainer,

def createTable(tableDef: TableDef): DataTable = {
logger.info(s"Creating table ${tableDef.name}")
pluginRegistry.withPlugin(tableDef.pluginType){
pluginRegistry.withPlugin(tableDef.pluginType) {
plugin =>
val table = plugin.tableFactory.createTable(tableDef, joinProvider)
tableContainer.addTable(table)
table
plugin.tableFactory.createTable(tableDef, tableContainer, joinProvider)
}
}

def createJoinTable(joinDef: JoinTableDef): DataTable = {
logger.info(s"Creating joinTable ${joinDef.name}")
pluginRegistry.withPlugin(joinDef.pluginType){
pluginRegistry.withPlugin(joinDef.pluginType) {
plugin =>
val table = plugin.joinTableFactory.createJoinTable(joinDef, tableContainer, joinProvider)
tableContainer.addTable(table)
table
plugin.joinTableFactory.createJoinTable(joinDef, tableContainer, joinProvider)
}
}

Expand Down
4 changes: 2 additions & 2 deletions vuu/src/main/scala/org/finos/vuu/feature/TableFactory.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package org.finos.vuu.feature

import org.finos.toolbox.jmx.MetricsProvider
import org.finos.vuu.api.TableDef
import org.finos.vuu.core.table.DataTable
import org.finos.vuu.core.table.{DataTable, TableContainer}
import org.finos.vuu.provider.JoinTableProvider

trait TableFactory {
def createTable(tableDef: TableDef, joinTableProvider: JoinTableProvider): DataTable
def createTable(tableDef: TableDef, tableContainer: TableContainer, joinTableProvider: JoinTableProvider): DataTable
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ class VuuInMemPlugin extends DefaultPlugin {
override def viewPortFactory: ViewPortFactory = ???
override def filterFactory: FilterFactory = ???
override def sortFactory: SortFactory = ???
override def tableFactory(implicit metrics: MetricsProvider): TableFactory = (tableDef: TableDef, joinTableProvider: JoinTableProvider) => {
new InMemDataTable(tableDef, joinTableProvider)
override def tableFactory(implicit metrics: MetricsProvider): TableFactory = (tableDef: TableDef, tableContainer: TableContainer, joinTableProvider: JoinTableProvider) => {
val table = new InMemDataTable(tableDef, joinTableProvider)
tableContainer.addTable(table)
table
}

final val viewPortCallableFactoryInstance = new InMemViewPortCallableFactory()
Expand Down
4 changes: 2 additions & 2 deletions vuu/src/test/scala/org/finos/vuu/plugin/TestPlugin.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.finos.vuu.plugin
import org.finos.toolbox.jmx.MetricsProvider
import org.finos.vuu.api.TableDef
import org.finos.vuu.core.table.DataTable
import org.finos.vuu.core.table.{DataTable, TableContainer}
import org.finos.vuu.feature.{Feature, FilterFactory, JoinTableFactory, SessionTableFactory, SortFactory, TableFactory, ViewPortCallableFactory, ViewPortFactory, ViewPortKeysCreator, ViewPortTableCreator, ViewPortTreeCallableFactory}
import org.finos.vuu.provider.JoinTableProvider

Expand Down Expand Up @@ -31,7 +31,7 @@ class TestPlugin extends Plugin with TableFactory {

override def sortFactory: SortFactory = ???

override def createTable(tableDef: TableDef, joinTableProvider: JoinTableProvider): DataTable = ???
override def createTable(tableDef: TableDef, tableContainer: TableContainer, joinTableProvider: JoinTableProvider): DataTable = ???

override def viewPortCallableFactory: ViewPortCallableFactory = ???

Expand Down

0 comments on commit d130fc3

Please sign in to comment.