Skip to content

Commit

Permalink
Refactor to fix Dax.Model.Extractor namespace (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
albertospelta authored Mar 22, 2024
1 parent dc1faf8 commit 3049bd8
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 27 deletions.
1 change: 0 additions & 1 deletion src/Dax.Model.Extractor.Tests/DaxModelFixture.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace Dax.Model.Extractor.Tests
{
using Dax.Metadata.Extractor;
using Microsoft.AnalysisServices;
using System.IO;
using TOM = Microsoft.AnalysisServices.Tabular;
Expand Down
1 change: 0 additions & 1 deletion src/Dax.Model.Extractor.Tests/DaxModelTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace Dax.Model.Extractor.Tests
{
using Dax.Metadata.Extractor;
using Microsoft.AnalysisServices;
using System.Linq;
using Xunit;
Expand Down
1 change: 0 additions & 1 deletion src/Dax.Model.Extractor.Tests/TomExtractorTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace Dax.Model.Extractor.Tests
{
using Dax.Metadata.Extractor;
using Microsoft.AnalysisServices;
using System;
using Xunit;
Expand Down
3 changes: 1 addition & 2 deletions src/Dax.Model.Extractor/Data/IDbConnectionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Dax.Metadata.Extractor;
using Microsoft.AnalysisServices.AdomdClient;
using Microsoft.AnalysisServices.AdomdClient;
using System.Data;
using System.Data.OleDb;

Expand Down
13 changes: 6 additions & 7 deletions src/Dax.Model.Extractor/DmvExtractor.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
using Dax.Model.Extractor.Data;
using Microsoft.AnalysisServices;
using Microsoft.AnalysisServices.AdomdClient;
using Dax.Metadata;
using Dax.Model.Extractor.Data;
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Linq;
using Tom = Microsoft.AnalysisServices.Tabular;

namespace Dax.Metadata.Extractor
namespace Dax.Model.Extractor
{

public class ExtractorException : Exception
Expand Down Expand Up @@ -67,7 +66,7 @@ public DmvExtractor(Dax.Metadata.Model daxModel, IDbConnection connection, strin

public static void PopulateFromDmv(Dax.Metadata.Model daxModel, IDbConnection connection, string serverName, string databaseName, string extractorApp, string extractorVersion)
{
Dax.Metadata.Extractor.DmvExtractor de = new Dax.Metadata.Extractor.DmvExtractor(daxModel, connection, serverName, databaseName, extractorApp, extractorVersion);
var de = new DmvExtractor(daxModel, connection, serverName, databaseName, extractorApp, extractorVersion);
de.PopulateModel();
de.PopulateTables();
de.PopulatePartitions();
Expand Down Expand Up @@ -1099,12 +1098,12 @@ SELECT DISTINCT
}
}
}
catch (AdomdErrorResponseException ex)
catch (Microsoft.AnalysisServices.AdomdClient.AdomdErrorResponseException ex)
{
// We ignore errors accessing this DMV
Debug.WriteLine($"Ignored error in DISCOVER_CALC_DEPENDENCY: {ex.Message}");
}
catch (AmoException ex)
catch (Microsoft.AnalysisServices.AmoException ex)
{
Debug.WriteLine($"Ignored error in DISCOVER_CALC_DEPENDENCY: {ex.Message}");
}
Expand Down
5 changes: 3 additions & 2 deletions src/Dax.Model.Extractor/StatExtractor.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using Dax.Model.Extractor.Data;
using Dax.Metadata;
using Dax.Model.Extractor.Data;
using System;
using System.Data;
using System.Linq;

namespace Dax.Metadata.Extractor
namespace Dax.Model.Extractor
{
public class StatExtractor
{
Expand Down
24 changes: 13 additions & 11 deletions src/Dax.Model.Extractor/TomExtractor.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using Microsoft.AnalysisServices.AdomdClient;
using Dax.Metadata;
using Microsoft.AnalysisServices.AdomdClient;
using System;
using System.Data.OleDb;
using System.Linq;
using Tom = Microsoft.AnalysisServices.Tabular;

namespace Dax.Metadata.Extractor
namespace Dax.Model.Extractor
{
public class TomExtractor
{
Expand Down Expand Up @@ -289,20 +290,21 @@ public static Dax.Metadata.Model GetDaxModel(string connectionString, string app
string databaseName = database.Name;
string serverName = GetDataSource(connectionString);

Model daxModel = Dax.Metadata.Extractor.TomExtractor.GetDaxModel(tomModel, applicationName, applicationVersion);
var daxModel = TomExtractor.GetDaxModel(tomModel, applicationName, applicationVersion);

using (AdomdConnection connection = new(connectionString)) {
using (AdomdConnection connection = new(connectionString))
{
// Populate statistics from DMV
Dax.Metadata.Extractor.DmvExtractor.PopulateFromDmv(daxModel, connection, serverName, databaseName, applicationName, applicationVersion);
DmvExtractor.PopulateFromDmv(daxModel, connection, serverName, databaseName, applicationName, applicationVersion);

// Populate statistics by querying the data model
if (readStatisticsFromData)
{
Dax.Metadata.Extractor.StatExtractor.UpdateStatisticsModel(daxModel, connection, sampleRows, analyzeDirectQuery, analyzeDirectLake);
StatExtractor.UpdateStatisticsModel(daxModel, connection, sampleRows, analyzeDirectQuery, analyzeDirectLake);

// if we have forced all columns into memory then re-run the DMVs to update the data with the new values after everything has been transcoded.
if (analyzeDirectLake > DirectLakeExtractionMode.ResidentOnly)
Dax.Metadata.Extractor.DmvExtractor.PopulateFromDmv(daxModel, connection, serverName, databaseName, applicationName, applicationVersion);
DmvExtractor.PopulateFromDmv(daxModel, connection, serverName, databaseName, applicationName, applicationVersion);
}
}
return daxModel;
Expand Down Expand Up @@ -344,23 +346,23 @@ public static Dax.Metadata.Model GetDaxModel(string serverName, string databaseN
Tom.Database db = GetDatabase(serverName, databaseName);
Tom.Model tomModel = db.Model;

Model daxModel = Dax.Metadata.Extractor.TomExtractor.GetDaxModel(tomModel, applicationName, applicationVersion);
var daxModel = TomExtractor.GetDaxModel(tomModel, applicationName, applicationVersion);

string connectionString = GetConnectionString(serverName, databaseName);

using (AdomdConnection connection = new(connectionString))
{
// Populate statistics from DMV
Dax.Metadata.Extractor.DmvExtractor.PopulateFromDmv(daxModel, connection, serverName, databaseName, applicationName, applicationVersion);
DmvExtractor.PopulateFromDmv(daxModel, connection, serverName, databaseName, applicationName, applicationVersion);

// Populate statistics by querying the data model
if (readStatisticsFromData)
{
Dax.Metadata.Extractor.StatExtractor.UpdateStatisticsModel(daxModel, connection, sampleRows, analyzeDirectQuery, analyzeDirectLake);
StatExtractor.UpdateStatisticsModel(daxModel, connection, sampleRows, analyzeDirectQuery, analyzeDirectLake);

// if we have forced all columns into memory then re-run the DMVs to update the data with the new values after everything has been transcoded.
if (analyzeDirectLake > DirectLakeExtractionMode.ResidentOnly)
Dax.Metadata.Extractor.DmvExtractor.PopulateFromDmv(daxModel, connection, serverName, databaseName, applicationName, applicationVersion);
DmvExtractor.PopulateFromDmv(daxModel, connection, serverName, databaseName, applicationName, applicationVersion);
}
}
return daxModel;
Expand Down
2 changes: 1 addition & 1 deletion src/Dax.Model.Extractor/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Diagnostics;
using Tom = Microsoft.AnalysisServices;

namespace Dax.Metadata.Extractor
namespace Dax.Model.Extractor
{
internal class ExtractorInfo
{
Expand Down
2 changes: 1 addition & 1 deletion src/Dax.Vpax.Tests/VpaxToolTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Dax.Vpax.Tests
{
using Dax.Metadata.Extractor;
using Dax.Model.Extractor;
using Dax.Vpax.Tools;
using Microsoft.AnalysisServices;
using System;
Expand Down

0 comments on commit 3049bd8

Please sign in to comment.