From 70add1d1771d447b703a615cad4c2e0ac4677579 Mon Sep 17 00:00:00 2001 From: laneser Date: Mon, 22 Jun 2020 14:56:15 +0000 Subject: [PATCH] Add logger to show jvm bridge launch info. --- .vscode/launch.json | 27 ++++++++++++ .vscode/settings.json | 3 ++ .vscode/tasks.json | 42 +++++++++++++++++++ .../Microsoft.Spark/Sql/Types/ComplexTypes.cs | 33 +++++++++++++-- 4 files changed, 101 insertions(+), 4 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json create mode 100644 .vscode/tasks.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..4e219e522 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,27 @@ +{ + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/src/csharp/Microsoft.Spark.Worker/bin/Debug/netcoreapp3.1/Microsoft.Spark.Worker.dll", + "args": [], + "cwd": "${workspaceFolder}/src/csharp/Microsoft.Spark.Worker", + // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console + "console": "internalConsole", + "stopAtEntry": false + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..d6ec7df72 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "dotnet-test-explorer.testProjectPath": "src/csharp/Microsoft.Spark.UnitTest" +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 000000000..0f8011d05 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,42 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/src/csharp/Microsoft.Spark.Worker/Microsoft.Spark.Worker.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/src/csharp/Microsoft.Spark.Worker/Microsoft.Spark.Worker.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "${workspaceFolder}/src/csharp/Microsoft.Spark.Worker/Microsoft.Spark.Worker.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/src/csharp/Microsoft.Spark/Sql/Types/ComplexTypes.cs b/src/csharp/Microsoft.Spark/Sql/Types/ComplexTypes.cs index 2b65ea6d1..2fa5f4f2f 100644 --- a/src/csharp/Microsoft.Spark/Sql/Types/ComplexTypes.cs +++ b/src/csharp/Microsoft.Spark/Sql/Types/ComplexTypes.cs @@ -69,9 +69,22 @@ private DataType FromJson(JObject json) return this; } - internal override bool NeedConversion() => true; + internal override bool NeedConversion() => ElementType.NeedConversion(); - internal override object FromInternal(object obj) => throw new NotImplementedException(); + internal override object FromInternal(object obj) + { + if (!NeedConversion()) + { + return obj; + } + + var convertedObj = new List(); + foreach(object o in (dynamic)obj) + { + convertedObj.Add(ElementType.FromInternal(o)); + } + return convertedObj; + } } /// @@ -142,9 +155,21 @@ private DataType FromJson(JObject json) return this; } - internal override bool NeedConversion() => true; + internal override bool NeedConversion() => KeyType.NeedConversion() && ValueType.NeedConversion(); - internal override object FromInternal(object obj) => throw new NotImplementedException(); + internal override object FromInternal(object obj) + { + if (!NeedConversion()) + { + return obj; + } + var convertedObj = new Dictionary(); + foreach(dynamic kv in (dynamic)obj) + { + convertedObj[kv.Key] = kv.Value; + } + return convertedObj; + } } ///