Skip to main content

CollectionHandle

Struct CollectionHandle 

Source
pub struct CollectionHandle { /* private fields */ }
Expand description

A named collection that is created with an inferred dimension on first use.

Implementations§

Source§

impl CollectionHandle

Source

pub fn upsert( &self, points: impl IntoIterator<Item = Point>, ) -> Result<WriteResult>

Adds or replaces points, creating a missing collection on first write.

The first write infers the collection dimension from its points. All vectors in that batch must be nonempty and have the same dimension.

Examples found in repository?
examples/persistence.rs (line 8)
3fn main() -> git_vdb::Result<()> {
4    let temporary = tempfile::TempDir::new()?;
5    let path = temporary.path().join("vectors.git");
6    open(&path)?
7        .collection("docs")
8        .upsert([Point::new("stable-id", [1.0, 0.0])])?;
9    assert_eq!(open(&path)?.collection("docs").count()?, 1);
10    Ok(())
11}
More examples
Hide additional examples
examples/history.rs (line 6)
3fn main() -> git_vdb::Result<()> {
4    let temporary = tempfile::TempDir::new()?;
5    let docs = open(temporary.path().join("vectors.git"))?.collection("docs");
6    docs.upsert([Point::new("v1", [1.0, 0.0])])?;
7    docs.upsert([Point::new("v2", [0.0, 1.0])])?;
8    assert_eq!(docs.advanced()?.history(10)?.len(), 3);
9    Ok(())
10}
examples/quickstart.rs (lines 7-10)
3fn main() -> git_vdb::Result<()> {
4    let temporary = tempfile::TempDir::new()?;
5    let db = open(temporary.path().join("vectors.git"))?;
6    let docs = db.collection("docs");
7    docs.upsert([
8        Point::new("east", [1.0, 0.0]),
9        Point::new("north", [0.0, 1.0]),
10    ])?;
11    let hits = docs.search([0.9, 0.1], 1)?;
12    assert_eq!(hits[0].id.to_string(), "east");
13    Ok(())
14}
examples/filtering.rs (lines 7-10)
4fn main() -> git_vdb::Result<()> {
5    let temporary = tempfile::TempDir::new()?;
6    let docs = open(temporary.path().join("vectors.git"))?.collection("docs");
7    docs.upsert([
8        Point::new("guide", [1.0, 0.0]).with_metadata(json!({"kind": "docs"}))?,
9        Point::new("code", [0.9, 0.1]).with_metadata(json!({"kind": "source"}))?,
10    ])?;
11    let result = docs.advanced()?.query(
12        Query::new([1.0, 0.0], 5)
13            .with_filter(Filter::must([Condition::matches("kind", "docs")]))
14            .with_payload(),
15    )?;
16    assert_eq!(result.points[0].id.to_string(), "guide");
17    Ok(())
18}
Source

pub fn search( &self, vector: impl IntoIterator<Item = f32>, limit: usize, ) -> Result<Vec<ScoredPoint>>

Searches for the nearest points using the collection’s automatic mode.

Payload metadata is included in every returned winner. Use CollectionHandle::advanced for filters, stored vectors, immutable roots, execution statistics, or explicit search tuning.

Examples found in repository?
examples/quickstart.rs (line 11)
3fn main() -> git_vdb::Result<()> {
4    let temporary = tempfile::TempDir::new()?;
5    let db = open(temporary.path().join("vectors.git"))?;
6    let docs = db.collection("docs");
7    docs.upsert([
8        Point::new("east", [1.0, 0.0]),
9        Point::new("north", [0.0, 1.0]),
10    ])?;
11    let hits = docs.search([0.9, 0.1], 1)?;
12    assert_eq!(hits[0].id.to_string(), "east");
13    Ok(())
14}
Source

pub fn query(&self, query: Query) -> Result<QueryResult>

Executes a detailed vector query without leaving the common facade.

Source

pub fn query_batch( &self, queries: impl IntoIterator<Item = Query>, ) -> Result<Vec<QueryResult>>

Executes detailed vector queries in input order.

Source

pub fn get(&self, request: GetRequest) -> Result<GetResult>

Retrieves records using IDs, filters, pagination, and include controls.

Source

pub fn get_ids( &self, ids: impl IntoIterator<Item = PointId>, ) -> Result<Vec<Record>>

Retrieves points by typed ID with payload metadata included.

Source

pub fn delete_ids( &self, ids: impl IntoIterator<Item = PointId>, ) -> Result<WriteResult>

Deletes points by typed ID. Missing IDs are ignored.

Source

pub fn delete(&self, selector: DeleteSelector) -> Result<WriteResult>

Deletes records selected by IDs, a filter, or both.

Source

pub fn apply( &self, mutations: impl IntoIterator<Item = SnapshotMutation>, ) -> Result<MutationResult>

Applies an ordered batch of upserts and deletions in one ref update.

Source

pub fn count(&self) -> Result<usize>

Returns the number of points in the collection.

Examples found in repository?
examples/persistence.rs (line 9)
3fn main() -> git_vdb::Result<()> {
4    let temporary = tempfile::TempDir::new()?;
5    let path = temporary.path().join("vectors.git");
6    open(&path)?
7        .collection("docs")
8        .upsert([Point::new("stable-id", [1.0, 0.0])])?;
9    assert_eq!(open(&path)?.collection("docs").count()?, 1);
10    Ok(())
11}
Source

pub fn count_where(&self, filter: Filter) -> Result<usize>

Returns the number of points matching a payload or ID filter.

Source

pub fn root(&self) -> Result<ObjectId>

Returns the current immutable collection root.

Source

pub fn restore(&self, revision: impl AsRef<str>) -> Result<WriteResult>

Restores a historical root as a new history-preserving commit.

Source

pub fn peek(&self, limit: usize) -> Result<Vec<Record>>

Returns the first limit canonically ordered points with payloads.

Source

pub fn advanced(&self) -> Result<Collection>

Opens the existing collection through the detailed named API.

Examples found in repository?
examples/history.rs (line 8)
3fn main() -> git_vdb::Result<()> {
4    let temporary = tempfile::TempDir::new()?;
5    let docs = open(temporary.path().join("vectors.git"))?.collection("docs");
6    docs.upsert([Point::new("v1", [1.0, 0.0])])?;
7    docs.upsert([Point::new("v2", [0.0, 1.0])])?;
8    assert_eq!(docs.advanced()?.history(10)?.len(), 3);
9    Ok(())
10}
More examples
Hide additional examples
examples/filtering.rs (line 11)
4fn main() -> git_vdb::Result<()> {
5    let temporary = tempfile::TempDir::new()?;
6    let docs = open(temporary.path().join("vectors.git"))?.collection("docs");
7    docs.upsert([
8        Point::new("guide", [1.0, 0.0]).with_metadata(json!({"kind": "docs"}))?,
9        Point::new("code", [0.9, 0.1]).with_metadata(json!({"kind": "source"}))?,
10    ])?;
11    let result = docs.advanced()?.query(
12        Query::new([1.0, 0.0], 5)
13            .with_filter(Filter::must([Condition::matches("kind", "docs")]))
14            .with_payload(),
15    )?;
16    assert_eq!(result.points[0].id.to_string(), "guide");
17    Ok(())
18}

Trait Implementations§

Source§

impl Clone for CollectionHandle

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CollectionHandle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V