Skip to main content

Module metadata

Module metadata 

Source
Expand description

Metadata storage for vector annotations. Metadata storage system for EdgeVec.

This module provides a type-safe metadata storage system for attaching key-value pairs to vectors. Metadata enables filtering, sorting, and enriching vector search results with additional context.

§Features

  • 5 Value Types: String, Integer, Float, Boolean, StringArray
  • Type-Safe: Strongly typed values with accessor methods
  • Validated: Keys and values are validated against limits
  • Serializable: JSON serialization with clear type tags

§Quick Start

use edgevec::metadata::{MetadataValue, MetadataStore};
use edgevec::metadata::validation::validate_key_value;

// Create values using constructors
let title = MetadataValue::String("Hello World".to_string());
let count = MetadataValue::Integer(42);
let score = MetadataValue::Float(0.95);
let active = MetadataValue::Boolean(true);
let tags = MetadataValue::StringArray(vec!["rust".into(), "wasm".into()]);

// Create values using From trait
let title: MetadataValue = "Hello World".into();
let count: MetadataValue = 42i64.into();
let active: MetadataValue = true.into();

// Validate before storing
assert!(validate_key_value("title", &title).is_ok());

// Check types
assert!(title.is_string());
assert!(count.is_integer());

// Extract values
assert_eq!(title.as_string(), Some("Hello World"));
assert_eq!(count.as_integer(), Some(42));

§Value Types

TypeRustJSONUse Case
StringStringstringTitles, descriptions
Integeri64numberCounts, IDs, timestamps
Floatf64numberScores, weights
BooleanboolbooleanFlags, filters
StringArrayVec<String>string[]Tags, categories

§Validation Limits

LimitValueDescription
Max keys per vector64Prevents memory bloat
Max key length256 bytesReasonable for field names
Max string value64KBPrevents abuse
Max array elements1,024Prevents excessive arrays

§JSON Serialization

Values serialize with adjacently-tagged representation:

{"type": "string", "value": "hello"}
{"type": "integer", "value": 42}
{"type": "float", "value": 2.5}
{"type": "boolean", "value": true}
{"type": "string_array", "value": ["a", "b"]}

§Module Structure

  • types - Core MetadataValue enum
  • error - MetadataError enum
  • validation - Validation constants and functions
  • store - MetadataStore for CRUD operations (Day 2)

Modules§

validation
Metadata validation rules and constants.

Structs§

MetadataStore
Storage for vector metadata.

Enums§

MetadataError
Errors that can occur during metadata operations.
MetadataValue
Supported metadata value types.
SerializationError
Errors that can occur during metadata serialization/deserialization.