Created
January 13, 2011 15:19
-
-
Save samhendley/778027 to your computer and use it in GitHub Desktop.
Query to be replicated
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
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; |
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
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