The Executor class serves as the abstract foundation for all execution engines in Superlinked. It defines the interface for running queries against indexed data and managing the complete execution pipeline from data sources to vector databases.

Constructor

Executor(sources, indices, vector_database, context)

Parameters

sources
SourceT | Sequence[SourceT]
required
One or more data sources that provide the data to be indexed and queried. Can be a single source or a sequence of sources.
indices
Index | Sequence[Index]
required
One or more indices that define the vector spaces and organization of the data. Can be a single index or a sequence of indices.
vector_database
VectorDatabase
required
The vector database implementation that will store and manage the vectorized data for efficient retrieval.
context
ExecutionContext
required
The execution context that provides runtime configuration and environment-specific settings.
This is an abstract base class and cannot be instantiated directly. Use concrete implementations for specific execution strategies.

Inheritance Hierarchy

The Executor class serves as the base for all execution engine implementations: Inheritance Chain: ExecutorABCGeneric

Available Implementations

Methods

run()

Execute the configured pipeline and return a running application instance.
run() -> App
Returns: An instance of App configured with the executor’s sources, indices, and vector database. This abstract method must be implemented by concrete executor classes to define their specific execution strategy and return the appropriate application type.

Execution Pipeline

All executors manage a consistent execution pipeline:
  1. Source Configuration: Initialize and configure data sources
  2. Index Setup: Prepare vector spaces and indexing strategies
  3. Vector Database Integration: Connect to the specified vector database
  4. Context Application: Apply execution context settings
  5. Application Creation: Return a configured application instance

Executor Types and Use Cases

Development Executors

InMemoryExecutor: Designed for development, testing, and prototyping with in-memory data storage and processing. InteractiveExecutor: Enables interactive development with real-time data ingestion and immediate query execution.

Production Executors

RestExecutor: Built for production REST API deployments with scalable request handling and robust error management. QueryExecutor: Specialized for complex query processing scenarios with advanced optimization capabilities.

Design Patterns

Configuration Management

Executors follow a builder pattern for configuration:
  • Sources: Define data input strategies
  • Indices: Specify vector organization and spaces
  • Vector Database: Configure storage and retrieval
  • Context: Provide runtime settings

Execution Strategy

Each executor implementation provides:
  • Specific Application Type: Returns appropriate app instance
  • Runtime Optimization: Optimizes for its deployment scenario
  • Resource Management: Manages resources appropriate to its context
  • Error Handling: Implements error handling suitable for its environment

Best Practices

Executor Selection

Development: Use InMemoryExecutor for quick testing and prototyping with small datasets.
Production APIs: Use RestExecutor for scalable web applications requiring REST API endpoints.
Interactive Development: Use InteractiveExecutor when building and testing incrementally with real-time data.

Configuration

Resource Matching: Ensure your vector database choice matches your executor type. For example, use InMemoryVectorDatabase with InMemoryExecutor.

Context Management

Execution Context: Provide appropriate context data that matches your deployment environment and performance requirements.

Integration Pattern

Executors integrate all core Superlinked components:
  • Sources: Provide data input from various sources
  • Indices: Define vector spaces and data organization
  • Vector Databases: Handle vector storage and retrieval
  • Applications: Create the final application interface
  • Queries: Enable search and retrieval operations

Application Lifecycle

The executor manages the complete application lifecycle:
  1. Initialization: Configure all components
  2. Startup: Initialize connections and resources
  3. Runtime: Handle queries and data operations
  4. Monitoring: Provide observability and health checks
  5. Shutdown: Clean up resources appropriately

Error Handling

Executors provide comprehensive error handling:
  • Configuration Errors: Validate component compatibility
  • Runtime Errors: Handle execution failures gracefully
  • Resource Errors: Manage database and network issues
  • Data Errors: Handle source and parsing failures
The abstract nature of the Executor class ensures consistent behavior across different deployment strategies while allowing each implementation to optimize for its specific use case and environment.