From 6e742a27b1113c423433ce06452861cec767c8f5 Mon Sep 17 00:00:00 2001 From: Scott Louvau Date: Sun, 28 Jan 2018 13:56:57 -0800 Subject: [PATCH] XForm: Join: Don't validate RHS table until BuildJoinDictionary, so Suggest succeeds for unbuilt tables. --- XForm/XForm/Verbs/Join.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/XForm/XForm/Verbs/Join.cs b/XForm/XForm/Verbs/Join.cs index 88829af1c..8d880dcff 100644 --- a/XForm/XForm/Verbs/Join.cs +++ b/XForm/XForm/Verbs/Join.cs @@ -42,7 +42,7 @@ public class Join : IXTable private Type _joinColumnType; private Func _joinFromColumnGetter; - private ISeekableXTable _joinToSource; + private IXTable _joinToSource; private IXColumn _joinToColumn; private Func _joinToSeekGetter; @@ -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); @@ -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); }