@@ -26,7 +26,7 @@ public static async Task<HttpResponseMessage> StartAsync([HttpTrigger(Authorizat
26
26
{
27
27
// retrieve storage blobs URI of the taxi dataset
28
28
var pathString = req . RequestUri . ParseQueryString ( ) [ @"path" ] ?? throw new ArgumentNullException ( @"required query string parameter 'path' not found" ) ;
29
- Uri path = new Uri ( pathString ) ;
29
+ var path = new Uri ( pathString ) ;
30
30
31
31
var containerUrl = path . GetLeftPart ( UriPartial . Authority ) + "/" + path . Segments [ 1 ] ;
32
32
var prefix = string . Join ( string . Empty , path . Segments . Skip ( 2 ) ) ;
@@ -66,7 +66,7 @@ public static async Task<string> BeginMapReduce([OrchestrationTrigger]IDurableOr
66
66
context . SetCustomStatus ( new { status = @"Creating mappers" , files } ) ;
67
67
}
68
68
//create mapper tasks which download and calculate avg speed from each csv file
69
- Task < double [ ] > [ ] tasks = new Task < double [ ] > [ files . Length ] ;
69
+ var tasks = new Task < double [ ] > [ files . Length ] ;
70
70
for ( var i = 0 ; i < files . Length ; i ++ )
71
71
{
72
72
tasks [ i ] = context . CallActivityAsync < double [ ] > (
@@ -108,13 +108,12 @@ public static async Task<string> BeginMapReduce([OrchestrationTrigger]IDurableOr
108
108
/// </summary>
109
109
[ FunctionName ( nameof ( GetFileListAsync ) ) ]
110
110
public static async Task < string [ ] > GetFileListAsync (
111
- [ ActivityTrigger ] string [ ] paras ,
112
- ILogger log )
111
+ [ ActivityTrigger ] string [ ] paras )
113
112
{
114
- CloudBlobContainer cloudBlobContainer = new CloudBlobContainer ( new Uri ( paras [ 0 ] ) ) ;
113
+ var cloudBlobContainer = new CloudBlobContainer ( new Uri ( paras [ 0 ] ) ) ;
115
114
116
115
var blobs = Enumerable . Empty < IListBlobItem > ( ) ;
117
- BlobContinuationToken continuationToken = default ( BlobContinuationToken ) ;
116
+ var continuationToken = default ( BlobContinuationToken ) ;
118
117
do
119
118
{
120
119
var segmentBlobs = await cloudBlobContainer . ListBlobsSegmentedAsync ( paras [ 1 ] , continuationToken ) ;
@@ -139,8 +138,10 @@ public static async Task<IEnumerable<double>> MapperAsync(
139
138
var numberOfLogsPerDayOfWeek = new int [ 7 ] ;
140
139
141
140
// download blob file
141
+ #pragma warning disable IDE0067 // Dispose objects before losing scope
142
142
// Don't wrap in a Using because this was causing occasional ObjectDisposedException errors in v2 executions
143
- StreamReader reader = new StreamReader ( await _httpClient . GetStreamAsync ( fileUri ) ) ;
143
+ var reader = new StreamReader ( await _httpClient . GetStreamAsync ( fileUri ) ) ;
144
+ #pragma warning restore IDE0067 // Dispose objects before losing scope
144
145
145
146
var lineText = string . Empty ;
146
147
// read a line from NetworkStream
@@ -156,10 +157,10 @@ public static async Task<IEnumerable<double>> MapperAsync(
156
157
}
157
158
158
159
// retrieve the value of pickup_datetime column
159
- DateTime pickup_datetime = DateTime . Parse ( segdata [ 1 ] ) ;
160
+ var pickup_datetime = DateTime . Parse ( segdata [ 1 ] ) ;
160
161
161
162
// retrieve the value of dropoff_datetime column
162
- DateTime dropoff_datetime = DateTime . Parse ( segdata [ 2 ] ) ;
163
+ var dropoff_datetime = DateTime . Parse ( segdata [ 2 ] ) ;
163
164
164
165
// retrieve the value of trip_distance column
165
166
var trip_distance = Convert . ToDouble ( segdata [ 4 ] ) ;
@@ -177,10 +178,12 @@ public static async Task<IEnumerable<double>> MapperAsync(
177
178
continue ;
178
179
}
179
180
}
181
+ #pragma warning disable CA1031 // Do not catch general exception types
180
182
catch ( DivideByZeroException )
181
183
{ // skip it
182
184
continue ;
183
185
}
186
+ #pragma warning restore CA1031 // Do not catch general exception types
184
187
185
188
// sum of avg speed by each day of week
186
189
speedsByDayOfWeek [ ( int ) pickup_datetime . DayOfWeek ] += avgSpeed ;
@@ -190,7 +193,7 @@ public static async Task<IEnumerable<double>> MapperAsync(
190
193
}
191
194
}
192
195
193
- List < double > results = numberOfLogsPerDayOfWeek
196
+ var results = numberOfLogsPerDayOfWeek
194
197
. Select ( ( val , idx ) => val != 0 ? speedsByDayOfWeek [ idx ] / val : 0 )
195
198
. AsParallel ( )
196
199
. ToList ( ) ;
@@ -241,11 +244,10 @@ public static string Reducer(
241
244
/// </summary>
242
245
[ FunctionName ( nameof ( WriteToBlob ) ) ]
243
246
public static async Task WriteToBlob (
244
- [ ActivityTrigger ] string content ,
245
- ILogger log )
247
+ [ ActivityTrigger ] string content )
246
248
{
247
249
var storageConnectionString = Environment . GetEnvironmentVariable ( "AzureWebJobsStorage" ) ;
248
- CloudStorageAccount storageAccount = CloudStorageAccount . Parse ( storageConnectionString ) ;
250
+ var storageAccount = CloudStorageAccount . Parse ( storageConnectionString ) ;
249
251
250
252
// Create the CloudBlobClient that represents the Blob storage endpoint for the storage account.
251
253
var cloudBlobClient = storageAccount . CreateCloudBlobClient ( ) ;
0 commit comments