Skip to content

Commit

Permalink
Stable point
Browse files Browse the repository at this point in the history
  • Loading branch information
pierredebelen committed Dec 14, 2023
1 parent 859499e commit 1c09633
Show file tree
Hide file tree
Showing 36 changed files with 1,708 additions and 355 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@
/legend-engine-xt-graphQL-grammar/gen/
/welcome.pure
/legend-engine-xt-nonrelationalStore-mongodb-grammar/gen/
/legend-engine-core-shared/legend-engine-shared-core/src/main/resources/legendExecutionVersion.json
/legend-engine-core/legend-engine-core-shared/legend-engine-shared-core/src/main/resources/legendExecutionVersion.json
temp
1 change: 1 addition & 0 deletions h2Console.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java -jar ~/.m2/repository/com/h2database/h2/2.1.214/h2-2.1.214.jar
2 changes: 1 addition & 1 deletion h2Server.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
java -cp ~/.m2/repository/com/h2database/h2/1.4.200/h2-1.4.200.jar org.h2.tools.Server -tcp -tcpPort 9092 -ifNotExists
java -cp ~/.m2/repository/com/h2database/h2/2.1.214/h2-2.1.214.jar org.h2.tools.Server -tcp -tcpPort 1975 -ifNotExists
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ function meta::pure::extension::print::printExtensions(extensions: Extension[*])
$extensions->sortBy(x | $x.type->toLower())->map(ext | $ext->printExtension(1))->joinStrings('[\n', ',\n\n', '\n]')
}

function <<access.private>> meta::pure::extension::print::printExtension(extension: Extension[1], depth: Integer[1]): String[1]
function meta::pure::extension::print::printExtension(extension: Extension[1], depth: Integer[1]): String[1]
{
let indent = indent($depth);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,11 @@ function <<access.private>> meta::pure::router::operations::getMappedLeafClasses
if($specs->isEmpty(), | $mappedClass, | $specs->map(s | $s->getMappedLeafClasses_recursive($mappedClass, $mapping, $state)));
}

function <<functionType.NotImplementedFunction>> meta::pure::mapping::from<T|m>(t:T[m], runtime:Runtime[1]):T[m]
{
$t
}

function <<functionType.NotImplementedFunction>> meta::pure::mapping::from<T|m>(t:T[m], m:meta::pure::mapping::Mapping[1], runtime:Runtime[1]):T[m]
{
$t
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,11 @@ function meta::pure::router::clustering::generateExecutionNodeFromCluster(cluste
sc:StoreMappingClusteredValueSpecification[1] |
//This is required to populate the setup sql for test connections where csv data has been supplied. It is done here to ensure that the plan generation is always
//the only place where sql is generated for this case.
let rt = $sc.runtime->match([
r:Runtime[1] | ^$r(connectionStores = $r.connectionStores->map(c | if ($sc.s.reprocessConnection->isEmpty(),|$c,|^$c(connection=$sc.s.reprocessConnection->toOne()->eval($c))))),
r:Runtime[0..1] | $r
]);




let query = ^meta::pure::mapping::StoreQuery(store=$sc.store, fe=$fe, inScopeVars=$inScopeVars);
let res = $sc.s.planExecution->toOne()->eval($query, $sc.val->match([r:RoutedValueSpecification[1]|$r, a:Any[*]|[]])->cast(@RoutedValueSpecification), $sc.mapping, $rt, if ($sc.exeCtx->isEmpty(), | $context, | $sc.exeCtx->toOne()), $extensions, $debugContext);
^$res(fromCluster=$cluster);,
$sc->buildExecutionNodeForStoreClusteredVS($fe, $sc.mapping, $inScopeVars, $context, $extensions, $debugContext),
sc:StoreClusteredValueSpecification[1] |
//This is required to populate the setup sql for test connections where csv data has been supplied. It is done here to ensure that the plan generation is always
//the only place where sql is generated for this case.
$sc->buildExecutionNodeForStoreClusteredVS($fe, [], $inScopeVars, $context, $extensions, $debugContext),
ef:ExternalFormatClusteredValueSpecification[1] |
let state = ^meta::external::format::shared::executionPlan::ExternalFormatPlanGenerationState(inScopeVars = $inScopeVars, exeCtx = $ef.exeCtx->toOne(), binding = $ef.binding);
$fe->meta::external::format::shared::executionPlan::processValueSpecification($state, $extensions, $debugContext)->toOne();,
Expand All @@ -70,6 +64,19 @@ function meta::pure::router::clustering::generateExecutionNodeFromCluster(cluste
]);
}

function meta::pure::router::clustering::buildExecutionNodeForStoreClusteredVS(sc:StoreClusteredValueSpecification[1], fe:FunctionExpression[1], mapping:meta::pure::mapping::Mapping[0..1], inScopeVars:Map<String, List<Any>>[1], context:ExecutionContext[1], extensions:meta::pure::extension::Extension[*], debugContext:DebugContext[1]):ExecutionNode[1]
{
//This is required to populate the setup sql for test connections where csv data has been supplied. It is done here to ensure that the plan generation is always
//the only place where sql is generated for this case.
let rt = $sc.runtime->match([
r:Runtime[1] | ^$r(connectionStores = $r.connectionStores->map(c | if ($sc.s.reprocessConnection->isEmpty(),|$c,|^$c(connection=$sc.s.reprocessConnection->toOne()->eval($c))))),
r:Runtime[0..1] | $r
]);
let query = ^meta::pure::mapping::StoreQuery(store=$sc.store, fe=$fe, inScopeVars=$inScopeVars);
let res = $sc.s.planExecution->toOne()->eval($query, $sc.val->match([r:RoutedValueSpecification[1]|$r, a:Any[*]|[]])->cast(@RoutedValueSpecification), $mapping, $rt, if ($sc.exeCtx->isEmpty(), | $context, | $sc.exeCtx->toOne()), $extensions, $debugContext);
^$res(fromCluster=$sc);
}

function meta::pure::router::clustering::areClustersCompatible(cluster1:ClusteredValueSpecification[1], cluster2:ClusteredValueSpecification[1], extensions:meta::pure::extension::Extension[*]):Boolean[1]
{
$cluster1->match([
Expand Down Expand Up @@ -99,6 +106,8 @@ function meta::pure::router::clustering::streamSupportedFunctionEvaluator(cluste
$cluster->match([
sc:StoreMappingClusteredValueSpecification[1] |
$sc.s.supportsStream,
sc:StoreClusteredValueSpecification[1] |
$sc.s.supportsStream,
ef:ExternalFormatClusteredValueSpecification[1] |
{fxn:FunctionExpression[1] | false},
pl:PlatformClusteredValueSpecification[1] |
Expand All @@ -111,6 +120,8 @@ function meta::pure::router::clustering::elementPathForCluster(cluster:Clustered
$cluster->match([
sc:StoreMappingClusteredValueSpecification[1] |
$sc.store->elementToPath(),
sc:StoreClusteredValueSpecification[1] |
$sc.store->elementToPath(),
ef:ExternalFormatClusteredValueSpecification[1] |
$ef.binding->elementToPath(),
pl:PlatformClusteredValueSpecification[1] |
Expand All @@ -126,6 +137,11 @@ function meta::pure::router::clustering::toString(cluster:ClusteredValueSpecific
| let start = '{'+$sc.store->toOne()->elementToPath()+'> ';
$start + $sc.val->asString($pref)->replace('\n','\n'+space($start->length()))+'}';
);,
sc:StoreClusteredValueSpecification[1] | if($pref.useClusterIndex,
| '[Node Index:'+$pref.clusterIndex->indexOf($sc)->toString()+']',
| let start = '{'+$sc.store->toOne()->elementToPath()+'> ';
$start + $sc.val->asString($pref)->replace('\n','\n'+space($start->length()))+'}';
);,
p:PlatformClusteredValueSpecification[1] | if($pref.useClusterIndex,
|'[Node Index:'+$pref.clusterIndex->indexOf($p)->toString()+']',
|'{Platform> '+$p.val->asString($pref)->replace('\n','\n'+space('{Platform>'->length()))+'}';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ Diagram meta::pure::router::metamodel::RouterMetaModelDiagram(width=0.0, height=
TypeView cview_4(
type=meta::pure::router::metamodel::RoutingStrategy,
position=(-623.81836, -111.50000),
width=203.98145,
height=142.00000,
width=313.31667,
height=184.00000,
stereotypesVisible=true,
attributesVisible=true,
attributeStereotypesVisible=true,
Expand Down Expand Up @@ -228,7 +228,7 @@ Diagram meta::pure::router::metamodel::RouterMetaModelDiagram(width=0.0, height=
GeneralizationView gview_2(
source=cview_6,
target=cview_4,
points=[(-720.13867,168.50000),(-521.82764,-40.50000)],
points=[(-720.13867,168.50000),(-467.16003,-19.50000)],
label='',
color=#000000,
lineWidth=-1.0,
Expand All @@ -255,7 +255,7 @@ Diagram meta::pure::router::metamodel::RouterMetaModelDiagram(width=0.0, height=
GeneralizationView gview_5(
source=cview_9,
target=cview_4,
points=[(-519.81445,247.50000),(-521.82764,-40.50000)],
points=[(-519.81445,247.50000),(-467.16003,-19.50000)],
label='',
color=#000000,
lineWidth=-1.0,
Expand Down Expand Up @@ -291,7 +291,7 @@ Diagram meta::pure::router::metamodel::RouterMetaModelDiagram(width=0.0, height=
GeneralizationView gview_9(
source=cview_13,
target=cview_4,
points=[(-331.81445,174.50000),(-521.82764,-40.50000)],
points=[(-331.81445,174.50000),(-467.16003,-19.50000)],
label='',
color=#000000,
lineWidth=-1.0,
Expand Down Expand Up @@ -324,11 +324,11 @@ Diagram meta::pure::router::metamodel::RouterMetaModelDiagram(width=0.0, height=
lineWidth=-1.0,
lineStyle=SIMPLE)

PropertyView pview_1(
PropertyView pview_0(
property=meta::pure::router::metamodel::ExtendedRoutedValueSpecification.routingStrategy,
source=cview_2,
target=cview_4
, points=[(160.08545,-41.50000),(-521.82764,-40.50000)],
target=cview_4,
points=[(160.08545,-41.50000),(-467.16003,-19.50000)],
label='',
propertyPosition=(0.0,0.0),
multiplicityPosition=(0.0,0.0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Class <<typemodifiers.abstract>> meta::pure::router::metamodel::ExtendedRoutedVa
// =========================================================================================

###Pure
import meta::pure::metamodel::relation::*;
import meta::pure::extension::*;
import meta::pure::router::metamodel::*;
import meta::pure::router::routing::*;
Expand All @@ -44,6 +45,12 @@ Class <<typemodifiers.abstract>> meta::pure::router::metamodel::RoutingStrategy
$this.processClass->eval($c, $i, $state, $executionContext, $debug)
}: RoutingState[1];

processRelationStoreAccessor : Function<{RelationStoreAccessor<Any>[1], InstanceValue[1], RoutingState[1], ExecutionContext[1], DebugContext[1] -> RoutingState[1]}>[0..1];
processRelationStoreAccessor(c:RelationStoreAccessor<Any>[1], i:InstanceValue[1], state:RoutingState[1], executionContext:ExecutionContext[1], debug:DebugContext[1])
{
$this.processRelationStoreAccessor->toOne()->eval($c, $i, $state, $executionContext, $debug)
}: RoutingState[1];

// Process Property
processProperty : Function<{Property<Nil,Any|*>[1], FunctionExpression[1], RoutingState[1], ExecutionContext[1], Map<VariableExpression, ValueSpecification>[1], Map<String, List<Any>>[1], Extension[*], DebugContext[1] -> RoutingState[1]}>[1];
processProperty(p:Property<Nil,Any|*>[1], fe:FunctionExpression[1], state:RoutingState[1], executionContext:ExecutionContext[1], vars:Map<VariableExpression, ValueSpecification>[1], inScopeVars:Map<String, List<Any>>[1], extensions:Extension[*], debug:DebugContext[1])
Expand Down Expand Up @@ -81,6 +88,7 @@ function meta::pure::router::routing::toString(evs:ExtendedRoutedValueSpecificat
{
$evs->match([
sc:StoreMappingRoutedValueSpecification[1] | '['+$sc.id+' '+if($sc.propertyMapping->isEmpty(),|'',|'@'+$sc.propertyMapping->map(p|$p.property.name->toOne()+'('+$p.sourceSetImplementationId+'->'+$p.targetSetImplementationId+')')->joinStrings(',')+'@ ')+$sc.sets.id->joinStrings(', ')+'/'+$sc.value->asString($pref)+']',
s:StoreRoutedValueSpecification[1] | '['+$s.id+' '+$s.value->asString($pref)+']',
p:PlatformRoutedValueSpecification[1] | '['+$p.id+' /'+$p.value->asString($pref)+']',
e:ExternalFormatRoutedValueSpecification[1] | '['+$e.id+' /'+$e.value->asString($pref)+']'
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import meta::pure::metamodel::relation::*;
import meta::pure::router::preeval::*;
import meta::pure::extension::*;
import meta::pure::metamodel::path::*;
Expand Down Expand Up @@ -82,18 +83,11 @@ function <<access.public>> meta::pure::router::preeval::preval(f : FunctionDefin
if(!$r->anyModified(),
|
$state->printDebug(|'No changes made for: ');
$state->printDebug(|$f->meta::protocols::pure::vX_X_X::transformation::fromPureGraph::valueSpecification::transformFunctionBody($extensions)->meta::protocols::pure::vX_X_X::transformation::fromPureGraph::toPureGrammar::toPure($extensions));,
$state->printDebug(|$f->meta::pure::metamodel::serialization::grammar::printFunctionDefinition(''));,
|
let res = $r.value->toOne();

// $state->printDebug('Transformed From:');
// $state->printDebug(|$f->meta::protocols::pure::vX_X_X::transformation::fromPureGraph::valueSpecification::transformFunctionBody($extensions)->meta::json::toJSON(50000));
// $state->printDebug(|$f->meta::protocols::pure::vX_X_X::transformation::fromPureGraph::valueSpecification::transformFunctionBody($extensions)->meta::protocols::pure::vX_X_X::transformation::toPureGrammar::toPure($extensions));

$state->printDebug('Transformed To:');
$state->printDebug(|$res->meta::protocols::pure::vX_X_X::transformation::fromPureGraph::valueSpecification::transformFunctionBody($extensions)->meta::json::toJSON(50000));
$state->printDebug(|$res->meta::protocols::pure::vX_X_X::transformation::fromPureGraph::valueSpecification::transformFunctionBody($extensions)->meta::protocols::pure::vX_X_X::transformation::fromPureGraph::toPureGrammar::toPure($extensions));

$state->printDebug(|$res->meta::pure::metamodel::serialization::grammar::printFunctionDefinition(''));
$state->printDebug($res);
);

Expand Down Expand Up @@ -270,6 +264,7 @@ function <<access.private>> meta::pure::router::preeval::prevalInternal(item : A
{r: meta::pure::graphFetch::RootGraphFetchTree<Any>[1] | ^PrevalWrapper<Any>(value = $r, canPreval = true, modified = false);},
{b: meta::external::format::shared::binding::Binding[1] | ^PrevalWrapper<Any>(value = $b, canPreval = true, modified = false);},
{s: meta::pure::store::Store[1] | ^PrevalWrapper<Any>(value = $s, canPreval = true, modified = false);},
{s: meta::pure::metamodel::relation::RelationStoreAccessor<Any>[1] | ^PrevalWrapper<Any>(value = $s, canPreval = false, modified = false);},
{a : Any[1]|
assert($state.stopPreeval->eval($a), | 'Unsupported type: ' + $a->type()->match([pe:PackageableElement[1]|$pe->elementToPath(), t:Type[1]|$t->makeString()]));
^PrevalWrapper<Any>(value = $a, canPreval = true, modified = false);
Expand Down Expand Up @@ -312,7 +307,6 @@ function <<access.private>> meta::pure::router::preeval::prevalFunctionDefinitio
| pair($state, list(if($p.second.values->isEmpty(), | $r, | $p.second.values->concatenate($r)))),
|
let fe = $r.value->cast(@FunctionExpression);

let varName = $fe.parametersValues->at(0)->reactivate($state.inScopeVars)->cast(@String)->toOne();
let varValue = $fe.parametersValues->at(1)
->match([
Expand Down Expand Up @@ -414,7 +408,11 @@ function <<access.private>> meta::pure::router::preeval::prevalGenericSimpleFunc
{
let newParamWrappers = if($sfe.parametersValues->isEmpty(),
| [],
| $sfe.func->match([p:Property<Any,Any|*>[1]|'this', f:Function<Any>[1]|$f->functionType().parameters.name])
| $sfe.func->match([
p:Property<Nil,Any|*>[1]|'this',
c:Column<Nil,Any|*>[1]|'this',
f:Function<Any>[1]|$f->functionType().parameters.name
])
->zip($sfe.parametersValues)
->evaluateAndDeactivate()
->map(p| $state->printDebugWithDepth(|'Processing parameter: ' + $p.first);
Expand Down Expand Up @@ -885,12 +883,16 @@ function <<access.private>> meta::pure::router::preeval::resolveGenericType(in :
{
if($in.typeParameter->isEmpty(),
|
let newTypeArgsWrappers = $in.typeArguments->map(ta|$ta->resolveGenericType($state));
if(!$newTypeArgsWrappers->anyModified(),
| ^PrevalWrapper<GenericType>(value = $in, canPreval=true, modified = false),
| let value = ^$in(typeArguments = $newTypeArgsWrappers.value);
^PrevalWrapper<GenericType>(value = $value, canPreval=$newTypeArgsWrappers->canPreval(), modified = $newTypeArgsWrappers->anyModified());
);,
if($in.rawType->isNotEmpty() && $in.rawType->toOne()->instanceOf(FunctionType),
|^PrevalWrapper<GenericType>(value = ^$in(rawType=$in.rawType->cast(@FunctionType)->toOne()->resolveFunctionType($state)), canPreval=false, modified = true);,
|let newTypeArgsWrappers = $in.typeArguments->map(ta|$ta->resolveGenericType($state));
if(!$newTypeArgsWrappers->anyModified(),
| ^PrevalWrapper<GenericType>(value = $in, canPreval=true, modified = false),
| let value = ^$in(typeArguments = $newTypeArgsWrappers.value);
^PrevalWrapper<GenericType>(value = $value, canPreval=$newTypeArgsWrappers->canPreval(), modified = $newTypeArgsWrappers->anyModified());
);
);
,
|
let value = $state.inScopeTypeParams->get($in.typeParameter->toOne().name);
if($value->isEmpty(),
Expand All @@ -900,6 +902,15 @@ function <<access.private>> meta::pure::router::preeval::resolveGenericType(in :
);
}

function <<access.private>> meta::pure::router::preeval::resolveFunctionType(in : FunctionType[1], state : meta::pure::router::preeval::State[1]):FunctionType[1]
{
^$in
(
parameters = $in.parameters->map(x|^$x(genericType = $x.genericType->resolveGenericType($state).value)),
returnType = $in.returnType->resolveGenericType($state).value
);
}

function <<access.private>> meta::pure::router::preeval::shouldInline(f:Function<Any>[1], state : meta::pure::router::preeval::State[1]):Boolean[1]
{
($f->instanceOf(FunctionDefinition) && ($f->cast(@FunctionDefinition<Any>).expressionSequence->size() == 1 ))
Expand Down
Loading

0 comments on commit 1c09633

Please sign in to comment.