@@ -270,16 +270,11 @@ public Plan getPlan(String... args) {
270
270
FileDataSource docs = new FileDataSource (RecordInputFormat .class , docsInput , "Docs Input" );
271
271
docs .setDegreeOfParallelism (noSubTasks );
272
272
docs .getCompilerHints ().setUniqueField (new FieldSet (0 ));
273
-
274
- docs .setParameter (RecordInputFormat .RECORD_DELIMITER , "\n " );
275
- docs .setParameter (RecordInputFormat .FIELD_DELIMITER_PARAMETER , "|" );
276
- docs .setParameter (RecordInputFormat .NUM_FIELDS_PARAMETER , 2 );
277
- // url
278
- docs .getParameters ().setClass (RecordInputFormat .FIELD_PARSER_PARAMETER_PREFIX +0 , VarLengthStringParser .class );
279
- docs .setParameter (RecordInputFormat .TEXT_POSITION_PARAMETER_PREFIX +0 , 0 );
280
- // doctext
281
- docs .getParameters ().setClass (RecordInputFormat .FIELD_PARSER_PARAMETER_PREFIX +1 , VarLengthStringParser .class );
282
- docs .setParameter (RecordInputFormat .TEXT_POSITION_PARAMETER_PREFIX +1 , 1 );
273
+ RecordInputFormat .configureRecordFormat (docs )
274
+ .recordDelimiter ('\n' )
275
+ .fieldDelimiter ('|' )
276
+ .field (VarLengthStringParser .class , 0 )
277
+ .field (VarLengthStringParser .class , 1 );
283
278
284
279
/*
285
280
* Output Format:
@@ -290,19 +285,12 @@ public Plan getPlan(String... args) {
290
285
// Create DataSourceContract for ranks relation
291
286
FileDataSource ranks = new FileDataSource (RecordInputFormat .class , ranksInput , "Ranks input" );
292
287
ranks .setDegreeOfParallelism (noSubTasks );
293
-
294
- ranks .setParameter (RecordInputFormat .RECORD_DELIMITER , "\n " );
295
- ranks .setParameter (RecordInputFormat .FIELD_DELIMITER_PARAMETER , "|" );
296
- ranks .setParameter (RecordInputFormat .NUM_FIELDS_PARAMETER , 3 );
297
- // url
298
- ranks .getParameters ().setClass (RecordInputFormat .FIELD_PARSER_PARAMETER_PREFIX +0 , VarLengthStringParser .class );
299
- ranks .setParameter (RecordInputFormat .TEXT_POSITION_PARAMETER_PREFIX +0 , 1 );
300
- // rank
301
- ranks .getParameters ().setClass (RecordInputFormat .FIELD_PARSER_PARAMETER_PREFIX +1 , DecimalTextIntParser .class );
302
- ranks .setParameter (RecordInputFormat .TEXT_POSITION_PARAMETER_PREFIX +1 , 0 );
303
- // avgDuration
304
- ranks .getParameters ().setClass (RecordInputFormat .FIELD_PARSER_PARAMETER_PREFIX +2 , DecimalTextIntParser .class );
305
- ranks .setParameter (RecordInputFormat .TEXT_POSITION_PARAMETER_PREFIX +2 , 2 );
288
+ RecordInputFormat .configureRecordFormat (ranks )
289
+ .recordDelimiter ('\n' )
290
+ .fieldDelimiter ('|' )
291
+ .field (VarLengthStringParser .class , 1 )
292
+ .field (DecimalTextIntParser .class , 0 )
293
+ .field (DecimalTextIntParser .class , 2 );
306
294
307
295
/*
308
296
* Output Format:
@@ -312,17 +300,11 @@ public Plan getPlan(String... args) {
312
300
// Create DataSourceContract for visits relation
313
301
FileDataSource visits = new FileDataSource (RecordInputFormat .class , visitsInput , "Visits input:q" );
314
302
visits .setDegreeOfParallelism (noSubTasks );
315
-
316
- visits .setParameter (RecordInputFormat .RECORD_DELIMITER , "\n " );
317
- visits .setParameter (RecordInputFormat .FIELD_DELIMITER_PARAMETER , "|" );
318
- visits .setParameter (RecordInputFormat .NUM_FIELDS_PARAMETER , 2 );
319
- // url
320
- visits .getParameters ().setClass (RecordInputFormat .FIELD_PARSER_PARAMETER_PREFIX +0 , VarLengthStringParser .class );
321
- visits .setParameter (RecordInputFormat .TEXT_POSITION_PARAMETER_PREFIX +0 , 1 );
322
- // date
323
- visits .getParameters ().setClass (RecordInputFormat .FIELD_PARSER_PARAMETER_PREFIX +1 , VarLengthStringParser .class );
324
- visits .setParameter (RecordInputFormat .TEXT_POSITION_PARAMETER_PREFIX +1 , 2 );
325
-
303
+ RecordInputFormat .configureRecordFormat (visits )
304
+ .recordDelimiter ('\n' )
305
+ .fieldDelimiter ('|' )
306
+ .field (VarLengthStringParser .class , 1 )
307
+ .field (VarLengthStringParser .class , 2 );
326
308
327
309
// Create MapContract for filtering the entries from the documents
328
310
// relation
@@ -375,16 +357,13 @@ public Plan getPlan(String... args) {
375
357
// Create DataSinkContract for writing the result of the OLAP query
376
358
FileDataSink result = new FileDataSink (RecordOutputFormat .class , output , antiJoinVisits , "Result" );
377
359
result .setDegreeOfParallelism (noSubTasks );
378
- result .getParameters ().setString (RecordOutputFormat .RECORD_DELIMITER_PARAMETER , "\n " );
379
- result .getParameters ().setString (RecordOutputFormat .FIELD_DELIMITER_PARAMETER , "|" );
380
- result .getParameters ().setBoolean (RecordOutputFormat .LENIENT_PARSING , true );
381
- result .getParameters ().setInteger (RecordOutputFormat .NUM_FIELDS_PARAMETER , 3 );
382
- result .getParameters ().setClass (RecordOutputFormat .FIELD_TYPE_PARAMETER_PREFIX + 0 , PactInteger .class );
383
- result .getParameters ().setInteger (RecordOutputFormat .RECORD_POSITION_PARAMETER_PREFIX + 0 , 1 );
384
- result .getParameters ().setClass (RecordOutputFormat .FIELD_TYPE_PARAMETER_PREFIX + 1 , PactString .class );
385
- result .getParameters ().setInteger (RecordOutputFormat .RECORD_POSITION_PARAMETER_PREFIX + 1 , 0 );
386
- result .getParameters ().setClass (RecordOutputFormat .FIELD_TYPE_PARAMETER_PREFIX + 2 , PactInteger .class );
387
- result .getParameters ().setInteger (RecordOutputFormat .RECORD_POSITION_PARAMETER_PREFIX + 2 , 2 );
360
+ RecordOutputFormat .configureRecordFormat (result )
361
+ .recordDelimiter ('\n' )
362
+ .fieldDelimiter ('|' )
363
+ .lenient (true )
364
+ .field (PactInteger .class , 1 )
365
+ .field (PactString .class , 0 )
366
+ .field (PactInteger .class , 2 );
388
367
389
368
// Return the PACT plan
390
369
return new Plan (result , "Weblog Analysis" );
0 commit comments