Skip to content

Replace Associate Session merging flows with Composite Sessions - #59

Draft
matias-mcl wants to merge 5 commits into
masterfrom
mdr/89128-composite-session-changes
Draft

matias-mcl wants to merge 5 commits into
masterfrom
mdr/89128-composite-session-changes

Conversation

@matias-mcl

@matias-mcl matias-mcl commented Jun 2, 2026 •

Copy link
Copy Markdown

Summary

Updates all SQL Race examples for the new CompositeSession API.

Changes

New examples demonstrating CompositeSession API:

  • LoadSSNWtihAssociates() — Load file session with associates via FileSessionManager.LoadCompositeSession
  • LoadSqlRaceDatabaseSessionWithAssociates() — Load from SQL database via SessionManager.LoadCompositeSession
  • LoadSessionViaQueryManagerWithAssociate() — Discover sessions via QueryManager, then load as composite
  • CreateFunctionAcrossMultipleSessionsWithCompositeSession() — Create FDL functions that span primary + associate sessions
  • AppendSessions() — Append multiple sessions into a composite session

New file:

  • FunctionHelper.cs — Utility for creating FDL function definitions (single and multi-parameter)

API migration:

  • SetSQLRaceConnection — last param changed from int (0/1/2) to bool for delete-on-close
  • RecordersConfiguration.AddConfiguration — same int → bool change
  • Removed LoadSSNWithAssociatedMerge() (old merging flow)
  • Removed CreateSessionWithTimeZoneValue() (moved to separate PR TimeZone Property SQL Race Example #57)
  • Renamed LoadAssociated() → GetAssociatedSessionSummaries()

Supersedes

@matias-mcl matias-mcl changed the title 89128 - Replace Associate Session merging flows with Composite Sessions Replace Associate Session merging flows with Composite Sessions Jun 2, 2026
Comment thread MAT.SQLRace.HelloData/MAT.SQLRace.HelloData.csproj Outdated
Co-authored-by: Matias Radmand <matias.radmand@motionapplied.com>
/// It then retrieves and prints a small number of sample values for a
/// specified parameter from both the Primary and the Associate sessions.
/// </summary>
private static void LoadSSNWtihAssociates()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should bin off LoadSSNWtihAssociates to be LoadAndAppendSSNSessions as it isn't limited to an Associate session.

Similarly

        /// <summary>
        ///     This example loads a Primary session and appends another session (but multiple can base passed in) in order to
        ///     create a Composite Session (a session made up of one or more sessions).
        ///     It then retrieves and prints a small number of sample values for a
        ///     specified parameter from both the Primary and the Appended session(s).
        /// </summary>

And then all variables referring to an associate do not make sense.

/// a small number of sample values for a specified parameter from both the
/// Primary session and its Associate.
/// </summary>
private static void LoadSqlRaceDatabaseSessionWithAssociates()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the above, this is not locked down to an Associate so should refer to the action of Appending.

Rather than LoadSqlRaceDatabaseSessionWithAssociates something like LoadAndAppendSqlRaceDatabaseSessions

        /// <summary>
        ///     This example demonstrates how to load a Primary session and Append a session
        ///     from a SQL backed session database in order to create a Composite Session
        ///     (a session made up of one or more sessions). It then retrieves and prints
        ///     a small number of sample values for a specified parameter from both the
        ///     Primary session and its Appended session.
        /// </summary>

And then all variables referring to an associate do not make sense.

var qm = QueryManager.CreateQueryManager(ConnectionString);
// Get the most recent live session from the database

// Get the most recent live sessions from the database

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this statement is correct?

/// used to retrieve samples. The example prints both the raw parameter values and the
/// resulting Function values to the console.
/// </summary>
private static void CreateFunctionAcrossMultipleSessionsWithCompositeSession()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary mentions Associate sessions but it is Appending any session.

Need to update variables with and comments to be Appended related rather than associates.

using (var pda = compositeSession.CreateParameterDataAccess(primaryParamId))
{
pda.GoTo(compositeSession.StartTime + (compositeSession.EndTime - compositeSession.StartTime) / 2);
var samples = pda.GetNextSamples(10);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My original PR had a comment for me to

               var samples = pda.GetNextSamples(10);
               if (samples == null)
               {
                   Console.WriteLine($"Failed to get samples for {primaryParameterIdentifier}");
                   return;
               }

Forgot to add a check to make sure we have samples.

using (var pda = compositeSession.CreateParameterDataAccess(associateParamId))
{
pda.GoTo(compositeSession.StartTime + (compositeSession.EndTime - compositeSession.StartTime) / 2);
var samples = pda.GetNextSamples(10);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original PR has a comment to

               var samples = pda.GetNextSamples(10);
               if (samples == null)
               {
                   Console.WriteLine($"Failed to get samples for {associateParameterIdentifier}");
                   return;
               }

Forgot to add a check to make sure we have samples.

/// </summary>
private static void CreateFunctionAcrossMultipleSessionsWithCompositeSession()
{
// ========= EDITABLE SECTION (tweak these values for your run) =========

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From Previous PR.


// ===================== REMINDER =====================
// To use Functions, LicenceProgramName must be "ATLAS Data Platform"
// =====================================================

Might be worth adding a reminder above the editable section.

[
primarySessionParameterIdentifier,
associateParameterIdentifier
]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From Previous PR.

      var buildResults = functionManager.Build(functionDefinition);
      if (buildResults .Errors.Any())
      {
          Console.WriteLine("Function build failed.");
          foreach (var error in buildResults .Errors)
          {
              Console.WriteLine($"{error}");
          }
          return;
      }

Forgot to actually build the function. Needs to happen before we build the PDA.

/// and prints their identifiers.
///
/// This is particularly useful in situations where you know you want to load associate
/// sessions but do not yet know which associates are available. The returned summaries

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return session summaries...


var compositeSession = new CompositeSession(
CompositeSessionKey.NewKey(),
"CompositeSessionWithvTagSessionsTest");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of the composite should probably be "AppendSessions", or something other than CompositeSessionWithvTagSessionsTest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants