Skip to content

Instantly share code, notes, and snippets.

@niektemme
Created July 31, 2015 09:58
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 niektemme/d36d34fbb39033a9a5bc to your computer and use it in GitHub Desktop.
Save niektemme/d36d34fbb39033a9a5bc to your computer and use it in GitHub Desktop.
Smart Thermostat AWS Spark - part Spark upload score
//calculate final score
val fscore = (numonoffs*10*60)+(ontime*2)+((math.abs(mresultmax-testval))*150)+(overflsocre)+(tempReached)
//put score in used scenario
val confputscore = HBaseConfiguration.create()
val tableputscore = new HTable(confputscore,"husedscenario")
val putscore = new Put(rowval)
putscore.add("fd".getBytes(), "score".getBytes(),fscore.toString.getBytes())
tableputscore.put(putscore)
//delete used scenario key from index table
val tabledelrow = new HTable(confputscore,"husedscenariotbsc")
val useddelete = new Delete(rowval)
tabledelrow.delete(useddelete)
tabledelrow.close()
tableputscore.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment