> For the complete documentation index, see [llms.txt](https://docs.rierino.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rierino.com/devops/pro-code/custom-query-managers.md).

# Custom Query Managers

All query managers extend the abstract QueryManager class or one of its subclasses.

```java
public class MyQueryManager extends QueryManager{

  /** 
   * Constructor with provided "alias", event runner which owns the manager
   * as well as all the configurations available to the runner
   */
  public MyQueryManager(String name, EventRunner runner, Map<String, String> config) {
    super(name, runner, config);
  }
  
  /** 
   * Function called during initialization of a query manager, typically
   * used to establish connections.
   */
  @Override
  public void configure() throws HotException {
  }
   
  /** 
   * Function called during termination of a query manager, typically
   * used to close connections with external systems.
   */
  @Override
  public void close() throws IOException {
  }
  
  /**
   * Function called for streaming records from
   * the query manager for a given query definition.
   * Data can be returned in any format preferred by the target
   * system, as convertToJson function is called for the output.
   */
  @Override
  public abstract Stream getRawQueryStream(Query query, InjectionHelper helper) throws HotException{
  }

  /**
   * Function called for translating target system specific records
   * into JsonNode.
   */
   public JsonNode convertToJson(Object object) throws HotException{
   }

}
```

Query managers typically utilize query producers for translating Rierino platform specific query definitions into target system specific language (e.g. SQL).  Query producers implement a wide range of abstract functions to provide this support, depending on their type:

* **CommandProducer:** For translating open ended query definitions to target system
* **SimpleProducer:** For translating regular queries with where condition, field selection and joins
* **AggregationProducer:** For translating group by and aggregation queries
* **PipelineProducer:** For translating step by step query pipelines supported by certain systems (e.g. MongoDB)
* **BundleProducer:** For translating bundled queries which submit multiple queries at once, supported by certain systems (e.g. Elasticsearch)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.rierino.com/devops/pro-code/custom-query-managers.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
