Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Godoc #100

Merged
merged 2 commits into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
13 changes: 10 additions & 3 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -284,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
Expand Down Expand Up @@ -432,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.
Expand Down Expand Up @@ -509,7 +516,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.
Expand Down
Loading