]> git.proxmox.com Git - ceph.git/blob - ceph/src/arrow/csharp/src/Apache.Arrow.Flight/FlightInfo.cs
import quincy 17.2.0
[ceph.git] / ceph / src / arrow / csharp / src / Apache.Arrow.Flight / FlightInfo.cs
1 // Licensed to the Apache Software Foundation (ASF) under one or more
2 // contributor license agreements. See the NOTICE file distributed with
3 // this work for additional information regarding copyright ownership.
4 // The ASF licenses this file to You under the Apache License, Version 2.0
5 // (the "License"); you may not use this file except in compliance with
6 // the License. You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15
16 using System;
17 using System.Collections.Generic;
18 using System.Text;
19 using Apache.Arrow.Flight.Internal;
20 using Apache.Arrow.Ipc;
21
22 namespace Apache.Arrow.Flight
23 {
24 public class FlightInfo
25 {
26 internal FlightInfo(Protocol.FlightInfo flightInfo)
27 {
28 Schema = FlightMessageSerializer.DecodeSchema(flightInfo.Schema.Memory);
29 Descriptor = new FlightDescriptor(flightInfo.FlightDescriptor);
30
31 var endpoints = new List<FlightEndpoint>();
32 foreach(var endpoint in flightInfo.Endpoint)
33 {
34 endpoints.Add(new FlightEndpoint(endpoint));
35 }
36 Endpoints = endpoints;
37
38 TotalBytes = flightInfo.TotalBytes;
39 TotalRecords = flightInfo.TotalRecords;
40 }
41
42 public FlightInfo(Schema schema, FlightDescriptor descriptor, IReadOnlyList<FlightEndpoint> endpoints, long totalRecords = 0, long totalBytes = 0)
43 {
44 Schema = schema;
45 Descriptor = descriptor;
46 Endpoints = endpoints;
47 TotalBytes = totalBytes;
48 TotalRecords = totalRecords;
49 }
50
51 public FlightDescriptor Descriptor { get; }
52
53 public Schema Schema { get; }
54
55 public long TotalBytes { get; }
56
57 public long TotalRecords { get; }
58
59 public IReadOnlyList<FlightEndpoint> Endpoints { get; }
60
61 internal Protocol.FlightInfo ToProtocol()
62 {
63 var serializedSchema = SchemaWriter.SerializeSchema(Schema);
64 var response = new Protocol.FlightInfo()
65 {
66 Schema = serializedSchema,
67 FlightDescriptor = Descriptor.ToProtocol()
68 };
69
70 foreach(var endpoint in Endpoints)
71 {
72 response.Endpoint.Add(endpoint.ToProtocol());
73 }
74
75 return response;
76 }
77 }
78 }