akka-stream文档中有这样的说明,说明如下:
......可重用的流描述不能绑定到"实时"资源,任何与此类资源的连接或分配必须推迟到实现时间."实时"资源的示例是已经存在的TCP连接,多播发布者等; ...
关于这个说明,我有几个问题:
Thread?ActorRef那个ActorSystem用过的现有的ActorFlowMaterializer怎么样?PushPullStage但不是在一个创建函数的构造函数中分配它是否安全FlowGraph?我正在读一个Kafka主题,其中包含使用KafkaAvroEncoder(使用主题自动注册模式)序列化的Avro消息.我正在使用maven-avro-plugin生成普通的Java类,我想在阅读时使用它.
该KafkaAvroDecoder只支持反序列化到GenericData.Record类型,(在我看来)错过具有静态类型语言的整点.我的反序列化代码目前看起来像这样:
SpecificDatumReader<event> reader = new SpecificDatumReader<>(
event.getClassSchema() // event is my class generated from the schema
);
byte[] in = ...; // my input bytes;
ByteBuffer stuff = ByteBuffer.wrap(in);
// the KafkaAvroEncoder puts a magic byte and the ID of the schema (as stored
// in the schema-registry) before the serialized message
if (stuff.get() != 0x0) {
return;
}
int id = stuff.getInt();
// lets just ignore those special bytes
int length = …Run Code Online (Sandbox Code Playgroud) 我是Scala的新手,我很简单Map[String, String]。
示例图:
val map = Map("a" -> "abc", "b" -> "xyz")
Run Code Online (Sandbox Code Playgroud)
我想编写一个逻辑,如果映射中存在特定密钥,则对该值调用crypto()方法,如果该密钥不存在,则返回空字符串。
我可以这样做的一种方法是:
encrypt(map.getOrElse(MARKETPLACE_ID.toString, ""))
Run Code Online (Sandbox Code Playgroud)
如果不存在密钥,这将失败,并且将使用空字符串调用crypto()方法。
请帮助我以最简单的方式解决此问题。