在 Scala 中将字节数组保存到 Riak

Save byte array to Riak in Scala

我尝试将文件保存到 riak 存储。这是我的问题的简化代码

val bytes: Array[Byte] = "bbb".toCharArray.map(_.toByte)
val client: RiakClient = RiakClient(host, port)
Await.ready(client.ping, Duration(30, TimeUnit.SECONDS))
val bucket: RiakBucket = client.bucket("fileStorage")
Await.ready(bucket.store("aaa",bytes), Duration.Inf)

我遇到了下一个错误

Error:(23, 29) could not find implicit value for evidence parameter of type com.scalapenos.riak.RiakMarshaller[Array[Byte]]
Await.ready(bucket.store("aaa",bytes), Duration.Inf)

我知道我需要在 bucket.store[X]("aaa",bytes) 中指定类型,但没有找到合适的类型,我必须用它来代替 X

Riak 库中有我需要的类型还是我应该自己实现?

PS:我使用这个来自 maven 的库:

<dependency>
    <groupId>com.scalapenos</groupId>
    <artifactId>riak-scala-client_2.11</artifactId>
    <version>0.9.5</version>
</dependency>

我找不到问题的解决方案。所以我将库更改为

    <dependency>
        <groupId>com.basho.riak</groupId>
        <artifactId>riak-client</artifactId>
    </dependency>

然后

val location = new Location(namespace, key)
val storeValue = new RiakObject()
storeValue.setValue(BinaryValue.create(data.bytes))
val command = new StoreValue.Builder(storeValue)
  .withLocation(location)
  .build()
client.execute(command)

其中 namespace 的类型为 NamespacekeyStringdata.bytesArray[Byte]