support ConcatAggIf

This commit is contained in:
wenchengyao 2024-04-19 14:25:10 +08:00
parent 86e041b13d
commit b14db8be88

View File

@ -326,46 +326,47 @@ public class LocalRunnerTest {
@Test @Test
public void doTestConcatAggIfDsl() { public void doTestConcatAggIfDsl() {
String dsl = String dsl =
"\n" "\n"
+ "GraphStructure {\n" + "GraphStructure {\n"
+ " (user:TuringCore.AlipayUser)<-[e:traveler]-(te:TuringCore.TravelEvent)\n" + " (user:TuringCore.AlipayUser)<-[e:traveler]-(te:TuringCore.TravelEvent)\n"
+ "}\n" + "}\n"
+ "Rule{\n" + "Rule{\n"
+ " concatEps = group(user).ConcatAggIf(te.travelMode == 'train', te.travelEndpoint)\n" + " concatEps = group(user).ConcatAggIf(te.travelMode == 'train', te.travelEndpoint)\n"
+ " R1: concatEps != ''\n" + " R1: concatEps != ''\n"
+ "}\n" + "}\n"
+ "Action{\n" + "Action{\n"
+ " get(user.id, concatEps)\n" + " get(user.id, concatEps)\n"
+ "}"; + "}";
LocalReasonerTask task = new LocalReasonerTask(); LocalReasonerTask task = new LocalReasonerTask();
task.setDsl(dsl); task.setDsl(dsl);
task.setGraphLoadClass( task.setGraphLoadClass(
"com.antgroup.openspg.reasoner.runner.local.loader.TestCrowdGraphLoader"); "com.antgroup.openspg.reasoner.runner.local.loader.TestCrowdGraphLoader");
// add mock catalog // add mock catalog
Map<String, scala.collection.immutable.Set<String>> schema = new HashMap<>(); Map<String, scala.collection.immutable.Set<String>> schema = new HashMap<>();
schema.put( schema.put(
"CKG.AdministrativeArea", Convert2ScalaUtil.toScalaImmutableSet(Sets.newHashSet("id"))); "CKG.AdministrativeArea", Convert2ScalaUtil.toScalaImmutableSet(Sets.newHashSet("id")));
schema.put( schema.put(
"TuringCore.TravelMode", Convert2ScalaUtil.toScalaImmutableSet(Sets.newHashSet("id"))); "TuringCore.TravelMode", Convert2ScalaUtil.toScalaImmutableSet(Sets.newHashSet("id")));
schema.put( schema.put(
"TuringCore.AlipayUser", Convert2ScalaUtil.toScalaImmutableSet(Sets.newHashSet("id"))); "TuringCore.AlipayUser", Convert2ScalaUtil.toScalaImmutableSet(Sets.newHashSet("id")));
schema.put( schema.put(
"TuringCore.TravelEvent", "TuringCore.TravelEvent",
Convert2ScalaUtil.toScalaImmutableSet(Sets.newHashSet("id", "eventTime", "travelMode", "travelEndpoint"))); Convert2ScalaUtil.toScalaImmutableSet(
Sets.newHashSet("id", "eventTime", "travelMode", "travelEndpoint")));
schema.put( schema.put(
"TuringCore.AlipayUser_workLoc_CKG.AdministrativeArea", "TuringCore.AlipayUser_workLoc_CKG.AdministrativeArea",
Convert2ScalaUtil.toScalaImmutableSet(Sets.newHashSet())); Convert2ScalaUtil.toScalaImmutableSet(Sets.newHashSet()));
schema.put( schema.put(
"TuringCore.TravelEvent_traveler_TuringCore.AlipayUser", "TuringCore.TravelEvent_traveler_TuringCore.AlipayUser",
Convert2ScalaUtil.toScalaImmutableSet(Sets.newHashSet())); Convert2ScalaUtil.toScalaImmutableSet(Sets.newHashSet()));
schema.put( schema.put(
"TuringCore.TravelEvent_travelEndpoint_CKG.AdministrativeArea", "TuringCore.TravelEvent_travelEndpoint_CKG.AdministrativeArea",
Convert2ScalaUtil.toScalaImmutableSet(Sets.newHashSet())); Convert2ScalaUtil.toScalaImmutableSet(Sets.newHashSet()));
schema.put( schema.put(
"TuringCore.TravelEvent_travelMode_TuringCore.TravelMode", "TuringCore.TravelEvent_travelMode_TuringCore.TravelMode",
Convert2ScalaUtil.toScalaImmutableSet(Sets.newHashSet())); Convert2ScalaUtil.toScalaImmutableSet(Sets.newHashSet()));
Catalog catalog = new PropertyGraphCatalog(Convert2ScalaUtil.toScalaImmutableMap(schema)); Catalog catalog = new PropertyGraphCatalog(Convert2ScalaUtil.toScalaImmutableMap(schema));
catalog.init(); catalog.init();
task.setCatalog(catalog); task.setCatalog(catalog);