-
-
Save isterin/9837523 to your computer and use it in GitHub Desktop.
Voltdb problem
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
CREATE TABLE results ( | |
event_id BIGINT NOT NULL, | |
race_id BIGINT NOT NULL, | |
bracket_id BIGINT NOT NULL, | |
interval_id BIGINT NOT NULL, | |
entry_id BIGINT NOT NULL, | |
iv_time_millis BIGINT NOT NULL, | |
iv_gun_time_millis BIGINT NOT NULL, | |
bib VARCHAR(15), | |
pace VARCHAR(23), | |
gun_pace VARCHAR(23), | |
rank INTEGER NOT NULL, | |
seq INTEGER NOT NULL, | |
CONSTRAINT results_pk PRIMARY KEY (event_id, race_id, bracket_id, interval_id, entry_id) | |
); | |
CREATE INDEX ix_rs_bib on results (bib); | |
CREATE INDEX ix_rs_interval_id on results (interval_id); | |
CREATE INDEX ix_rs_entry_id on results (entry_id); | |
CREATE INDEX ix_rs_race_id on results (race_id); | |
CREATE INDEX ix_rs_iv_time_millis on results (iv_time_millis); | |
CREATE INDEX ix_rs_iv_gun_time_millis on results (iv_gun_time_millis); | |
PARTITION TABLE results ON COLUMN event_id; | |
CREATE PROCEDURE FROM CLASS InsertResults; | |
PARTITION PROCEDURE InsertResults ON TABLE results COLUMN event_id; |
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
import org.voltdb.{VoltTable, SQLStmt, VoltProcedure} | |
/** | |
* User: ilya | |
* Date: 3/25/14 | |
* Time: 12:56 PM | |
*/ | |
class InsertResults extends VoltProcedure { | |
val sql = new SQLStmt( | |
"""INSERT INTO results ( | |
|event_id,race_id,bracket_id, | |
|interval_id,entry_id,iv_time_millis,iv_gun_time_millis, | |
|bib,pace,gun_pace,rank,seq) | |
|VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);""".stripMargin | |
) | |
def run(eventId: Long, | |
raceId: Long, | |
bracketId: Long, | |
intervalId: Long, | |
entryId: Long, | |
ivTimeMillis: Long, | |
ivGunTimeMillis: Long, | |
bib: String, | |
pace: String, | |
gunPace: String, | |
rank: Int, | |
seq: Int): Array[VoltTable] = { | |
voltQueueSQL(sql, List(eventId, raceId, | |
bracketId, intervalId, entryId, ivTimeMillis, ivGunTimeMillis, | |
bib, pace, gunPace, rank, seq).map(_.asInstanceOf[AnyRef]): _*) | |
voltExecuteSQL() | |
null | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment