- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我的重复删除代码(在 MongoDB shell 中)是这样的:
db.<collection_name>.aggregate([
{
$group: {
_id: { <duplicated_keys>: "$<duplicated_keys>" },
dups: { $addToSet: "$_id" },
count: { $sum: 1 }
}
},
{
$match: {
count: { $gt: 1 }
}
}
], { allowDiskUse: true })
.forEach(function(doc) {
doc.dups.shift();
db.<collection_name>.remove({ _id: { $in: doc.dups } });
});
我遇到了这样的错误:
[thread1] Error: getMore command failed: {
"ok" : 0,
"errmsg" : "Cursor not found, cursor id: 144931661890",
"code" : 43
}
这个错误的原因是什么?我该如何解决这个问题?
更新
在forEach
之前,结果是:
{ "_id" : { <duplicated_keys>: <dupkey_values> }, "dups" : [ ObjectId("56f8e4d37a88ea2aa938414d"), ObjectId("56f63ab87a88ea141ca33856") ], "count" : 2 }
如果我用 ObjectId("56f63ab87a88ea141ca33856")
找到,它就是重复的文档。
最佳答案
终于找到解决办法了。 MongoDB 中的游标是有生命周期的,默认是 10 分钟。一旦超过这个时间,shell就再也找不到下一个游标了。
为避免这种情况,请使用 noCursorTimeout()
设置光标的生命周期。例如:
db.<collection_name>.aggregate([
{
$group: {
_id: { <duplicated_keys>: "$<duplicated_keys>" },
dups: { $addToSet: "$_id" },
count: { $sum: 1 }
}
},
{
$match: {
count: { $gt: 1 }
}
},
{
$out: "tempCollection"
}
], { allowDiskUse: true });
db.tempCollection.find().noCursorTimeout().forEach(...);
或者使用更小的批量大小。例如:
db.<collection_name>.aggregate([
{
$group: {
_id: { <duplicated_keys>: "$<duplicated_keys>" },
dups: { $addToSet: "$_id" },
count: { $sum: 1 }
}
},
{
$match: {
count: { $gt: 1 }
}
},
{
$out: "tempCollection"
}
],
{
allowDiskUse: true,
cursor: { batchSize: 0 }
});
db.tempCollection.find().forEach(...);
关于删除重复项时出现 MongoDB 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36262385/
有人可以给我一个想法,例如将高度从0添加时动画化,并在移除时返回0动画化? 最佳答案 添加动画时很容易,只需将Animated中的componentDidMount与listRow一起使用,例如: c
我目前有一个包含 3 个选项卡的 tabview。 1 选项卡加载 ActivityGroup,然后加载 listview。我有这个,所以我可以加载不同的 Activity 并查看并仍然显示选项卡。当
此正则表达式 /({{(?!{*textdata.*)#\s*.[\w\.]+\.*}})/gm在 chrome 上使用正则表达式只给我两个匹配项(期望 4)。当我在 http://www.regex
我一直在尝试从头开发一个简单的 Accordion ,但这个问题让我无法这样做。 我正在尝试实现一种效果,您可以在其中展开元素,内容弹出,加号图标变成目标 Accordion 元素的减号 - 至此一切
当用户点击 tabbaritem 进入 uitabbarcontroller 来改变某些东西时,我需要检索..这是我的代码: - (void)tabBar:(UITabBar *)tabBar did
我尝试使用 kv_t 存储一些数据但没有成功。我也尝试过例子forum.c & kv.c。当尝试创建第二个论坛线程时,forum.c 挂起,而 kv.c 崩溃。 当我向 kv 添加 1 个项目时,kv
我正在为 map 构建一个主题选择器,并希望反射(reflect)当前选择的主题。 该代码似乎有效,但从不返回“li”项目的值,它总是为我单击的任何“li”项目返回“s-thumbs”。我尝试使用 .
我正在浏览 Go 并想了解以下内容: package main import "fmt" func main() { s := []int{2, 3, 5, 7, 11, 13} pr
我正在使用 VS2013、.net4.5、WPF 桌面应用程序。 Xaml: CS: this
我正在尝试创建一个搜索抛出 ListView 项目的 Activity 。我创建了一个 switch与 case Category其中 Category是 main 中的一项 ,但是当我单击该项目时,
我是一名优秀的程序员,十分优秀!