From 2a2921d82a5a46549e9be2c2eb5703ce28fa7579 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Sun, 17 Jun 2018 10:00:28 -0700 Subject: hbase table and zk host as arguments --- .../src/main/scala/sandcrawler/HBaseCountJob.scala | 10 ++++++---- .../main/scala/sandcrawler/HBaseRowCountJob.scala | 21 ++++++++++++--------- .../test/scala/sandcrawler/HBaseMimeCountTest.scala | 5 ++++- .../test/scala/sandcrawler/HBaseRowCountTest.scala | 5 ++++- .../scala/sandcrawler/HBaseStatusCountTest.scala | 5 ++++- 5 files changed, 30 insertions(+), 16 deletions(-) (limited to 'scalding/src') diff --git a/scalding/src/main/scala/sandcrawler/HBaseCountJob.scala b/scalding/src/main/scala/sandcrawler/HBaseCountJob.scala index 815478b..53ce325 100644 --- a/scalding/src/main/scala/sandcrawler/HBaseCountJob.scala +++ b/scalding/src/main/scala/sandcrawler/HBaseCountJob.scala @@ -13,7 +13,9 @@ class HBaseCountJob(args: Args, colSpec: String) extends JobBase(args) with HBas HBaseBuilder.parseColSpec(colSpec) val Col: String = colSpec.split(":")(1) - HBaseCountJob.getHBaseSource(colSpec) + HBaseCountJob.getHBaseSource(args("hbase-table"), + args("zookeeper-hosts"), + colSpec) .read .fromBytesWritable(Symbol(Col)) .debug @@ -22,9 +24,9 @@ class HBaseCountJob(args: Args, colSpec: String) extends JobBase(args) with HBas } object HBaseCountJob { - def getHBaseSource(colSpec: String) = HBaseBuilder.build( - "wbgrp-journal-extract-0-qa", // HBase Table Name - "mtrcs-zk1.us.archive.org:2181", // HBase Zookeeper server (to get runtime config info; can be array?) + def getHBaseSource(hbase_table: String, zookeeper_hosts: String, colSpec: String) = HBaseBuilder.build( + hbase_table, // HBase Table Name + zookeeper_hosts, // HBase Zookeeper server (to get runtime config info; can be array?) List(colSpec), SourceMode.SCAN_ALL) } diff --git a/scalding/src/main/scala/sandcrawler/HBaseRowCountJob.scala b/scalding/src/main/scala/sandcrawler/HBaseRowCountJob.scala index 0c8e615..7f5c84a 100644 --- a/scalding/src/main/scala/sandcrawler/HBaseRowCountJob.scala +++ b/scalding/src/main/scala/sandcrawler/HBaseRowCountJob.scala @@ -10,12 +10,10 @@ import parallelai.spyglass.hbase.HBaseConstants.SourceMode class HBaseRowCountJob(args: Args) extends JobBase(args) with HBasePipeConversions { - - // For now doesn't actually count, just dumps a "word count" - val output = args("output") - HBaseRowCountJob.getHBaseSource + HBaseRowCountJob.getHBaseSource(args("hbase-table"), + args("zookeeper-hosts")) .read .debug .groupAll { _.size('count) } @@ -23,9 +21,14 @@ class HBaseRowCountJob(args: Args) extends JobBase(args) with HBasePipeConversio } object HBaseRowCountJob { - def getHBaseSource = HBaseBuilder.build( - "wbgrp-journal-extract-0-qa", // HBase Table Name - "mtrcs-zk1.us.archive.org:2181", // HBase Zookeeper server (to get runtime config info; can be array?) - List("file:size", "file:mime"), - SourceMode.SCAN_ALL) + + // eg, "wbgrp-journal-extract-0-qa", "mtrcs-zk1.us.archive.org:2181" + def getHBaseSource(hbase_table: String, zookeeper_hosts: String) : HBaseSource = { + return HBaseBuilder.build( + hbase_table, + zookeeper_hosts, + List("file:size"), + SourceMode.SCAN_ALL) + } + } diff --git a/scalding/src/test/scala/sandcrawler/HBaseMimeCountTest.scala b/scalding/src/test/scala/sandcrawler/HBaseMimeCountTest.scala index cc400c5..fcd9087 100644 --- a/scalding/src/test/scala/sandcrawler/HBaseMimeCountTest.scala +++ b/scalding/src/test/scala/sandcrawler/HBaseMimeCountTest.scala @@ -16,6 +16,7 @@ import scala._ class HBaseMimeCountTest extends FunSpec with TupleConversions { val output = "/tmp/testOutput" + val (test_table, test_host) = ("test-table", "dummy-host:2181") val log = LoggerFactory.getLogger(this.getClass.getName) @@ -40,8 +41,10 @@ class HBaseMimeCountTest extends FunSpec with TupleConversions { .arg("test", "") .arg("app.conf.path", "app.conf") .arg("output", output) + .arg("hbase-table", test_table) + .arg("zookeeper-hosts", test_host) .arg("debug", "true") - .source[Tuple](HBaseCountJob.getHBaseSource("file:mime"), + .source[Tuple](HBaseCountJob.getHBaseSource(test_table, test_host, "file:mime"), sampleData.map(l => new Tuple(l.map(s => {new ImmutableBytesWritable(Bytes.toBytes(s))}):_*))) .sink[Tuple](Tsv(output)) { outputBuffer => diff --git a/scalding/src/test/scala/sandcrawler/HBaseRowCountTest.scala b/scalding/src/test/scala/sandcrawler/HBaseRowCountTest.scala index 6f61eb3..a5c35a2 100644 --- a/scalding/src/test/scala/sandcrawler/HBaseRowCountTest.scala +++ b/scalding/src/test/scala/sandcrawler/HBaseRowCountTest.scala @@ -19,6 +19,7 @@ import scala._ class HBaseRowCountTest extends FunSpec with TupleConversions { val output = "/tmp/testOutput" + val (test_table, test_host) = ("test-table", "dummy-host:2181") val log = LoggerFactory.getLogger(this.getClass.getName) @@ -37,8 +38,10 @@ class HBaseRowCountTest extends FunSpec with TupleConversions { .arg("test", "") .arg("app.conf.path", "app.conf") .arg("output", output) + .arg("hbase-table", test_table) + .arg("zookeeper-hosts", test_host) .arg("debug", "true") - .source[Tuple](HBaseRowCountJob.getHBaseSource, + .source[Tuple](HBaseRowCountJob.getHBaseSource(test_table, test_host), sampleData.map(l => new Tuple(l.map(s => {new ImmutableBytesWritable(Bytes.toBytes(s))}):_*))) .sink[Tuple](Tsv(output)) { outputBuffer => diff --git a/scalding/src/test/scala/sandcrawler/HBaseStatusCountTest.scala b/scalding/src/test/scala/sandcrawler/HBaseStatusCountTest.scala index a0b313e..1877d6f 100644 --- a/scalding/src/test/scala/sandcrawler/HBaseStatusCountTest.scala +++ b/scalding/src/test/scala/sandcrawler/HBaseStatusCountTest.scala @@ -16,6 +16,7 @@ import scala._ class HBaseStatusCountTest extends FunSpec with TupleConversions { val output = "/tmp/testOutput" + val (test_table, test_host) = ("test-table", "dummy-host:2181") val log = LoggerFactory.getLogger(this.getClass.getName) @@ -40,8 +41,10 @@ class HBaseStatusCountTest extends FunSpec with TupleConversions { .arg("test", "") .arg("app.conf.path", "app.conf") .arg("output", output) + .arg("hbase-table", test_table) + .arg("zookeeper-hosts", test_host) .arg("debug", "true") - .source[Tuple](HBaseCountJob.getHBaseSource("grobid0:status"), + .source[Tuple](HBaseCountJob.getHBaseSource(test_table, test_host, "grobid0:status"), sampleData.map(l => new Tuple(l.map(s => {new ImmutableBytesWritable(Bytes.toBytes(s))}):_*))) .sink[Tuple](Tsv(output)) { outputBuffer => -- cgit v1.2.3 From 071f4ff633eaa2669c4afcfc421f95cdc0a6765f Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Fri, 13 Jul 2018 15:02:56 -0400 Subject: snake_case to lowerCamelCase ... following scala norms. (as per Ellen's review) --- scalding/src/main/scala/sandcrawler/HBaseCountJob.scala | 6 +++--- scalding/src/main/scala/sandcrawler/HBaseRowCountJob.scala | 6 +++--- scalding/src/test/scala/sandcrawler/HBaseMimeCountTest.scala | 8 ++++---- scalding/src/test/scala/sandcrawler/HBaseRowCountTest.scala | 8 ++++---- scalding/src/test/scala/sandcrawler/HBaseStatusCountTest.scala | 8 ++++---- 5 files changed, 18 insertions(+), 18 deletions(-) (limited to 'scalding/src') diff --git a/scalding/src/main/scala/sandcrawler/HBaseCountJob.scala b/scalding/src/main/scala/sandcrawler/HBaseCountJob.scala index 53ce325..863c16f 100644 --- a/scalding/src/main/scala/sandcrawler/HBaseCountJob.scala +++ b/scalding/src/main/scala/sandcrawler/HBaseCountJob.scala @@ -24,9 +24,9 @@ class HBaseCountJob(args: Args, colSpec: String) extends JobBase(args) with HBas } object HBaseCountJob { - def getHBaseSource(hbase_table: String, zookeeper_hosts: String, colSpec: String) = HBaseBuilder.build( - hbase_table, // HBase Table Name - zookeeper_hosts, // HBase Zookeeper server (to get runtime config info; can be array?) + def getHBaseSource(hbaseTable: String, zookeeperHosts: String, colSpec: String) = HBaseBuilder.build( + hbaseTable, // HBase Table Name + zookeeperHosts, // HBase Zookeeper server (to get runtime config info; can be array?) List(colSpec), SourceMode.SCAN_ALL) } diff --git a/scalding/src/main/scala/sandcrawler/HBaseRowCountJob.scala b/scalding/src/main/scala/sandcrawler/HBaseRowCountJob.scala index 7f5c84a..334b7a6 100644 --- a/scalding/src/main/scala/sandcrawler/HBaseRowCountJob.scala +++ b/scalding/src/main/scala/sandcrawler/HBaseRowCountJob.scala @@ -23,10 +23,10 @@ class HBaseRowCountJob(args: Args) extends JobBase(args) with HBasePipeConversio object HBaseRowCountJob { // eg, "wbgrp-journal-extract-0-qa", "mtrcs-zk1.us.archive.org:2181" - def getHBaseSource(hbase_table: String, zookeeper_hosts: String) : HBaseSource = { + def getHBaseSource(hbaseTable: String, zookeeperHosts: String) : HBaseSource = { return HBaseBuilder.build( - hbase_table, - zookeeper_hosts, + hbaseTable, + zookeeperHosts, List("file:size"), SourceMode.SCAN_ALL) } diff --git a/scalding/src/test/scala/sandcrawler/HBaseMimeCountTest.scala b/scalding/src/test/scala/sandcrawler/HBaseMimeCountTest.scala index fcd9087..fde2290 100644 --- a/scalding/src/test/scala/sandcrawler/HBaseMimeCountTest.scala +++ b/scalding/src/test/scala/sandcrawler/HBaseMimeCountTest.scala @@ -16,7 +16,7 @@ import scala._ class HBaseMimeCountTest extends FunSpec with TupleConversions { val output = "/tmp/testOutput" - val (test_table, test_host) = ("test-table", "dummy-host:2181") + val (testTable, testHost) = ("test-table", "dummy-host:2181") val log = LoggerFactory.getLogger(this.getClass.getName) @@ -41,10 +41,10 @@ class HBaseMimeCountTest extends FunSpec with TupleConversions { .arg("test", "") .arg("app.conf.path", "app.conf") .arg("output", output) - .arg("hbase-table", test_table) - .arg("zookeeper-hosts", test_host) + .arg("hbase-table", testTable) + .arg("zookeeper-hosts", testHost) .arg("debug", "true") - .source[Tuple](HBaseCountJob.getHBaseSource(test_table, test_host, "file:mime"), + .source[Tuple](HBaseCountJob.getHBaseSource(testTable, testHost, "file:mime"), sampleData.map(l => new Tuple(l.map(s => {new ImmutableBytesWritable(Bytes.toBytes(s))}):_*))) .sink[Tuple](Tsv(output)) { outputBuffer => diff --git a/scalding/src/test/scala/sandcrawler/HBaseRowCountTest.scala b/scalding/src/test/scala/sandcrawler/HBaseRowCountTest.scala index a5c35a2..3424a36 100644 --- a/scalding/src/test/scala/sandcrawler/HBaseRowCountTest.scala +++ b/scalding/src/test/scala/sandcrawler/HBaseRowCountTest.scala @@ -19,7 +19,7 @@ import scala._ class HBaseRowCountTest extends FunSpec with TupleConversions { val output = "/tmp/testOutput" - val (test_table, test_host) = ("test-table", "dummy-host:2181") + val (testTable, testHost) = ("test-table", "dummy-host:2181") val log = LoggerFactory.getLogger(this.getClass.getName) @@ -38,10 +38,10 @@ class HBaseRowCountTest extends FunSpec with TupleConversions { .arg("test", "") .arg("app.conf.path", "app.conf") .arg("output", output) - .arg("hbase-table", test_table) - .arg("zookeeper-hosts", test_host) + .arg("hbase-table", testTable) + .arg("zookeeper-hosts", testHost) .arg("debug", "true") - .source[Tuple](HBaseRowCountJob.getHBaseSource(test_table, test_host), + .source[Tuple](HBaseRowCountJob.getHBaseSource(testTable, testHost), sampleData.map(l => new Tuple(l.map(s => {new ImmutableBytesWritable(Bytes.toBytes(s))}):_*))) .sink[Tuple](Tsv(output)) { outputBuffer => diff --git a/scalding/src/test/scala/sandcrawler/HBaseStatusCountTest.scala b/scalding/src/test/scala/sandcrawler/HBaseStatusCountTest.scala index 1877d6f..35a4177 100644 --- a/scalding/src/test/scala/sandcrawler/HBaseStatusCountTest.scala +++ b/scalding/src/test/scala/sandcrawler/HBaseStatusCountTest.scala @@ -16,7 +16,7 @@ import scala._ class HBaseStatusCountTest extends FunSpec with TupleConversions { val output = "/tmp/testOutput" - val (test_table, test_host) = ("test-table", "dummy-host:2181") + val (testTable, testHost) = ("test-table", "dummy-host:2181") val log = LoggerFactory.getLogger(this.getClass.getName) @@ -41,10 +41,10 @@ class HBaseStatusCountTest extends FunSpec with TupleConversions { .arg("test", "") .arg("app.conf.path", "app.conf") .arg("output", output) - .arg("hbase-table", test_table) - .arg("zookeeper-hosts", test_host) + .arg("hbase-table", testTable) + .arg("zookeeper-hosts", testHost) .arg("debug", "true") - .source[Tuple](HBaseCountJob.getHBaseSource(test_table, test_host, "grobid0:status"), + .source[Tuple](HBaseCountJob.getHBaseSource(testTable, testHost, "grobid0:status"), sampleData.map(l => new Tuple(l.map(s => {new ImmutableBytesWritable(Bytes.toBytes(s))}):_*))) .sink[Tuple](Tsv(output)) { outputBuffer => -- cgit v1.2.3