Skip to content

Commit bcb46f5

Browse files
authored
Merge pull request #9688 from wangkuiyi/cpplint-recordio
Fix cpplint errors with paddle/fluid/recordio
2 parents b2a1c9e + c839ec6 commit bcb46f5

File tree

10 files changed

+35
-19
lines changed

10 files changed

+35
-19
lines changed

cmake/external/snappystream.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,7 @@ add_library(snappystream STATIC IMPORTED GLOBAL)
5454
set_property(TARGET snappystream PROPERTY IMPORTED_LOCATION
5555
"${SNAPPYSTREAM_INSTALL_DIR}/lib/libsnappystream.a")
5656

57-
include_directories(${SNAPPYSTREAM_INCLUDE_DIR})
57+
include_directories(${SNAPPYSTREAM_INCLUDE_DIR}) # For snappysteam to include its own headers.
58+
include_directories(${THIRD_PARTY_PATH}/install) # For Paddle to include snappy stream headers.
59+
5860
add_dependencies(snappystream extern_snappystream)

cmake/external/zlib.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ ELSE(WIN32)
2525
SET(ZLIB_LIBRARIES "${ZLIB_INSTALL_DIR}/lib/libz.a" CACHE FILEPATH "zlib library." FORCE)
2626
ENDIF(WIN32)
2727

28-
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
28+
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) # For zlib code to include its own headers.
29+
INCLUDE_DIRECTORIES(${THIRD_PARTY_PATH}/install) # For Paddle code to include zlib.h.
2930

3031
ExternalProject_Add(
3132
extern_zlib

paddle/fluid/recordio/chunk.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414

1515
#include "paddle/fluid/recordio/chunk.h"
1616

17+
#include <algorithm>
1718
#include <memory>
1819
#include <sstream>
20+
1921
#include "paddle/fluid/platform/enforce.h"
20-
#include "snappystream.hpp"
21-
#include "zlib.h"
22+
#include "snappy_stream/include/snappystream.hpp"
23+
#include "zlib/include/zlib.h"
2224

2325
namespace paddle {
2426
namespace recordio {

paddle/fluid/recordio/chunk_test.cc

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,27 @@
1818

1919
#include "gtest/gtest.h"
2020

21-
using namespace paddle::recordio;
22-
2321
TEST(Chunk, SaveLoad) {
24-
Chunk ch;
22+
paddle::recordio::Chunk ch;
2523
ch.Add(std::string("12345", 6));
2624
ch.Add(std::string("123", 4));
2725
std::stringstream ss;
28-
ch.Write(ss, Compressor::kNoCompress);
26+
ch.Write(ss, paddle::recordio::Compressor::kNoCompress);
2927
ss.seekg(0);
3028
ch.Parse(ss);
3129
ASSERT_EQ(ch.NumBytes(), 10U);
3230
}
3331

3432
TEST(Chunk, Compressor) {
35-
Chunk ch;
33+
paddle::recordio::Chunk ch;
3634
ch.Add(std::string("12345", 6));
3735
ch.Add(std::string("123", 4));
3836
ch.Add(std::string("123", 4));
3937
ch.Add(std::string("123", 4));
4038
std::stringstream ss;
41-
ch.Write(ss, Compressor::kSnappy);
39+
ch.Write(ss, paddle::recordio::Compressor::kSnappy);
4240
std::stringstream ss2;
43-
ch.Write(ss2, Compressor::kNoCompress);
41+
ch.Write(ss2, paddle::recordio::Compressor::kNoCompress);
4442
ASSERT_LE(ss.tellp(), ss2.tellp()); // Compress should contain less data;
4543

4644
ch.Clear();

paddle/fluid/recordio/header_test.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,12 @@
1818

1919
#include "gtest/gtest.h"
2020

21-
using namespace paddle::recordio;
22-
2321
TEST(Recordio, ChunkHead) {
24-
Header hdr(0, 1, Compressor::kGzip, 3);
22+
paddle::recordio::Header hdr(0, 1, paddle::recordio::Compressor::kGzip, 3);
2523
std::stringstream ss;
2624
hdr.Write(ss);
2725
ss.seekg(0, std::ios::beg);
28-
Header hdr2;
26+
paddle::recordio::Header hdr2;
2927
hdr2.Parse(ss);
3028
EXPECT_TRUE(hdr == hdr2);
3129
}

paddle/fluid/recordio/scanner.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@
1313
// limitations under the License.
1414

1515
#include "paddle/fluid/recordio/scanner.h"
16+
17+
#include <string>
18+
1619
#include "paddle/fluid/platform/enforce.h"
1720

1821
namespace paddle {
1922
namespace recordio {
23+
2024
Scanner::Scanner(std::unique_ptr<std::istream> &&stream)
2125
: stream_(std::move(stream)) {
2226
Reset();

paddle/fluid/recordio/scanner.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616

1717
#include <fstream>
1818
#include <memory>
19+
#include <string>
20+
1921
#include "paddle/fluid/recordio/chunk.h"
22+
2023
namespace paddle {
2124
namespace recordio {
2225

paddle/fluid/recordio/writer.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,14 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414
#include "paddle/fluid/recordio/writer.h"
15+
16+
#include <string>
17+
1518
#include "paddle/fluid/platform/enforce.h"
19+
1620
namespace paddle {
1721
namespace recordio {
22+
1823
void Writer::Write(const std::string& record) {
1924
cur_chunk_.Add(record);
2025
if (cur_chunk_.NumRecords() >= max_num_records_in_chunk_) {

paddle/fluid/recordio/writer.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14-
1514
#pragma once
15+
16+
#include <string>
17+
1618
#include "paddle/fluid/recordio/chunk.h"
1719
namespace paddle {
1820
namespace recordio {

paddle/fluid/recordio/writer_scanner_test.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#include "gtest/gtest.h"
16-
1715
#include <sstream>
16+
#include <string>
17+
18+
#include "gtest/gtest.h"
1819
#include "paddle/fluid/recordio/scanner.h"
1920
#include "paddle/fluid/recordio/writer.h"
2021

@@ -66,4 +67,4 @@ TEST(WriterScanner, TinyChunk) {
6667
ASSERT_EQ(scanner.Next(), "DEFG");
6768
ASSERT_FALSE(scanner.HasNext());
6869
}
69-
}
70+
}

0 commit comments

Comments
 (0)