You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "CurtHagenlocher (via GitHub)" <gi...@apache.org> on 2024/03/18 02:22:32 UTC

[PR] Added simple C# example [arrow-experiments]

CurtHagenlocher opened a new pull request, #25:
URL: https://github.com/apache/arrow-experiments/pull/25

   (no comment)


-- 
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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

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


Re: [PR] Added simple C# example [arrow-experiments]

Posted by "ianmcook (via GitHub)" <gi...@apache.org>.
ianmcook commented on code in PR #25:
URL: https://github.com/apache/arrow-experiments/pull/25#discussion_r1528747286


##########
http/get_simple/csharp/client/ArrowHttpClient.cs:
##########
@@ -0,0 +1,64 @@
+/*
+ * 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.Net.Http;
+using System.Threading.Tasks;
+using Apache.Arrow;
+using Apache.Arrow.Ipc;
+
+namespace ArrowHttpClient
+{
+    public class Program
+    {
+        public static async Task Main(string[] args)
+        {
+            string serverUri = "http://127.0.0.1:8008/";
+
+            DateTime startTime = DateTime.UtcNow;
+
+            HttpClient httpClient = new HttpClient
+            {
+                BaseAddress = new Uri(serverUri),
+            };
+
+            using (var stream = await httpClient.GetStreamAsync(serverUri))
+            using (var reader = new ArrowStreamReader(stream))
+            {
+                Console.WriteLine("Connected");
+
+                Schema schema = reader.Schema;

Review Comment:
   Thanks. In the meantime: I moved this line lower in #26.



-- 
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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

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


Re: [PR] Added simple C# example [arrow-experiments]

Posted by "ianmcook (via GitHub)" <gi...@apache.org>.
ianmcook commented on code in PR #25:
URL: https://github.com/apache/arrow-experiments/pull/25#discussion_r1528667639


##########
http/get_simple/csharp/client/ArrowHttpClient.cs:
##########
@@ -0,0 +1,64 @@
+/*
+ * 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.Net.Http;
+using System.Threading.Tasks;
+using Apache.Arrow;
+using Apache.Arrow.Ipc;
+
+namespace ArrowHttpClient
+{
+    public class Program
+    {
+        public static async Task Main(string[] args)
+        {
+            string serverUri = "http://127.0.0.1:8008/";
+
+            DateTime startTime = DateTime.UtcNow;
+
+            HttpClient httpClient = new HttpClient
+            {
+                BaseAddress = new Uri(serverUri),
+            };
+
+            using (var stream = await httpClient.GetStreamAsync(serverUri))
+            using (var reader = new ArrowStreamReader(stream))
+            {
+                Console.WriteLine("Connected");
+
+                Schema schema = reader.Schema;

Review Comment:
   This line doesn't seem to be setting the schema. If I try to access it after, I get a `NullReferenceException`.



-- 
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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

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


Re: [PR] Added simple C# example [arrow-experiments]

Posted by "CurtHagenlocher (via GitHub)" <gi...@apache.org>.
CurtHagenlocher merged PR #25:
URL: https://github.com/apache/arrow-experiments/pull/25


-- 
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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

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


Re: [PR] Added simple C# example [arrow-experiments]

Posted by "ianmcook (via GitHub)" <gi...@apache.org>.
ianmcook commented on PR #25:
URL: https://github.com/apache/arrow-experiments/pull/25#issuecomment-2004174468

   Cool, thanks. I changed the server URIs in #26 for consistency / interoperability.


-- 
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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

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


Re: [PR] Added simple C# example [arrow-experiments]

Posted by "ianmcook (via GitHub)" <gi...@apache.org>.
ianmcook commented on PR #25:
URL: https://github.com/apache/arrow-experiments/pull/25#issuecomment-2004067735

   Thanks @CurtHagenlocher!
   
   I tested these with all other clients and servers, and everything works, except that I needed to set the server URI to `"http://localhost:8008/"` or `"http://*:8008/"` to get some of the client/server pairs to work.


-- 
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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

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


Re: [PR] Added simple C# example [arrow-experiments]

Posted by "CurtHagenlocher (via GitHub)" <gi...@apache.org>.
CurtHagenlocher commented on code in PR #25:
URL: https://github.com/apache/arrow-experiments/pull/25#discussion_r1528699976


##########
http/get_simple/csharp/client/ArrowHttpClient.cs:
##########
@@ -0,0 +1,64 @@
+/*
+ * 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.Net.Http;
+using System.Threading.Tasks;
+using Apache.Arrow;
+using Apache.Arrow.Ipc;
+
+namespace ArrowHttpClient
+{
+    public class Program
+    {
+        public static async Task Main(string[] args)
+        {
+            string serverUri = "http://127.0.0.1:8008/";
+
+            DateTime startTime = DateTime.UtcNow;
+
+            HttpClient httpClient = new HttpClient
+            {
+                BaseAddress = new Uri(serverUri),
+            };
+
+            using (var stream = await httpClient.GetStreamAsync(serverUri))
+            using (var reader = new ArrowStreamReader(stream))
+            {
+                Console.WriteLine("Connected");
+
+                Schema schema = reader.Schema;

Review Comment:
   This looks like a bug in the C# IPC reader where reader.Schema isn't set until after the first batch is read. I filed [#40634](https://github.com/apache/arrow/issues/40634) to track this.



-- 
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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

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


Re: [PR] Added simple C# example [arrow-experiments]

Posted by "CurtHagenlocher (via GitHub)" <gi...@apache.org>.
CurtHagenlocher commented on code in PR #25:
URL: https://github.com/apache/arrow-experiments/pull/25#discussion_r1528699976


##########
http/get_simple/csharp/client/ArrowHttpClient.cs:
##########
@@ -0,0 +1,64 @@
+/*
+ * 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.Net.Http;
+using System.Threading.Tasks;
+using Apache.Arrow;
+using Apache.Arrow.Ipc;
+
+namespace ArrowHttpClient
+{
+    public class Program
+    {
+        public static async Task Main(string[] args)
+        {
+            string serverUri = "http://127.0.0.1:8008/";
+
+            DateTime startTime = DateTime.UtcNow;
+
+            HttpClient httpClient = new HttpClient
+            {
+                BaseAddress = new Uri(serverUri),
+            };
+
+            using (var stream = await httpClient.GetStreamAsync(serverUri))
+            using (var reader = new ArrowStreamReader(stream))
+            {
+                Console.WriteLine("Connected");
+
+                Schema schema = reader.Schema;

Review Comment:
   This looks like a bug in the C# IPC reader where reader.Schema isn't set until after the first batch is read. I filed #40634 to track this.



-- 
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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

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


Re: [PR] Added simple C# example [arrow-experiments]

Posted by "CurtHagenlocher (via GitHub)" <gi...@apache.org>.
CurtHagenlocher commented on PR #25:
URL: https://github.com/apache/arrow-experiments/pull/25#issuecomment-2004097904

   I confess I only tested with the Rust implementation, and at least on my Windows box the Rust client did not work with localhost so I changed it to the IP address.


-- 
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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

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


Re: [PR] Added simple C# example [arrow-experiments]

Posted by "ianmcook (via GitHub)" <gi...@apache.org>.
ianmcook commented on PR #25:
URL: https://github.com/apache/arrow-experiments/pull/25#issuecomment-2004186090

   I tested a version of the C# client example that writes the received data to an IPC stream file ([Gist here](https://gist.github.com/ianmcook/7c9e4033b59bf71245603b67e69e4235)) and it works as expected.


-- 
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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

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