Skip to content

Commit

Permalink
refactor(driver): refactor reduce driver
Browse files Browse the repository at this point in the history
  • Loading branch information
hanxiao committed Jul 17, 2020
1 parent 66c8e75 commit b23ed07
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions jina/drivers/rank.py
Expand Up @@ -10,6 +10,7 @@
if False:
from ..proto import jina_pb2


class BaseRankDriver(BaseExecutableDriver):
"""Drivers inherited from this Driver will bind :meth:`craft` by default """

Expand Down
4 changes: 2 additions & 2 deletions jina/drivers/reduce.py
Expand Up @@ -7,7 +7,7 @@
from . import BaseRecursiveDriver
from ..excepts import NoExplicitMessage
from ..proto import jina_pb2

from copy import copy

class ReduceDriver(BaseRecursiveDriver):

Expand Down Expand Up @@ -71,7 +71,7 @@ def reduce(self, *args, **kwargs):

def apply(self, doc: 'jina_pb2.Document', *args, **kwargs):
if doc.id not in self.doc_pointers:
self.doc_pointers[doc.id] = doc # what? why is this deep copy?
self.doc_pointers[doc.id] = copy(doc) # force a shallow copy
else:
self.doc_pointers[doc.id].chunks.extend(doc.chunks)
self.doc_pointers[doc.id].matches.extend(doc.matches)

0 comments on commit b23ed07

Please sign in to comment.