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
implicit object YearDayConverter extends ByteConverter[YearDay] { | |
val SPLITTER = "_".r | |
override def toBytes(t:YearDay) = Bytes.toBytes(t.year.toString + "_" + t.day.toString) | |
override def fromBytes(bytes:Array[Byte]) = { | |
val strRep = Bytes.toString(bytes) | |
val strRepSpl = SPLITTER.split(strRep) | |
val year = strRepSpl(0).toInt | |
val day = strRepSpl(1).toInt | |
YearDay(year,day) | |
} |
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 YearDay(year: Int, day: Int) |
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
implicit object StringConverter extends ByteConverter[String] { | |
override def toBytes(t: String) = Bytes.toBytes(t) | |
override def fromBytes(bytes: Array[Byte]) = Bytes.toString(bytes) | |
} |
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
ExampleSchema.ExampleTable.put(1346l).valueMap(_.viewCounts, Map("Today" -> 61l, "Yesterday" -> 86l)).execute |
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
val viewCounts = family[String, String, Long]("views") |
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
ExampleSchema.ExampleTable | |
.put("Chris").value(_.title, "My Life, My Times") | |
.put("Joe").value(_.title, "Joe's Life and Times") | |
.increment("Chris").value(_.views, 10l) | |
.execute() |
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
println(ExampleSchema.ExampleTable.createScript()) |
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
object ExampleSchema extends Schema { | |
//There should only be one HBaseConfiguration object per process. You'll probably want to manage that | |
//instance yourself, so this library expects a reference to that instance. It's implicitly injected into | |
//the code, so the most convenient place to put it is right after you declare your Schema. | |
implicit val conf = LocalCluster.getTestConfiguration | |
//A table definition, where the row keys are Strings | |
class ExampleTable extends HbaseTable[ExampleTable,String, ExampleTableRow](tableName = "schema_example",rowKeyClass=classOf[String]) | |
{ |
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
new WebSearchAggregationJob().run(Settings.None, LocalCluster.getTestConfiguration) |
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
class WebSearchAggregationJob extends HJob[NoSettings]("Aggregate web searches by site", | |
HMapReduceTask( | |
HTaskID("Aggregation task"), | |
HTaskConfigs(), | |
HIO( | |
HTableInput(WebCrawlingSchema.WebTable), | |
HTableOutput(WebCrawlingSchema.Sites) | |
), | |
new FromTableBinaryMapperFx(WebCrawlingSchema.WebTable) { | |
val webPage = row |