@@ -37,6 +37,14 @@ public sealed class HashJoinTransform : OneToOneTransformBase
37
37
public const int NumBitsMin = 1 ;
38
38
public const int NumBitsLim = 32 ;
39
39
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
+
40
48
public sealed class Arguments : TransformInputBase
41
49
{
42
50
[ Argument ( ArgumentType . Multiple | ArgumentType . Required , HelpText = "New column definition(s) (optional form: name:src)" ,
@@ -45,17 +53,17 @@ public sealed class Arguments : TransformInputBase
45
53
public Column [ ] Column ;
46
54
47
55
[ 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 ;
49
57
50
58
[ Argument ( ArgumentType . AtMostOnce , HelpText = "Number of bits to hash into. Must be between 1 and 31, inclusive." ,
51
59
ShortName = "bits" , SortOrder = 2 ) ]
52
- public int HashBits = NumBitsLim - 1 ;
60
+ public int HashBits = Defaults . HashBits ;
53
61
54
62
[ Argument ( ArgumentType . AtMostOnce , HelpText = "Hashing seed" ) ]
55
- public uint Seed = 314489979 ;
63
+ public uint Seed = Defaults . Seed ;
56
64
57
65
[ 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 ;
59
67
}
60
68
61
69
public sealed class Column : OneToOneColumn
@@ -166,6 +174,25 @@ private static VersionInfo GetVersionInfo()
166
174
167
175
private readonly ColumnInfoEx [ ] _exes ;
168
176
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
+
169
196
public HashJoinTransform ( IHostEnvironment env , Arguments args , IDataView input )
170
197
: base ( env , RegistrationName , Contracts . CheckRef ( args , nameof ( args ) ) . Column , input , TestColumnType )
171
198
{
0 commit comments