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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
17 using System.Collections.Generic;
19 using Apache.Arrow.Flight.Internal;
20 using Apache.Arrow.Ipc;
22 namespace Apache.Arrow.Flight
24 public class FlightInfo
26 internal FlightInfo(Protocol.FlightInfo flightInfo)
28 Schema = FlightMessageSerializer.DecodeSchema(flightInfo.Schema.Memory);
29 Descriptor = new FlightDescriptor(flightInfo.FlightDescriptor);
31 var endpoints = new List<FlightEndpoint>();
32 foreach(var endpoint in flightInfo.Endpoint)
34 endpoints.Add(new FlightEndpoint(endpoint));
36 Endpoints = endpoints;
38 TotalBytes = flightInfo.TotalBytes;
39 TotalRecords = flightInfo.TotalRecords;
42 public FlightInfo(Schema schema, FlightDescriptor descriptor, IReadOnlyList<FlightEndpoint> endpoints, long totalRecords = 0, long totalBytes = 0)
45 Descriptor = descriptor;
46 Endpoints = endpoints;
47 TotalBytes = totalBytes;
48 TotalRecords = totalRecords;
51 public FlightDescriptor Descriptor { get; }
53 public Schema Schema { get; }
55 public long TotalBytes { get; }
57 public long TotalRecords { get; }
59 public IReadOnlyList<FlightEndpoint> Endpoints { get; }
61 internal Protocol.FlightInfo ToProtocol()
63 var serializedSchema = SchemaWriter.SerializeSchema(Schema);
64 var response = new Protocol.FlightInfo()
66 Schema = serializedSchema,
67 FlightDescriptor = Descriptor.ToProtocol()
70 foreach(var endpoint in Endpoints)
72 response.Endpoint.Add(endpoint.ToProtocol());