Skip to content

Commit

Permalink
Fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
acvictor committed Apr 12, 2024
1 parent d5ebf03 commit cda6f24
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 16 deletions.
13 changes: 8 additions & 5 deletions velox/connectors/hive/FileHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,15 @@ std::shared_ptr<FileHandle> FileHandleGenerator::operator()(
MicrosecondTimer timer(&elapsedTimeUs);
fileHandle = std::make_shared<FileHandle>();
filesystems::FileOptions options;
options.fileSize = std::get<1>(fileProperties) == -1 ? std::nullopt
: std::optional<int64_t>{std::get<1>(fileProperties)};
fileHandle->file = filesystems::getFileSystem(std::get<0>(fileProperties), properties_)
->openFileForRead(std::get<0>(fileProperties), options);
options.fileSize = std::get<1>(fileProperties) == -1
? std::nullopt
: std::optional<int64_t>{std::get<1>(fileProperties)};
fileHandle->file =
filesystems::getFileSystem(std::get<0>(fileProperties), properties_)
->openFileForRead(std::get<0>(fileProperties), options);
fileHandle->uuid = StringIdLease(fileIds(), std::get<0>(fileProperties));
fileHandle->groupId = StringIdLease(fileIds(), groupName(std::get<0>(fileProperties)));
fileHandle->groupId =
StringIdLease(fileIds(), groupName(std::get<0>(fileProperties)));
VLOG(1) << "Generating file handle for: " << std::get<0>(fileProperties);
}
RECORD_HISTOGRAM_METRIC_VALUE(
Expand Down
5 changes: 3 additions & 2 deletions velox/connectors/hive/FileHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ struct FileHandle {
// first diff we'll not include the map.
};

using FileHandleCache = SimpleLRUCache<std::tuple<std::string, int64_t, int64_t>, FileHandle>;
using FileHandleCache =
SimpleLRUCache<std::tuple<std::string, int64_t, int64_t>, FileHandle>;

// Creates FileHandles via the Generator interface the CachedFactory requires.
class FileHandleGenerator {
Expand All @@ -63,7 +64,7 @@ class FileHandleGenerator {
FileHandleGenerator(std::shared_ptr<const Config> properties)
: properties_(std::move(properties)) {}
std::shared_ptr<FileHandle> operator()(
std::tuple<std::string, int64_t, int64_t> params);
std::tuple<std::string, int64_t, int64_t> params);

private:
const std::shared_ptr<const Config> properties_;
Expand Down
5 changes: 3 additions & 2 deletions velox/connectors/hive/HiveConnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ HiveConnector::HiveConnector(
hiveConfig_(std::make_shared<HiveConfig>(config)),
fileHandleFactory_(
hiveConfig_->isFileHandleCacheEnabled()
? std::make_unique<
SimpleLRUCache<std::tuple<std::string, int64_t, int64_t>, std::shared_ptr<FileHandle>>>(
? std::make_unique<SimpleLRUCache<
std::tuple<std::string, int64_t, int64_t>,
std::shared_ptr<FileHandle>>>(
hiveConfig_->numCacheFileHandles())
: nullptr,
std::make_unique<FileHandleGenerator>(config)),
Expand Down
8 changes: 6 additions & 2 deletions velox/connectors/hive/SplitReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,12 @@ void SplitReader::createReader() {

std::shared_ptr<FileHandle> fileHandle;
try {
fileHandle = fileHandleFactory_->generate(std::make_tuple(
hiveSplit_->filePath, hiveSplit_->fileSize, hiveSplit_->modificationTime)).second;
fileHandle = fileHandleFactory_
->generate(std::make_tuple(
hiveSplit_->filePath,
hiveSplit_->fileSize,
hiveSplit_->modificationTime))
.second;
} catch (const VeloxRuntimeError& e) {
if (e.errorCode() == error_code::kFileNotFound &&
hiveConfig_->ignoreMissingFiles(
Expand Down
3 changes: 2 additions & 1 deletion velox/connectors/hive/iceberg/PositionalDeleteFileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ PositionalDeleteFileReader::PositionalDeleteFileReader(
deleteSplit_);

auto deleteFileHandle =
fileHandleFactory_->generate(make_tuple(deleteFile_.filePath, -1, -1)).second;
fileHandleFactory_->generate(make_tuple(deleteFile_.filePath, -1, -1))
.second;
auto deleteFileInput = createBufferedInput(
*deleteFileHandle,
deleteReaderOpts,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ TEST_F(S3FileSystemRegistrationTest, fileHandle) {
}
auto hiveConfig = minioServer_->hiveConfig();
FileHandleFactory factory(
std::make_unique<
SimpleLRUCache<std::tuple<std::string, int64_t, int64_t>, std::shared_ptr<FileHandle>>>(1000),
std::make_unique<SimpleLRUCache<
std::tuple<std::string, int64_t, int64_t>,
std::shared_ptr<FileHandle>>>(1000),
std::make_unique<FileHandleGenerator>(hiveConfig));
auto fileHandle = factory.generate(s3File).second;
readData(fileHandle->file.get());
Expand Down
5 changes: 3 additions & 2 deletions velox/connectors/hive/tests/FileHandleTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ TEST(FileHandleTest, localFile) {
}

FileHandleFactory factory(
std::make_unique<
SimpleLRUCache<std::tuple<std::string, int64_t, int64_t>, std::shared_ptr<FileHandle>>>(1000),
std::make_unique<SimpleLRUCache<
std::tuple<std::string, int64_t, int64_t>,
std::shared_ptr<FileHandle>>>(1000),
std::make_unique<FileHandleGenerator>());
auto fileHandle = factory.generate(std::make_tuple(filename, -1, -1)).second;
ASSERT_EQ(fileHandle->file->size(), 3);
Expand Down

0 comments on commit cda6f24

Please sign in to comment.