-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'rumakt_issue_989_big_data' into issue_989-big-data-supp…
…ort-scaling-vuu-how-to-abstract-vuu-interfaces-to-allow-different-implementations-of-key-classes-by-adding-features-on-construction
- Loading branch information
Showing
2 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
...able/src/main/scala/org/finos/vuu/example/virtualtable/module/IgniteOrderDataModule.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
.../src/main/scala/org/finos/vuu/example/virtualtable/provider/IgniteOrderDataProvider.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = ??? | ||
} |