-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ISSUE-377] Fix demo job and auto create demo job when console starts (…
- Loading branch information
Showing
13 changed files
with
287 additions
and
17 deletions.
There are no files selected for viewing
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
8 changes: 8 additions & 0 deletions
8
...le/app/biz/shared/src/main/java/com/antgroup/geaflow/console/biz/shared/demo/DemoJob.java
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,8 @@ | ||
package com.antgroup.geaflow.console.biz.shared.demo; | ||
|
||
import com.antgroup.geaflow.console.core.model.job.GeaflowJob; | ||
|
||
public abstract class DemoJob { | ||
|
||
public abstract GeaflowJob build(); | ||
} |
23 changes: 23 additions & 0 deletions
23
...app/biz/shared/src/main/java/com/antgroup/geaflow/console/biz/shared/demo/SocketDemo.java
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,23 @@ | ||
package com.antgroup.geaflow.console.biz.shared.demo; | ||
|
||
import com.antgroup.geaflow.console.common.util.VelocityUtil; | ||
import com.antgroup.geaflow.console.core.model.job.GeaflowJob; | ||
import com.antgroup.geaflow.console.core.model.job.GeaflowProcessJob; | ||
import java.util.HashMap; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@Slf4j | ||
public class SocketDemo extends DemoJob { | ||
|
||
private static final String DEMO_JOB_TEMPLATE = "template/demoJob.vm"; | ||
|
||
public GeaflowJob build() { | ||
GeaflowProcessJob job = new GeaflowProcessJob(); | ||
String code = VelocityUtil.applyResource(DEMO_JOB_TEMPLATE, new HashMap<>()); | ||
job.setUserCode(code); | ||
job.setName("demoJob"); | ||
return job; | ||
} | ||
} |
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
72 changes: 72 additions & 0 deletions
72
geaflow-console/app/bootstrap/src/main/resources/template/demoJob.vm
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,72 @@ | ||
set geaflow.dsl.window.size = 1; | ||
set geaflow.dsl.ignore.exception = true; | ||
|
||
CREATE GRAPH IF NOT EXISTS dy_modern ( | ||
Vertex person ( | ||
id bigint ID, | ||
name varchar | ||
), | ||
Edge knows ( | ||
srcId bigint SOURCE ID, | ||
targetId bigint DESTINATION ID, | ||
weight double | ||
) | ||
) WITH ( | ||
storeType='rocksdb', | ||
shardCount = 1 | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS tbl_source ( | ||
text varchar | ||
) WITH ( | ||
type='file', | ||
`geaflow.dsl.file.path` = 'resource:///demo/demo_job_data.txt', | ||
`geaflow.dsl.column.separator`='|' | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS tbl_result ( | ||
a_id bigint, | ||
b_id bigint, | ||
c_id bigint, | ||
d_id bigint, | ||
a1_id bigint | ||
) WITH ( | ||
type='file', | ||
`geaflow.dsl.file.path` = '/tmp/geaflow/demo_job_result' | ||
); | ||
|
||
USE GRAPH dy_modern; | ||
|
||
INSERT INTO dy_modern.person(id, name) | ||
SELECT | ||
cast(trim(split_ex(t1, ',', 0)) as bigint), | ||
split_ex(trim(t1), ',', 1) | ||
FROM ( | ||
Select trim(substr(text, 2)) as t1 | ||
FROM tbl_source | ||
WHERE substr(text, 1, 1) = '.' | ||
); | ||
|
||
INSERT INTO dy_modern.knows | ||
SELECT | ||
cast(split_ex(t1, ',', 0) as bigint), | ||
cast(split_ex(t1, ',', 1) as bigint), | ||
cast(split_ex(t1, ',', 2) as double) | ||
FROM ( | ||
Select trim(substr(text, 2)) as t1 | ||
FROM tbl_source | ||
WHERE substr(text, 1, 1) = '-' | ||
); | ||
|
||
INSERT INTO tbl_result | ||
SELECT DISTINCT | ||
a_id, | ||
b_id, | ||
c_id, | ||
d_id, | ||
a1_id | ||
FROM ( | ||
MATCH (a:person) -[:knows]->(b:person) -[:knows]-> (c:person) | ||
-[:knows]-> (d:person) -> (a:person) | ||
RETURN a.id as a_id, b.id as b_id, c.id as c_id, d.id as d_id, a.id as a1_id | ||
); |
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
13 changes: 13 additions & 0 deletions
13
geaflow/geaflow-dsl/geaflow-dsl-runtime/src/main/resources/demo/demo_job_data.txt
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,13 @@ | ||
. 1,jim | ||
. 2,kate | ||
. 3,lily | ||
. 4,lucy | ||
. 5,brown | ||
. 6,jack | ||
. 7,jackson | ||
- 1,2,0.2 | ||
- 2,3,0.3 | ||
- 3,4,0.2 | ||
- 4,1,0.1 | ||
- 4,5,0.1 | ||
- 6,7,0.1 |
Oops, something went wrong.