org.eclipse.viatra.query.runtime.api.ViatraQueryEngine.on()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(70)

本文整理了Java中org.eclipse.viatra.query.runtime.api.ViatraQueryEngine.on()方法的一些代码示例,展示了ViatraQueryEngine.on()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ViatraQueryEngine.on()方法的具体详情如下:
包路径:org.eclipse.viatra.query.runtime.api.ViatraQueryEngine
类名称:ViatraQueryEngine
方法名:on

ViatraQueryEngine.on介绍

[英]Obtain a (managed) ViatraQueryEngine to evaluate queries over a given scope specified by an QueryScope.

For a given matcher scope, the same engine will be returned to any client. This facilitates the reuse of internal caches of the engine, greatly improving performance.

The lifecycle of this engine is centrally managed, and will not be disposed as long as the model is retained in memory. The engine will be garbage collected along with the model.

Advanced users: see AdvancedViatraQueryEngine#createUnmanagedEngine(QueryScope) to obtain a private, unmanaged engine that is not shared with other clients and allows tight control over its lifecycle.
[中]获取一个(托管的)ViatraQueryEngine,以在QueryScope指定的给定范围内评估查询。
对于给定的matcher作用域,相同的引擎将返回给任何客户机。这有助于重用引擎的内部缓存,从而大大提高性能。
此引擎的生命周期是集中管理的,只要模型保留在内存中,就不会进行处理。引擎将与模型一起被垃圾收集。
高级用户:请参阅AdvancedViatraQueryEngine#createUnmanagedEngine(QueryScope),以获得一个私有的非托管引擎,该引擎不与其他客户端共享,并允许对其生命周期进行严格控制。

代码示例

代码示例来源:origin: org.eclipse.viatra/org.eclipse.viatra.transformation.runtime.emf

public EventDrivenTransformationBuilder setScope(EMFScope scope) {
  this.engine = ViatraQueryEngine.on(scope);
  return this;
}

代码示例来源:origin: org.eclipse.viatra/org.eclipse.viatra.transformation.runtime.emf

public static BatchTransformationBuilder forScope(EMFScope scope) {
  return forEngine(ViatraQueryEngine.on(scope));
}

代码示例来源:origin: org.eclipse.viatra/org.eclipse.viatra.transformation.runtime.emf

public static EventDrivenTransformationBuilder forScope(EMFScope scope) {
  return forEngine(ViatraQueryEngine.on(scope));
}

代码示例来源:origin: org.eclipse.viatra/org.eclipse.viatra.dse

/**
 * Initialize this SolutionTrajectory for transforming the model along the trajectory.
 * 
 * @param model
 *            The model.
 * @throws ViatraQueryRuntimeException
 *             If the VIATRA Query fails to initialize.
 */
public void setModel(Notifier model) {
  editingDomain = null;
  EMFScope scope = new EMFScope(model);
  this.engine = ViatraQueryEngine.on(scope);
  this.model = model;
  stateCoder = stateCoderFactory.createStateCoder();
  stateCoder.init(model);
  currentIndex = 0;
  DseIdPoolHelper.INSTANCE.disposeByThread();
  DseIdPoolHelper.INSTANCE.registerRules(rule -> {
    int id = 0;
    for (BatchTransformationRule<?,?> r : transformationRules.subList(0, currentIndex)) {
      if (r.equals(rule)) {
        id ++;
      }
    }
    return id;
  }, new HashSet<BatchTransformationRule<?,?>>(transformationRules));
}

代码示例来源:origin: org.eclipse.viatra/org.eclipse.viatra.dse

@Override
  public void init(Notifier notifier, StatecodingDependencyGraph statecodingDependencyGraph) {

    try {
      EMFScope scope = new EMFScope(notifier);
      ViatraQueryEngine queryEngine = ViatraQueryEngine.on(scope);

      Set<EClass> classes = new HashSet<EClass>();
//          Set<EReference> references = new HashSet<EReference>();
      for (StatecodingNode node : statecodingDependencyGraph.getNodes()) {
        classes.add(node.getClazz());
//              for (StatecodingDependency dependency : node.getStatecodingDependencies()) {
//                  // TODO inverse reference
//                  references.add(dependency.eReference);
//              }
      }
      baseIndex = EMFScope.extractUnderlyingEMFIndex(queryEngine);
      baseIndex.registerEClasses(classes, IndexingLevel.FULL);
    } catch (ViatraQueryException e) {
      logger.error("Failed to initialize VIATRA Query engine on the given notifier", e);
      throw new DSEException("Failed to initialize VIATRA Query engine on the given notifier");
    }
  }

代码示例来源:origin: org.eclipse.viatra/org.eclipse.viatra.addon.validation.runtime

public ConstraintAdapter(IEditorPart editorPart, Notifier notifier, Logger logger) {
  this.logger = logger;
  resourceForEditor = getIResourceForEditor(editorPart);
  this.markerMap = new HashMap<IPatternMatch, IMarker>();
  this.violationMarkerMap = new HashMap<IViolation, IMarker>();
  try {
    ViatraQueryEngine queryEngine = ViatraQueryEngine.on(new EMFScope(notifier));
    engine = ValidationEngine.builder().setEngine(queryEngine).setLogger(logger).build();
    engine.initialize();
    
    MarkerManagerViolationListener markerManagerViolationListener = new MarkerManagerViolationListener(logger, this);
    Set<IConstraintSpecification> constraintSpecificationsForEditorId = ConstraintExtensionRegistry
        .getConstraintSpecificationsForEditorId(editorPart.getSite().getId());
    for (IConstraintSpecification constraint : constraintSpecificationsForEditorId) {
      IConstraint coreConstraint = engine.addConstraintSpecification(constraint);
      coreConstraint.addListener(markerManagerViolationListener);
    }
  } catch (ViatraQueryException e) {
    logger.error(String.format("Exception occured during validation initialization: %s", e.getMessage()), e);
  }
}

代码示例来源:origin: org.eclipse.viatra/org.eclipse.viatra.dse

try {
  EMFScope scope = new EMFScope(notifier);
  ViatraQueryEngine queryEngine = ViatraQueryEngine.on(scope);
  EMFBaseIndexWrapper baseIndex = (EMFBaseIndexWrapper) queryEngine.getBaseIndex();
  navigationHelper = baseIndex.getNavigationHelper();

代码示例来源:origin: org.eclipse.viatra/org.eclipse.viatra.addon.validation.runtime

/**
 * Initializes a new validation engine implementing the IValidationEngine interface on the provided Notifier
 * instance with the constrains specified for the given editor Id.
 * 
 * @param scope
 *            The Notifier object on which the validation engine should be initialized.
 * @param editorId
 *            An editor Id for which we wish to use the registered constraint specifications at the
 *            org.eclipse.viatra.addon.livevalidation.runtime.constraintspecification extension point.
 * @return The initialized validation engine.
 */
public static IValidationEngine initializeValidationWithRegisteredConstraintsOnScope(QueryScope scope,
    String editorId) {
  ViatraQueryEngine engine = ViatraQueryEngine.on(scope);
  Logger logger = ViatraQueryLoggingUtil.getLogger(ValidationEngine.class);
  IValidationEngine validationEngine = ValidationEngine.builder().setEngine(engine).setLogger(logger).build();

  for (IConstraintSpecification constraintSpecification : ConstraintExtensionRegistry.getConstraintSpecificationsForEditorId(editorId)) {
    validationEngine.addConstraintSpecification(constraintSpecification);
  }
  validationEngine.initialize();

  return validationEngine;
}

代码示例来源:origin: org.eclipse.viatra/org.eclipse.viatra.dse

queryEngine = ViatraQueryEngine.on(scope);

相关文章