jina.executors.indexers.cache

class jina.executors.indexers.cache.BaseCache(*args, **kwargs)[source]

Bases: jina.executors.indexers.BaseKVIndexer

Base class of the cache inherited BaseKVIndexer

The difference between a cache and a BaseKVIndexer is the handler_mutex is released in cache, this allows one to query-while-indexing.

Parameters
  • index_filename – the name of the file for storing the index, when not given metas.name is used.

  • args

  • kwargs

post_init()[source]

query handler and write handler can not be serialized, thus they must be put into post_init().

class jina.executors.indexers.cache.DocIDCache(index_filename=None, *args, **kwargs)[source]

Bases: jina.executors.indexers.cache.BaseCache

Store doc ids in a int64 set and persistent it to a numpy array

Parameters
  • index_filename (Optional[str]) – the name of the file for storing the index, when not given metas.name is used.

  • args

  • kwargs

add(doc_id, *args, **kwargs)[source]
query(doc_id, *args, **kwargs)[source]

Find the protobuf chunk/doc using id

Parameters

keyid

Return type

Optional[bool]

Returns

protobuf chunk or protobuf document

get_query_handler()[source]

Get a readable index handler when the index_abspath already exist, need to be overrided

null_query_handler
get_add_handler()[source]

Get a writable index handler when the index_abspath already exist, need to be overrided

get_create_handler()[source]

Get a writable index handler when the index_abspath does not exist, need to be overrided