forked from finos/vuu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
finos#1167 handle when external data schema is different from internal
- uses SchemaMapper to build the schema mappings b/w external and internal. - Sort + Filters to use the mapper to build SQL queries instead of internal table def. - refactors and improves the flow of IgniteOrderDataProvider.
- Loading branch information
1 parent
75fe017
commit 3121c95
Showing
25 changed files
with
865 additions
and
275 deletions.
There are no files selected for viewing
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
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
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
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
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
40 changes: 40 additions & 0 deletions
40
...he-ignite/src/main/scala/org/finos/vuu/example/ignite/provider/IgniteOrderDataQuery.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,40 @@ | ||
package org.finos.vuu.example.ignite.provider | ||
|
||
import org.finos.vuu.core.module.simul.model.ChildOrder | ||
import org.finos.vuu.core.sort.ModelType.SortSpecInternal | ||
import org.finos.vuu.example.ignite.IgniteOrderStore | ||
import org.finos.vuu.example.ignite.provider.IgniteOrderDataQuery.RowKeyAndData | ||
import org.finos.vuu.feature.ignite.FilterAndSortSpecToSql | ||
import org.finos.vuu.feature.ignite.schema.SchemaMapper | ||
import org.finos.vuu.net.FilterSpec | ||
|
||
class IgniteOrderDataQuery private (private val igniteOrderStore: IgniteOrderStore, | ||
private val schemaMapper: SchemaMapper) { | ||
|
||
private val filterAndSortSpecToSql = FilterAndSortSpecToSql(schemaMapper) | ||
|
||
def fetch(filterSpec: FilterSpec, sortSpec: SortSpecInternal, startIndex: Long, rowCount: Int): LazyList[ChildOrder] = { | ||
igniteOrderStore.findChildOrder( | ||
filterAndSortSpecToSql.filterToSql(filterSpec), | ||
filterAndSortSpecToSql.sortToSql(sortSpec), | ||
startIndex = startIndex, | ||
rowCount = rowCount | ||
) | ||
} | ||
|
||
def toInternalRow(keyField: String): Product => RowKeyAndData = | ||
dto => { | ||
val values = dto.productIterator.toList | ||
val rowData = schemaMapper.toTableRowData(values) | ||
val key = values(schemaMapper.externalSchemaField(keyField).get.index) | ||
(key.toString, rowData) | ||
} | ||
} | ||
|
||
object IgniteOrderDataQuery { | ||
def apply(igniteOrderStore: IgniteOrderStore, schemaMapper: SchemaMapper): IgniteOrderDataQuery = | ||
new IgniteOrderDataQuery(igniteOrderStore, schemaMapper) | ||
|
||
private type RowKey = String | ||
type RowKeyAndData = (RowKey, Map[String, Any]) | ||
} |
31 changes: 31 additions & 0 deletions
31
...he-ignite/src/main/scala/org/finos/vuu/example/ignite/schema/IgniteChildOrderEntity.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,31 @@ | ||
package org.finos.vuu.example.ignite.schema | ||
|
||
import scala.jdk.CollectionConverters.IterableHasAsJava | ||
import org.apache.ignite.cache.{QueryEntity, QueryIndex, QueryIndexType} | ||
import org.finos.vuu.core.module.simul.model.ChildOrder | ||
|
||
object IgniteChildOrderEntity { | ||
|
||
private val _schema: IgniteEntitySchema = createSchema() | ||
|
||
def getSchema: IgniteEntitySchema = _schema | ||
|
||
def buildQueryEntity: QueryEntity = _schema.queryEntity(classOf[Int], classOf[ChildOrder]) | ||
|
||
def getListToChildOrder: List[_] => ChildOrder = { | ||
val converter = ChildOrder.getClass.getMethods | ||
.find(x => x.getName == "apply" && x.isBridge) | ||
.get | ||
|
||
values => | ||
converter.invoke(ChildOrder, values map (_.asInstanceOf[AnyRef]): _*).asInstanceOf[ChildOrder] | ||
} | ||
|
||
private def createSchema(): IgniteEntitySchema = { | ||
IgniteEntitySchemaBuilder() | ||
.withCaseClass[ChildOrder] | ||
.withIndex(new QueryIndex(List("parentId").asJavaCollection, QueryIndexType.SORTED).setName("PARENTID_IDX")) | ||
.withIndex(new QueryIndex(List("id").asJavaCollection, QueryIndexType.SORTED).setName("CHILDID_IDX")) | ||
.build() | ||
} | ||
} |
Oops, something went wrong.