Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into call-compiler-via-jni
Browse files Browse the repository at this point in the history
  • Loading branch information
liulx20 committed Jan 13, 2025
2 parents 4347546 + f577fae commit 8cb0b05
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 18 deletions.
3 changes: 1 addition & 2 deletions analytical_engine/apps/pregel/louvain/louvain_app_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 18 additions & 0 deletions interactive_engine/executor/ir/core/src/plan/logical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}
}
43 changes: 27 additions & 16 deletions interactive_engine/executor/ir/core/src/plan/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,14 @@ impl Schema {
(false, 0)
}
}

pub(crate) fn get_entities(&self) -> &Vec<schema_pb::EntityMeta> {
self.entities.as_ref()
}

pub(crate) fn get_relations(&self) -> &Vec<schema_pb::RelationMeta> {
self.relations.as_ref()
}
}

impl From<Schema> for schema_pb::Schema {
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 8cb0b05

Please sign in to comment.