org.eclipse.viatra.query.runtime.tabular

## Class TabularIndexHost

- java.lang.Object
- - org.eclipse.viatra.query.runtime.tabular.TabularIndexHost

- Direct Known Subclasses:
    EcoreIndexHost

      public abstract class TabularIndexHost
      extends java.lang.Object

  Simple tabular index host. Unlike traditional Viatra instances initialized on a model, this index host can be initialized and then queried, while its queriable "contents" (base relations) can be separately written using table writer API.

  Deriving classes are responsible for setting up the tables of this index and providing the writer API to clients. For the former, use `newUnaryInputTable(IInputKey, boolean)`, `newBinaryInputTable(IInputKey, boolean)` to create input tables, or `registerNewTable(IIndexTable)` to register manually created derived tables. Instantiate such tables with `runtimeContext` as their table context.

  EXPERIMENTAL. This class or interface has been added as part of a work in progress. There is no guarantee that this API will work or that it will remain the same.

  Since:
    2.1
  See Also:
    `EcoreIndexHost for EMF-specific example usage.`

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `class` | `TabularIndexHost.TabularIndexScope` A scope describing queries evaluated against tzhis index host.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected TabularRuntimeContext` | `runtimeContext`
    `protected TabularIndexHost.TabularIndexScope` | `scope`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TabularIndexHost(IStorageBackend storage, TabularRuntimeContext runtimeContext)`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `finishUpdateTransaction()` Marks the end of an update transaction.
    `TabularRuntimeContext` | `getRuntimeContext()`
    `TabularIndexHost.TabularIndexScope` | `getScope()`
    `protected abstract boolean` | `isQueryScopeEmulated(java.lang.Class<? extends QueryScope> queryScopeClass)`
    `protected ITableWriterBinary.Table<java.lang.Object,java.lang.Object>` | `newBinaryInputTable(IInputKey key, boolean unique)` To be called by deriving class.
    `protected ITableWriterUnary.Table<java.lang.Object>` | `newUnaryInputTable(IInputKey key, boolean unique)` To be called by deriving class.
    `protected <Table extends IIndexTable> Table` | `registerNewTable(Table newTable)` To be called by deriving class.
    `void` | `startUpdateTransaction()` Marks the beginning of an update transaction.

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

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

- - ### Field Detail

    - #### runtimeContext

          protected final TabularRuntimeContext runtimeContext

    - #### scope

          protected final TabularIndexHost.TabularIndexScope scope

  - ### Constructor Detail

    - #### TabularIndexHost

          public TabularIndexHost(IStorageBackend storage,
                                  TabularRuntimeContext runtimeContext)

  - ### Method Detail

    - #### getRuntimeContext

          public TabularRuntimeContext getRuntimeContext()

    - #### getScope

          public TabularIndexHost.TabularIndexScope getScope()

    - #### isQueryScopeEmulated

          protected abstract boolean isQueryScopeEmulated(java.lang.Class<? extends QueryScope> queryScopeClass)

      Returns:
        true if this index host aims to serve queries that have a scope of the given type

    - #### startUpdateTransaction

          public void startUpdateTransaction()

      Marks the beginning of an update transaction. In transaction mode, index table updates may be temporarily delayed for better performance. Stateful query backends will not update their results during the index update transaction. (TODO actually achieve this)

    - #### finishUpdateTransaction

          public void finishUpdateTransaction()

      Marks the end of an update transaction. Any updates to index tables that were delayed during the transaction must now be flushed. Afterwards, stateful query backends will update their results. (TODO actually achieve this)

    - #### newUnaryInputTable

          protected ITableWriterUnary.Table<java.lang.Object> newUnaryInputTable(IInputKey key,
                                                                                 boolean unique)

      To be called by deriving class. Creates and registers a new unary input table.

    - #### newBinaryInputTable

          protected ITableWriterBinary.Table<java.lang.Object,java.lang.Object> newBinaryInputTable(IInputKey key,
                                                                                                    boolean unique)

      To be called by deriving class. Creates and registers a new binary input table.

    - #### registerNewTable

          protected <Table extends IIndexTable> Table registerNewTable(Table newTable)

      To be called by deriving class. Registers the given freshly created table and also returns it for convenience.