You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@quickstep.apache.org by "Zuyu Zhang (JIRA)" <ji...@apache.org> on 2017/03/26 22:53:41 UTC

[jira] [Created] (QUICKSTEP-86) RangePartitionSchemeSerialization Failure Due to protobuf debug checks.

Zuyu Zhang created QUICKSTEP-86:
-----------------------------------

             Summary: RangePartitionSchemeSerialization Failure Due to protobuf debug checks.
                 Key: QUICKSTEP-86
                 URL: https://issues.apache.org/jira/browse/QUICKSTEP-86
             Project: Apache Quickstep
          Issue Type: Test
          Components: Catalog
         Environment: Travis CI with Clang in the debug build mode only.
            Reporter: Zuyu Zhang
            Priority: Minor


The following test in PartitionScheme_unittest.cpp (in https://github.com/apache/incubator-quickstep/pull/217) failed due to a debug check in protobuf: https://travis-ci.org/apache/incubator-quickstep/jobs/213492259#L3473

I have not figured out why, since serialization::RangePartitionSchemeHeader::partition_range_boundaries is similar to serialization::SortMergeRunWorkOrder::runs defined in WorkOrder.proto.

TEST(PartitionSchemeTest, CheckRangePartitionSchemeSerialization) {
  const std::size_t num_partitions = 4;
  vector<PartitionSchemeHeader::PartitionValues> partition_ranges;
  // Partition boundaries are 0, 10, 20.
  // Last partition can hold upto infinity.
  // First partition can hold from -infinity to -1.
  for (std::size_t i = 0; i < num_partitions - 1; ++i) {
    partition_ranges.push_back({ TypedValue(static_cast<int>(i * 10)) });
  }
  std::unique_ptr<PartitionScheme> part_scheme(
      new PartitionScheme(
          new RangePartitionSchemeHeader(num_partitions, { 0 }, { &TypeFactory::GetType(kInt) },
                                         move(partition_ranges))));
  for (int i = 0; i < 10; ++i) {
    part_scheme->addBlockToPartition(i * 5, i % num_partitions);
  }
  std::unique_ptr<PartitionScheme> part_scheme_from_proto;
  part_scheme_from_proto.reset(
      PartitionScheme::ReconstructFromProto(part_scheme->getProto()));
  const PartitionSchemeHeader &header = part_scheme->getPartitionSchemeHeader();
  const PartitionSchemeHeader &header_from_proto = part_scheme_from_proto->getPartitionSchemeHeader();
  // Check the partition type
  EXPECT_EQ(header.getPartitionType(),
            header_from_proto.getPartitionType());
  // Check number of partitions
  EXPECT_EQ(header.getNumPartitions(),
            header_from_proto.getNumPartitions());
  // Check the partition attribute id
  EXPECT_EQ(header.getPartitionAttributeIds(),
            header_from_proto.getPartitionAttributeIds());
  // Check the partition range boundaries' size.
  const std::vector<PartitionSchemeHeader::PartitionValues> &range_boundaries_part_scheme =
      static_cast<const RangePartitionSchemeHeader&>(header).getPartitionRangeBoundaries();
  const std::vector<PartitionSchemeHeader::PartitionValues> &range_boundaries_part_scheme_from_proto =
      static_cast<const RangePartitionSchemeHeader&>(header_from_proto).getPartitionRangeBoundaries();
  EXPECT_EQ(range_boundaries_part_scheme.size(),
            range_boundaries_part_scheme_from_proto.size());
  // Check the partition range boundaries' values.
  const Comparison &equal_comparison_op(EqualComparison::Instance());
  std::unique_ptr<UncheckedComparator> equal_unchecked_comparator;
  equal_unchecked_comparator.reset(
      equal_comparison_op.makeUncheckedComparatorForTypes(
          TypeFactory::GetType(kInt), TypeFactory::GetType(kInt)));
  for (std::size_t i = 0; i < range_boundaries_part_scheme.size(); ++i) {
    EXPECT_EQ(range_boundaries_part_scheme[i].size(),
              range_boundaries_part_scheme_from_proto[i].size());
    for (size_t j = 0; j < range_boundaries_part_scheme[i].size(); ++j) {
      EXPECT_TRUE(equal_unchecked_comparator->compareTypedValues(
          range_boundaries_part_scheme[i][j],
          range_boundaries_part_scheme_from_proto[i][j]));
    }
  }
  // Check the blocks in each partition from both the Partition Scheme's
  // C++ object and protocol buffer.
  for (partition_id part_id = 0; part_id < num_partitions; ++part_id) {
    std::vector<block_id> blocks_in_part_scheme =
        part_scheme->getBlocksInPartition(part_id);
    std::vector<block_id> blocks_in_part_scheme_from_proto =
        part_scheme_from_proto->getBlocksInPartition(part_id);
    std::sort(blocks_in_part_scheme.begin(), blocks_in_part_scheme.end());
    std::sort(blocks_in_part_scheme_from_proto.begin(),
              blocks_in_part_scheme_from_proto.end());
    EXPECT_EQ(blocks_in_part_scheme, blocks_in_part_scheme_from_proto);
  }
}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)