Skip to content

Instantly share code, notes, and snippets.

Embed
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
You can’t perform that action at this time.