Skip to content
Open
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
24 changes: 14 additions & 10 deletions cpp/velox/compute/VeloxPlanConverter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,31 @@ std::shared_ptr<SplitInfo> parseScanSplitInfo(
using SubstraitFileFormatCase = ::substrait::ReadRel_LocalFiles_FileOrFiles::FileFormatCase;

auto splitInfo = std::make_shared<SplitInfo>();
splitInfo->paths.reserve(fileList.size());
splitInfo->starts.reserve(fileList.size());
splitInfo->lengths.reserve(fileList.size());
splitInfo->partitionColumns.reserve(fileList.size());
splitInfo->properties.reserve(fileList.size());
splitInfo->metadataColumns.reserve(fileList.size());
const size_t fileCount = fileList.size();

splitInfo->paths.reserve(fileCount);
splitInfo->starts.reserve(fileCount);
splitInfo->lengths.reserve(fileCount);
splitInfo->partitionColumns.reserve(fileCount);
splitInfo->properties.reserve(fileCount);
splitInfo->metadataColumns.reserve(fileCount);
for (const auto& file : fileList) {
// Expect all Partitions share the same index.
splitInfo->partitionIndex = file.partition_index();

std::unordered_map<std::string, std::string> partitionColumnMap;
partitionColumnMap.reserve(file.partition_columns_size());
for (const auto& partitionColumn : file.partition_columns()) {
partitionColumnMap[partitionColumn.key()] = partitionColumn.value();
partitionColumnMap.emplace(partitionColumn.key(), partitionColumn.value());
}
splitInfo->partitionColumns.emplace_back(partitionColumnMap);
splitInfo->partitionColumns.emplace_back(std::move(partitionColumnMap));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check if the partitionColumnMap isEmpty first

Copy link
Contributor Author

@beliefer beliefer Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::move is safe here even if partitionColumnMap is empty.
emplace_back could accept the empty partitionColumnMap.

The overhead of std::move is very small and check if the partitionColumnMap isEmpty brings extra overhead.

I will change the code as you said if you insist. :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the interface, if the table is not a partitioned table, we should not set the field, I miss an issue before, #10622

Copy link
Contributor Author

@beliefer beliefer Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happened if we set the field with empty partitionColumnMap?


std::unordered_map<std::string, std::string> metadataColumnMap;
metadataColumnMap.reserve(file.metadata_columns_size());
for (const auto& metadataColumn : file.metadata_columns()) {
metadataColumnMap[metadataColumn.key()] = metadataColumn.value();
metadataColumnMap.emplace(metadataColumn.key(), metadataColumn.value());
}
splitInfo->metadataColumns.emplace_back(metadataColumnMap);
splitInfo->metadataColumns.emplace_back(std::move(metadataColumnMap));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto


splitInfo->paths.emplace_back(file.uri_file());
splitInfo->starts.emplace_back(file.start());
Expand Down