jina.types.arrays.chunk module

class jina.types.arrays.chunk.ChunkArray(doc_views, reference_doc)[source]

Bases: jina.types.arrays.document.DocumentArray

ChunkArray inherits from DocumentArray. It’s a subset of Documents.

Parameters
  • doc_views – Set of sub-documents (i.e chunks) of reference_doc

  • reference_doc (Document) – Reference Document for the sub-documents

Set constructor method.

Parameters
  • doc_views – protobuf representation of the chunks

  • reference_doc (Document) – parent document

append(document, **kwargs)[source]

Add a sub-document (i.e chunk) to the current Document.

Parameters
  • document (Document) – Sub-document to be appended

  • kwargs – additional keyword arguments

Returns

the newly added sub-document in Document view

Return type

Document

Note

Comparing to DocumentArray.append(), this method adds more safeguard to make sure the added chunk is legit.

extend(iterable)[source]

Extend the DocumentArray by appending all the items from the iterable.

Parameters

iterable (Iterable[Document]) – the iterable of Documents to extend this array with

Return type

None

property reference_doc: Document

Get the document that ChunkArray belongs to.

Return type

Document

Returns

reference doc

property granularity: int

Get granularity of all document in this array.

Return type

int

Returns

granularity

property adjacency: int

Get adjacency of all document in this array.

Return type

int

Returns

adjacency