-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: Using Typebuilder to create simple struct params for rust client
- Loading branch information
1 parent
a3aa36c
commit 9cc3730
Showing
7 changed files
with
216 additions
and
71 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
use std::{collections::HashSet, num::NonZeroUsize}; | ||
use typed_builder::TypedBuilder; | ||
|
||
use ahnlich_types::{ | ||
ai::{AIModel, PreprocessAction}, | ||
keyval::{StoreInput, StoreName, StoreValue}, | ||
metadata::MetadataKey, | ||
predicate::PredicateCondition, | ||
similarity::{Algorithm, NonLinearAlgorithm}, | ||
}; | ||
|
||
#[derive(TypedBuilder)] | ||
pub struct CreateStoreParams { | ||
#[builder(setter(into, transform = |s: String| StoreName(s)))] | ||
pub store: StoreName, | ||
|
||
#[builder(default = AIModel::AllMiniLML6V2)] | ||
pub query_model: AIModel, | ||
|
||
#[builder(default = AIModel::AllMiniLML6V2)] | ||
pub index_model: AIModel, | ||
|
||
#[builder(default = HashSet::new())] | ||
pub predicates: HashSet<MetadataKey>, | ||
|
||
#[builder(default = HashSet::new())] | ||
pub non_linear_indices: HashSet<NonLinearAlgorithm>, | ||
|
||
#[builder(default = true)] | ||
pub error_if_exists: bool, | ||
|
||
#[builder(default = true)] | ||
pub store_original: bool, | ||
|
||
pub tracing_id: Option<String>, | ||
} | ||
|
||
#[derive(TypedBuilder)] | ||
pub struct GetPredParams { | ||
#[builder(setter(into, transform = |s: String| StoreName(s)))] | ||
pub store: StoreName, | ||
pub condition: PredicateCondition, | ||
pub tracing_id: Option<String>, | ||
} | ||
|
||
#[derive(TypedBuilder)] | ||
pub struct GetSimNParams { | ||
#[builder(setter(into, transform = |s: String| StoreName(s)))] | ||
pub store: StoreName, | ||
pub search_input: StoreInput, | ||
pub condition: Option<PredicateCondition>, | ||
|
||
#[builder(default=NonZeroUsize::new(1).unwrap())] | ||
pub closest_n: NonZeroUsize, | ||
|
||
#[builder(default=Algorithm::CosineSimilarity)] | ||
pub algorithm: Algorithm, | ||
|
||
pub tracing_id: Option<String>, | ||
} | ||
|
||
#[derive(TypedBuilder)] | ||
pub struct CreatePredIndexParams { | ||
#[builder(setter(into, transform = |s: String| StoreName(s)))] | ||
pub store: StoreName, | ||
|
||
//#[builder(default = HashSet::new())] | ||
pub predicates: HashSet<MetadataKey>, | ||
|
||
pub tracing_id: Option<String>, | ||
} | ||
|
||
#[derive(TypedBuilder)] | ||
pub struct CreateNonLinearAlgorithmIndexParams { | ||
#[builder(setter(into, transform = |s: String| StoreName(s)))] | ||
pub store: StoreName, | ||
|
||
#[builder(default = HashSet::from_iter(&[NonLinearAlgorithm::KDTree]))] | ||
pub non_linear_indices: HashSet<NonLinearAlgorithm>, | ||
|
||
pub tracing_id: Option<String>, | ||
} | ||
|
||
#[derive(TypedBuilder)] | ||
pub struct DropPredIndexParams { | ||
#[builder(setter(into, transform = |s: String| StoreName(s)))] | ||
pub store: StoreName, | ||
|
||
//#[builder(default = HashSet::new())] | ||
pub predicates: HashSet<MetadataKey>, | ||
|
||
#[builder(default = true)] | ||
pub error_if_not_exists: bool, | ||
|
||
pub tracing_id: Option<String>, | ||
} | ||
|
||
#[derive(TypedBuilder)] | ||
pub struct SetParams { | ||
#[builder(setter(into, transform = |s: String| StoreName(s)))] | ||
pub store: StoreName, | ||
|
||
pub inputs: Vec<(StoreInput, StoreValue)>, | ||
|
||
#[builder(default = PreprocessAction::NoPreprocessing)] | ||
pub preprocess_action: PreprocessAction, | ||
|
||
pub tracing_id: Option<String>, | ||
} | ||
|
||
#[derive(TypedBuilder)] | ||
pub struct DelKeyParams { | ||
#[builder(setter(into, transform = |s: String| StoreName(s)))] | ||
pub store: StoreName, | ||
|
||
pub key: StoreInput, | ||
pub tracing_id: Option<String>, | ||
} | ||
|
||
#[derive(TypedBuilder)] | ||
pub struct DropStoreParams { | ||
#[builder(setter(into, transform = |s: String| StoreName(s)))] | ||
pub store: StoreName, | ||
|
||
#[builder(default = true)] | ||
pub error_if_not_exists: bool, | ||
|
||
pub tracing_id: Option<String>, | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod ai; | ||
pub mod db; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters