You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2020/11/17 22:30:42 UTC

[GitHub] [arrow] eerhardt commented on a change in pull request #8694: ARROW-10542: [C#][Flight] Add beginning on flight code for net core

eerhardt commented on a change in pull request #8694:
URL: https://github.com/apache/arrow/pull/8694#discussion_r525550665



##########
File path: .github/workflows/csharp.yml
##########
@@ -38,8 +38,12 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        dotnet: [2.2.103]
+        dotnet: ['3.0']

Review comment:
       A couple thoughts:
   
   1. It may make sense to do this in a separate change. That way we can isolate it and ensure our CI remains running correctly.
   2. `3.0` is currently end of life. We should use `3.1` instead. https://dotnet.microsoft.com/platform/support/policy/dotnet-core

##########
File path: .github/workflows/csharp.yml
##########
@@ -38,8 +38,12 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        dotnet: [2.2.103]
+        dotnet: ['3.0']
     steps:
+      - name: Setup .net core 2.2
+        uses: actions/setup-dotnet@v1
+        with:
+          dotnet-version: '2.2.103'

Review comment:
       Instead, we should just move all our test projects to `3.1` and no longer require this EOL version.

##########
File path: csharp/test/Apache.Arrow.Flight.TestWeb/Apache.Arrow.Flight.TestWeb.csproj
##########
@@ -0,0 +1,16 @@
+<Project Sdk="Microsoft.NET.Sdk.Web">
+
+  <PropertyGroup>
+    <TargetFramework>netcoreapp3.0</TargetFramework>

Review comment:
       Let's move all the tests to `netcoreapp3.1`.

##########
File path: csharp/src/Apache.Arrow.Flight/Apache.Arrow.Flight.csproj
##########
@@ -0,0 +1,28 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>netstandard2.1</TargetFramework>
+    <LangVersion>8.0</LangVersion>
+    <EmbedUntrackedSources>true</EmbedUntrackedSources>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <None Remove="Format\Flight.proto" />

Review comment:
       This shouldn't be nececessary. Just having the `<Protobuf Include="path-to\Flight.proto" />` should be enough.

##########
File path: csharp/src/Apache.Arrow.Flight/Format/Flight.proto
##########
@@ -0,0 +1,335 @@
+/*

Review comment:
       This file is a duplicate of https://github.com/apache/arrow/blob/master/format/Flight.proto. We should remove this duplicate and just add the `csharp_namespace` line to the `format/Flight.proto` file.

##########
File path: csharp/src/Apache.Arrow.Flight/Apache.Arrow.Flight.csproj
##########
@@ -0,0 +1,28 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>netstandard2.1</TargetFramework>
+    <LangVersion>8.0</LangVersion>

Review comment:
       If it just works - moving this change to the Directory.Build.props would be fine with me. That way we are using the latest C# for all projects.

##########
File path: csharp/src/Apache.Arrow.Flight/Apache.Arrow.Flight.csproj
##########
@@ -0,0 +1,28 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>netstandard2.1</TargetFramework>
+    <LangVersion>8.0</LangVersion>
+    <EmbedUntrackedSources>true</EmbedUntrackedSources>

Review comment:
       I think this may make sense to move to the `csharp\Directory.Build.props` file instead.

##########
File path: csharp/src/Apache.Arrow.Flight/Reader/RecordBatcReaderImplementation.cs
##########
@@ -0,0 +1,110 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using Apache.Arrow.Flatbuf;
+using Apache.Arrow.Ipc;
+using Grpc.Core;
+
+namespace Apache.Arrow.Flight
+{
+    internal class RecordBatcReaderImplementation : ArrowReaderImplementation
+    {
+        private readonly IAsyncStreamReader<Protocol.FlightData> _flightDataStream;
+        private FlightDescriptor _flightDescriptor;
+
+        public RecordBatcReaderImplementation(IAsyncStreamReader<Protocol.FlightData> streamReader)
+        {
+            _flightDataStream = streamReader;
+        }
+
+        public override RecordBatch ReadNextRecordBatch()
+        {
+            throw new NotImplementedException();
+        }
+
+        public async ValueTask<FlightDescriptor> ReadFlightDescriptor()
+        {
+            if (!HasReadSchema)
+            {
+                await ReadSchema();
+            }
+            return _flightDescriptor;
+        }
+
+        public async ValueTask<Schema> ReadSchema()
+        {
+            if (HasReadSchema)
+            {
+                return Schema;
+            }
+
+            var moveNextResult = await _flightDataStream.MoveNext();
+
+            if (!moveNextResult)
+            {
+                throw new Exception("No records or schema in this flight");
+            }
+
+            var header = _flightDataStream.Current.DataHeader.Memory;
+            Message message = Message.GetRootAsMessage(
+                ArrowReaderImplementation.CreateByteBuffer(header));
+
+
+            if(_flightDataStream.Current.FlightDescriptor != null)
+            {
+                _flightDescriptor = new FlightDescriptor(_flightDataStream.Current.FlightDescriptor);
+            }
+
+            switch (message.HeaderType)
+            {
+                case MessageHeader.Schema:
+                    Schema = FlightMessageSerializer.DecodeSchema(message.ByteBuffer);
+                    break;
+                default:
+                    throw new Exception($"Expected schema as the first message, but got: {message.HeaderType.ToString()}");
+            }
+            return Schema;
+        }
+
+        public override async ValueTask<RecordBatch> ReadNextRecordBatchAsync(CancellationToken cancellationToken)
+        {
+            if (!HasReadSchema)
+            {
+                await ReadSchema();

Review comment:
       Since this is library code, every call to `await` should have a `.ConfigureAwait(false)` on it.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org