-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResponseMetaDataExtensions.cs
More file actions
50 lines (46 loc) · 1.75 KB
/
ResponseMetaDataExtensions.cs
File metadata and controls
50 lines (46 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using Couchbase.AnalyticsClient.Query;
using Couchbase.Grpc.Protocol.Columnar;
using Google.Protobuf.WellKnownTypes;
namespace Couchbase.Analytics.Performer.Internal.Utils;
public static class ResponseMetaDataExtensions
{
public static QueryResultMetadataResponse.Types.QueryMetadata ToResponseMetaData(this QueryMetaData metadata)
{
var sdkMetrics = metadata.Metrics!;
var protoMetadata = new QueryResultMetadataResponse.Types.QueryMetadata()
{
Metrics = new QueryResultMetadataResponse.Types.QueryMetadata.Types.Metrics
{
ElapsedTime = new Duration
{
Seconds = sdkMetrics.ElapsedTime!.Value.Seconds,
Nanos = sdkMetrics.ElapsedTime.Value.Nanoseconds
},
ExecutionTime = new Duration
{
Seconds = sdkMetrics.ExecutionTime!.Value.Seconds,
Nanos = sdkMetrics.ExecutionTime.Value.Nanoseconds
},
ProcessedObjects = (ulong)sdkMetrics.ProcessedObjects,
ResultCount = (ulong)sdkMetrics.ResultCount,
ResultSize = (ulong)sdkMetrics.ResultSize
}
};
if (metadata.RequestId is not null)
{
protoMetadata.RequestId = metadata.RequestId;
}
if (metadata.Warnings is not null)
{
foreach (var warnings in metadata.Warnings)
{
protoMetadata.Warnings.Add(new QueryResultMetadataResponse.Types.QueryMetadata.Types.Warning()
{
Code = (uint)warnings.Code,
Message = warnings.Message
});
}
}
return protoMetadata;
}
}