Skip to content

Commit

Permalink
XForm: Join: Don't validate RHS table until BuildJoinDictionary, so S…
Browse files Browse the repository at this point in the history
…uggest succeeds for unbuilt tables.
  • Loading branch information
Scott Louvau committed Jan 28, 2018
1 parent bcb336b commit 6e742a2
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions XForm/XForm/Verbs/Join.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class Join : IXTable
private Type _joinColumnType;
private Func<XArray> _joinFromColumnGetter;

private ISeekableXTable _joinToSource;
private IXTable _joinToSource;
private IXColumn _joinToColumn;
private Func<ArraySelector, XArray> _joinToSeekGetter;

Expand All @@ -56,8 +56,7 @@ public Join(IXTable source, string joinFromColumn, IXTable joinToSource, string
if (source == null) throw new ArgumentNullException("source");

_source = source;
_joinToSource = joinToSource as ISeekableXTable;
if (_joinToSource == null) throw new ArgumentException($"Join requires a single built Binary Table as the right side table.");
_joinToSource = joinToSource;

// Request the JoinFromColumn Getter
IXColumn joinFrom = source.Columns.Find(joinFromColumn);
Expand Down Expand Up @@ -137,7 +136,11 @@ public int Next(int desiredCount)

private void BuildJoinDictionary()
{
XArray allJoinToValues = _joinToSeekGetter(ArraySelector.All(_joinToSource.Count));
// Validate the RHS is a seekable table (only on build, so that Suggest doesn't fail)
ISeekableXTable joinToSource = _joinToSource as ISeekableXTable;
if (joinToSource == null) throw new ArgumentException($"Join requires a single built Binary Table as the right side table.");

XArray allJoinToValues = _joinToSeekGetter(ArraySelector.All(joinToSource.Count));
_joinDictionary = (IJoinDictionary)Allocator.ConstructGenericOf(typeof(JoinDictionary<>), _joinColumnType, allJoinToValues.Count);
_joinDictionary.Add(allJoinToValues, 0);
}
Expand Down

0 comments on commit 6e742a2

Please sign in to comment.