Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(parquet): Add support for weak functions to register parquet readers and writers #11882

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions velox/dwio/parquet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ if(VELOX_ENABLE_PARQUET)
endif()
endif()

velox_add_library(velox_dwio_parquet_reader RegisterParquetReader.cpp)
velox_add_library(velox_dwio_parquet_writer RegisterParquetWriter.cpp)
velox_add_library(velox_dwio_parquet_reader RegisterParquetReaderImpl.cpp)
velox_add_library(velox_dwio_parquet_writer RegisterParquetWriterImpl.cpp)

if(VELOX_ENABLE_PARQUET)
velox_link_libraries(velox_dwio_parquet_reader
Expand Down
16 changes: 2 additions & 14 deletions velox/dwio/parquet/RegisterParquetReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,10 @@
* limitations under the License.
*/

#ifdef VELOX_ENABLE_PARQUET
#include "velox/dwio/parquet/reader/ParquetReader.h" // @manual
#endif

namespace facebook::velox::parquet {

void registerParquetReaderFactory() {
#ifdef VELOX_ENABLE_PARQUET
dwio::common::registerReaderFactory(std::make_shared<ParquetReaderFactory>());
#endif
}
void registerParquetReaderFactory() {}

void unregisterParquetReaderFactory() {
#ifdef VELOX_ENABLE_PARQUET
dwio::common::unregisterReaderFactory(dwio::common::FileFormat::PARQUET);
#endif
}
void unregisterParquetReaderFactory() {}

} // namespace facebook::velox::parquet
6 changes: 4 additions & 2 deletions velox/dwio/parquet/RegisterParquetReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@

namespace facebook::velox::parquet {

void registerParquetReaderFactory();
/// Registers the Parquet reader factory.
/// Has the weak attribute so that it can be overridden by a custom factory.
__attribute__((__weak__)) void registerParquetReaderFactory();

void unregisterParquetReaderFactory();
__attribute__((__weak__)) void unregisterParquetReaderFactory();

} // namespace facebook::velox::parquet
31 changes: 31 additions & 0 deletions velox/dwio/parquet/RegisterParquetReaderImpl.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// This file invokes the Parquet Reader

#include "velox/dwio/parquet/reader/ParquetReader.h"

namespace facebook::velox::parquet {

void registerParquetReaderFactory() {
dwio::common::registerReaderFactory(std::make_shared<ParquetReaderFactory>());
}

void unregisterParquetReaderFactory() {
dwio::common::unregisterReaderFactory(dwio::common::FileFormat::PARQUET);
}

} // namespace facebook::velox::parquet
16 changes: 2 additions & 14 deletions velox/dwio/parquet/RegisterParquetWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,10 @@
* limitations under the License.
*/

#ifdef VELOX_ENABLE_PARQUET
#include "velox/dwio/parquet/writer/Writer.h" // @manual
#endif

namespace facebook::velox::parquet {

void registerParquetWriterFactory() {
#ifdef VELOX_ENABLE_PARQUET
dwio::common::registerWriterFactory(std::make_shared<ParquetWriterFactory>());
#endif
}
void registerParquetWriterFactory() {}

void unregisterParquetWriterFactory() {
#ifdef VELOX_ENABLE_PARQUET
dwio::common::unregisterWriterFactory(dwio::common::FileFormat::PARQUET);
#endif
}
void unregisterParquetWriterFactory() {}

} // namespace facebook::velox::parquet
6 changes: 4 additions & 2 deletions velox/dwio/parquet/RegisterParquetWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@

namespace facebook::velox::parquet {

void registerParquetWriterFactory();
/// Registers the Parquet writer factory.
/// Has the weak attribute so that it can be overridden by a custom factory.
__attribute__((__weak__)) void registerParquetWriterFactory();

void unregisterParquetWriterFactory();
__attribute__((__weak__)) void unregisterParquetWriterFactory();

} // namespace facebook::velox::parquet
29 changes: 29 additions & 0 deletions velox/dwio/parquet/RegisterParquetWriterImpl.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "velox/dwio/parquet/writer/Writer.h"

namespace facebook::velox::parquet {

void registerParquetWriterFactory() {
dwio::common::registerWriterFactory(std::make_shared<ParquetWriterFactory>());
}

void unregisterParquetWriterFactory() {
dwio::common::unregisterWriterFactory(dwio::common::FileFormat::PARQUET);
}

} // namespace facebook::velox::parquet
4 changes: 2 additions & 2 deletions velox/dwio/parquet/tests/reader/ParquetTableScanTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "velox/dwio/common/tests/utils/DataFiles.h" // @manual
#include "velox/dwio/parquet/RegisterParquetReader.h" // @manual
#include "velox/dwio/parquet/reader/PageReader.h" // @manual
#include "velox/dwio/parquet/reader/ParquetReader.h" // @manual=//velox/connectors/hive:velox_hive_connector_parquet
#include "velox/dwio/parquet/reader/ParquetReader.h"
#include "velox/exec/tests/utils/AssertQueryBuilder.h"
#include "velox/exec/tests/utils/HiveConnectorTestBase.h" // @manual
#include "velox/exec/tests/utils/PlanBuilder.h"
Expand All @@ -29,7 +29,7 @@
#include "velox/type/tests/SubfieldFiltersBuilder.h"
#include "velox/type/tz/TimeZoneMap.h"

#include "velox/connectors/hive/HiveConfig.h" // @manual=//velox/connectors/hive:velox_hive_connector_parquet
#include "velox/connectors/hive/HiveConfig.h"
#include "velox/dwio/parquet/writer/Writer.h" // @manual

using namespace facebook::velox;
Expand Down
Loading