Skip to content

Commit

Permalink
Merge pull request #1183 from girder/reduce-pipeline-memory
Browse files Browse the repository at this point in the history
Reduce memory use in a mongo aggregation pipeline
  • Loading branch information
manthey authored May 30, 2023
2 parents 037e9dc + 0064a9b commit 7b20a92
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## 1.22.1

### Improvements
- Reduce memory use in a mongo aggregation pipeline ([#1183](../../pull/1183))

## 1.22.0

### Features
Expand Down
13 changes: 11 additions & 2 deletions girder_annotation/girder_large_image_annotation/rest/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,8 +630,17 @@ def getFolderAnnotations(self, id, recurse, user, limit=False, offset=False, sor
pipeline = recursivePipeline + [
{'$lookup': {
'from': 'item',
'localField': '_id',
'foreignField': 'folderId',
# We have to use a pipeline to use a projection to reduce the
# data volume, so instead of specifying localField and
# foreignField, we set the localField to a variable, then match
# it in a pipeline and project to exclude everything but id.
# 'localField': '_id',
# 'foreignField': 'folderId',
'let': {'fid': '$_id'},
'pipeline': [
{'$match': {'$expr': {'$eq': ['$$fid', '$folderId']}}},
{'$project': {'_id': 1}}
],
'as': '__items'
}},
{'$lookup': {
Expand Down

0 comments on commit 7b20a92

Please sign in to comment.