SqlAggregator provides aggregated SQL execution over multiple SqlLocalConnection shards within a single process. It exposes the common ISqlConnection contract while routing statements and queries to one or more local SQL engines.
public class SqlAggregator : ISqlConnection, IDisposable
{
// ===== CONSTRUCTORS =====
public SqlAggregator(Database db, SqlLocalConnection[] engines);
public SqlAggregator(Database db, SqlLocalConnection[] engines, int bufferSize);
// ===== PROPERTIES =====
public IDatabaseWrapper Wrapper { get; }
// ===== QUERY EXECUTION METHODS =====
public SqlResultSet ExecuteQuery(String query, params Object[] args);
public int ExecuteStatement(String stmt, params Object[] args);
// ===== LIFECYCLE METHODS =====
public void Disconnect();
public void Dispose();
// ===== INTERNAL MANAGEMENT =====
public void DetachResultSet(SqlResultSet result);
}
SqlAggregator(Database, SqlLocalConnection[])
SqlAggregator(Database, SqlLocalConnection[], int)
Wrapper
IDatabaseWrapper instance for low-level database operations. Part of the ISqlConnection interface contract.ExecuteQuery(String, params Object[])
SqlResultSet for iterating through the aggregated rows. If another result set is still attached to the aggregator, it is closed before the new query is executed. Throws SqlException if the aggregator is already closed.ExecuteStatement(String, params Object[])
SqlException if the aggregator is already closed.Disconnect()
SqlLocalConnection shards.Dispose()
Disconnect(). Implements the IDisposable pattern for use with using statements.DetachResultSet(SqlResultSet)
SqlResultSet when the active result set is closed or disposed. Applications should not call this method directly.SqlAggregator behaves like a distributed SQL connection within one process. It works over an array of SqlLocalConnection shards and can execute statements against all shards or against selected shards depending on the SQL text.1:, 2:, or ?: to control where a statement is executed. Statements without an explicit shard prefix can be broadcast to all aggregated shards.SqlAggregator instance is not thread-safe. Use separate aggregator instances per thread. The underlying shard connections must remain valid for the aggregator's lifetime and should not be used directly elsewhere while the aggregator is active.ExecuteQuery and ExecuteStatement support parameter binding through the params Object[] argument list. In most cases the standard ? placeholder can be used, while the SQL engine also supports typed %x placeholders when explicit argument formatting is required.Dispose() or use a using block to ensure timely release of native aggregator resources.
The aggregator does not own the underlying engine connections; they must be disconnected separately after the aggregator is closed.SqlException if the aggregator is already closed. Query execution errors from individual engines are propagated to the caller.defaultStringEncoding for converting .NET strings to the wire format expected by the eXtremeDB engine.SqlAggregator, the maximum SQL statement or query string length is limited by the bufferSize constructor argument. The default value is 64 KB.