They were originally commented out because the expression parsing utils weren't ready (now they are).
55 lines
2.7 KiB
C#
55 lines
2.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace BCG
|
|
{
|
|
/// <summary>
|
|
/// Same as a join except can join based on
|
|
/// multiple columns (this abstracts what we
|
|
/// have been doing for ages - concatenating,
|
|
/// joining and then projecting the concatanted
|
|
/// columns out)
|
|
/// </summary>
|
|
public class MultiColumnJoinStream : ViewStream
|
|
{
|
|
public MultiColumnJoinStream(ViewStream leftStream, string leftJoinColumns, string leftProject,
|
|
ViewStream rightStream, string rightJoinColumns, string rightProject)
|
|
: this(leftStream, leftJoinColumns, leftProject,
|
|
rightStream, rightJoinColumns, rightProject, false)
|
|
{ }
|
|
|
|
public MultiColumnJoinStream(ViewStream leftStream, string leftJoinColumns, string leftProject,
|
|
ViewStream rightStream, string rightJoinColumns, string rightProject, bool leftJoin)
|
|
{
|
|
string[] leftJoinColArray = leftJoinColumns.Split(' ', ',', ';'),
|
|
rightJoinColArray = rightJoinColumns.Split(' ', ',', ';');
|
|
if (leftJoinColArray.Length == 1 && rightJoinColArray.Length == 1)
|
|
/// so that this handles regular joins too
|
|
mySetRealSource(leftJoin ? new SuperLeftJoinStream(leftStream, leftJoinColArray[0], leftProject,
|
|
rightStream, rightJoinColArray[0], rightProject) :
|
|
new SuperJoinStream(leftStream, leftJoinColArray[0], leftProject,
|
|
rightStream, rightJoinColArray[0], rightProject));
|
|
else
|
|
{
|
|
string leftCols = "ljc:";
|
|
foreach (string c in leftJoinColArray)
|
|
leftCols += c + " ";
|
|
leftCols = leftCols.Trim();
|
|
string rightCols = "rjc:";
|
|
foreach (string c in rightJoinColArray)
|
|
rightCols += c + " ";
|
|
rightCols = rightCols.Trim();
|
|
ViewStream res =
|
|
leftJoin ? new SuperLeftJoinStream(new ConcatenateColumnsStream(leftStream, leftCols), "ljc", leftProject,
|
|
new ConcatenateColumnsStream(rightStream, rightCols), "rjc", rightProject) :
|
|
new SuperJoinStream(new ConcatenateColumnsStream(leftStream, leftCols), "ljc", leftProject,
|
|
new ConcatenateColumnsStream(rightStream, rightCols), "rjc", rightProject);
|
|
res = new ProjectStream(res, "!ljc rjc");
|
|
mySetRealSource(res);
|
|
}
|
|
}
|
|
}
|
|
}
|