@@ -190,6 +190,7 @@ Status ParseAvro(const AvroParserConfig& config,
190
190
191
191
// This parameter affects performance in a big and data-dependent way.
192
192
const size_t kMiniBatchSizeBytes = 50000 ;
193
+ size_t avro_num_minibatches_;
193
194
194
195
// Calculate number of minibatches.
195
196
// In main regime make each minibatch around kMiniBatchSizeBytes bytes.
@@ -206,10 +207,9 @@ Status ParseAvro(const AvroParserConfig& config,
206
207
minibatch_bytes = 0 ;
207
208
}
208
209
}
209
- if (const char * n_minibatches =
210
- std::getenv (" AVRO_PARSER_NUM_MINIBATCHES" )) {
211
- VLOG (5 ) << " Overriding num_minibatches with " << n_minibatches;
212
- result = std::stoi (n_minibatches);
210
+ if (avro_num_minibatches_) {
211
+ VLOG (5 ) << " Overriding num_minibatches with " << avro_num_minibatches_;
212
+ result = avro_num_minibatches_;
213
213
}
214
214
// This is to ensure users can control the num minibatches all the way down
215
215
// to size of 1(no parallelism).
@@ -406,6 +406,8 @@ class ParseAvroOp : public OpKernel {
406
406
OP_REQUIRES_OK (ctx, ctx->GetAttr (" sparse_types" , &sparse_types_));
407
407
OP_REQUIRES_OK (ctx, ctx->GetAttr (" dense_types" , &dense_types_));
408
408
OP_REQUIRES_OK (ctx, ctx->GetAttr (" dense_shapes" , &dense_shapes_));
409
+ OP_REQUIRES_OK (
410
+ ctx, ctx->GetAttr (" avro_num_minibatches" , &avro_num_minibatches_));
409
411
410
412
OP_REQUIRES_OK (ctx, ctx->GetAttr (" sparse_keys" , &sparse_keys_));
411
413
OP_REQUIRES_OK (ctx, ctx->GetAttr (" dense_keys" , &dense_keys_));
@@ -419,6 +421,11 @@ class ParseAvroOp : public OpKernel {
419
421
dense_shapes_[d].dims () > 1 && dense_shapes_[d].dim_size (0 ) == -1 ;
420
422
}
421
423
424
+ // Check that avro_num_minibatches is positive
425
+ OP_REQUIRES (ctx, avro_num_minibatches_ >= 0 ,
426
+ errors::InvalidArgument (" Need avro_num_minibatches >= 0, got " ,
427
+ avro_num_minibatches_));
428
+
422
429
string reader_schema_str;
423
430
OP_REQUIRES_OK (ctx, ctx->GetAttr (" reader_schema" , &reader_schema_str));
424
431
@@ -513,6 +520,7 @@ class ParseAvroOp : public OpKernel {
513
520
avro::ValidSchema reader_schema_;
514
521
size_t num_dense_;
515
522
size_t num_sparse_;
523
+ int64 avro_num_minibatches_;
516
524
517
525
private:
518
526
std::vector<std::pair<string, DataType>> CreateKeysAndTypes () {
0 commit comments