@@ -0,0 +1,3050 @@
+# Copyright 2018 The TensorFlow Authors. All Rights Reserved.%0A#%0A# Licensed under the Apache License, Version 2.0 (the %22License%22);%0A# you may not use this file except in compliance with the License.%0A# You may obtain a copy of the License at%0A#%0A#     http://www.apache.org/licenses/LICENSE-2.0%0A#%0A# Unless required by applicable law or agreed to in writing, software%0A# distributed under the License is distributed on an %22AS IS%22 BASIS,%0A# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A# See the License for the specific language governing permissions and%0A# limitations under the License.%0A# ==============================================================================%0A%22%22%22SequenceFile Dataset.%22%22%22%0Afrom __future__ import absolute_import%0Afrom __future__ import division%0Afrom __future__ import print_function%0A%0Afrom tensorflow.contrib.hadoop.python.ops import hadoop_op_loader  # pylint: disable=unused-import%0Afrom tensorflow.contrib.hadoop.python.ops import gen_dataset_ops%0Afrom tensorflow.python.data.ops.dataset_ops import Dataset%0Afrom tensorflow.python.data.util import nest%0Afrom tensorflow.python.framework import dtypes%0Afrom tensorflow.python.framework import ops%0Afrom tensorflow.python.framework import tensor_shape%0A%0A%0Aclass SequenceFileDataset(Dataset):%0A  %22%22%22A Sequence File Dataset that reads the sequence file.%22%22%22%0A%0A  def __init__(self, filenames, output_types=(dtypes.string, dtypes.string)):%0A    %22%22%22Create a %60SequenceFileDataset%60.%0A%0A    %60SequenceFileDataset%60 allows a user to read data from a hadoop sequence%0A    file. A sequence file consists of (key value) pairs sequentially. At%0A    the moment, %60org.apache.hadoop.io.Text%60 is the only serialization type%0A    being supported, and there is no compression support.%0A%0A    For example:%0A%0A    %60%60%60python%0A    dataset = tf.contrib.hadoop.SequenceFileDataset(%0A        %22/foo/bar.seq%22, (tf.string, tf.string))%0A    iterator = dataset.make_one_shot_iterator()%0A    next_element = iterator.get_next()%0A    # Prints the (key, value) pairs inside a hadoop sequence file.%0A    while True:%0A      try:%0A        print(sess.run(next_element))%0A      except tf.errors.OutOfRangeError:%0A        break%0A    %60%60%60%0A%0A    Args:%0A      filenames: A %60tf.string%60 tensor containing one or more filenames.%0A      output_types: A tuple of %60tf.DType%60 objects representing the types of the%0A        key-value pairs returned. Only %60(tf.string, tf.string)%60 is supported%0A        at the moment.%0A    %22%22%22%0A    super(SequenceFileDataset, self).__init__()%0A    self._filenames = ops.convert_to_tensor(%0A        filenames, dtype=dtypes.string, name=%22filenames%22)%0A    self._output_types = output_types%0A%0A  def _as_variant_tensor(self):%0A    return gen_dataset_ops.sequence_file_dataset(%0A        self._filenames, nest.flatten(self.output_types))%0A%0A  @property%0A  def output_classes(self):%0A    return nest.map_structure(lambda _: ops.Tensor, self._output_types)%0A%0A  @property%0A  def output_shapes(self):%0A    return (tensor_shape.TensorShape(%5B%5D), tensor_shape.TensorShape(%5B%5D))%0A%0A  @property%0A  def output_types(self):%0A    return self._output_types%0A

Add python wrapper for tf.contrib.hadoop.SequenceFileDataset