MCPcopy Create free account
hub / github.com/apache/orc / testConvertReader

Function testConvertReader

c++/test/TestSchemaEvolution.cc:27–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25namespace orc {
26
27 bool testConvertReader(const std::string file, const std::string& read, bool can, bool need) {
28 auto fileType = std::shared_ptr<Type>(Type::buildTypeFromString(file).release());
29 auto readType = std::shared_ptr<Type>(Type::buildTypeFromString(read).release());
30
31 if (!can) {
32 EXPECT_THROW(SchemaEvolution(readType, fileType.get()), SchemaEvolutionError)
33 << "fileType: " << fileType->toString() << "\nreadType: " << readType->toString();
34 } else {
35 // if can convert, check that there are no excepted be thrown and
36 // we can create reader successfully
37 SchemaEvolution se(readType, fileType.get());
38 EXPECT_FALSE(se.needConvert(*fileType));
39 EXPECT_EQ(need, se.needConvert(*fileType->getSubtype(0)))
40 << "fileType: " << fileType->toString() << "\nreadType: " << readType->toString();
41 MockStripeStreams streams;
42 std::vector<bool> selectedColumns(2);
43 EXPECT_CALL(streams, getSelectedColumns()).WillRepeatedly(testing::Return(selectedColumns));
44 proto::ColumnEncoding directEncoding;
45 directEncoding.set_kind(proto::ColumnEncoding_Kind_DIRECT);
46 EXPECT_CALL(streams, getEncoding(testing::_)).WillRepeatedly(testing::Return(directEncoding));
47
48 std::string dummyStream("dummy");
49 EXPECT_CALL(streams, getStreamProxy(testing::_, testing::_, testing::_))
50 .WillRepeatedly(testing::ReturnNew<SeekableArrayInputStream>(dummyStream.c_str(),
51 dummyStream.length()));
52
53 EXPECT_CALL(streams, isDecimalAsLong()).WillRepeatedly(testing::Return(false));
54 EXPECT_CALL(streams, getSchemaEvolution()).WillRepeatedly(testing::Return(&se));
55 EXPECT_CALL(streams, getSelectedColumns())
56 .WillRepeatedly(testing::Return(std::vector<bool>{true, true}));
57
58 EXPECT_TRUE(buildReader(*fileType, streams, true) != nullptr);
59 }
60 return true;
61 }
62
63 TEST(SchemaEvolution, createConvertReader) {
64 std::map<size_t, std::string> types = {

Callers 1

TESTFunction · 0.85

Calls 7

buildReaderFunction · 0.85
needConvertMethod · 0.80
getSubtypeMethod · 0.80
lengthMethod · 0.80
SchemaEvolutionClass · 0.50
getMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected