需要帮助重写XQuery以避免MarkLogic中扩展的树缓存已满错误 [英] Need help rewriting XQuery to avoid expanded tree cache full error in MarkLogic

查看:53
本文介绍了需要帮助重写XQuery以避免MarkLogic中扩展的树缓存已满错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是XQuery和MarkLogic的新手.我正在尝试更新MarkLogic中的文档并获取扩展树缓存已满错误.为了完成工作,我增加了扩展的树缓存,但是不建议这样做.我想调整此查询,以便它不需要同时缓存尽可能多的XML.

I am new to XQuery and MarkLogic. I am trying to update documents in MarkLogic and get the extended tree cache full error. Just to get the work done I have increased the expanded tree cache but that is not recommended. I would like to tune this query so that it does not need to simultaneously cache as much XML.

这是我的查询

我已将查询上传为图像,因为当我将其粘贴到编辑器上时,它不是那么漂亮.如果有人知道更好的方法,请提出建议.

I have uploaded my query as an image because it was not so pretty when I pasted it on the editor. If any one knows a better way please suggest.

谢谢.

推荐答案

我恰好解决了这种情况.我做了两件事

I've just solved exactly this scenario. There are two things I did

  • 我将node-replace和node-insert类型调用(即修改XML结构的所有调用放入单独的模块,然后使用 xdmp:invoke 调用该模块,通过像这样的任何必需参数

  • I put the node-replace and node-insert type calls (that is any calls that modify the XML structure into a separate module and then called that module using xdmp:invoke, passing in any parameters required, like this

let $ update:= xdmp:invoke("/app/lib/update-attribute-node.xqy",(xs:QName("newValue"),$ new),{xdmp:modules-database()})

let $update := xdmp:invoke("/app/lib/update-attribute-node.xqy", (xs:QName("newValue"), $new), {xdmp:modules-database()})

之所以可行,是因为对xdmp:invoke的调用发生在它自己的事务中,一旦完成,便清除了内存.如果您不这样做,那么每次调用update或insert函数时,它实际上都不会执行写操作,直到在单个事务中结束时,这意味着您的内存将很快填满.

The reason why this works is that the call to xdmp:invoke happens in it's own transaction and once it completes, the memory is cleared up. If you don't do this then, each time you call the update or insert function, it will not actually do the write, until the end in a single transaction meaning your memory will fill up pretty quickly.

  • 每当我需要遍历MarkLogic中的路径(或文档或任何称为它们的路径-我仅使用MarkLogic几天),并且有很多路径时,我只处理了一个一次如下所示.我想出了一种精心制作的方法,一次可以跳过和仅处理一批文档,但是您可以采用多种方法来完成它.

  • Any time I needed to loop over paths in MarkLogic (or documents or whatever they are called - I've only been using MarkLogic for a few days) and there are a large number of them I processed them only a few at a time like below. I came up with an elaborate way of skipping and taking only a batch of documents at a time, but you can do it in any number of ways.

让$ whatever:= xdmp:directory("/whatever/")[$ start to $ end]

let $whatever:= xdmp:directory("/whatever/")[$start to $end]

我还将其放入单独的模块中,以便立即处理而不是在单个事务中处理.

I also put this into a separate module so that it is processed immediately and not in a single transaction.

将所有昂贵的调用放入单独的模块中,一次只获取大数据集的一个子集,可以帮助我解决扩展的树缓存的全部错误.

Putting all expensive calls into separate modules and taking only a subset of large data sets at a time helped me solve my expanded tree cache full errors.

这篇关于需要帮助重写XQuery以避免MarkLogic中扩展的树缓存已满错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆