graphtest

package
v0.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package graphtest is the contract every brain graph backend must meet. Run it from a backend's own tests, as helixgraph does, so any graph database a host substitutes behaves as Engine expects.

Each case writes fresh object ids, namespaces and search words, so cases never see each other's data, even on one long-lived graph. A backend owns its embedding, so the contract hands newGraph the Embedder each case needs: nil for a text-only graph, or Embedder, whose vectors the contract chooses.

Index

Constants

View Source
const Dimension = 2

Dimension is the length of every vector Embedder returns.

View Source
const EdgeSearchLabel = "cites"

EdgeSearchLabel is the one relation the contract searches edges on. A backend that indexes edges per relation indexes it (text and vector) before Run.

View Source
const OtherEdgeSearchLabel = "quotes"

OtherEdgeSearchLabel is the second relation the contract searches edges on. A graph under test indexes both for edge search.

Variables

This section is empty.

Functions

func Run

func Run(t *testing.T, newGraph func(t *testing.T, emb brain.Embedder) brain.Graph)

Run runs the contract. newGraph returns the graph a case writes to, which embeds with emb (nil: text only).

Types

type Embedder

type Embedder struct{}

Embedder embeds a text as the vector of the first marker word in it: veca is (1, 0), vecb (0.6, 0.8), vecc (0.9, 0.1) and anything else (0, 1). Markers are ordinary words to text search. A text with the word poison fails.

func (Embedder) Embed

func (Embedder) Embed(_ context.Context, texts []string) ([][]float32, error)

Embed implements brain.Embedder.

func (Embedder) Model

func (Embedder) Model() string

Model implements brain.Embedder.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL