marklogic - 产生多个线程以删除多个相同元素时出错
问题描述
我想在 xml 中删除复制 2353218 次的相同元素,只保留一个。试图生成该进程但出现以下错误。没有产卵它需要太多时间。请帮忙。
xquery version "1.0-ml";
let $input := doc("http://www.somedomain.com/name/12345.xml")/xpath/toMultipleElement[2 to last()]
let $batch-size := 50000
let $input-size := fn:count($input)
let $num-batches := xs:int(math:ceil($input-size div $batch-size ))
let $result :=
<root>{
for $batch-start in (1 to $num-batches)
let $processing-seq := $input[($batch-size * ($batch-start - 1) + 1) to ($batch-size * ($batch-start ))]
return
xdmp:spawn-function(function() {
xdmp:node-delete($processing-seq),
<success batch-start='{$batch-start}'> processing sequence deleted</success>
},
<options xmlns="xdmp:eval">
<result>true</result>
<transaction-mode>update-auto-commit</transaction-mode>
</options>)
}</root>
return
xdmp:save("D:/batch-wise-delete.xml", $result)
错误:[1.0-ml] XDMP-DELEXTNODES: let $processing-seq := $input[$batch-size * ($batch-start - 1) + 1 to $batch-size * $batch-start] -- 不能删除外部节点
解决方案
与其删除所有孩子,不如写一个有一个孩子的新父母。
let $parent := doc("http://www.somedomain.com/name/12345.xml")/xpath/parent
let $chosen-child := $parent/toMultipleElement[1]
return xdmp:node-replace($parent, <parent>{ $chosen-child }</parent>
推荐阅读
- sql-server - SQL Server - 多次循环自加入
- angular - Angular 定义要在嵌套 HTML 元素中重复使用的变量
- sql - 在两列中搜索文本框中的相同值
- python - Visual Studio 代码和模块中的 Python 未导入
- php - Laravel:为什么无效的路由动作?
- c# - 从异步任务方法返回“正常”变量
- mongodb - mongodb - 具有多个标识符和混合条件 (AND/OR) 的 arrayFilters
- javascript - Handsontable 更新公式变量
- entity-framework-core - 使用 Entity Framework Core 查找最大日期 - 在 Razor 页面中
- php - 如何在 CodeIgniter 中创建全局变量?