From 9a18da82738c16d3066e02e886ee84e04156889f Mon Sep 17 00:00:00 2001 From: Ellen Spertus Date: Mon, 4 Jun 2018 14:45:26 -0700 Subject: Made changes suggested in merge request review. - Changed inverseSchema from Map to List, eliminating incorrect comment. - Changing format of argument to HBaseBuilder.build from String to List[String]. --- scalding/src/main/scala/sandcrawler/HBaseBuilder.scala | 13 ++++--------- scalding/src/main/scala/sandcrawler/HBaseRowCountJob.scala | 2 +- 2 files changed, 5 insertions(+), 10 deletions(-) (limited to 'scalding/src/main/scala') diff --git a/scalding/src/main/scala/sandcrawler/HBaseBuilder.scala b/scalding/src/main/scala/sandcrawler/HBaseBuilder.scala index eb108a2..87cc0cb 100644 --- a/scalding/src/main/scala/sandcrawler/HBaseBuilder.scala +++ b/scalding/src/main/scala/sandcrawler/HBaseBuilder.scala @@ -11,16 +11,11 @@ object HBaseBuilder { "file" -> List("size", "mime", "cdx"), "grobid0" -> List("status_code", "quality", "status", "tei_xml", "tei_json", "metadata"), "match0" -> List("status", "doi", "info")) - // map from colFamily:colName -> colFamily - // Code from https://stackoverflow.com/a/50595189/6310511 - val inverseSchema = for ((k, vs) <- schema; v <- vs) yield (k + ":" + v, k) + val inverseSchema = {for ((k,vs) <- schema; v <-vs) yield (k + ":" + v)}.toList - // The argument should be a string with a comma-separated list of family:column, - // such as "f:c, file:size". Spaces after the comma are optional. + // The argument should be a comma-separated list of family:column, such as "f:c, file:size". @throws(classOf[IllegalArgumentException]) - def parseColSpec(colSpec: String) : (List[String], List[Fields]) = { - val colSpecs = (if (colSpec.trim.length == 0) List() else colSpec.split(", *").toList) - + def parseColSpec(colSpecs: List[String]) : (List[String], List[Fields]) = { // Verify that all column specifiers are legal. for (colSpec <- colSpecs) { if (!(inverseSchema contains colSpec)) { @@ -44,7 +39,7 @@ object HBaseBuilder { (families, groupedColNames.map({fields => new Fields(fields : _*)})) } - def build(table: String, server: String, colSpec: String, sourceMode: SourceMode, keyList: List[String] = List("key")) = { + def build(table: String, server: String, colSpec: List[String], sourceMode: SourceMode, keyList: List[String] = List("key")) = { val (families, fields) = parseColSpec(colSpec) new HBaseSource(table, server, new Fields("key"), families, fields, sourceMode = sourceMode, keyList = keyList) } diff --git a/scalding/src/main/scala/sandcrawler/HBaseRowCountJob.scala b/scalding/src/main/scala/sandcrawler/HBaseRowCountJob.scala index 041df4d..9d074ab 100644 --- a/scalding/src/main/scala/sandcrawler/HBaseRowCountJob.scala +++ b/scalding/src/main/scala/sandcrawler/HBaseRowCountJob.scala @@ -27,6 +27,6 @@ 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?) - "file:size, file:mime", + List("file:size", "file:mime"), SourceMode.SCAN_ALL) } -- cgit v1.2.3