Created
September 9, 2013 15:18
-
-
Save koeninger/6497066 to your computer and use it in GitHub Desktop.
hector vs datastax batch performance
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
// 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