Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ignite provider and module #1102

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.finos.vuu.example.virtualtable.module

import org.finos.toolbox.lifecycle.LifecycleContainer
import org.finos.toolbox.time.Clock
import org.finos.vuu.api.ViewPortDef
import org.finos.vuu.core.module.{DefaultModule, ModuleFactory, TableDefContainer, ViewServerModule}
import org.finos.vuu.core.table.Columns
import org.finos.vuu.data.order.ignite.IgniteOrderStore
import org.finos.vuu.example.virtualtable.provider.IgniteOrderDataProvider
import org.finos.vuu.plugin.virtualized.api.VirtualizedSessionTableDef


class IgniteOrderDataModule extends DefaultModule {
final val NAME = "IGNITE_ORDER_VIRTUAL"

def apply(igniteOrderStore: IgniteOrderStore)(implicit clock: Clock, lifecycle: LifecycleContainer, tableDefContainer: TableDefContainer): ViewServerModule = {
ModuleFactory.withNamespace(NAME)
.addSessionTable(
VirtualizedSessionTableDef(
name = "bigOrders",
keyField = "orderId",
Columns.fromNames("orderId".string(), "quantity".int(), "price".long(), "side".string(), "trader".string())
),
(table, _) => new IgniteOrderDataProvider(table, igniteOrderStore),
(table, _, _, _) => ViewPortDef(
columns = table.getTableDef.columns,
service = new VirtualService()
)
).asModule()
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package org.finos.vuu.example.virtualtable.provider

import org.finos.toolbox.time.Clock
import org.finos.vuu.core.table.{DataTable, RowWithData}
import org.finos.vuu.data.order.ignite.IgniteOrderStore
import org.finos.vuu.plugin.virtualized.table.{VirtualizedRange, VirtualizedSessionTable}
import org.finos.vuu.provider.VirtualizedProvider
import org.finos.vuu.viewport.ViewPort

import java.util.concurrent.atomic.AtomicInteger

class IgniteOrderDataProvider(final val table: DataTable,
final val igniteStore: IgniteOrderStore)(implicit clock: Clock) extends VirtualizedProvider {
private final val internalTable = table.asInstanceOf[VirtualizedSessionTable]

override def runOnce(viewPort: ViewPort): Unit = {

val range = viewPort.getRange
val totalSize = igniteStore.childOrderCount().toInt

internalTable.setSize(totalSize)
internalTable.setRange(VirtualizedRange(range.from, range.to))
val iterator = igniteStore.findWindow(range.from, range.to)
val index = new AtomicInteger(range.from) // todo: get rid of working assumption here that the dataset is fairly immutable.
iterator.foreach(childOrder => {
val row = RowWithData(childOrder.id.toString,
Map(
"orderId" -> childOrder.id,
"price" -> childOrder.price,
"quantity" -> childOrder.exchange,
"side" -> childOrder.side,
"trader" -> "N/A"
))
internalTable.processUpdateForIndex(index.getAndIncrement(), childOrder.id.toString, row, clock.now())
})
}

override def subscribe(key: String): Unit = ???

override def doStart(): Unit = ???

override def doStop(): Unit = ???

override def doInitialize(): Unit = ???

override def doDestroy(): Unit = ???

override val lifecycleId: String = ???
}
Loading