Package org.eclipse.viatra.query.runtime.api.impl

## Class RunOnceQueryEngine

- java.lang.Object
- - org.eclipse.viatra.query.runtime.api.impl.RunOnceQueryEngine

- All Implemented Interfaces:
    `IRunOnceQueryEngine`

      public class RunOnceQueryEngine
      extends java.lang.Object
      implements IRunOnceQueryEngine

  Run-once query engines can be used to retrieve the current match set of query specifications in a given scope. The engine is initialized with a `Notifier` as scope and a base index options that specifically allows traversing derived features that are not well-behaving.

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected boolean` | `samplingMode` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `RunOnceQueryEngine​(org.eclipse.emf.common.notify.Notifier notifier)` | Creates a run-once query engine on the given notifier.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `<Match extends IPatternMatch> java.util.Collection<Match>` | `getAllMatches​(IQuerySpecification<? extends ViatraQueryMatcher<Match>> querySpecification)` | Returns the set of all matches for the given query in the scope of the engine.
    `BaseIndexOptions` | `getBaseIndexOptions()` | The base index options specifies how the base index is built, including wildcard mode (defaults to false) and dynamic EMF mode (defaults to false).
    `org.eclipse.emf.common.notify.Notifier` | `getScope()` |
    `void` | `resampleOnNextCall()` | If automatic resampling is enabled and the value of derived features may change without model modifications, calling this method will make sure that re-sampling will occur before returning match results.
    `void` | `setAutomaticResampling​(boolean automaticResampling)` | When set to true, the run-once query engine will not dispose it's engine and will resample the values of derived features before returning matches if the model changed since the last call.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### samplingMode

          protected boolean samplingMode

  - ### Constructor Detail

    - #### RunOnceQueryEngine

          public RunOnceQueryEngine​(org.eclipse.emf.common.notify.Notifier notifier)

      Creates a run-once query engine on the given notifier.

  - ### Method Detail

    - #### getAllMatches

          public <Match extends IPatternMatch> java.util.Collection<Match> getAllMatches​(IQuerySpecification<? extends ViatraQueryMatcher<Match>> querySpecification)

      Description copied from interface: `IRunOnceQueryEngine`
      Returns the set of all matches for the given query in the scope of the engine.
      Specified by:
        `getAllMatches` in interface `IRunOnceQueryEngine`
      Parameters:
        `querySpecification` - the query that is evaluated
      Returns:
        matches represented as a Match object.

    - #### getBaseIndexOptions

          public BaseIndexOptions getBaseIndexOptions()

      Description copied from interface: `IRunOnceQueryEngine`
      The base index options specifies how the base index is built, including wildcard mode (defaults to false) and dynamic EMF mode (defaults to false). See `NavigationHelper` for the explanation of wildcard mode and dynamic EMF mode.

      The returned options can be modified in order to affect subsequent calls of `IRunOnceQueryEngine.getAllMatches(org.eclipse.viatra.query.runtime.api.IQuerySpecification<? extends org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher<Match>>)`.
      Specified by:
        `getBaseIndexOptions` in interface `IRunOnceQueryEngine`
      Returns:
        the base index options used by the engine.

    - #### getScope

          public org.eclipse.emf.common.notify.Notifier getScope()

      Specified by:
        `getScope` in interface `IRunOnceQueryEngine`
      Returns:
        the scope of pattern matching, i.e. the root of the EMF model tree that this engine is attached to.

    - #### setAutomaticResampling

          public void setAutomaticResampling​(boolean automaticResampling)

      Description copied from interface: `IRunOnceQueryEngine`
      When set to true, the run-once query engine will not dispose it's engine and will resample the values of derived features before returning matches if the model changed since the last call. If the values of derived features may change without any model modification, call `IRunOnceQueryEngine.resampleOnNextCall()` before subsequent calls of `IRunOnceQueryEngine.getAllMatches(org.eclipse.viatra.query.runtime.api.IQuerySpecification<? extends org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher<Match>>)`.
      Specified by:
        `setAutomaticResampling` in interface `IRunOnceQueryEngine`

    - #### resampleOnNextCall

          public void resampleOnNextCall()

      Description copied from interface: `IRunOnceQueryEngine`
      If automatic resampling is enabled and the value of derived features may change without model modifications, calling this method will make sure that re-sampling will occur before returning match results.
      Specified by:
        `resampleOnNextCall` in interface `IRunOnceQueryEngine`