Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
  • Loading branch information
yongtang committed Jul 21, 2019
1 parent bb59998 commit 04070cc
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
11 changes: 4 additions & 7 deletions tensorflow_io/core/kernels/file_input.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
/* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -42,10 +42,12 @@ class FileContentInput: public FileInput<bool> {
}
std::vector<string> entries;
Status status = Status::OK();
int64 total_size = 0;
while (status.ok()) {
string buffer;
status = s->ReadNBytes(chunk_size, &buffer);
if (status.ok() || errors::IsOutOfRange(status)) {
total_size += buffer.size();
entries.emplace_back(std::move(buffer));
}
}
Expand All @@ -57,12 +59,8 @@ class FileContentInput: public FileInput<bool> {
value_tensor.flat<string>()((*record_read)) = std::move(entries[0]);
} else {
string buffer;
int64 total_size = 0;
for (size_t i = 0; i < entries.size(); i++) {
total_size += entries[i].size();
}
buffer.reserve(total_size);
for (size_t i = 0; i < entries.size(); i++) {
for (size_t i = 0; i < entries.size(); ++i) {
buffer.append(entries[i]);
}
value_tensor.flat<string>()((*record_read)) = std::move(buffer);
Expand All @@ -79,7 +77,6 @@ class FileContentInput: public FileInput<bool> {
bool DecodeAttributes(const VariantTensorData& data) override {
return true;
}
protected:
};

REGISTER_UNARY_VARIANT_DECODE_FUNCTION(FileContentInput, "tensorflow::data::FileContentInput");
Expand Down
2 changes: 1 addition & 1 deletion tensorflow_io/core/ops/file_ops.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
/* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion tensorflow_io/core/python/ops/data_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def __init__(self, fn, data_input, batch, dtypes, shapes):
output_shapes=self._shapes), self._batch, self._dtypes, self._shapes)

class FileDataset(BaseDataset):
"""A FileDataset that read file content as string"""
"""A FileDataset that reads file content as string"""

def __init__(self, filename):
"""Create a FileDataset."""
Expand Down
2 changes: 1 addition & 1 deletion tensorflow_io/image/python/ops/image_dataset_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from tensorflow import dtypes
from tensorflow.compat.v1 import data
from tensorflow_io import _load_library
from tensorflow_io.core.python.ops import data_ops as data_ops
from tensorflow_io.core.python.ops import data_ops
image_ops = _load_library('_image_ops.so')

class TIFFDataset(data.Dataset):
Expand Down

0 comments on commit 04070cc

Please sign in to comment.