parquet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject [1/2] parquet-cpp git commit: PARQUET-991: Resolve msvc warnings; Appveyor treats msvc warnings as …
Date Mon, 29 May 2017 19:56:05 GMT
Repository: parquet-cpp
Updated Branches:
  refs/heads/master b36c9ac00 -> fc5228af3


http://git-wip-us.apache.org/repos/asf/parquet-cpp/blob/fc5228af/src/parquet/file/file-deserialize-test.cc
----------------------------------------------------------------------
diff --git a/src/parquet/file/file-deserialize-test.cc b/src/parquet/file/file-deserialize-test.cc
index 8e5e868..a823591 100644
--- a/src/parquet/file/file-deserialize-test.cc
+++ b/src/parquet/file/file-deserialize-test.cc
@@ -192,7 +192,7 @@ TEST_F(TestPageSerde, Compression) {
     std::vector<uint8_t> buffer;
     for (int i = 0; i < num_pages; ++i) {
       const uint8_t* data = faux_data[i].data();
-      int data_size = faux_data[i].size();
+      int data_size = static_cast<int>(faux_data[i].size());
 
       int64_t max_compressed_size = codec->MaxCompressedLen(data_size, data);
       buffer.resize(max_compressed_size);
@@ -200,7 +200,7 @@ TEST_F(TestPageSerde, Compression) {
       int64_t actual_size =
           codec->Compress(data_size, data, max_compressed_size, &buffer[0]);
 
-      WriteDataPageHeader(1024, data_size, actual_size);
+      WriteDataPageHeader(1024, data_size, static_cast<int32_t>(actual_size));
       out_stream_->Write(buffer.data(), actual_size);
     }
 
@@ -209,7 +209,7 @@ TEST_F(TestPageSerde, Compression) {
     std::shared_ptr<Page> page;
     const DataPage* data_page;
     for (int i = 0; i < num_pages; ++i) {
-      int data_size = faux_data[i].size();
+      int data_size = static_cast<int>(faux_data[i].size());
       page = page_reader_->NextPage();
       data_page = static_cast<const DataPage*>(page.get());
       ASSERT_EQ(data_size, data_page->size());

http://git-wip-us.apache.org/repos/asf/parquet-cpp/blob/fc5228af/src/parquet/file/file-metadata-test.cc
----------------------------------------------------------------------
diff --git a/src/parquet/file/file-metadata-test.cc b/src/parquet/file/file-metadata-test.cc
index 7f71955..a4a2016 100644
--- a/src/parquet/file/file-metadata-test.cc
+++ b/src/parquet/file/file-metadata-test.cc
@@ -48,7 +48,7 @@ TEST(Metadata, TestBuildAccess) {
       .set_min(std::string(reinterpret_cast<const char*>(&int_min), 4))
       .set_max(std::string(reinterpret_cast<const char*>(&int_max), 4));
   EncodedStatistics stats_float;
-  float float_min = 100.100, float_max = 200.200;
+  float float_min = 100.100f, float_max = 200.200f;
   stats_float.set_null_count(0)
       .set_distinct_count(nrows)
       .set_min(std::string(reinterpret_cast<const char*>(&float_min), 4))
@@ -84,7 +84,7 @@ TEST(Metadata, TestBuildAccess) {
 
   // file metadata
   ASSERT_EQ(nrows, f_accessor->num_rows());
-  ASSERT_LE(0, f_accessor->size());
+  ASSERT_LE(0, static_cast<int>(f_accessor->size()));
   ASSERT_EQ(2, f_accessor->num_row_groups());
   ASSERT_EQ(ParquetVersion::PARQUET_2_0, f_accessor->version());
   ASSERT_EQ(DEFAULT_CREATED_BY, f_accessor->created_by());

http://git-wip-us.apache.org/repos/asf/parquet-cpp/blob/fc5228af/src/parquet/file/metadata.cc
----------------------------------------------------------------------
diff --git a/src/parquet/file/metadata.cc b/src/parquet/file/metadata.cc
index 3df8fbd..7120d88 100644
--- a/src/parquet/file/metadata.cc
+++ b/src/parquet/file/metadata.cc
@@ -287,7 +287,7 @@ class RowGroupMetaData::RowGroupMetaDataImpl {
       : row_group_(row_group), schema_(schema), writer_version_(writer_version) {}
   ~RowGroupMetaDataImpl() {}
 
-  inline int num_columns() const { return row_group_->columns.size(); }
+  inline int num_columns() const { return static_cast<int>(row_group_->columns.size());
}
 
   inline int64_t num_rows() const { return row_group_->num_rows; }
 
@@ -371,10 +371,14 @@ class FileMetaData::FileMetaDataImpl {
   inline uint32_t size() const { return metadata_len_; }
   inline int num_columns() const { return schema_.num_columns(); }
   inline int64_t num_rows() const { return metadata_->num_rows; }
-  inline int num_row_groups() const { return metadata_->row_groups.size(); }
+  inline int num_row_groups() const {
+    return static_cast<int>(metadata_->row_groups.size());
+  }
   inline int32_t version() const { return metadata_->version; }
   inline const std::string& created_by() const { return metadata_->created_by; }
-  inline int num_schema_elements() const { return metadata_->schema.size(); }
+  inline int num_schema_elements() const {
+    return static_cast<int>(metadata_->schema.size());
+  }
 
   const ApplicationVersion& writer_version() const { return writer_version_; }
 
@@ -404,7 +408,7 @@ class FileMetaData::FileMetaDataImpl {
   std::unique_ptr<format::FileMetaData> metadata_;
   void InitSchema() {
     schema::FlatSchemaConverter converter(
-        &metadata_->schema[0], metadata_->schema.size());
+        &metadata_->schema[0], static_cast<int>(metadata_->schema.size()));
     schema_.Init(converter.Convert());
   }
   SchemaDescriptor schema_;
@@ -743,7 +747,7 @@ class RowGroupMetaDataBuilder::RowGroupMetaDataBuilderImpl {
     row_group_->__set_total_byte_size(total_byte_size);
   }
 
-  int num_columns() { return row_group_->columns.size(); }
+  int num_columns() { return static_cast<int>(row_group_->columns.size()); }
 
  private:
   void InitializeColumns(int ncols) { row_group_->columns.resize(ncols); }

http://git-wip-us.apache.org/repos/asf/parquet-cpp/blob/fc5228af/src/parquet/file/reader-internal.cc
----------------------------------------------------------------------
diff --git a/src/parquet/file/reader-internal.cc b/src/parquet/file/reader-internal.cc
index 3543759..c542000 100644
--- a/src/parquet/file/reader-internal.cc
+++ b/src/parquet/file/reader-internal.cc
@@ -68,7 +68,7 @@ std::shared_ptr<Page> SerializedPageReader::NextPage() {
       if (bytes_available == 0) { return std::shared_ptr<Page>(nullptr); }
 
       // This gets used, then set by DeserializeThriftMsg
-      header_size = bytes_available;
+      header_size = static_cast<uint32_t>(bytes_available);
       try {
         DeserializeThriftMsg(buffer, &header_size, &current_page_header_);
         break;

http://git-wip-us.apache.org/repos/asf/parquet-cpp/blob/fc5228af/src/parquet/file/writer-internal.cc
----------------------------------------------------------------------
diff --git a/src/parquet/file/writer-internal.cc b/src/parquet/file/writer-internal.cc
index 633498c..019271f 100644
--- a/src/parquet/file/writer-internal.cc
+++ b/src/parquet/file/writer-internal.cc
@@ -101,8 +101,8 @@ int64_t SerializedPageWriter::WriteDataPage(const CompressedDataPage&
page) {
 
   format::PageHeader page_header;
   page_header.__set_type(format::PageType::DATA_PAGE);
-  page_header.__set_uncompressed_page_size(uncompressed_size);
-  page_header.__set_compressed_page_size(compressed_data->size());
+  page_header.__set_uncompressed_page_size(static_cast<int32_t>(uncompressed_size));
+  page_header.__set_compressed_page_size(static_cast<int32_t>(compressed_data->size()));
   page_header.__set_data_page_header(data_page_header);
   // TODO(PARQUET-594) crc checksum
 
@@ -139,8 +139,8 @@ int64_t SerializedPageWriter::WriteDictionaryPage(const DictionaryPage&
page) {
 
   format::PageHeader page_header;
   page_header.__set_type(format::PageType::DICTIONARY_PAGE);
-  page_header.__set_uncompressed_page_size(uncompressed_size);
-  page_header.__set_compressed_page_size(compressed_data->size());
+  page_header.__set_uncompressed_page_size(static_cast<int32_t>(uncompressed_size));
+  page_header.__set_compressed_page_size(static_cast<int32_t>(compressed_data->size()));
   page_header.__set_dictionary_page_header(dict_page_header);
   // TODO(PARQUET-594) crc checksum
 
@@ -260,12 +260,12 @@ FileSerializer::~FileSerializer() {
 
 void FileSerializer::WriteMetaData() {
   // Write MetaData
-  uint32_t metadata_len = sink_->Tell();
+  uint32_t metadata_len = static_cast<uint32_t>(sink_->Tell());
 
   // Get a FileMetaData
   auto metadata = metadata_->Finish();
   metadata->WriteTo(sink_.get());
-  metadata_len = sink_->Tell() - metadata_len;
+  metadata_len = static_cast<uint32_t>(sink_->Tell()) - metadata_len;
 
   // Write Footer
   sink_->Write(reinterpret_cast<uint8_t*>(&metadata_len), 4);

http://git-wip-us.apache.org/repos/asf/parquet-cpp/blob/fc5228af/src/parquet/reader-test.cc
----------------------------------------------------------------------
diff --git a/src/parquet/reader-test.cc b/src/parquet/reader-test.cc
index e8a6813..fcce38b 100644
--- a/src/parquet/reader-test.cc
+++ b/src/parquet/reader-test.cc
@@ -90,7 +90,7 @@ TEST_F(TestAllTypesPlain, TestBatchRead) {
 
   ASSERT_TRUE(col->HasNext());
   int64_t values_read;
-  int levels_read = col->ReadBatch(4, def_levels, rep_levels, values, &values_read);
+  auto levels_read = col->ReadBatch(4, def_levels, rep_levels, values, &values_read);
   ASSERT_EQ(4, levels_read);
   ASSERT_EQ(4, values_read);
 

http://git-wip-us.apache.org/repos/asf/parquet-cpp/blob/fc5228af/src/parquet/schema-test.cc
----------------------------------------------------------------------
diff --git a/src/parquet/schema-test.cc b/src/parquet/schema-test.cc
index b894cd0..f8a7205 100644
--- a/src/parquet/schema-test.cc
+++ b/src/parquet/schema-test.cc
@@ -385,7 +385,7 @@ TEST_F(TestSchemaConverter, NestedExample) {
   elements.push_back(
       NewPrimitive("item", FieldRepetitionType::OPTIONAL, format::Type::INT64, 4));
 
-  Convert(&elements[0], elements.size());
+  Convert(&elements[0], static_cast<int>(elements.size()));
 
   // Construct the expected schema
   NodeVector fields;

http://git-wip-us.apache.org/repos/asf/parquet-cpp/blob/fc5228af/src/parquet/schema.cc
----------------------------------------------------------------------
diff --git a/src/parquet/schema.cc b/src/parquet/schema.cc
index e6380ae..a3debd0 100644
--- a/src/parquet/schema.cc
+++ b/src/parquet/schema.cc
@@ -361,7 +361,7 @@ const format::SchemaElement& FlatSchemaConverter::Next() {
 }
 
 std::shared_ptr<SchemaDescriptor> FromParquet(const std::vector<SchemaElement>&
schema) {
-  FlatSchemaConverter converter(&schema[0], schema.size());
+  FlatSchemaConverter converter(&schema[0], static_cast<int>(schema.size()));
   std::unique_ptr<Node> root = converter.Convert();
 
   std::shared_ptr<SchemaDescriptor> descr = std::make_shared<SchemaDescriptor>();
@@ -594,7 +594,7 @@ void SchemaDescriptor::BuildTree(const NodePtr& node, int16_t max_def_level,
   } else {
     // Primitive node, append to leaves
     leaves_.push_back(ColumnDescriptor(node, max_def_level, max_rep_level, this));
-    leaf_to_base_.emplace(leaves_.size() - 1, base);
+    leaf_to_base_.emplace(static_cast<int>(leaves_.size()) - 1, base);
   }
 }
 

http://git-wip-us.apache.org/repos/asf/parquet-cpp/blob/fc5228af/src/parquet/schema.h
----------------------------------------------------------------------
diff --git a/src/parquet/schema.h b/src/parquet/schema.h
index 30aea44..1615798 100644
--- a/src/parquet/schema.h
+++ b/src/parquet/schema.h
@@ -250,7 +250,7 @@ class PARQUET_EXPORT GroupNode : public Node {
 
   const NodePtr& field(int i) const { return fields_[i]; }
 
-  int field_count() const { return fields_.size(); }
+  int field_count() const { return static_cast<int>(fields_.size()); }
 
   void ToParquet(void* opaque_element) const override;
   void Visit(Visitor* visitor) override;
@@ -365,7 +365,7 @@ class PARQUET_EXPORT SchemaDescriptor {
   bool Equals(const SchemaDescriptor& other) const;
 
   // The number of physical columns appearing in the file
-  int num_columns() const { return leaves_.size(); }
+  int num_columns() const { return static_cast<int>(leaves_.size()); }
 
   const schema::NodePtr& schema_root() const { return schema_; }
 

http://git-wip-us.apache.org/repos/asf/parquet-cpp/blob/fc5228af/src/parquet/types-test.cc
----------------------------------------------------------------------
diff --git a/src/parquet/types-test.cc b/src/parquet/types-test.cc
index 06f202e..ba3fe69 100644
--- a/src/parquet/types-test.cc
+++ b/src/parquet/types-test.cc
@@ -78,8 +78,8 @@ TEST(TypePrinter, StatisticsTypes) {
   ASSERT_STREQ("10240000000000", FormatStatValue(Type::INT64, smin.c_str()).c_str());
   ASSERT_STREQ("20480000000000", FormatStatValue(Type::INT64, smax.c_str()).c_str());
 
-  float float_min = 1.024;
-  float float_max = 2.048;
+  float float_min = 1.024f;
+  float float_max = 2.048f;
   smin = std::string(reinterpret_cast<char*>(&float_min), sizeof(float));
   smax = std::string(reinterpret_cast<char*>(&float_max), sizeof(float));
   ASSERT_STREQ("1.024", FormatStatValue(Type::FLOAT, smin.c_str()).c_str());

http://git-wip-us.apache.org/repos/asf/parquet-cpp/blob/fc5228af/src/parquet/util/bit-stream-utils.h
----------------------------------------------------------------------
diff --git a/src/parquet/util/bit-stream-utils.h b/src/parquet/util/bit-stream-utils.h
index 1fdf563..497a960 100644
--- a/src/parquet/util/bit-stream-utils.h
+++ b/src/parquet/util/bit-stream-utils.h
@@ -49,7 +49,9 @@ class BitWriter {
 
   /// The number of current bytes written, including the current byte (i.e. may include a
   /// fraction of a byte). Includes buffered values.
-  int bytes_written() const { return byte_offset_ + BitUtil::Ceil(bit_offset_, 8); }
+  int bytes_written() const {
+    return byte_offset_ + static_cast<int>(BitUtil::Ceil(bit_offset_, 8));
+  }
   uint8_t* buffer() const { return buffer_; }
   int buffer_len() const { return max_bytes_; }
 
@@ -144,7 +146,9 @@ class BitReader {
 
   /// Returns the number of bytes left in the stream, not including the current
   /// byte (i.e., there may be an additional fraction of a byte).
-  int bytes_left() { return max_bytes_ - (byte_offset_ + BitUtil::Ceil(bit_offset_, 8));
}
+  int bytes_left() {
+    return max_bytes_ - (byte_offset_ + static_cast<int>(BitUtil::Ceil(bit_offset_,
8)));
+  }
 
   /// Maximum byte length of a vlq encoded int
   static const int MAX_VLQ_BYTE_LEN = 5;

http://git-wip-us.apache.org/repos/asf/parquet-cpp/blob/fc5228af/src/parquet/util/bit-stream-utils.inline.h
----------------------------------------------------------------------
diff --git a/src/parquet/util/bit-stream-utils.inline.h b/src/parquet/util/bit-stream-utils.inline.h
index c3486f7..5db1639 100644
--- a/src/parquet/util/bit-stream-utils.inline.h
+++ b/src/parquet/util/bit-stream-utils.inline.h
@@ -50,7 +50,7 @@ inline bool BitWriter::PutValue(uint64_t v, int num_bits) {
 }
 
 inline void BitWriter::Flush(bool align) {
-  int num_bytes = BitUtil::Ceil(bit_offset_, 8);
+  int num_bytes = static_cast<int>(BitUtil::Ceil(bit_offset_, 8));
   DCHECK_LE(byte_offset_ + num_bytes, max_bytes_);
   memcpy(buffer_ + byte_offset_, &buffered_values_, num_bytes);
 
@@ -91,8 +91,15 @@ inline bool BitWriter::PutVlqInt(uint32_t v) {
 template <typename T>
 inline void GetValue_(int num_bits, T* v, int max_bytes, const uint8_t* buffer,
     int* bit_offset, int* byte_offset, uint64_t* buffered_values) {
-  *v = BitUtil::TrailingBits(*buffered_values, *bit_offset + num_bits) >> *bit_offset;
-
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable : 4800)
+#endif
+  *v = static_cast<T>(
+      BitUtil::TrailingBits(*buffered_values, *bit_offset + num_bits) >> *bit_offset);
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
   *bit_offset += num_bits;
   if (*bit_offset >= 64) {
     *byte_offset += 8;
@@ -104,10 +111,16 @@ inline void GetValue_(int num_bits, T* v, int max_bytes, const uint8_t*
buffer,
     } else {
       memcpy(buffered_values, buffer + *byte_offset, bytes_remaining);
     }
-
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable : 4800 4805)
+#endif
     // Read bits of v that crossed into new buffered_values_
     *v |= BitUtil::TrailingBits(*buffered_values, *bit_offset)
           << (num_bits - *bit_offset);
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
     DCHECK_LE(*bit_offset, 64);
   }
 }
@@ -132,7 +145,9 @@ inline int BitReader::GetBatch(int num_bits, T* v, int batch_size) {
 
   uint64_t needed_bits = num_bits * batch_size;
   uint64_t remaining_bits = (max_bytes - byte_offset) * 8 - bit_offset;
-  if (remaining_bits < needed_bits) { batch_size = remaining_bits / num_bits; }
+  if (remaining_bits < needed_bits) {
+    batch_size = static_cast<int>(remaining_bits) / num_bits;
+  }
 
   int i = 0;
   if (UNLIKELY(bit_offset != 0)) {
@@ -156,7 +171,14 @@ inline int BitReader::GetBatch(int num_bits, T* v, int batch_size) {
           unpack_buffer, unpack_size, num_bits);
       if (num_unpacked == 0) { break; }
       for (int k = 0; k < num_unpacked; ++k) {
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable : 4800)
+#endif
         v[i + k] = unpack_buffer[k];
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
       }
       i += num_unpacked;
       byte_offset += num_unpacked * num_bits / 8;
@@ -185,7 +207,7 @@ inline int BitReader::GetBatch(int num_bits, T* v, int batch_size) {
 template <typename T>
 inline bool BitReader::GetAligned(int num_bytes, T* v) {
   DCHECK_LE(num_bytes, static_cast<int>(sizeof(T)));
-  int bytes_read = BitUtil::Ceil(bit_offset_, 8);
+  int bytes_read = static_cast<int>(BitUtil::Ceil(bit_offset_, 8));
   if (UNLIKELY(byte_offset_ + bytes_read + num_bytes > max_bytes_)) return false;
 
   // Advance byte_offset to next unread byte and read num_bytes
@@ -227,7 +249,7 @@ inline bool BitReader::GetZigZagVlqInt(int32_t* v) {
   int32_t u_signed;
   if (!GetVlqInt(&u_signed)) return false;
   uint32_t u = static_cast<uint32_t>(u_signed);
-  *reinterpret_cast<uint32_t*>(v) = (u >> 1) ^ -(u & 1);
+  *reinterpret_cast<uint32_t*>(v) = (u >> 1) ^ -(static_cast<int32_t>(u
& 1));
   return true;
 }
 

http://git-wip-us.apache.org/repos/asf/parquet-cpp/blob/fc5228af/src/parquet/util/bit-util.h
----------------------------------------------------------------------
diff --git a/src/parquet/util/bit-util.h b/src/parquet/util/bit-util.h
index 559d5d5..e315b5f 100644
--- a/src/parquet/util/bit-util.h
+++ b/src/parquet/util/bit-util.h
@@ -312,7 +312,7 @@ class BitUtil {
   }
 
   static inline bool GetArrayBit(const uint8_t* bits, int i) {
-    return bits[i / 8] & (1 << (i % 8));
+    return (bits[i / 8] & (1 << (i % 8))) != 0;
   }
 
   static inline void SetArrayBit(uint8_t* bits, int i, bool is_set) {

http://git-wip-us.apache.org/repos/asf/parquet-cpp/blob/fc5228af/src/parquet/util/comparison-test.cc
----------------------------------------------------------------------
diff --git a/src/parquet/util/comparison-test.cc b/src/parquet/util/comparison-test.cc
index ec85485..7ef0338 100644
--- a/src/parquet/util/comparison-test.cc
+++ b/src/parquet/util/comparison-test.cc
@@ -34,7 +34,7 @@ using parquet::schema::PrimitiveNode;
 
 static ByteArray ByteArrayFromString(const std::string& s) {
   auto ptr = reinterpret_cast<const uint8_t*>(s.data());
-  return ByteArray(s.size(), ptr);
+  return ByteArray(static_cast<uint32_t>(s.size()), ptr);
 }
 
 static FLBA FLBAFromString(const std::string& s) {
@@ -68,7 +68,7 @@ TEST(Comparison, FLBA) {
   auto arr2 = FLBAFromString(b);
 
   NodePtr node = PrimitiveNode::Make("FLBA", Repetition::REQUIRED,
-      Type::FIXED_LEN_BYTE_ARRAY, LogicalType::NONE, a.size());
+      Type::FIXED_LEN_BYTE_ARRAY, LogicalType::NONE, static_cast<int>(a.size()));
   ColumnDescriptor descr(node, 0, 0);
   Compare<parquet::FixedLenByteArray> less(&descr);
   ASSERT_TRUE(less(arr1, arr2));

http://git-wip-us.apache.org/repos/asf/parquet-cpp/blob/fc5228af/src/parquet/util/cpu-info.cc
----------------------------------------------------------------------
diff --git a/src/parquet/util/cpu-info.cc b/src/parquet/util/cpu-info.cc
index 0e19223..c6c143e 100644
--- a/src/parquet/util/cpu-info.cc
+++ b/src/parquet/util/cpu-info.cc
@@ -112,7 +112,7 @@ void CpuInfo::Init() {
         // that when impala is running, the core will not be in a lower power state.
         // TODO: is there a more robust way to do this, such as
         // Window's QueryPerformanceFrequency()
-        float mhz = atof(value.c_str());
+        float mhz = static_cast<float>(atof(value.c_str()));
         max_mhz = max(mhz, max_mhz);
       } else if (name.compare("processor") == 0) {
         ++num_cores;
@@ -148,7 +148,7 @@ void CpuInfo::Init() {
 #endif
 
   if (max_mhz != 0) {
-    cycles_per_ms_ = max_mhz * 1000;
+    cycles_per_ms_ = static_cast<int64_t>(max_mhz) * 1000;
   } else {
     cycles_per_ms_ = 1000000;
   }

http://git-wip-us.apache.org/repos/asf/parquet-cpp/blob/fc5228af/src/parquet/util/hash-util.h
----------------------------------------------------------------------
diff --git a/src/parquet/util/hash-util.h b/src/parquet/util/hash-util.h
index 96701da..28a523d 100644
--- a/src/parquet/util/hash-util.h
+++ b/src/parquet/util/hash-util.h
@@ -216,7 +216,7 @@ class HashUtil {
       return MurmurHash2_64(data, bytes, seed);
     }
 #else
-    return MurmurHash2_64(data, bytes, seed);
+    return static_cast<uint32_t>(MurmurHash2_64(data, bytes, seed));
 #endif
   }
 

http://git-wip-us.apache.org/repos/asf/parquet-cpp/blob/fc5228af/src/parquet/util/memory.cc
----------------------------------------------------------------------
diff --git a/src/parquet/util/memory.cc b/src/parquet/util/memory.cc
index 07dd20e..9613182 100644
--- a/src/parquet/util/memory.cc
+++ b/src/parquet/util/memory.cc
@@ -275,7 +275,7 @@ std::string ChunkedAllocator::DebugString() {
   char str[16];
   out << "ChunkedAllocator(#chunks=" << chunks_.size() << " [";
   for (size_t i = 0; i < chunks_.size(); ++i) {
-    sprintf(str, "0x%lx=", reinterpret_cast<size_t>(chunks_[i].data));  // NOLINT
+    sprintf(str, "0x%zx=", reinterpret_cast<size_t>(chunks_[i].data));  // NOLINT
     out << (i > 0 ? " " : "") << str << chunks_[i].size << "/"
         << chunks_[i].allocated_bytes;
   }

http://git-wip-us.apache.org/repos/asf/parquet-cpp/blob/fc5228af/src/parquet/util/memory.h
----------------------------------------------------------------------
diff --git a/src/parquet/util/memory.h b/src/parquet/util/memory.h
index 45d8bf0..ca244a7 100644
--- a/src/parquet/util/memory.h
+++ b/src/parquet/util/memory.h
@@ -46,7 +46,7 @@
 #define PARQUET_IGNORE_NOT_OK(s) \
   try {                          \
     (s);                         \
-  } catch (const ::parquet::ParquetException& e) {}
+  } catch (const ::parquet::ParquetException& e) { UNUSED(e); }
 
 #define PARQUET_THROW_NOT_OK(s)                     \
   do {                                              \
@@ -222,7 +222,7 @@ class PARQUET_EXPORT ChunkedAllocator {
   /// Return offset to unoccpied space in current chunk.
   int GetFreeOffset() const {
     if (current_chunk_idx_ == -1) return 0;
-    return chunks_[current_chunk_idx_].allocated_bytes;
+    return static_cast<int>(chunks_[current_chunk_idx_].allocated_bytes);
   }
 
   template <bool CHECK_LIMIT_FIRST>

http://git-wip-us.apache.org/repos/asf/parquet-cpp/blob/fc5228af/src/parquet/util/rle-encoding.h
----------------------------------------------------------------------
diff --git a/src/parquet/util/rle-encoding.h b/src/parquet/util/rle-encoding.h
index aa888ad..d9eb6a2 100644
--- a/src/parquet/util/rle-encoding.h
+++ b/src/parquet/util/rle-encoding.h
@@ -168,9 +168,10 @@ class RleEncoder {
   static int MinBufferSize(int bit_width) {
     /// 1 indicator byte and MAX_VALUES_PER_LITERAL_RUN 'bit_width' values.
     int max_literal_run_size =
-        1 + BitUtil::Ceil(MAX_VALUES_PER_LITERAL_RUN * bit_width, 8);
+        1 + static_cast<int>(BitUtil::Ceil(MAX_VALUES_PER_LITERAL_RUN * bit_width,
8));
     /// Up to MAX_VLQ_BYTE_LEN indicator and a single 'bit_width' value.
-    int max_repeated_run_size = BitReader::MAX_VLQ_BYTE_LEN + BitUtil::Ceil(bit_width, 8);
+    int max_repeated_run_size =
+        BitReader::MAX_VLQ_BYTE_LEN + static_cast<int>(BitUtil::Ceil(bit_width, 8));
     return std::max(max_literal_run_size, max_repeated_run_size);
   }
 
@@ -181,14 +182,15 @@ class RleEncoder {
     // 8 values per smallest run, 8 bits per byte
     // int bytes_per_run = BitUtil::Ceil(bit_width * 8, 8);
     int bytes_per_run = bit_width;
-    int num_runs = BitUtil::Ceil(num_values, 8);
+    int num_runs = static_cast<int>(BitUtil::Ceil(num_values, 8));
     int literal_max_size = num_runs + num_runs * bytes_per_run;
 
     // In the very worst case scenario, the data is a concatenation of repeated
     // runs of 8 values. Repeated run has a 1 byte varint followed by the
     // bit-packed repeated value
-    int min_repeated_run_size = 1 + BitUtil::Ceil(bit_width, 8);
-    int repeated_max_size = BitUtil::Ceil(num_values, 8) * min_repeated_run_size;
+    int min_repeated_run_size = 1 + static_cast<int>(BitUtil::Ceil(bit_width, 8));
+    int repeated_max_size =
+        static_cast<int>(BitUtil::Ceil(num_values, 8)) * min_repeated_run_size;
 
     return std::max(literal_max_size, repeated_max_size);
   }
@@ -286,8 +288,8 @@ inline int RleDecoder::GetBatch(T* values, int batch_size) {
     if (repeat_count_ > 0) {
       int repeat_batch =
           std::min(batch_size - values_read, static_cast<int>(repeat_count_));
-      std::fill(
-          values + values_read, values + values_read + repeat_batch, current_value_);
+      std::fill(values + values_read, values + values_read + repeat_batch,
+          static_cast<T>(current_value_));
       repeat_count_ -= repeat_batch;
       values_read += repeat_batch;
     } else if (literal_count_ > 0) {
@@ -349,10 +351,10 @@ inline int RleDecoder::GetBatchWithDictSpaced(const Vector<T>&
dictionary, T* va
   DCHECK_GE(bit_width_, 0);
   int values_read = 0;
   int remaining_nulls = null_count;
-  INIT_BITSET(valid_bits, valid_bits_offset);
+  INIT_BITSET(valid_bits, static_cast<int>(valid_bits_offset));
 
   while (values_read < batch_size) {
-    bool is_valid = (bitset_valid_bits & (1 << bit_offset_valid_bits));
+    bool is_valid = (bitset_valid_bits & (1 << bit_offset_valid_bits)) != 0;
     READ_NEXT_BITSET(valid_bits);
 
     if (is_valid) {
@@ -431,8 +433,9 @@ bool RleDecoder::NextCounts() {
     literal_count_ = (indicator_value >> 1) * 8;
   } else {
     repeat_count_ = indicator_value >> 1;
-    bool result = bit_reader_.GetAligned<T>(
-        BitUtil::Ceil(bit_width_, 8), reinterpret_cast<T*>(&current_value_));
+    bool result =
+        bit_reader_.GetAligned<T>(static_cast<int>(BitUtil::Ceil(bit_width_,
8)),
+            reinterpret_cast<T*>(&current_value_));
     DCHECK(result);
   }
   return true;
@@ -507,7 +510,8 @@ inline void RleEncoder::FlushRepeatedRun() {
   // The lsb of 0 indicates this is a repeated run
   int32_t indicator_value = repeat_count_ << 1 | 0;
   result &= bit_writer_.PutVlqInt(indicator_value);
-  result &= bit_writer_.PutAligned(current_value_, BitUtil::Ceil(bit_width_, 8));
+  result &= bit_writer_.PutAligned(
+      current_value_, static_cast<int>(BitUtil::Ceil(bit_width_, 8)));
   DCHECK(result);
   num_buffered_values_ = 0;
   repeat_count_ = 0;

http://git-wip-us.apache.org/repos/asf/parquet-cpp/blob/fc5228af/src/parquet/util/rle-test.cc
----------------------------------------------------------------------
diff --git a/src/parquet/util/rle-test.cc b/src/parquet/util/rle-test.cc
index 86c05bc..4aa96c3 100644
--- a/src/parquet/util/rle-test.cc
+++ b/src/parquet/util/rle-test.cc
@@ -80,7 +80,7 @@ TEST(BitArray, TestBool) {
     bool val = false;
     bool result = reader.GetValue(1, &val);
     EXPECT_TRUE(result);
-    EXPECT_EQ(val, i % 2);
+    EXPECT_EQ(val, (i % 2) != 0);
   }
 
   for (int i = 0; i < 8; ++i) {
@@ -103,7 +103,7 @@ TEST(BitArray, TestBool) {
 
 // Writes 'num_vals' values with width 'bit_width' and reads them back.
 void TestBitArrayValues(int bit_width, int num_vals) {
-  int len = BitUtil::Ceil(bit_width * num_vals, 8);
+  int len = static_cast<int>(BitUtil::Ceil(bit_width * num_vals, 8));
   EXPECT_TRUE(len > 0);
   const uint64_t mod = bit_width == 64 ? 1 : 1LL << bit_width;
 
@@ -210,7 +210,8 @@ void ValidateRle(const vector<int>& values, int bit_width, uint8_t*
expected_enc
   {
     RleDecoder decoder(buffer, len, bit_width);
     vector<int> values_read(values.size());
-    ASSERT_EQ(values.size(), decoder.GetBatch(values_read.data(), values.size()));
+    ASSERT_EQ(values.size(),
+        decoder.GetBatch(values_read.data(), static_cast<int>(values.size())));
     EXPECT_EQ(values, values_read);
   }
 }
@@ -241,7 +242,7 @@ bool CheckRoundTrip(const vector<int>& values, int bit_width)
{
     RleDecoder decoder(buffer, len, bit_width);
     vector<int> values_read(values.size());
     if (static_cast<int>(values.size()) !=
-        decoder.GetBatch(values_read.data(), values.size())) {
+        decoder.GetBatch(values_read.data(), static_cast<int>(values.size()))) {
       return false;
     }
     if (values != values_read) { return false; }
@@ -274,14 +275,14 @@ TEST(Rle, SpecificSequences) {
   }
 
   for (int width = 9; width <= MAX_WIDTH; ++width) {
-    ValidateRle(values, width, NULL, 2 * (1 + BitUtil::Ceil(width, 8)));
+    ValidateRle(values, width, NULL, 2 * (1 + static_cast<int>(BitUtil::Ceil(width,
8))));
   }
 
   // Test 100 0's and 1's alternating
   for (int i = 0; i < 100; ++i) {
     values[i] = i % 2;
   }
-  int num_groups = BitUtil::Ceil(100, 8);
+  int num_groups = static_cast<int>(BitUtil::Ceil(100, 8));
   expected_buffer[0] = (num_groups << 1) | 1;
   for (int i = 1; i <= 100 / 8; ++i) {
     expected_buffer[i] = BOOST_BINARY(1 0 1 0 1 0 1 0);
@@ -292,8 +293,9 @@ TEST(Rle, SpecificSequences) {
   // num_groups and expected_buffer only valid for bit width = 1
   ValidateRle(values, 1, expected_buffer, 1 + num_groups);
   for (int width = 2; width <= MAX_WIDTH; ++width) {
-    int num_values = BitUtil::Ceil(100, 8) * 8;
-    ValidateRle(values, width, NULL, 1 + BitUtil::Ceil(width * num_values, 8));
+    int num_values = static_cast<int>(BitUtil::Ceil(100, 8)) * 8;
+    ValidateRle(
+        values, width, NULL, 1 + static_cast<int>(BitUtil::Ceil(width * num_values,
8)));
   }
 }
 
@@ -446,7 +448,7 @@ TEST(BitRle, Overflow) {
     for (int i = 0; i < num_added; ++i) {
       bool result = decoder.Get(&v);
       EXPECT_TRUE(result);
-      EXPECT_EQ(v, parity);
+      EXPECT_EQ(v != 0, parity);
       parity = !parity;
     }
     // Make sure we get false when reading past end a couple times.

http://git-wip-us.apache.org/repos/asf/parquet-cpp/blob/fc5228af/src/parquet/util/visibility.h
----------------------------------------------------------------------
diff --git a/src/parquet/util/visibility.h b/src/parquet/util/visibility.h
index ccaefd8..1601335 100644
--- a/src/parquet/util/visibility.h
+++ b/src/parquet/util/visibility.h
@@ -19,6 +19,17 @@
 #define PARQUET_UTIL_VISIBILITY_H
 
 #if defined(_WIN32) || defined(__CYGWIN__)
+#ifdef _MSC_VER
+#pragma warning(push)
+// Disable warning for STL types usage in DLL interface https://web.archive.org/web/20130317015847/http://connect.microsoft.com/VisualStudio/feedback/details/696593/vc-10-vs-2010-basic-string-exports
+#pragma warning(disable : 4275 4251)
+// Disable diamond inheritance warnings
+#pragma warning(disable : 4250)
+// Disable macro redefinition warnings
+#pragma warning(disable : 4005)
+// Disable extern before exported template warnings
+#pragma warning(disable : 4910)
+#endif
 #define PARQUET_EXPORT __declspec(dllexport)
 #define PARQUET_NO_EXPORT
 #else  // Not Windows
@@ -30,4 +41,21 @@
 #endif
 #endif  // Non-Windows
 
+// gcc and clang disagree about how to handle template visibility when you have
+// explicit specializations https://llvm.org/bugs/show_bug.cgi?id=24815
+
+#if defined(__clang__)
+#define PARQUET_EXTERN_TEMPLATE extern template class PARQUET_EXPORT
+#else
+#define PARQUET_EXTERN_TEMPLATE extern template class
+#endif
+
+// This is a complicated topic, some reading on it:
+// http://www.codesynthesis.com/~boris/blog/2010/01/18/dll-export-cxx-templates/
+#ifdef _MSC_VER
+#define PARQUET_TEMPLATE_EXPORT PARQUET_EXPORT
+#else
+#define PARQUET_TEMPLATE_EXPORT
+#endif
+
 #endif  // PARQUET_UTIL_VISIBILITY_H


Mime
View raw message