jina.executors.indexers.keyvalue

class jina.executors.indexers.keyvalue.BinaryPbIndexer(delete_on_dump=False, *args, **kwargs)[source]

Bases: jina.executors.indexers.BaseKVIndexer

Simple Key-value indexer.

class WriteHandler(path, mode)[source]

Bases: object

Write file handler.

Parameters
  • path – Path of the file.

  • mode – Writing mode. (e.g. ‘ab’, ‘wb’)

close()[source]

Close the file.

flush()[source]

Clear the body and header.

class ReadHandler(path, key_length)[source]

Bases: object

Read file handler.

Parameters
  • path – Path of the file.

  • key_length – Length of key.

close()[source]

Close the file.

get_add_handler()[source]

Get write file handler.

Return type

WriteHandler

Returns

write handler

get_create_handler()[source]

Get write file handler.

Return type

WriteHandler

Returns

write handler.

get_query_handler()[source]

Get read file handler.

Return type

ReadHandler

Returns

read handler.

add(keys, values, *args, **kwargs)[source]

Add the serialized documents to the index via document ids.

Parameters
  • keys (Iterable[str]) – a list of id, i.e. doc.id in protobuf

  • values (Iterable[bytes]) – serialized documents

  • args – extra arguments

  • kwargs – keyword arguments

Return type

None

sample()[source]

Return a random entry from the indexer for sanity check.

Return type

Optional[bytes]

Returns

A random entry from the indexer.

query(key, *args, **kwargs)[source]

Find the serialized document to the index via document id.

Parameters
  • key (str) – document id

  • args – extra arguments

  • kwargs – keyword arguments

Return type

Optional[bytes]

Returns

serialized documents

update(keys, values, *args, **kwargs)[source]

Update the serialized documents on the index via document ids.

Parameters
  • keys (Iterable[str]) – a list of id, i.e. doc.id in protobuf

  • values (Iterable[bytes]) – serialized documents

  • args – extra arguments

  • kwargs – keyword arguments

Return type

None

delete(keys, *args, **kwargs)[source]

Delete the serialized documents from the index via document ids.

Parameters
  • keys (Iterable[str]) – a list of id, i.e. doc.id in protobuf

  • args – extra arguments

  • kwargs – keyword arguments

Return type

None

class jina.executors.indexers.keyvalue.KeyValueIndexer(delete_on_dump=False, *args, **kwargs)[source]

Bases: jina.executors.indexers.keyvalue.BinaryPbIndexer

Alias for BinaryPbIndexer

class jina.executors.indexers.keyvalue.DataURIPbIndexer(delete_on_dump=False, *args, **kwargs)[source]

Bases: jina.executors.indexers.keyvalue.BinaryPbIndexer

Alias for BinaryPbIndexer

class jina.executors.indexers.keyvalue.UniquePbIndexer(routes=None, resolve_all=True, *args, **kwargs)[source]

Bases: jina.executors.compound.CompoundExecutor

A frequently used pattern for combining a BaseKVIndexer and a DocCache