Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
common_helper_mongo
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fact-gitdep
common_helper_mongo
Commits
c30111c2
Unverified
Commit
c30111c2
authored
5 years ago
by
Johannes vom Dorp
Committed by
GitHub
5 years ago
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3 from fkie-cad/bugfix_and_refactoring
added allowDiskUse for large aggregation queries
parents
5baef28e
7cb937ab
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
aggregate.py
common_helper_mongo/aggregate.py
+4
-4
No files found.
common_helper_mongo/aggregate.py
View file @
c30111c2
...
...
@@ -21,7 +21,7 @@ def get_list_of_all_values(collection, object_path, unwind=False, match=None):
:return: list
'''
pipeline
=
_build_pipeline
(
object_path
,
{
'_id'
:
object_path
},
unwind
,
SON
([(
'_id'
,
1
)]),
match
)
result
=
_get_list_of_aggregate_list
(
list
(
collection
.
aggregate
(
pipeline
)))
result
=
_get_list_of_aggregate_list
(
list
(
collection
.
aggregate
(
pipeline
,
allowDiskUse
=
True
)))
logging
.
debug
(
result
)
return
result
...
...
@@ -47,7 +47,7 @@ def get_all_value_combinations_of_fields(collection, primary_field, secondary_fi
primary_field
,
{
'_id'
:
primary_field
,
'additional_information'
:
{
'$addToSet'
:
secondary_field
}},
unwind
,
SON
([(
'_id'
,
1
)]),
match
)
result
=
list
(
collection
.
aggregate
(
pipeline
))
result
=
list
(
collection
.
aggregate
(
pipeline
,
allowDiskUse
=
True
))
result
=
_get_dict_from_aggregate_list
(
result
)
logging
.
debug
(
result
)
return
result
...
...
@@ -81,7 +81,7 @@ def get_objects_and_count_of_occurrence(collection, object_path, unwind=False, m
'''
pipeline
=
_build_pipeline
(
object_path
,
{
'_id'
:
object_path
,
'count'
:
{
'$sum'
:
1
}},
unwind
,
SON
([(
'count'
,
-
1
),
(
'_id'
,
-
1
)]),
match
)
result
=
list
(
collection
.
aggregate
(
pipeline
))
result
=
list
(
collection
.
aggregate
(
pipeline
,
allowDiskUse
=
True
))
logging
.
debug
(
result
)
return
result
...
...
@@ -120,7 +120,7 @@ def get_field_average(collection, object_path, match=None):
def
get_field_execute_operation
(
operation
,
collection
,
object_path
,
match
=
None
):
pipeline
=
_build_pipeline
(
object_path
,
{
'_id'
:
'null'
,
'total'
:
{
operation
:
object_path
}},
match
=
match
)
query_result
=
collection
.
aggregate
(
pipeline
)
query_result
=
collection
.
aggregate
(
pipeline
,
allowDiskUse
=
True
)
try
:
return
query_result
.
next
()[
'total'
]
except
StopIteration
:
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment