0

我正在努力使用 Scio/Bigtable/HBase 验证以下示例项目的错误。依赖树需要 protobuf 版本(2.5、2.6.1、3.0、3.1)并且似乎默认为 3.2。我使用了 的着色组件sbt-assembly,不确定我是否正确。

我的build.sbt

name := "scalalab"

version := "1.0"

scalaVersion := "2.11.8"

libraryDependencies ++= Seq(
  "com.spotify" %% "scio-core" % "0.3.2",
  "com.google.cloud.bigtable" % "bigtable-hbase-1.2" % "0.9.2",
  "org.apache.hbase" % "hbase-client" % "1.2.5",
  "org.apache.hbase" % "hbase-common" % "1.2.5",
  "org.apache.hadoop" % "hadoop-common" % "2.7.3"
)

assemblyShadeRules in assembly := Seq(
  ShadeRule.rename("com.google.**" -> "shadeio.@1").inAll
)

assemblyMergeStrategy in assembly := {
  case x => MergeStrategy.first
}

我的Main.scala

import com.google.cloud.bigtable.hbase.adapters.Adapters
import com.google.cloud.bigtable.hbase.adapters.read.DefaultReadHooks
import org.apache.hadoop.hbase.client.Scan

object Main {
  def main(args: Array[String]): Unit = {
    val scan = new Scan
    scan.setMaxVersions()
    scan.addFamily("family".getBytes)
    scan.setRowPrefixFilter("prefix".getBytes)

    val builder = Adapters.SCAN_ADAPTER.adapt(scan, new DefaultReadHooks)

    System.out.println(builder)
  }
}

输出到:

scalalab git:(master) ? java -cp .:target/scala-2.11/scalalab-assembly-1.0.jar Main
Exception in thread "main" java.lang.VerifyError: Bad return type
Exception Details:
  Location:
    shadeio/cloud/bigtable/hbase/adapters/AppendAdapter.adapt(Lorg/apache/hadoop/hbase/client/Operation;)Lshadeio/bigtable/repackaged/com/google/protobuf/GeneratedMessageV3$Builder; @8: areturn
  Reason:
    Type 'shadeio/bigtable/v2/ReadModifyWriteRowRequest$Builder' (current frame, stack[0]) is not assignable to 'shadeio/bigtable/repackaged/com/google/protobuf/GeneratedMessageV3$Builder' (from method signature)
  Current Frame:
    bci: @8
    flags: { }
    locals: { 'shadeio/cloud/bigtable/hbase/adapters/AppendAdapter', 'org/apache/hadoop/hbase/client/Operation' }
    stack: { 'shadeio/bigtable/v2/ReadModifyWriteRowRequest$Builder' }
  Bytecode:
    0x0000000: 2a2b c000 28b6 00a0 b0

        at shadeio.cloud.bigtable.hbase.adapters.Adapters.<clinit>(Adapters.java:40)
        at Main$.main(Main.scala:12)
        at Main.main(Main.scala)

我究竟做错了什么 ?

谢谢你的帮助

4

2 回答 2

1

对于 Cloud Bigtable HBase 客户端来说,依赖性问题是一个难题。我们将在下一个版本中修复它。要解决您当前的问题,请导入“bigtable-hbase”而不是“bigtable-hbase-1.2”

另外,我建议可以使用最新版本的客户端,即 0.9.7.1。

于 2017-06-23T20:35:38.890 回答
0

Scio 有一个 bigtable 工件,您可以通过以下方式包含它:

libraryDependencies ++= Seq(
  "com.spotify" %% "scio-core" % "0.3.2",
  "com.spotify" %% "scio-bigtable" % "0.3.2"
)

通常,其他依赖项不需要使用 Bigtable,实际上它们可能会导致问题。

确保通过以下方式导入 bigtable 包:

import com.spotify.scio.bigtable._

检查这个BigtableExample

旁注您可能想sbt-pack尝试一下,而不是sbt-assembly充分利用工件缓存。有关 sbt 设置的示例,请查看此处的模板。

于 2017-06-23T20:24:53.820 回答