Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-2561

Remove CommandCursor.batch_size

    • Type: Icon: Task Task
    • Resolution: Won't Do
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      CommandCursor.batch_size is redundant. Users should pass "batchSize" to aggregate() instead. This code:

      cursor = collection.aggregate([]).batch_size(100)
      

      Can be changed to this:

      cursor = collection.aggregate([], batchSize=100)
      

      Another reason to remove CommandCursor.batch_size is that it lets users configure different batchSizes per getMore:

      cursor = collection.aggregate([], batchSize=100)
      # next getMore will send batchSize=2
      cursor.batch_size(2)
      ...
      # next getMore will send batchSize=5
      cursor.batch_size(5)
      

      Note that starting in PyMongo 3.6 (PYTHON-1338) the following calls are equivalent:

      collection.aggregate([], batchSize=100).batch_size(100)
      collection.aggregate([], batchSize=100)
      

      Before 3.6, the second example would only set the batchSize for the initial aggregate command and not for any subsequent getMores.

            Assignee:
            Unassigned Unassigned
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: