0

If I run the following code Python kills the process since the list to process is too big. In fact, if I limit the number of results everything works just fine.

pipeline = [
        { "$unwind" : "$calls" },
    ]

calls_data = list(db.Data.aggregate(pipeline,allowDiskUse=True))

The obvious solution would be to iterate over the query result instead of making a list out of it. The problem is that I need to process the elements using a sliding window, i.e. given each element I need to access the next 3. Is there a way to actually get the first x results from the query, convert those into a list, process them and then do the same on the next x? Any possible solution is welcomed.

1 Answers1

0

You are right that processing the results using iterator is the way to go. You can do sliding window also with iterator: Rolling or sliding window iterator?

Messa
  • 24,321
  • 6
  • 68
  • 92