From b052dd4c3cac2db0053130e4648359b0dfc2dffa Mon Sep 17 00:00:00 2001 From: Songqing Zhang Date: Mon, 13 Jan 2025 14:22:21 +0800 Subject: [PATCH 1/2] fix(analytical): Fix Louvain algorithm's stop condition (#4387) ## What do these changes do? When using Louvain algorithm, I found a question with its stop condition, the Louvain algotithm's quality may be 0, 0.85, 0.80, I want to stop the iterations at 0.80 as the quality has started to decrease, but the current stop condition can't do that. Besides, the change is consistent with [NetworkX's implementation](https://github.com/networkx/networkx/blob/c34400f1ea5b9daa733b971f7f5ef7072fe410a9/networkx/algorithms/community/louvain.py#L216) ## Related issue number Fixes --- analytical_engine/apps/pregel/louvain/louvain_app_base.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/analytical_engine/apps/pregel/louvain/louvain_app_base.h b/analytical_engine/apps/pregel/louvain/louvain_app_base.h index aa8fd9d53138..d8462cbc6124 100644 --- a/analytical_engine/apps/pregel/louvain/louvain_app_base.h +++ b/analytical_engine/apps/pregel/louvain/louvain_app_base.h @@ -226,8 +226,7 @@ class LouvainAppBase // after one pass if already decided halt, that means the pass yield no // changes, so we halt computation. if (current_super_step <= 14 || - std::fabs(actual_quality - ctx.prev_quality()) < - min_quality_improvement) { + (actual_quality - ctx.prev_quality()) <= min_quality_improvement) { // turn to sync community result ctx.compute_context().set_superstep(sync_result_step); syncCommunity(frag, ctx, messages); From f577fae87f494acbdf67c9b44b83387e5a6dc592 Mon Sep 17 00:00:00 2001 From: BingqingLyu Date: Mon, 13 Jan 2025 19:08:18 +0800 Subject: [PATCH 2/2] fix(interactive): Fix bug in datatype conversion in ir-core (#4421) ## What do these changes do? As titled. ## Related issue number Fixes #4420 --- .../executor/ir/core/src/plan/logical.rs | 18 ++++++++ .../executor/ir/core/src/plan/meta.rs | 43 ++++++++++++------- 2 files changed, 45 insertions(+), 16 deletions(-) diff --git a/interactive_engine/executor/ir/core/src/plan/logical.rs b/interactive_engine/executor/ir/core/src/plan/logical.rs index f565d383f667..0d0290e7ec60 100644 --- a/interactive_engine/executor/ir/core/src/plan/logical.rs +++ b/interactive_engine/executor/ir/core/src/plan/logical.rs @@ -4944,4 +4944,22 @@ mod test { .unwrap() ); } + + #[test] + fn test_data_type_conversion() { + let schema = + Schema::from_json(std::fs::File::open("resource/modern_schema_pk.json").unwrap()).unwrap(); + for entity in schema.get_entities() { + let columns = &entity.columns; + for column in columns { + assert!(column.data_type.is_some()); + } + } + for relation in schema.get_relations() { + let columns = &relation.columns; + for column in columns { + assert!(&column.data_type.is_some()); + } + } + } } diff --git a/interactive_engine/executor/ir/core/src/plan/meta.rs b/interactive_engine/executor/ir/core/src/plan/meta.rs index 749ba82f1e9b..1930839252cb 100644 --- a/interactive_engine/executor/ir/core/src/plan/meta.rs +++ b/interactive_engine/executor/ir/core/src/plan/meta.rs @@ -231,6 +231,14 @@ impl Schema { (false, 0) } } + + pub(crate) fn get_entities(&self) -> &Vec { + self.entities.as_ref() + } + + pub(crate) fn get_relations(&self) -> &Vec { + self.relations.as_ref() + } } impl From for schema_pb::Schema { @@ -492,33 +500,36 @@ impl JsonIO for Schema { // } fn convert_data_type(data_type_int: i64) -> serde_json::Value { use serde_json::json; - match data_type_int { + let dt = match data_type_int { // Primitive types mapping - 0 => json!({ "primitive_type": "DT_BOOL" }), // BOOLEAN - 1 => json!({ "primitive_type": "DT_SIGNED_INT32" }), // INT32 - 2 => json!({ "primitive_type": "DT_SIGNED_INT64" }), // INT64 - 3 => json!({ "primitive_type": "DT_DOUBLE" }), // DOUBLE + 0 => json!({ "PrimitiveType": 5 }), // BOOLEAN + 1 => json!({ "PrimitiveType": 1 }), // INT32 + 2 => json!({ "PrimitiveType": 3 }), // INT64 + 3 => json!({ "PrimitiveType": 7 }), // DOUBLE // String type mapping - 4 => json!({ "string": { "long_text": {} } }), // STRING + 4 => json!({ "String": { "item": {"LongText": {}} } }), // STRING // Array types mapping - 6 => json!({ "array": { "component_type": { "primitive_type": "DT_SIGNED_INT32" } } }), // INT32_ARRAY - 7 => json!({ "array": { "component_type": { "primitive_type": "DT_SIGNED_INT64" } } }), // INT64_ARRAY - 8 => json!({ "array": { "component_type": { "primitive_type": "DT_DOUBLE" } } }), // DOUBLE_ARRAY - 9 => json!({ "array": { "component_type": { "string": { "long_text": {} } } } }), // STRING_ARRAY + 6 => json!({ "Array": { "component_type": { "item": {"PrimitiveType": 1 } }} , "max_length": 1024}), // INT32_ARRAY + 7 => json!({ "Array": { "component_type": { "item": {"PrimitiveType": 3 }} } , "max_length": 1024}), // INT64_ARRAY + 8 => json!({ "Array": { "component_type": { "item": {"PrimitiveType": 7 }} } , "max_length": 1024}), // DOUBLE_ARRAY + 9 => { + json!({ "Array": { "component_type": { "item": { "String": { "item": {"LongText": {}} } } } , "max_length": 1024} }) + } // STRING_ARRAY // None type mapping - 11 => json!({ "primitive_type": "DT_NULL" }), // NONE + 11 => json!({ "PrimitiveType": 8 }), // NONE // Temporal types mapping - 12 => json!({ "temporal": { "date32": {} } }), // DATE32 - 13 => json!({ "temporal": { "time32": {} } }), // TIME32 - 14 => json!({ "temporal": { "timestamp": {} } }), // TIMESTAMP + 12 => json!({ "Temporal": { "item": {"Date32": {} }} }), // DATE32 + 13 => json!({ "Temporal": {"item": { "Time32": {} }} }), // TIME32 + 14 => json!({ "Temporal": { "item": {"Timestamp": {} }} }), // TIMESTAMP // Other types handling (default to a NONE-like type if applicable) - _ => json!({ "primitive_type": "DT_ANY" }), // NONE or unsupported types - } + _ => json!({ "PrimitiveType": 0 }), // NONE or unsupported types + }; + json!({"item": dt}) } /// To define the options of required columns by the computing node of the query plan.