tinkoff / aerospike-scala Goto Github PK
View Code? Open in Web Editor NEWTypesafe DSL for work with Aerospike Database
License: Apache License 2.0
Typesafe DSL for work with Aerospike Database
License: Apache License 2.0
Save - spike.callKB(CallKB.Put, "testKey3", SingleBin("array_in_array", Array(Array("val1"), Array("val2"))))
Read - spike.getByKey[String, Array[Array[String]]]("testKey3", List("array_in_array"))
Result - (Map(array_in_array -> Some({})),14,228416602)
But case with List works good.
Save - spike.callKB(CallKB.Put, "testKey3", SingleBin("list_in_list", List(List("val1"), List("val2"))))
Read - spike.getByKey[String, List[List[String]]]("testKey3", List("list_in_list"))
Result - (Map(list_in_list -> Some([List(val1), List(val2)])),14,228416602)
It's needed to subscribe on WriteListener to retrieve errors that appeared during writing into Aerospike. It's could be implemented via Promise.
At now only exceptions in direct method call could be caught, but it is not enough in case of asynchronous client.
Instead of working just with aerospikescala
DSL it's needed to know about aerospikemacro
and aerospikedomain
subproject. It brings knowledge complexity and misunderstanding.
For example typical import:
import ru.tinkoff.aerospike.dsl.{CallKB, SpikeImpl}
import ru.tinkoff.aerospikemacro.domain.DBCredentials
import ru.tinkoff.aerospikescala.domain.SingleBin
import ru.tinkoff.aerospikemacro.converters._
AClient.scala
val hosts = scala.util.Try(List(config.getString("ru-tinkoff-aerospike-dsl.example-host"))).toOption .getOrElse(throw new Exception("Add host for aerospike in application.conf file"))
toOption
is redundant. Try
already contains getOrElse
method.
println(Await.result(
spike.getByKey[String, Seq[ArrayBuffer[Double]]]("1-1111A1", Nil).collect {
case (xs, _, _) if xs.head._2.isDefined โ
xs.head._2.get
}, Duration.Inf
).getClass)
returns: class java.util.ArrayList
class SpikeImpl(spikeClient: IAsyncClient)(implicit val ec: ExecutionContext)
and some of its methods (getByKey
for example) require ExecutionContext independently.
spike.getByKey[String, Array[Array[String]]]("testKey3333", List("array_in_array")), Duration.Inf)
throws
Exception in thread "main" java.lang.NullPointerException at HelloAerospike$$anon$8.apply(HelloAerospike.scala:22) at ru.tinkoff.aerospike.dsl.SpikeImpl$$anonfun$getByKey$2.apply(SpikeImpl.scala:207) at ru.tinkoff.aerospike.dsl.SpikeImpl$$anonfun$getByKey$2.apply(SpikeImpl.scala:207) at scala.util.Success$$anonfun$map$1.apply(Try.scala:237) at scala.util.Try$.apply(Try.scala:192) at scala.util.Success.map(Try.scala:237) at scala.concurrent.Future$$anonfun$map$1.apply(Future.scala:237) at scala.concurrent.Future$$anonfun$map$1.apply(Future.scala:237) at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32) at scala.concurrent.impl.ExecutionContextImpl$AdaptedForkJoinTask.exec(ExecutionContextImpl.scala:121) at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.pollAndExecAll(ForkJoinPool.java:1253) at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1346) at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.