-
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.
#1213 added example of rowbuilder interface
- Loading branch information
1 parent
4236412
commit 3e31219
Showing
10 changed files
with
121 additions
and
32 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
45 changes: 45 additions & 0 deletions
45
vuu/src/main/scala/org/finos/vuu/core/row/InMemMapRowBuilder.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,45 @@ | ||
package org.finos.vuu.core.row | ||
import org.finos.vuu.core.table.{Column, RowData, RowWithData} | ||
|
||
import scala.collection.mutable | ||
|
||
class InMemMapRowBuilder extends RowBuilder { | ||
|
||
private val mutableMap = new mutable.HashMap[String, Any]() | ||
private var key: String = "" | ||
override def setLong(column: Column, v: Long): RowBuilder = { | ||
mutableMap.put(column.name, v) | ||
this | ||
} | ||
|
||
override def setDouble(column: Column, v: Double): RowBuilder = { | ||
mutableMap.put(column.name, v) | ||
this | ||
} | ||
|
||
override def setInt(column: Column, v: Int): RowBuilder = { | ||
mutableMap.put(column.name, v) | ||
this | ||
} | ||
|
||
override def setString(column: Column, v: String): RowBuilder = { | ||
mutableMap.put(column.name, v) | ||
this | ||
} | ||
|
||
override def setBoolean(column: Column, v: Boolean): RowBuilder = { | ||
mutableMap.put(column.name, v) | ||
this | ||
} | ||
override def setKey(key: String): RowBuilder = { | ||
this.key = key | ||
this | ||
} | ||
override def asRow: RowData = { | ||
val immMap = mutableMap.toMap | ||
val rowData = RowWithData(key, immMap) | ||
mutableMap.clear() | ||
key = "" | ||
rowData | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
vuu/src/main/scala/org/finos/vuu/core/row/RowBuilder.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,13 @@ | ||
package org.finos.vuu.core.row | ||
|
||
import org.finos.vuu.core.table.{Column, RowData} | ||
|
||
trait RowBuilder { | ||
def setKey(key: String): RowBuilder | ||
def setLong(column: Column, v: Long): RowBuilder | ||
def setDouble(column: Column, v: Double): RowBuilder | ||
def setInt(column: Column, v: Int): RowBuilder | ||
def setString(column: Column, v: String): RowBuilder | ||
def setBoolean(column: Column, v: Boolean): RowBuilder | ||
def asRow: RowData | ||
} |
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