I can't paste the program itself as it's covered by an NDA. However, here's a program that follows exactly the same pattern. I've not compiled it, so it may contain typos.
def main(args: Array[String]) {
// initialize database stuff
val boot = new Boot
boot.boot()
val file = args(0)
parseAll(new FileReader(file)) { row =>
PersonAddress.fromRow(row).save()
}
}
class PersonAddress private () extends LongKeyedMapper[PersonAddress] with CreatedUpdated with IdPK {
def getSingleton: KeyedMetaMapper[Long, PersonAddress] = PersonAddress
object firstName extends MappedString(this, 20)
object lastName extends MappedString(this, 20)
object fullName extends MappedString(this, 50)
object address1 extends MappedString(this, 50)
object address2 extends MappedString(this, 50)
object city extends MappedString(this, 30)
object postcode extends MappedString(this, 10)
}
object PersonAddress extends PersonAddress with LongKeyedMetaMapper[PersonAddress] with CRUDify[Long, PersonAddress] {
def fromRow(row: Row): PersonAddress = {
val (ftN::ltN::flN::addr1::addr2::cty::pc::Nil) = row.cols
firstName := ftN
lastName := ltN
fullName := flN
address1 := addr1
address2 := addr2
city := cty
postcode := pc
}
}
In the real application, there are several tables and the data model for representing the content of a file is richer. However, none of that has much to do with the key part, which is that in a loop (once per row of a file) I am creating an object and saving it. It looks like I am not getting throughput much above 30 objects a second but the CPU is not maxed out for either Java or Mysql and although my disk is grunching, it is two orders of magnitude below top write speed. Does that help?
Matthew