Skip to content

Instantly share code, notes, and snippets.

@koeninger
Created September 9, 2013 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koeninger/6497066 to your computer and use it in GitHub Desktop.
Save koeninger/6497066 to your computer and use it in GitHub Desktop.
hector vs datastax batch performance
// hector version
val mutator: Mutator[Composite] = HFactory.createMutator(ksp, CompositeSerializer.get)
val column = HFactory.createColumn(deviceId, Array[Byte]())
column.setClock(clock)
profiles.foreach { p =>
if (p(attributes))
mutator.addInsertion(rowkey(brandCode, p.id.get), columnFamilyName, column)
else
mutator.addDeletion(rowkey(brandCode, p.id.get), columnFamilyName, deviceId, StringSerializer.get, clock)
}
mutator.execute()
// datastax version
val batch = QB.batch()
profiles.foreach { p =>
val pid: java.lang.Long = p.id.get.asInstanceOf[Long]
batch.add(if (p(attributes)) {
QB.insertInto("profile_devices").
values(Array("brandCode", "profileId", "deviceId"), Array(brandCode, pid, deviceId))
} else {
QB.delete().all().
from("profile_devices").
where(QB.eq("brandCode", brandCode)).
and(QB.eq("profileId", pid)).
and(QB.eq("deviceId", deviceId))
})
}
session.execute(batch.using(QB.timestamp(clock)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment