public static CommonOutputs.TransformOutput Apply(IHostEnvironment env, HashJoinTransform.Arguments input) { Contracts.CheckValue(env, nameof(env)); env.CheckValue(input, nameof(input)); var h = EntryPointUtils.CheckArgsAndCreateHost(env, "HashJoin", input); var view = new HashJoinTransform(h, input, input.Data); return(new CommonOutputs.TransformOutput() { Model = new TransformModel(h, view, input.Data), OutputData = view }); }
public static string CreateStratificationColumn(IHost host, ref IDataView data, string stratificationColumn = null) { host.CheckValue(data, nameof(data)); host.CheckValueOrNull(stratificationColumn); // Pick a unique name for the stratificationColumn. const string stratColName = "StratificationKey"; string stratCol = stratColName; int col; int j = 0; while (data.Schema.TryGetColumnIndex(stratCol, out col)) { stratCol = string.Format("{0}_{1:000}", stratColName, j++); } // Construct the stratification column. If user-provided stratification column exists, use HashJoin // of it to construct the strat column, otherwise generate a random number and use it. if (stratificationColumn == null) { data = new GenerateNumberTransform(host, new GenerateNumberTransform.Arguments { Column = new[] { new GenerateNumberTransform.Column { Name = stratCol } } }, data); } else { data = new HashJoinTransform(host, new HashJoinTransform.Arguments { Column = new[] { new HashJoinTransform.Column { Name = stratCol, Source = stratificationColumn } }, Join = true, HashBits = 30 }, data); } return(stratCol); }