Skip to content

Instantly share code, notes, and snippets.

Last active March 19, 2020 08:39
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Transcations split in Exposed
private fun loadData(db : Database, table: Table, fileName: String, partitions: Int, operation: BatchInsertStatement.(String) -> Unit){
val reader = File(fileName).bufferedReader()
reader.readLine() // pass headers
val lines = reader.readLines()
val partitionSize = lines.size / partitions
val listOfLists = lines.chunked(partitionSize)
var increment = 0
for(listOfList in listOfLists){
increment += 1
println("-------- $increment")
transaction(db) {
table.batchInsert(listOfList, body = operation)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment