mirror of
https://github.com/OpenSPG/openspg.git
synced 2025-09-17 20:48:04 +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;
|
return graphState;
|
||||||
}
|
}
|
||||||
|
|
||||||
String graphLoadClass = task.getGraphLoadClass();
|
String graphStateClass = task.getGraphStateClassName();
|
||||||
MemGraphState memGraphState = new MemGraphState();
|
if (StringUtils.isNotEmpty(graphStateClass)) {
|
||||||
AbstractLocalGraphLoader graphLoader;
|
|
||||||
if (StringUtils.isEmpty(task.getGraphStateInitString())) {
|
|
||||||
try {
|
try {
|
||||||
graphLoader =
|
graphState =
|
||||||
(AbstractLocalGraphLoader) Class.forName(graphLoadClass).getConstructor().newInstance();
|
(GraphState<IVertexId>)
|
||||||
} catch (Exception e) {
|
Class.forName(graphStateClass)
|
||||||
throw new RuntimeException("can not create graph loader from name " + graphLoadClass, e);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
graphLoader =
|
|
||||||
(AbstractLocalGraphLoader)
|
|
||||||
Class.forName(graphLoadClass)
|
|
||||||
.getConstructor(String.class)
|
.getConstructor(String.class)
|
||||||
.newInstance(task.getGraphStateInitString());
|
.newInstance(task.getGraphStateInitString());
|
||||||
} catch (Exception e) {
|
} 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.setGraphState(memGraphState);
|
||||||
graphLoader.load();
|
graphLoader.load();
|
||||||
|
@ -217,7 +217,7 @@ public class LocalRunnerMain {
|
|||||||
task.setDsl(dsl);
|
task.setDsl(dsl);
|
||||||
task.setOutputFile(outputFile);
|
task.setOutputFile(outputFile);
|
||||||
task.setConnInfo(new KgSchemaConnectionInfo(schemaUri, schemaToken));
|
task.setConnInfo(new KgSchemaConnectionInfo(schemaUri, schemaToken));
|
||||||
task.setGraphLoadClass(graphStateClass);
|
task.setGraphStateClassName(graphStateClass);
|
||||||
task.setGraphStateInitString(graphStateUrl);
|
task.setGraphStateInitString(graphStateUrl);
|
||||||
task.setStartIdList(new ArrayList<>());
|
task.setStartIdList(new ArrayList<>());
|
||||||
task.addStartId(startIdList);
|
task.addStartId(startIdList);
|
||||||
|
@ -51,12 +51,16 @@ public class LocalReasonerTask implements Serializable {
|
|||||||
private KgSchemaConnectionInfo connInfo = null;
|
private KgSchemaConnectionInfo connInfo = null;
|
||||||
private String schemaString = 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 graphLoadClass = null;
|
||||||
|
|
||||||
private String graphStateInitString = null;
|
|
||||||
private GraphState<IVertexId> graphState = null;
|
private GraphState<IVertexId> graphState = null;
|
||||||
|
|
||||||
|
/** User specified the name of graphstate */
|
||||||
|
private String graphStateClassName = null;
|
||||||
|
|
||||||
|
private String graphStateInitString = null;
|
||||||
|
|
||||||
/** start id from input */
|
/** start id from input */
|
||||||
private List<Tuple2<String, String>> startIdList;
|
private List<Tuple2<String, String>> startIdList;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user