@@ -37,6 +37,14 @@ public sealed class HashJoinTransform : OneToOneTransformBase
3737 public const int NumBitsMin = 1 ;
3838 public const int NumBitsLim = 32 ;
3939
40+ private static class Defaults
41+ {
42+ public const bool Join = true ;
43+ public const int HashBits = NumBitsLim - 1 ;
44+ public const uint Seed = 314489979 ;
45+ public const bool Ordered = true ;
46+ }
47+
4048 public sealed class Arguments : TransformInputBase
4149 {
4250 [ Argument ( ArgumentType . Multiple | ArgumentType . Required , HelpText = "New column definition(s) (optional form: name:src)" ,
@@ -45,17 +53,17 @@ public sealed class Arguments : TransformInputBase
4553 public Column [ ] Column ;
4654
4755 [ Argument ( ArgumentType . AtMostOnce , HelpText = "Whether the values need to be combined for a single hash" ) ]
48- public bool Join = true ;
56+ public bool Join = Defaults . Join ;
4957
5058 [ Argument ( ArgumentType . AtMostOnce , HelpText = "Number of bits to hash into. Must be between 1 and 31, inclusive." ,
5159 ShortName = "bits" , SortOrder = 2 ) ]
52- public int HashBits = NumBitsLim - 1 ;
60+ public int HashBits = Defaults . HashBits ;
5361
5462 [ Argument ( ArgumentType . AtMostOnce , HelpText = "Hashing seed" ) ]
55- public uint Seed = 314489979 ;
63+ public uint Seed = Defaults . Seed ;
5664
5765 [ Argument ( ArgumentType . AtMostOnce , HelpText = "Whether the position of each term should be included in the hash" , ShortName = "ord" ) ]
58- public bool Ordered = true ;
66+ public bool Ordered = Defaults . Ordered ;
5967 }
6068
6169 public sealed class Column : OneToOneColumn
@@ -166,6 +174,25 @@ private static VersionInfo GetVersionInfo()
166174
167175 private readonly ColumnInfoEx [ ] _exes ;
168176
177+ /// <summary>
178+ /// Convenience constructor for public facing API.
179+ /// </summary>
180+ /// <param name="env">Host Environment.</param>
181+ /// <param name="input">Input <see cref="IDataView"/>. This is the output from previous transform or loader.</param>
182+ /// <param name="name">Name of the output column.</param>
183+ /// <param name="source">Name of the column to be transformed. If this is null '<paramref name="name"/>' will be used.</param>
184+ /// <param name="join">Whether the values need to be combined for a single hash.</param>
185+ /// <param name="hashBits">Number of bits to hash into. Must be between 1 and 31, inclusive.</param>
186+ public HashJoinTransform ( IHostEnvironment env ,
187+ IDataView input ,
188+ string name ,
189+ string source = null ,
190+ bool join = Defaults . Join ,
191+ int hashBits = Defaults . HashBits )
192+ : this ( env , new Arguments ( ) { Column = new [ ] { new Column ( ) { Source = source ?? name , Name = name } } , Join = join , HashBits = hashBits } , input )
193+ {
194+ }
195+
169196 public HashJoinTransform ( IHostEnvironment env , Arguments args , IDataView input )
170197 : base ( env , RegistrationName , Contracts . CheckRef ( args , nameof ( args ) ) . Column , input , TestColumnType )
171198 {
0 commit comments