From 7c49fecd01cbd89bb5987442b89a4aafc1186ff9 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Mon, 20 Aug 2018 18:50:07 -0700 Subject: make col counter generic --- please | 28 ++++++++++++++++ .../scala/sandcrawler/GrobidMetadataCountJob.scala | 36 --------------------- .../main/scala/sandcrawler/HBaseColCountJob.scala | 37 ++++++++++++++++++++++ 3 files changed, 65 insertions(+), 36 deletions(-) delete mode 100644 scalding/src/main/scala/sandcrawler/GrobidMetadataCountJob.scala create mode 100644 scalding/src/main/scala/sandcrawler/HBaseColCountJob.scala diff --git a/please b/please index 0cc4b72..8a46978 100755 --- a/please +++ b/please @@ -165,6 +165,30 @@ def run_grobidscorabledump(args): env=args.env) subprocess.call(cmd, shell=True) +def run_colcount(args): + if args.rebuild: + rebuild_scalding() + print("Starting colcount job...") + output = "{}/output-{}/{}-colcount-{}".format( + HDFS_DIR, + args.env, + datetime.strftime(datetime.now(), "%Y-%m-%d-%H%M.%S"), + args.column) + cmd = """hadoop jar \ + scalding/target/scala-2.11/sandcrawler-assembly-0.2.0-SNAPSHOT.jar \ + com.twitter.scalding.Tool sandcrawler.HBaseColCountJob \ + --hdfs \ + --app.conf.path scalding/ia_cluster.conf \ + --hbase-table wbgrp-journal-extract-0-{env} \ + --zookeeper-hosts {zookeeper_hosts} \ + --column {column} \ + --output {output}""".format( + column=args.column, + output=output, + zookeeper_hosts=ZOOKEEPER_HOSTS, + env=args.env) + subprocess.call(cmd, shell=True) + def main(): parser = argparse.ArgumentParser() @@ -206,6 +230,10 @@ def main(): sub_grobidscorabledump = subparsers.add_parser('grobid-scorable-dump') sub_grobidscorabledump.set_defaults(func=run_grobidscorabledump) + sub_colcount = subparsers.add_parser('col-count') + sub_colcount.set_defaults(func=run_colcount) + sub_colcount.add_argument('column', + help="column name to use in count") args = parser.parse_args() if not args.__dict__.get("func"): diff --git a/scalding/src/main/scala/sandcrawler/GrobidMetadataCountJob.scala b/scalding/src/main/scala/sandcrawler/GrobidMetadataCountJob.scala deleted file mode 100644 index 08f3340..0000000 --- a/scalding/src/main/scala/sandcrawler/GrobidMetadataCountJob.scala +++ /dev/null @@ -1,36 +0,0 @@ -package sandcrawler - -import java.util.Properties - -import cascading.property.AppProps -import cascading.tuple.Fields -import com.twitter.scalding._ -import parallelai.spyglass.base.JobBase -import parallelai.spyglass.hbase.HBaseConstants.SourceMode -import parallelai.spyglass.hbase.HBasePipeConversions -import parallelai.spyglass.hbase.HBaseSource - -class GrobidMetadataCountJob(args: Args) extends JobBase(args) with HBasePipeConversions { - - val output = args("output") - - GrobidMetadataCountJob.getHBaseSource( - args("hbase-table"), - args("zookeeper-hosts")) - .read - .debug - .groupAll { _.size('count) } - .write(Tsv(output)) -} - -object GrobidMetadataCountJob { - - // eg, "wbgrp-journal-extract-0-qa",7 "mtrcs-zk1.us.archive.org:2181" - def getHBaseSource(hbaseTable: String, zookeeperHosts: String) : HBaseSource = { - HBaseBuilder.build( - hbaseTable, - zookeeperHosts, - List("grobid0:metadata"), - SourceMode.SCAN_ALL) - } -} diff --git a/scalding/src/main/scala/sandcrawler/HBaseColCountJob.scala b/scalding/src/main/scala/sandcrawler/HBaseColCountJob.scala new file mode 100644 index 0000000..a007339 --- /dev/null +++ b/scalding/src/main/scala/sandcrawler/HBaseColCountJob.scala @@ -0,0 +1,37 @@ +package sandcrawler + +import java.util.Properties + +import cascading.property.AppProps +import cascading.tuple.Fields +import com.twitter.scalding._ +import parallelai.spyglass.base.JobBase +import parallelai.spyglass.hbase.HBaseConstants.SourceMode +import parallelai.spyglass.hbase.HBasePipeConversions +import parallelai.spyglass.hbase.HBaseSource + +class HBaseColCountJob(args: Args) extends JobBase(args) with HBasePipeConversions { + + val output = args("output") + + HBaseColCountJob.getHBaseSource( + args("hbase-table"), + args("zookeeper-hosts"), + args("column") + .read + .debug + .groupAll { _.size('count) } + .write(Tsv(output)) +} + +object HBaseColCountJob { + + // eg, "wbgrp-journal-extract-0-qa",7 "mtrcs-zk1.us.archive.org:2181" + def getHBaseSource(hbaseTable: String, zookeeperHosts: String, col: String) : HBaseSource = { + HBaseBuilder.build( + hbaseTable, + zookeeperHosts, + List(col), + SourceMode.SCAN_ALL) + } +} -- cgit v1.2.3