diff --git a/tensorflow/core/BUILD b/tensorflow/core/BUILD index 0b05f9c0ee7..6806a2bda75 100644 --- a/tensorflow/core/BUILD +++ b/tensorflow/core/BUILD @@ -219,6 +219,7 @@ cc_library( "lib/hash/crc32c.h", "lib/histogram/histogram.h", "lib/io/buffered_inputstream.h", + "lib/io/compression.h", "lib/io/inputstream_interface.h", "lib/io/path.h", "lib/io/proto_encode_helper.h", diff --git a/tensorflow/core/lib/io/compression.cc b/tensorflow/core/lib/io/compression.cc new file mode 100644 index 00000000000..c12de98e401 --- /dev/null +++ b/tensorflow/core/lib/io/compression.cc @@ -0,0 +1,27 @@ +/* Copyright 2015 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. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#include "tensorflow/core/lib/io/compression.h" + +namespace tensorflow { +namespace io { +namespace compression { + +const char kNone[] = ""; +const char kGzip[] = "GZIP"; + +} +} +} diff --git a/tensorflow/core/lib/io/compression.h b/tensorflow/core/lib/io/compression.h new file mode 100644 index 00000000000..7a0c5c12a74 --- /dev/null +++ b/tensorflow/core/lib/io/compression.h @@ -0,0 +1,30 @@ +/* Copyright 2015 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. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef THIRD_PARTY_TENSORFLOW_CORE_LIB_IO_COMPRESSION_H_ +#define THIRD_PARTY_TENSORFLOW_CORE_LIB_IO_COMPRESSION_H_ + +namespace tensorflow { +namespace io { +namespace compression { + +extern const char kNone[]; +extern const char kGzip[]; + +} +} +} + +#endif // THIRD_PARTY_TENSORFLOW_CORE_LIB_IO_COMPRESSION_H_ diff --git a/tensorflow/core/lib/io/record_reader.cc b/tensorflow/core/lib/io/record_reader.cc index 8cc9d9154c8..450f10d2999 100644 --- a/tensorflow/core/lib/io/record_reader.cc +++ b/tensorflow/core/lib/io/record_reader.cc @@ -20,6 +20,7 @@ limitations under the License. #include "tensorflow/core/lib/core/coding.h" #include "tensorflow/core/lib/core/errors.h" #include "tensorflow/core/lib/hash/crc32c.h" +#include "tensorflow/core/lib/io/compression.h" #include "tensorflow/core/lib/io/random_inputstream.h" #include "tensorflow/core/platform/env.h" @@ -37,7 +38,7 @@ RecordReaderOptions RecordReaderOptions::CreateRecordReaderOptions( #else options.zlib_options = io::ZlibCompressionOptions::DEFAULT(); #endif // IS_SLIM_BUILD - } else if (compression_type == "GZIP") { + } else if (compression_type == compression::kGzip) { options.compression_type = io::RecordReaderOptions::ZLIB_COMPRESSION; #if defined(IS_SLIM_BUILD) LOG(ERROR) << "Compression is not supported but compression_type is set." @@ -45,7 +46,7 @@ RecordReaderOptions RecordReaderOptions::CreateRecordReaderOptions( #else options.zlib_options = io::ZlibCompressionOptions::GZIP(); #endif // IS_SLIM_BUILD - } else if (compression_type != "") { + } else if (compression_type != compression::kNone) { LOG(ERROR) << "Unsupported compression_type:" << compression_type << ". No comprression will be used."; } diff --git a/tensorflow/core/lib/io/record_writer.cc b/tensorflow/core/lib/io/record_writer.cc index 6b217444740..d77a1016dad 100644 --- a/tensorflow/core/lib/io/record_writer.cc +++ b/tensorflow/core/lib/io/record_writer.cc @@ -17,6 +17,7 @@ limitations under the License. #include "tensorflow/core/lib/core/coding.h" #include "tensorflow/core/lib/hash/crc32c.h" +#include "tensorflow/core/lib/io/compression.h" #include "tensorflow/core/platform/env.h" namespace tensorflow { @@ -38,7 +39,7 @@ RecordWriterOptions RecordWriterOptions::CreateRecordWriterOptions( #else options.zlib_options = io::ZlibCompressionOptions::DEFAULT(); #endif // IS_SLIM_BUILD - } else if (compression_type == "GZIP") { + } else if (compression_type == compression::kGzip) { options.compression_type = io::RecordWriterOptions::ZLIB_COMPRESSION; #if defined(IS_SLIM_BUILD) LOG(ERROR) << "Compression is not supported but compression_type is set." @@ -46,7 +47,7 @@ RecordWriterOptions RecordWriterOptions::CreateRecordWriterOptions( #else options.zlib_options = io::ZlibCompressionOptions::GZIP(); #endif // IS_SLIM_BUILD - } else if (compression_type != "") { + } else if (compression_type != compression::kNone) { LOG(ERROR) << "Unsupported compression_type:" << compression_type << ". No comprression will be used."; }