memory

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package memory provides in-memory implementations for testing and development.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HashEmbedder

type HashEmbedder struct {
	// contains filtered or unexported fields
}

HashEmbedder creates deterministic embeddings using hashing. This is for testing only - not suitable for production.

func NewHashEmbedder

func NewHashEmbedder(dimensions int) *HashEmbedder

NewHashEmbedder creates a new hash-based embedder.

func (*HashEmbedder) Embed

func (e *HashEmbedder) Embed(ctx context.Context, text string) ([]float32, error)

Embed implements vector.Embedder.

func (*HashEmbedder) EmbedBatch

func (e *HashEmbedder) EmbedBatch(ctx context.Context, texts []string) ([][]float32, error)

EmbedBatch implements vector.Embedder.

func (*HashEmbedder) Model

func (e *HashEmbedder) Model() string

Model implements vector.Embedder.

type KnowledgeGraph

type KnowledgeGraph struct {
	// contains filtered or unexported fields
}

KnowledgeGraph is an in-memory knowledge graph.

func NewKnowledgeGraph

func NewKnowledgeGraph(name string) *KnowledgeGraph

NewKnowledgeGraph creates a new in-memory knowledge graph.

func (*KnowledgeGraph) AddEdge

func (kg *KnowledgeGraph) AddEdge(ctx context.Context, edge graph.Edge) error

AddEdge implements graph.KnowledgeGraph.

func (*KnowledgeGraph) AddEdgeBatch

func (kg *KnowledgeGraph) AddEdgeBatch(ctx context.Context, edges []graph.Edge) error

AddEdgeBatch implements graph.BatchKnowledgeGraph.

func (*KnowledgeGraph) AddNode

func (kg *KnowledgeGraph) AddNode(ctx context.Context, node graph.Node) error

AddNode implements graph.KnowledgeGraph.

func (*KnowledgeGraph) AddNodeBatch

func (kg *KnowledgeGraph) AddNodeBatch(ctx context.Context, nodes []graph.Node) error

AddNodeBatch implements graph.BatchKnowledgeGraph.

func (*KnowledgeGraph) DeleteEdge

func (kg *KnowledgeGraph) DeleteEdge(ctx context.Context, from, to, edgeType string) error

DeleteEdge implements graph.KnowledgeGraph.

func (*KnowledgeGraph) DeleteNode

func (kg *KnowledgeGraph) DeleteNode(ctx context.Context, id string) error

DeleteNode implements graph.KnowledgeGraph.

func (*KnowledgeGraph) DeleteNodeBatch

func (kg *KnowledgeGraph) DeleteNodeBatch(ctx context.Context, ids []string) error

DeleteNodeBatch implements graph.BatchKnowledgeGraph.

func (*KnowledgeGraph) EdgeCount

func (kg *KnowledgeGraph) EdgeCount() int

EdgeCount returns the number of edges in the graph.

func (*KnowledgeGraph) FindNodes

func (kg *KnowledgeGraph) FindNodes(ctx context.Context, nodeType string, filters map[string]string) ([]graph.Node, error)

FindNodes implements graph.KnowledgeGraph.

func (*KnowledgeGraph) Name

func (kg *KnowledgeGraph) Name() string

Name implements graph.KnowledgeGraph.

func (*KnowledgeGraph) NodeCount

func (kg *KnowledgeGraph) NodeCount() int

NodeCount returns the number of nodes in the graph.

func (*KnowledgeGraph) Traverse

func (kg *KnowledgeGraph) Traverse(ctx context.Context, startNodes []string, opts graph.TraversalOptions) (*graph.TraversalResult, error)

Traverse implements graph.KnowledgeGraph.

func (*KnowledgeGraph) UpsertEdge

func (kg *KnowledgeGraph) UpsertEdge(ctx context.Context, edge graph.Edge) error

UpsertEdge implements graph.KnowledgeGraph.

func (*KnowledgeGraph) UpsertEdgeBatch

func (kg *KnowledgeGraph) UpsertEdgeBatch(ctx context.Context, edges []graph.Edge) error

UpsertEdgeBatch implements graph.BatchKnowledgeGraph.

func (*KnowledgeGraph) UpsertNode

func (kg *KnowledgeGraph) UpsertNode(ctx context.Context, node graph.Node) error

UpsertNode implements graph.KnowledgeGraph.

func (*KnowledgeGraph) UpsertNodeBatch

func (kg *KnowledgeGraph) UpsertNodeBatch(ctx context.Context, nodes []graph.Node) error

UpsertNodeBatch implements graph.BatchKnowledgeGraph.

type VectorIndex

type VectorIndex struct {
	// contains filtered or unexported fields
}

VectorIndex is an in-memory vector index using brute-force search.

func NewVectorIndex

func NewVectorIndex(name string) *VectorIndex

NewVectorIndex creates a new in-memory vector index.

func (*VectorIndex) Count

func (idx *VectorIndex) Count() int

Count returns the number of nodes in the index.

func (*VectorIndex) Delete

func (idx *VectorIndex) Delete(ctx context.Context, id string) error

Delete implements vector.Index.

func (*VectorIndex) DeleteBatch

func (idx *VectorIndex) DeleteBatch(ctx context.Context, ids []string) error

DeleteBatch implements vector.BatchIndex.

func (*VectorIndex) Insert

func (idx *VectorIndex) Insert(ctx context.Context, node vector.Node) error

Insert implements vector.Index.

func (*VectorIndex) InsertBatch

func (idx *VectorIndex) InsertBatch(ctx context.Context, nodes []vector.Node) error

InsertBatch implements vector.BatchIndex.

func (*VectorIndex) Name

func (idx *VectorIndex) Name() string

Name implements vector.Index.

func (*VectorIndex) Search

func (idx *VectorIndex) Search(ctx context.Context, embedding []float32, k int, filters map[string]string) ([]vector.SearchResult, error)

Search implements vector.Index.

func (*VectorIndex) Upsert

func (idx *VectorIndex) Upsert(ctx context.Context, node vector.Node) error

Upsert implements vector.Index.

func (*VectorIndex) UpsertBatch

func (idx *VectorIndex) UpsertBatch(ctx context.Context, nodes []vector.Node) error

UpsertBatch implements vector.BatchIndex.

Jump to

Keyboard shortcuts

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