Skip to content

Commit

Permalink
Merge pull request #100 from philippgille/improve-godoc
Browse files Browse the repository at this point in the history
Improve Godoc
  • Loading branch information
philippgille authored Sep 1, 2024
2 parents 57c073a + ccbb70c commit b5632c0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
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

0 comments on commit b5632c0

Please sign in to comment.