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

slow as turtle #33

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
some logical fixes
  • Loading branch information
ssddOnTop committed Sep 12, 2024
commit 3ce51f6fffc0ef0e8abef917d72724fc66a25b01
66 changes: 66 additions & 0 deletions projects/ssddOnTop/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions projects/ssddOnTop/Cargo.toml
Original file line number Diff line number Diff line change
@@ -52,3 +52,6 @@ async-recursion = "1.1.1"

[dev-dependencies]
http-cache = "0.18.0"

[workspace]
members = []
16 changes: 5 additions & 11 deletions projects/ssddOnTop/src/blueprint/blueprint.rs
Original file line number Diff line number Diff line change
@@ -133,14 +133,13 @@ impl TryFrom<&Config> for Blueprint {

fn fields_to_map(qry: &str, config: &Config, defs: Vec<Definition>) -> HashMap<FieldHash, Field> {
let mut fields = HashMap::new();
populate_nested_field(config, qry, 0, &mut fields, &defs);
populate_nested_field(config, qry, &mut fields, &defs);
fields
}

fn populate_nested_field(
config: &Config,
ty_name: &str,
field_id: usize,
field_map: &mut HashMap<FieldHash, Field>,
defs: &[Definition],
) {
@@ -149,24 +148,22 @@ fn populate_nested_field(
if let Some(ty) = config.types.get(ty_name) {
for (field_name, field) in ty.fields.iter() {
let field_name = FieldName(field_name.clone());
populate_nested_field(config, field.ty_of.name(), field_id + 1, field_map, defs);
let mut arg_id = 0;
populate_nested_field(config, field.ty_of.name(), field_map, defs);
let field = Field {
id: FieldId::new(field_id),
name: field_name.clone(),
type_of: field.ty_of.clone(),
ir: {
let x = defs.iter().find_map(|def| match def {
Definition::Interface(int) => Some(
int.fields
.iter()
.find(|f| field_name.0.eq(&f.name))?
.find(|f| field_name.0.eq(&f.name) && int.name.eq(ty_name))?
.clone(),
),
Definition::Object(obj) => Some(
obj.fields
.iter()
.find(|f| field_name.0.eq(&f.name))?
.find(|f| field_name.0.eq(&f.name) && obj.name.eq(ty_name))?
.clone(),
),
Definition::InputObject(_) => None,
@@ -180,12 +177,9 @@ fn populate_nested_field(
.iter()
.map(|(arg_name, arg)| {
let arg = Arg {
id: ArgId::new(arg_id),
name: arg_name.clone(),
type_of: arg.type_of.clone(),
};
arg_id += 1;

arg
})
.collect(),
@@ -214,6 +208,6 @@ mod test {
.read(format!("{}/schema/schema.graphql", root))
.unwrap();
let blueprint = crate::blueprint::Blueprint::try_from(&config).unwrap();
// println!("{:#?}", blueprint);
println!("{:#?}", blueprint.fields );
}
}
2 changes: 0 additions & 2 deletions projects/ssddOnTop/src/blueprint/model.rs
Original file line number Diff line number Diff line change
@@ -48,7 +48,6 @@ impl FieldId {

#[derive(Clone, Debug)]
pub struct Arg {
pub id: ArgId,
pub name: String,
pub type_of: crate::blueprint::wrapping_type::Type,
}
@@ -60,7 +59,6 @@ pub struct Flat(FieldId);

#[derive(Clone, Debug)]
pub struct Field {
pub id: FieldId,
pub name: FieldName,
pub type_of: crate::blueprint::wrapping_type::Type,
pub ir: Option<IR>,