Skip to content

Instantly share code, notes, and snippets.

@samhendley
Created January 13, 2011 15:19
Show Gist options
  • Save samhendley/778027 to your computer and use it in GitHub Desktop.
Save samhendley/778027 to your computer and use it in GitHub Desktop.
Query to be replicated
Select
Measurement.pointId,
Measurement.measTime
from Measurement
inner join (
select max(Measurement.measTime) as t1,
Measurement.pointId as p1
from Measurement
where Measurement.pointId in (1, 2, 5, 10)
group by pointId
) SubMax
on Measurement.measTime = t1 and Measurement.pointId = p1;
case class Measurement(
val pointId: Long,
val measTime: Long,
val proto: Array[Byte]) extends KeyedEntity[Long] {
var id: Long = 0
}
case class MeasName(
val name: String) extends KeyedEntity[Long] {
var id: Long = 0
}
object SqlMeasurementStoreSchema extends Schema {
val updates = table[Measurement]
val names = table[MeasName]
on(updates)(s => declare(
columns(s.pointId, s.measTime.~) are (indexed),
columns(s.pointId, s.measTime.~, s.id) are (indexed)
))
on(names)(s => declare(
columns(s.name) are (indexed)))
def reset() = {
drop // its protected for some reason
create
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment