WeaviateEx.Cluster.Shard (WeaviateEx v0.7.4)

View Source

Represents a shard in a Weaviate collection.

Shards are the unit of data distribution in Weaviate. Each collection can have multiple shards distributed across nodes.

Shard Status Values

  • :ready - Shard is ready for queries
  • :readonly - Shard is in read-only mode
  • :indexing - Shard is building indexes
  • :loading - Shard is loading data

Examples

%Shard{
  name: "shard-0",
  collection: "Article",
  status: :ready,
  object_count: 1000,
  vector_queue_size: 0
}

Summary

Functions

Parse shard from API response.

Parse status string to atom.

Check if shard is ready for queries.

Convert status atom to API string.

Check if vectors are fully indexed.

Types

status()

@type status() :: :ready | :readonly | :indexing | :loading | :lazy_loading

t()

@type t() :: %WeaviateEx.Cluster.Shard{
  collection: String.t() | nil,
  compressed: boolean(),
  loaded: boolean() | nil,
  name: String.t(),
  node: String.t() | nil,
  object_count: non_neg_integer(),
  status: status(),
  vector_indexing_status: String.t() | nil,
  vector_queue_size: non_neg_integer()
}

Functions

from_api(map)

@spec from_api(map()) :: t()

Parse shard from API response.

Examples

iex> Shard.from_api(%{"name" => "shard-0", "status" => "READY", "objectCount" => 100})
%Shard{name: "shard-0", status: :ready, object_count: 100}

parse_status(arg1)

@spec parse_status(String.t()) :: status()

Parse status string to atom.

Examples

iex> Shard.parse_status("READY")
:ready

iex> Shard.parse_status("INDEXING")
:indexing

ready?(arg1)

@spec ready?(t()) :: boolean()

Check if shard is ready for queries.

A shard is considered ready when its status is :ready and there are no pending vectors in the indexing queue.

Examples

iex> Shard.ready?(%Shard{status: :ready, vector_queue_size: 0})
true

iex> Shard.ready?(%Shard{status: :ready, vector_queue_size: 100})
false

iex> Shard.ready?(%Shard{status: :indexing, vector_queue_size: 0})
false

status_to_api(atom)

@spec status_to_api(status()) :: String.t()

Convert status atom to API string.

Examples

iex> Shard.status_to_api(:ready)
"READY"

vectors_indexed?(arg1)

@spec vectors_indexed?(t()) :: boolean()

Check if vectors are fully indexed.

Returns true when the vector queue is empty, meaning all vectors have been processed by the async indexing system.

Examples

iex> Shard.vectors_indexed?(%Shard{vector_queue_size: 0})
true

iex> Shard.vectors_indexed?(%Shard{vector_queue_size: 50})
false