build: Downgrade new DataStream code from net8 -> net7

The AddColumnsStream, SortStream, and requisite yacc/lex grammar were
originally added to a new branch, off of development, which is on net8.
I forgot to change it to net7 when I cherry-picked the commits for the
regular development branch.

It's wasn't quite as simple as flipping net8 -> net7 in csproj files,
because I was eager to use new language features only available in net8!
Namely, primary constructors and collection expressions.
This commit is contained in:
John Colvin committed 2024-02-08 14:24:31 -06:00
1 parent d0ddc1d57b
commit 8660dea85a
10 files changed
+41 -25

No files matched your search

@@ -1,4 +1,6 @@
namespace BCG;
public class AddColumnsStream(ViewStream vs, string columnDef)
: MapStream(vs, new ColumnAdder(columnDef)) { }
public class AddColumnsStream : MapStream {
public AddColumnsStream(ViewStream vs, string columnDef)
: base(vs, new ColumnAdder(columnDef)) { }
}
@@ -13,14 +13,16 @@ namespace BCG;
/// <param name="columnsExpression">
/// String represting the columns to add to the output table
/// </param>
public class ColumnAdder(string columnsExpression) : IStreamMapper {
public class ColumnAdder : IStreamMapper {
// Store tuples of (column, index) to preserve order
protected readonly IDictionary<string, (ColumnExpression column, int index)> myNewColumns =
(ColumnExpressionInterpreter.Evaluate(columnsExpression) ??
protected readonly IDictionary<string, (ColumnExpression column, int index)> myNewColumns;
protected IBlueTableSchema? mySchema;
public ColumnAdder(string columnsExpression) =>
myNewColumns = (ColumnExpressionInterpreter.Evaluate(columnsExpression) ??
throw new Exception("Invalid columnn expression: " + columnsExpression))
.Select((c, i) => (c, i))
.ToDictionary(c => c.c.Name, c => (c.c, c.i));
protected IBlueTableSchema? mySchema;
[MemberNotNull(nameof(mySchema))]
public virtual IBlueRow map(IBlueRow row) {
@@ -1,5 +1,6 @@
using Bts.ColumnSortExpressions;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
@@ -30,7 +31,7 @@ public class SortStream : ViewStream {
public SortStream(ViewStream stream, IComparer comparer) {
this.stream = stream;
this.comparer = comparer;
sortCols = [];
sortCols = Array.Empty<ColumnSortExpression>();
}
[MemberNotNull(nameof(sortCols))]
@@ -11,9 +11,9 @@ namespace BCG;
/// Represents an IBlueRowCollection with the rows sorted according to the
/// </summary>
public class SortedTable : IBlueRowCollection {
readonly List<SortRow> rows = [];
readonly Dictionary<int, IBlueRow> rowIndex = [];
readonly IList<ColumnSortExpression> sortCols = [];
readonly List<SortRow> rows = new(0);
readonly Dictionary<int, IBlueRow> rowIndex = new(0);
readonly IList<ColumnSortExpression> sortCols = Array.Empty<ColumnSortExpression>();
readonly IComparer? comparer;
/// <summary>