mirror of
https://github.com/OpenSPG/openspg.git
synced 2025-09-17 12:37:19 +00:00
local runner support specify a graph state class name
This commit is contained in:
parent
52ca5d8a4d
commit
1eadad5ddd
@ -176,26 +176,28 @@ public class KGReasonerLocalRunner {
|
||||
return graphState;
|
||||
}
|
||||
|
||||
String graphLoadClass = task.getGraphLoadClass();
|
||||
MemGraphState memGraphState = new MemGraphState();
|
||||
AbstractLocalGraphLoader graphLoader;
|
||||
if (StringUtils.isEmpty(task.getGraphStateInitString())) {
|
||||
String graphStateClass = task.getGraphStateClassName();
|
||||
if (StringUtils.isNotEmpty(graphStateClass)) {
|
||||
try {
|
||||
graphLoader =
|
||||
(AbstractLocalGraphLoader) Class.forName(graphLoadClass).getConstructor().newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("can not create graph loader from name " + graphLoadClass, e);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
graphLoader =
|
||||
(AbstractLocalGraphLoader)
|
||||
Class.forName(graphLoadClass)
|
||||
graphState =
|
||||
(GraphState<IVertexId>)
|
||||
Class.forName(graphStateClass)
|
||||
.getConstructor(String.class)
|
||||
.newInstance(task.getGraphStateInitString());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("can not create graph loader from name " + graphLoadClass, e);
|
||||
throw new RuntimeException("can not create graph state from name " + graphStateClass, e);
|
||||
}
|
||||
return graphState;
|
||||
}
|
||||
|
||||
String graphLoadClass = task.getGraphLoadClass();
|
||||
MemGraphState memGraphState = new MemGraphState();
|
||||
AbstractLocalGraphLoader graphLoader;
|
||||
try {
|
||||
graphLoader =
|
||||
(AbstractLocalGraphLoader) Class.forName(graphLoadClass).getConstructor().newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("can not create graph loader from name " + graphLoadClass, e);
|
||||
}
|
||||
graphLoader.setGraphState(memGraphState);
|
||||
graphLoader.load();
|
||||
|
@ -217,7 +217,7 @@ public class LocalRunnerMain {
|
||||
task.setDsl(dsl);
|
||||
task.setOutputFile(outputFile);
|
||||
task.setConnInfo(new KgSchemaConnectionInfo(schemaUri, schemaToken));
|
||||
task.setGraphLoadClass(graphStateClass);
|
||||
task.setGraphStateClassName(graphStateClass);
|
||||
task.setGraphStateInitString(graphStateUrl);
|
||||
task.setStartIdList(new ArrayList<>());
|
||||
task.addStartId(startIdList);
|
||||
|
@ -51,12 +51,16 @@ public class LocalReasonerTask implements Serializable {
|
||||
private KgSchemaConnectionInfo connInfo = null;
|
||||
private String schemaString = null;
|
||||
|
||||
/** Choose between graphLoadClass or graphState */
|
||||
/** Choose between graphLoadClass and graphState, or specify a class name */
|
||||
private String graphLoadClass = null;
|
||||
|
||||
private String graphStateInitString = null;
|
||||
private GraphState<IVertexId> graphState = null;
|
||||
|
||||
/** User specified the name of graphstate */
|
||||
private String graphStateClassName = null;
|
||||
|
||||
private String graphStateInitString = null;
|
||||
|
||||
/** start id from input */
|
||||
private List<Tuple2<String, String>> startIdList;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user