我使用的是本机排序脚本&想要反序列化其中的源文档(以访问多层嵌套对象)。我可以使用获取SourceLookup对象
SourceLookup source = source();
它给了我的字节
byte[] bytes = source.internalSourceRef().toBytes()
这些字节的序列化格式是什么?我如何反序列化它?此外,执行此操作的性能考虑因素是什么?是否要求每个文档都有一个磁盘访问权限?
看一看SourceLookup
的源代码,就可以进一步了解其中的内容。该字节数组基本上是一个序列化的Map
(可能是压缩的),象征着文档源。
使用它的方法是在获得的source
引用上再次调用source()
,以便检索底层Map
:
SourceLookup source = source();
// number of keys in the map
int size = source.size();
// retrieve the content of the source
Map<String, Object> map = source.source();
// use the source map