-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/group-by_with_predicates_bis_(#380)' into develop
# Conflicts: # NBi.NUnit/Builder/ResultSetRowCountBuilder.cs # NBi.Testing/Acceptance/Resources/Positive/ResultSetConstraint.nbits
- Loading branch information
Showing
99 changed files
with
1,688 additions
and
1,028 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 0 additions & 35 deletions
35
NBi.Core/Calculation/Combination/AndCombinationPredicateFilter.cs
This file was deleted.
Oops, something went wrong.
43 changes: 0 additions & 43 deletions
43
NBi.Core/Calculation/Combination/BaseCombinationPredicateFilter.cs
This file was deleted.
Oops, something went wrong.
35 changes: 0 additions & 35 deletions
35
NBi.Core/Calculation/Combination/OrCombinationPredicateFilter.cs
This file was deleted.
Oops, something went wrong.
34 changes: 0 additions & 34 deletions
34
NBi.Core/Calculation/Combination/XOrCombinationPredicateFilter.cs
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
NBi.Core/Calculation/Grouping/CaseBased/CaseGroupByArgs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using NBi.Core.Calculation.Predication; | ||
using NBi.Core.Variable; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace NBi.Core.Calculation.Grouping.CaseBased | ||
{ | ||
public class CaseGroupByArgs : IGroupByArgs | ||
{ | ||
public IEnumerable<IPredication> Cases { get; set; } | ||
public Context Context { get; set; } | ||
|
||
public CaseGroupByArgs(IEnumerable<IPredication> cases, Context context) | ||
=> (Cases, Context) = (cases, context); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using NBi.Core.Calculation.Predication; | ||
using NBi.Core.Variable; | ||
using NBi.Extensibility; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Data; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace NBi.Core.Calculation.Grouping.CaseBased | ||
{ | ||
class CaseGrouping : IGroupBy | ||
{ | ||
protected IEnumerable<IPredication> Cases { get; } | ||
protected Context Context { get; } | ||
|
||
public CaseGrouping(IEnumerable<IPredication> cases, Context context) | ||
=> (Cases, Context) = (cases, context); | ||
|
||
public IDictionary<ResultSet.KeyCollection, DataTable> Execute(ResultSet.ResultSet resultSet) | ||
{ | ||
var stopWatch = new Stopwatch(); | ||
var dico = new Dictionary<ResultSet.KeyCollection, DataTable>(); | ||
stopWatch.Start(); | ||
|
||
foreach (DataRow row in resultSet.Rows) | ||
{ | ||
Context.Switch(row); | ||
var index = Cases.Select((p, i) => new { Predication = p, Index = i }) | ||
.FirstOrDefault(x => x.Predication.Execute(Context)) | ||
?.Index ?? -1; | ||
var key = new ResultSet.KeyCollection(new object[] { index }); | ||
if (!dico.ContainsKey(key)) | ||
dico.Add(key, row.Table.Clone()); | ||
dico[key].ImportRow(row); | ||
} | ||
|
||
Trace.WriteLineIf(NBiTraceSwitch.TraceInfo, $"Building rows' groups by cases: {dico.Count} [{stopWatch.Elapsed.ToString(@"d\d\.hh\h\:mm\m\:ss\s\ \+fff\m\s")}"); | ||
return dico; | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
NBi.Core/Calculation/Grouping/ColumnBased/ColumnGroupByArgs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using NBi.Core.ResultSet; | ||
using NBi.Core.Variable; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace NBi.Core.Calculation.Grouping.ColumnBased | ||
{ | ||
public class ColumnGroupByArgs : IGroupByArgs | ||
{ | ||
|
||
public IEnumerable<IColumnDefinitionLight> Columns { get; set; } | ||
public Context Context { get; set; } | ||
|
||
public ColumnGroupByArgs(IEnumerable<IColumnDefinitionLight> columns, Context context) | ||
=> (Columns, Context) = (columns, context); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.