Skip to content

Commit

Permalink
fix: pb indexer flush
Browse files Browse the repository at this point in the history
  • Loading branch information
hanxiao committed Jun 3, 2020
1 parent aaa3a10 commit 39a97c7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 0 additions & 1 deletion jina/executors/indexers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,3 @@ class ChunkIndexer(CompoundExecutor):
- !ControlReqDriver {}
"""

pass
4 changes: 3 additions & 1 deletion jina/executors/indexers/keyvalue/proto.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class BasePbIndexer(BaseKVIndexer):
"""Storing and querying protobuf chunk/document using gzip and Python dict. """

compress_level = 1 #: The compresslevel argument is an integer from 0 to 9 controlling the level of compression
flush_on_add = True #: When set to true, the indexer is flushed on every add, it is safer but slower

def get_query_handler(self):
r = {}
Expand Down Expand Up @@ -47,7 +48,8 @@ def add(self, obj):
"""
json.dump(obj, self.write_handler)
self.write_handler.write('\n')
self.flush()
if self.flush_on_add:
self.flush()

def query(self, key: int) -> Union['jina_pb2.Chunk', 'jina_pb2.Document']:
""" Find the protobuf chunk/doc using id
Expand Down

0 comments on commit 39a97c7

Please sign in to comment.