我有一个名为public class StatusListCell extends ListCell<String> {
private final Map<String, WeakReference<Image>> cache;
private final ImageView imageView;
public StatusListCell(Map<String, WeakReference<Image>> cache) {
imageView = new ImageView();
imageView.setFitWidth(40);
imageView.setFitHeight(40);
setGraphic(imageView); // keep image even if empty for constant cell size
this.cache = cache;
}
protected void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
if (empty || item == null) {
setText("");
imageView.setImage(null); // don't display a image
} else {
cache.compute(item, (k, v) -> {
// retrieve image or load
Image img = null;
if (v != null) {
img = v.get();
}
if (img == null) {
img = new Image(k);
v = new WeakReference<>(img);
}
// change image in imageview
imageView.setImage(img);
return v;
});
setText("a");
}
}
}
的服务器统计信息的MongoDB集合。
每10分钟将一个文档添加到此集合中,包括一些统计信息和时间戳。
假装我有这个系列:
stats
我想检索所有其他{"id": "something", "ts"=1}
{"id": "something", "ts"=2}
{"id": "something", "ts"=3}
{"id": "something", "ts"=4}
{"id": "something", "ts"=5}
{"id": "something", "ts"=6}
{"id": "something", "ts"=7}
{"id": "something", "ts"=8}
文档。 N
的示例:
N = 2
{"id": "something", "ts"=1}
{"id": "something", "ts"=3}
{"id": "something", "ts"=5}
{"id": "something", "ts"=7}
的示例:
N = 3
在pymongo中这样做的快速有效方法是什么?