This commit is contained in:
Diego Garbervetsky 2016-08-31 14:10:27 -07:00
Родитель f960eb96d6 5d6cee3c8e
Коммит 49db57d706
4 изменённых файлов: 64 добавлений и 23 удалений

Просмотреть файл

@ -273,7 +273,14 @@ namespace ScopeProgramAnalysis
{
var log = CreateSarifOutput();
var allSchemas = program.ReadSchemasFromXML(inputPath);
IReadOnlyDictionary<string, Tuple<Schema, Schema>> allSchemas;
if (useScopeFactory)
{
allSchemas = program.ReadSchemasFromXML(inputPath);
} else
{
allSchemas = program.ReadSchemasFromXML2(inputPath);
}
foreach (var methodPair in scopeMethodPairs)
{
@ -714,6 +721,28 @@ namespace ScopeProgramAnalysis
return d;
}
private IReadOnlyDictionary<string, Tuple<Schema, Schema>>
ReadSchemasFromXML2(string inputPath)
{
var d = new Dictionary<string, Tuple<Schema, Schema>>();
var inputDirectory = Path.GetDirectoryName(inputPath);
var xmlFile = Path.Combine(inputDirectory, "Schema.xml");
if (File.Exists(xmlFile))
{
XElement x = XElement.Load(xmlFile);
var operators = x.Descendants("operator");
foreach (var op in operators)
{
var inputSchema = op.Descendants("input").First();
var outputSchema = op.Descendants("output").First();
var inputColumns = ParseColumns(inputSchema.Value);
var outputColumns = ParseColumns(outputSchema.Value);
d.Add(op.Attribute("className").Value, Tuple.Create(new Schema(inputColumns), new Schema(outputColumns)));
}
}
return d;
}
private static SarifLog CreateSarifOutput()
{
JsonSerializerSettings settings = new JsonSerializerSettings()

Просмотреть файл

@ -67,26 +67,4 @@ namespace CodeUnderTest
}
}
public class ProjectOnlyOneColumnProcessor : Processor
{
public override Schema Produces(string[] requested_columns, string[] args, Schema input_schema)
{
var output_schema = input_schema.Clone();
var newcol = new ColumnInfo("NewColumn", typeof(string));
output_schema.Add(newcol);
return output_schema;
}
public override IEnumerable<Row> Process(RowSet input_rowset, Row output_row, string[] args)
{
foreach (Row input_row in input_rowset.Rows)
{
input_row.CopyTo(output_row);
string market = input_row[0].String;
output_row[2].Set("FOO" + market);
yield return output_row;
}
}
}
}

Просмотреть файл

@ -44,6 +44,11 @@
<Compile Include="DataStructures.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Schema.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

Просмотреть файл

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8" ?>
<ScopeVertices helperAssembly="__ScopeCodeGen__.dll" signatureVersion="1">
<ScopeVertex id="CodeUnderTest" cppReady="true">
<operator id="Process_2" uid="5" assemblyName="__ScopeCodeGen__.dll" className="CopyProcessor">
<input id="Process_1_Data0" uid="4" schema="JobGUID:string,SubmitTime:DateTime?" />
<output id="Process_2_Data0" uid="6" schema="JobGUID:string,SubmitTime:DateTime?" />
<ReflectedScopeScript>
<![CDATA[_var_100004_PROCESS = PROCESS _var_100003_TRANSFORM PRODUCE JobGUID, SubmitTime USING CopyProcessor();
]]>
</ReflectedScopeScript>
</operator>
<operator id="Process_3" uid="7" assemblyName="__ScopeCodeGen__.dll" className="ModifyExistingColumnProcessor">
<input id="Process_2_Data0" uid="6" schema="JobGUID:string,SubmitTime:DateTime?" />
<output id="Process_3_Data0" uid="8" schema="JobGUID:string,SubmitTime:DateTime?" />
<ReflectedScopeScript>
<![CDATA[_var_100005_PROCESS = PROCESS _var_100004_PROCESS PRODUCE JobGUID, SubmitTime USING ModifyExistingColumnProcessor();
]]>
</ReflectedScopeScript>
</operator>
<operator id="Process_4" uid="9" assemblyName="__ScopeCodeGen__.dll" className="AddOneColumnProcessor">
<input id="Process_3_Data0" uid="8" schema="JobGUID:string,SubmitTime:DateTime?" />
<output id="SV1_Extract_out0" uid="10" schema="JobGUID:string,SubmitTime:DateTime?,NewColumn:string" outputIndex="0" numberOfOutputs="1" />
<ReflectedScopeScript>
<![CDATA[_var_100006_PROCESS = PROCESS _var_100005_PROCESS PRODUCE JobGUID, SubmitTime, NewColumn USING AddOneColumnProcessor();
]]>
</ReflectedScopeScript>
</operator>
</ScopeVertex>
</ScopeVertices>