forked from facebookincubator/velox
    
        
        - 
                Notifications
    
You must be signed in to change notification settings  - Fork 4
 
Iceberg refactor into a separate lakehouse connector #1249
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
          
     Open
      
      
            nmahadevuni
  wants to merge
  3
  commits into
  IBM:oss-main
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
nmahadevuni:iceberg-refactor-naveen-oss-main
  
      
      
   
  
    
  
  
  
 
  
      
    base: oss-main
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Open
                    Changes from 1 commit
      Commits
    
    
  File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # 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. | ||
| 
     | 
||
| #velox_add_library(velox_connector Connector.cpp) | ||
| # | ||
| #velox_link_libraries(velox_connector velox_common_config velox_vector) | ||
| 
     | 
||
| add_subdirectory(storage_adapters) | ||
| add_subdirectory(common) | ||
| add_subdirectory(iceberg) | ||
| 
     | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| # 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. | ||
| 
     | 
||
| #if(${VELOX_BUILD_TESTING}) | ||
                
       | 
||
| # add_subdirectory(tests) | ||
| #elseif(${VELOX_BUILD_TEST_UTILS}) | ||
| # add_subdirectory(tests/utils) | ||
| #endif() | ||
| 
     | 
||
| 
     | 
||
| 
     | 
||
| velox_add_library( | ||
| velox_lakehouse_common | ||
| STATIC | ||
| ConnectorConfigBase.cpp | ||
| DataSourceBase.cpp | ||
| ConnectorSplitBase.cpp | ||
| ConnectorUtil.cpp | ||
| FileHandle.cpp | ||
| SplitReaderBase.cpp | ||
| TableHandleBase.cpp) | ||
| 
     | 
||
| #velox_include_directories(velox_connectors_common PRIVATE ${Protobuf_INCLUDE_DIRS}) | ||
| 
     | 
||
| velox_link_libraries( | ||
| velox_lakehouse_common | ||
| velox_buffer | ||
| velox_caching | ||
| velox_common_io | ||
| velox_common_compression | ||
| velox_common_config | ||
| velox_dwio_common_encryption | ||
| velox_dwio_common_exception | ||
| velox_exception | ||
| velox_expression | ||
| velox_memory | ||
| velox_type_tz | ||
| Boost::regex | ||
| Folly::folly | ||
| glog::glog | ||
| protobuf::libprotobuf) | ||
| 
     | 
||
| if(${VELOX_BUILD_TESTING}) | ||
| add_subdirectory(tests) | ||
| endif() | ||
        
          
          
            153 changes: 153 additions & 0 deletions
          
          153 
        
  velox/connectors/lakehouse/common/ConnectorConfigBase.cpp
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,153 @@ | ||
| /* | ||
| * 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 "ConnectorConfigBase.h" | ||
| 
     | 
||
| #include "velox/common/config/Config.h" | ||
| 
     | 
||
| namespace facebook::velox::connector::lakehouse::common { | ||
| 
     | 
||
| std::string ConnectorConfigBase::gcsEndpoint() const { | ||
| return config_->get<std::string>(kGcsEndpoint, std::string("")); | ||
| } | ||
| 
     | 
||
| std::string ConnectorConfigBase::gcsCredentialsPath() const { | ||
| return config_->get<std::string>(kGcsCredentialsPath, std::string("")); | ||
| } | ||
| 
     | 
||
| std::optional<int> ConnectorConfigBase::gcsMaxRetryCount() const { | ||
| return static_cast<std::optional<int>>(config_->get<int>(kGcsMaxRetryCount)); | ||
| } | ||
| 
     | 
||
| std::optional<std::string> ConnectorConfigBase::gcsMaxRetryTime() const { | ||
| return static_cast<std::optional<std::string>>( | ||
| config_->get<std::string>(kGcsMaxRetryTime)); | ||
| } | ||
| 
     | 
||
| bool ConnectorConfigBase::isOrcUseColumnNames( | ||
| const config::ConfigBase* session) const { | ||
| return session->get<bool>( | ||
| kOrcUseColumnNamesSession, config_->get<bool>(kOrcUseColumnNames, false)); | ||
| } | ||
| 
     | 
||
| bool ConnectorConfigBase::isParquetUseColumnNames( | ||
| const config::ConfigBase* session) const { | ||
| return session->get<bool>( | ||
| kParquetUseColumnNamesSession, | ||
| config_->get<bool>(kParquetUseColumnNames, false)); | ||
| } | ||
| 
     | 
||
| bool ConnectorConfigBase::isFileColumnNamesReadAsLowerCase( | ||
| const config::ConfigBase* session) const { | ||
| return session->get<bool>( | ||
| kFileColumnNamesReadAsLowerCaseSession, | ||
| config_->get<bool>(kFileColumnNamesReadAsLowerCase, false)); | ||
| } | ||
| 
     | 
||
| bool ConnectorConfigBase::isPartitionPathAsLowerCase( | ||
| const config::ConfigBase* session) const { | ||
| return session->get<bool>(kPartitionPathAsLowerCaseSession, true); | ||
| } | ||
| 
     | 
||
| bool ConnectorConfigBase::allowNullPartitionKeys( | ||
| const config::ConfigBase* session) const { | ||
| return session->get<bool>( | ||
| kAllowNullPartitionKeysSession, | ||
| config_->get<bool>(kAllowNullPartitionKeys, true)); | ||
| } | ||
| 
     | 
||
| int64_t ConnectorConfigBase::maxCoalescedBytes( | ||
| const config::ConfigBase* session) const { | ||
| return session->get<int64_t>( | ||
| kMaxCoalescedBytesSession, | ||
| config_->get<int64_t>(kMaxCoalescedBytes, 128 << 20)); // 128MB | ||
| } | ||
| 
     | 
||
| int32_t ConnectorConfigBase::maxCoalescedDistanceBytes( | ||
| const config::ConfigBase* session) const { | ||
| const auto distance = config::toCapacity( | ||
| session->get<std::string>( | ||
| kMaxCoalescedDistanceSession, | ||
| config_->get<std::string>(kMaxCoalescedDistance, "512kB")), | ||
| config::CapacityUnit::BYTE); | ||
| VELOX_USER_CHECK_LE( | ||
| distance, | ||
| std::numeric_limits<int32_t>::max(), | ||
| "The max merge distance to combine read requests must be less than 2GB." | ||
| " Got {} bytes.", | ||
| distance); | ||
| return int32_t(distance); | ||
| } | ||
| 
     | 
||
| int32_t ConnectorConfigBase::prefetchRowGroups() const { | ||
| return config_->get<int32_t>(kPrefetchRowGroups, 1); | ||
| } | ||
| 
     | 
||
| int32_t ConnectorConfigBase::loadQuantum(const config::ConfigBase* session) const { | ||
| return session->get<int32_t>( | ||
| kLoadQuantumSession, config_->get<int32_t>(kLoadQuantum, 8 << 20)); | ||
| } | ||
| 
     | 
||
| int32_t ConnectorConfigBase::numCacheFileHandles() const { | ||
| return config_->get<int32_t>(kNumCacheFileHandles, 20'000); | ||
| } | ||
| 
     | 
||
| uint64_t ConnectorConfigBase::fileHandleExpirationDurationMs() const { | ||
| return config_->get<uint64_t>(kFileHandleExpirationDurationMs, 0); | ||
| } | ||
| 
     | 
||
| bool ConnectorConfigBase::isFileHandleCacheEnabled() const { | ||
| return config_->get<bool>(kEnableFileHandleCache, true); | ||
| } | ||
| 
     | 
||
| std::string ConnectorConfigBase::writeFileCreateConfig() const { | ||
| return config_->get<std::string>(kWriteFileCreateConfig, ""); | ||
| } | ||
| 
     | 
||
| uint64_t ConnectorConfigBase::footerEstimatedSize() const { | ||
| return config_->get<uint64_t>(kFooterEstimatedSize, 256UL << 10); | ||
| } | ||
| 
     | 
||
| uint64_t ConnectorConfigBase::filePreloadThreshold() const { | ||
| return config_->get<uint64_t>(kFilePreloadThreshold, 8UL << 20); | ||
| } | ||
| 
     | 
||
| uint8_t ConnectorConfigBase::readTimestampUnit( | ||
| const config::ConfigBase* session) const { | ||
| const auto unit = session->get<uint8_t>( | ||
| kReadTimestampUnitSession, | ||
| config_->get<uint8_t>(kReadTimestampUnit, 3 /*milli*/)); | ||
| VELOX_CHECK( | ||
| unit == 3 || unit == 6 /*micro*/ || unit == 9 /*nano*/, | ||
| "Invalid timestamp unit."); | ||
| return unit; | ||
| } | ||
| 
     | 
||
| bool ConnectorConfigBase::readTimestampPartitionValueAsLocalTime( | ||
| const config::ConfigBase* session) const { | ||
| return session->get<bool>( | ||
| kReadTimestampPartitionValueAsLocalTimeSession, | ||
| config_->get<bool>(kReadTimestampPartitionValueAsLocalTime, true)); | ||
| } | ||
| 
     | 
||
| bool ConnectorConfigBase::readStatsBasedFilterReorderDisabled( | ||
| const config::ConfigBase* session) const { | ||
| return session->get<bool>( | ||
| kReadStatsBasedFilterReorderDisabledSession, | ||
| config_->get<bool>(kReadStatsBasedFilterReorderDisabled, false)); | ||
| } | ||
| 
     | 
||
| } // namespace facebook::velox::connector::lakehouse::common | 
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the unused lines