Skip to content

Commit

Permalink
split collection update api into several endpoints #32
Browse files Browse the repository at this point in the history
  • Loading branch information
generall committed Nov 28, 2021
1 parent eb1d6ca commit 1fb014b
Show file tree
Hide file tree
Showing 11 changed files with 1,445 additions and 526 deletions.
595 changes: 467 additions & 128 deletions docs/redoc/openapi.json

Large diffs are not rendered by default.

64 changes: 47 additions & 17 deletions lib/storage/src/content_manager/storage_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,42 @@ use schemars::JsonSchema;
use segment::types::Distance;
use serde::{Deserialize, Serialize};

/// Create alternative name for a collection.
/// Collection will be available under both names for search, retrieve,
#[derive(Debug, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct CreateAlias {
pub collection_name: String,
pub alias_name: String,
}

/// Delete alias if exists
#[derive(Debug, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct DeleteAlias {
pub alias_name: String
}

/// Change alias to a new one
#[derive(Debug, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct RenameAlias {
pub old_alias_name: String,
pub new_alias_name: String,
}

#[derive(Debug, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum AliasOperations {
/// Create alternative name for a collection.
/// Collection will be available under both names for search, retrieve,
CreateAlias {
collection_name: String,
alias_name: String,
},
/// Delete alias if exists
DeleteAlias { alias_name: String },
/// Change alias to a new one
RenameAlias {
old_alias_name: String,
new_alias_name: String,
},
CreateAlias(CreateAlias),
DeleteAlias(DeleteAlias),
RenameAlias(RenameAlias),
}

/// Operation for creating new collection and (optionally) specify index params
#[derive(Debug, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct CreateCollectionOperation {
pub name: String,
pub struct CreateCollection {
pub vector_size: usize,
pub distance: Distance,
/// Custom params for HNSW index. If none - values from service configuration file are used.
Expand All @@ -36,16 +49,33 @@ pub struct CreateCollectionOperation {
pub optimizers_config: Option<OptimizersConfigDiff>,
}

/// Operation for updating parameters of the existing collection
/// Operation for creating new collection and (optionally) specify index params
#[derive(Debug, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct UpdateCollectionOperation {
pub struct CreateCollectionOperation {
pub name: String,
#[serde(flatten)]
pub create_collection: CreateCollection,
}

/// Operation for updating parameters of the existing collection
#[derive(Debug, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct UpdateCollection {
/// Custom params for Optimizers. If none - values from service configuration file are used.
/// This operation is blocking, it will only proceed ones all current optimizations are complete
pub optimizers_config: Option<OptimizersConfigDiff>, // ToDo: Allow updates for other configuration params as well
}

/// Operation for updating parameters of the existing collection
#[derive(Debug, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct UpdateCollectionOperation {
pub name: String,
#[serde(flatten)]
pub update_collection: UpdateCollection,
}

/// Operation for performing changes of collection aliases.
/// Alias changes are atomic, meaning that no collection modifications can happen between
/// alias operations.
Expand Down

0 comments on commit 1fb014b

Please sign in to comment.