From 98326366da19e650f6574a6e950347b897e09b97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Gill=C3=A9?= Date: Sun, 1 Sep 2024 18:55:26 +0200 Subject: [PATCH 1/2] Add and update Godoc internal links --- collection.go | 2 +- db.go | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/collection.go b/collection.go index 8a0bdcb..4dbd7a4 100644 --- a/collection.go +++ b/collection.go @@ -417,7 +417,7 @@ func (c *Collection) Query(ctx context.Context, queryText string, nResults int, // QueryWithOptions performs an exhaustive nearest neighbor search on the collection. // -// - options: The options for the query. See QueryOptions for more information. +// - options: The options for the query. See [QueryOptions] for more information. func (c *Collection) QueryWithOptions(ctx context.Context, options QueryOptions) ([]Result, error) { if options.QueryText == "" && len(options.QueryEmbedding) == 0 { return nil, errors.New("QueryText and QueryEmbedding options are empty") diff --git a/db.go b/db.go index 001271e..2b229a8 100644 --- a/db.go +++ b/db.go @@ -62,8 +62,9 @@ func NewDB() *DB { // will make this configurable (encoding, async writes, WAL-based writes, etc.). // // In addition to persistence for each added collection and document you can use -// [DB.Export] and [DB.Import] to export and import the entire DB to/from a file, -// which also works for the pure in-memory DB. +// [DB.ExportToFile] / [DB.ExportToWriter] and [DB.ImportFromFile] / +// [DB.ImportFromReader] to export and import the entire DB to/from a file or +// writer/reader, which also works for the pure in-memory DB. func NewPersistentDB(path string, compress bool) (*DB, error) { if path == "" { path = "./chromem-go" @@ -509,7 +510,7 @@ func (db *DB) CreateCollection(name string, metadata map[string]string, embeddin // ListCollections returns all collections in the DB, mapping name->Collection. // The returned map is a copy of the internal map, so it's safe to directly modify // the map itself. Direct modifications of the map won't reflect on the DB's map. -// To do that use the DB's methods like CreateCollection() and DeleteCollection(). +// To do that use the DB's methods like [DB.CreateCollection] and [DB.DeleteCollection]. // The map is not an entirely deep clone, so the collections themselves are still // the original ones. Any methods on the collections like Add() for adding documents // will be reflected on the DB's collections and are concurrency-safe. From ccbb70c6c765e4e7fa6f9478062d4c5987b6d505 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Gill=C3=A9?= Date: Sun, 1 Sep 2024 18:55:40 +0200 Subject: [PATCH 2/2] Add links to S3 export/import example --- db.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/db.go b/db.go index 2b229a8..210e00e 100644 --- a/db.go +++ b/db.go @@ -285,6 +285,9 @@ func (db *DB) ImportFromFile(filePath string, encryptionKey string, collections // This works for both the in-memory and persistent DBs. // Existing collections are overwritten. // If the writer has to be closed, it's the caller's responsibility. +// This can be used to import DBs from object storage like S3. See +// https://github.com/philippgille/chromem-go/tree/main/examples/s3-export-import +// for an example. // // - reader: An implementation of [io.ReadSeeker] // - encryptionKey: Optional, must be 32 bytes long if provided @@ -433,6 +436,9 @@ func (db *DB) ExportToFile(filePath string, compress bool, encryptionKey string, // optionally compressed with flate (as gzip) and optionally encrypted with AES-GCM. // This works for both the in-memory and persistent DBs. // If the writer has to be closed, it's the caller's responsibility. +// This can be used to export DBs to object storage like S3. See +// https://github.com/philippgille/chromem-go/tree/main/examples/s3-export-import +// for an example. // // - writer: An implementation of [io.Writer] // - compress: Optional. Compresses as gzip if true.