WeaviateEx.Debug.ObjectCompare (WeaviateEx v0.7.4)
View SourceObject comparison utilities for debugging REST vs gRPC responses.
Provides deep comparison of objects retrieved via different protocols, helping to identify discrepancies between REST and gRPC implementations.
Example
{:ok, rest_obj} = Debug.get_object_rest(client, "Article", uuid)
{:ok, grpc_obj} = Debug.get_object_grpc(client, "Article", uuid)
result = ObjectCompare.compare(rest_obj, grpc_obj)
if result.match do
IO.puts("Objects are identical")
else
IO.puts(ObjectCompare.format_diff(result.differences))
end
Summary
Functions
Compare two objects and return detailed comparison result.
Calculate differences between two objects.
Format differences as a human-readable string.
Types
Functions
@spec compare(rest_object :: map(), grpc_object :: map()) :: comparison_result()
Compare two objects and return detailed comparison result.
Parameters
rest_object- Object retrieved via REST APIgrpc_object- Object retrieved via gRPC API
Returns
A comparison result map containing:
:match- boolean indicating if objects are identical:rest_object- the original REST object:grpc_object- the original gRPC object:differences- list of differences found
Example
result = ObjectCompare.compare(rest_obj, grpc_obj)
if result.match, do: :ok, else: handle_differences(result.differences)
@spec diff(map(), map()) :: [difference()]
Calculate differences between two objects.
Returns a list of difference maps, each containing:
:path- list of keys showing where the difference is located:rest_value- value from REST object (or:missing):grpc_value- value from gRPC object (or:missing)
Example
diffs = ObjectCompare.diff(rest_obj, grpc_obj)
Enum.each(diffs, fn d ->
IO.puts("Difference at #{Enum.join(d.path, ".")}")
end)
@spec format_diff([difference()]) :: String.t()
Format differences as a human-readable string.
Example
diffs = ObjectCompare.diff(rest_obj, grpc_obj)
IO.puts(ObjectCompare.format_diff(diffs))