Skip to content
Permalink
Browse files

feat(indexer): add preprocessor and lvdb for storing gif

  • Loading branch information...
jemmyshin committed Aug 21, 2019
1 parent 4e1e53f commit 38567b0071dc3ccc59bb72e9f7f936b9e0443388
Showing with 1 addition and 14 deletions.
  1. +1 −14 gnes/indexer/fulltext/filesys.py
@@ -46,9 +46,8 @@ def add(self, keys: List[int], docs: List['gnes_pb2.Document'], *args, **kwargs)
dirs = os.path.join(self.data_path, str(k))
if not os.path.exists(dirs):
os.makedirs(dirs)
self.file_suffix = self._get_file_type(d.doc_type)
for i, chunk in enumerate(d.chunks):
with open(os.path.join(dirs, str(i)+self.file_suffix), 'wb') as f:
with open(os.path.join(dirs, '%d.%s' % (i, self.file_suffix)), 'wb') as f:
f.write(chunk.raw)

def query(self, keys: List[int], *args, **kwargs) -> List['gnes_pb2.Document']:
@@ -73,16 +72,4 @@ def query(self, keys: List[int], *args, **kwargs) -> List['gnes_pb2.Document']:
res.append(doc)
return res

@staticmethod
def _get_file_type(doc_type):
if doc_type == gnes_pb2.Document.VIDEO:
return '.gif'
elif doc_type == gnes_pb2.Document.IMAGE:
raise NotImplementedError
elif doc_type == gnes_pb2.Document.TEXT:
raise NotImplementedError
elif doc_type == gnes_pb2.Document.AUDIO:
raise NotImplementedError
else:
raise ValueError("doc type can only be TEXT, IMAGE, VIDEO or AUDIO!")

0 comments on commit 38567b0

Please sign in to comment.
You can’t perform that action at this time.