|
16 | 16 |
|
17 | 17 | #include <gmock/gmock.h> |
18 | 18 | #include <gtest/gtest.h> |
| 19 | +#include "velox/common/base/tests/GTestUtils.h" |
| 20 | +#include "velox/connectors/hive/BufferedInputBuilder.h" |
19 | 21 | #include "velox/dwio/common/BufferedInput.h" |
20 | 22 |
|
21 | 23 | using namespace facebook::velox::dwio::common; |
@@ -144,7 +146,6 @@ class TestBufferedInput : public testing::Test { |
144 | 146 |
|
145 | 147 | const std::shared_ptr<MemoryPool> pool_ = memoryManager()->addLeafPool(); |
146 | 148 | }; |
147 | | -} // namespace |
148 | 149 |
|
149 | 150 | TEST_F(TestBufferedInput, ZeroLengthStream) { |
150 | 151 | auto readFile = |
@@ -391,3 +392,45 @@ TEST_F(TestBufferedInput, VReadSortingWithLabels) { |
391 | 392 | EXPECT_EQ(next.value(), r.second); |
392 | 393 | } |
393 | 394 | } |
| 395 | + |
| 396 | +class CustomBufferedInputBuilder |
| 397 | + : public facebook::velox::connector::hive::BufferedInputBuilder { |
| 398 | + public: |
| 399 | + std::unique_ptr<facebook::velox::dwio::common::BufferedInput> create( |
| 400 | + const facebook::velox::FileHandle& fileHandle, |
| 401 | + const facebook::velox::dwio::common::ReaderOptions& readerOpts, |
| 402 | + const facebook::velox::connector::ConnectorQueryCtx* connectorQueryCtx, |
| 403 | + std::shared_ptr<facebook::velox::io::IoStatistics> ioStats, |
| 404 | + std::shared_ptr<facebook::velox::filesystems::File::IoStats> fsStats, |
| 405 | + folly::Executor* executor, |
| 406 | + const folly::F14FastMap<std::string, std::string>& fileReadOps = {}) |
| 407 | + override { |
| 408 | + VELOX_NYI("Not implemented in CustomBufferedInputBuilder"); |
| 409 | + } |
| 410 | +}; |
| 411 | + |
| 412 | +class CustomBufferedInputTest : public testing::Test { |
| 413 | + protected: |
| 414 | + static void SetUpTestCase() { |
| 415 | + MemoryManager::testingSetInstance(MemoryManager::Options{}); |
| 416 | + facebook::velox::connector::hive::BufferedInputBuilder::registerBuilder( |
| 417 | + std::make_shared<CustomBufferedInputBuilder>()); |
| 418 | + } |
| 419 | + |
| 420 | + const std::shared_ptr<MemoryPool> pool_ = memoryManager()->addLeafPool(); |
| 421 | +}; |
| 422 | + |
| 423 | +} // namespace |
| 424 | + |
| 425 | +TEST_F(CustomBufferedInputTest, basic) { |
| 426 | + facebook::velox::FileHandle fileHandle; |
| 427 | + facebook::velox::dwio::common::ReaderOptions readerOpts(pool_.get()); |
| 428 | + auto ioStats = std::make_shared<facebook::velox::io::IoStatistics>(); |
| 429 | + auto fsStats = |
| 430 | + std::make_shared<facebook::velox::filesystems::File::IoStats>(); |
| 431 | + |
| 432 | + VELOX_ASSERT_THROW( |
| 433 | + facebook::velox::connector::hive::BufferedInputBuilder::getInstance() |
| 434 | + ->create(fileHandle, readerOpts, nullptr, ioStats, fsStats, nullptr), |
| 435 | + "Not implemented in CustomBufferedInputBuilder"); |
| 436 | +} |
0 commit comments