Skip to content

Commit 5f54aee

Browse files
author
Omar Marzouk
committed
Linting
1 parent eb90e69 commit 5f54aee

File tree

3 files changed

+162
-160
lines changed

3 files changed

+162
-160
lines changed

tensorflow_io/core/filesystems/dfs/dfs_filesystem.cc

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ namespace dfs {
1313
namespace tf_random_access_file {
1414
typedef struct DFSRandomAccessFile {
1515
std::string dfs_path;
16-
DFS *daos;
16+
DFS* daos;
1717
dfs_t* daos_fs;
1818
dfs_obj_t* daos_file;
1919
std::vector<ReadBuffer> buffers;
2020
daos_size_t file_size;
2121
bool caching;
2222
size_t buff_size;
2323
size_t num_of_buffers;
24-
DFSRandomAccessFile(std::string aDfs_path, DFS *daos, dfs_t* file_system,
24+
DFSRandomAccessFile(std::string aDfs_path, DFS* daos, dfs_t* file_system,
2525
dfs_obj_t* obj, daos_handle_t eq_handle)
2626
: dfs_path(std::move(aDfs_path)), daos(daos) {
2727
daos_fs = file_system;
@@ -152,13 +152,13 @@ int64_t Read(const TF_RandomAccessFile* file, uint64_t offset, size_t n,
152152
namespace tf_writable_file {
153153
typedef struct DFSWritableFile {
154154
std::string dfs_path;
155-
DFS *daos;
155+
DFS* daos;
156156
dfs_t* daos_fs;
157157
dfs_obj_t* daos_file;
158158
daos_size_t file_size;
159159
bool size_known;
160160

161-
DFSWritableFile(std::string dfs_path, DFS *daos, dfs_t* file_system,
161+
DFSWritableFile(std::string dfs_path, DFS* daos, dfs_t* file_system,
162162
dfs_obj_t* obj)
163163
: dfs_path(std::move(dfs_path)), daos(daos) {
164164
daos_fs = file_system;
@@ -211,9 +211,8 @@ void Append(const TF_WritableFile* file, const char* buffer, size_t n,
211211
return;
212212
}
213213

214-
rc = dfs_file->daos->libdfs->dfs_write(dfs_file->daos_fs,
215-
dfs_file->daos_file, &wsgl,
216-
cur_file_size, NULL);
214+
rc = dfs_file->daos->libdfs->dfs_write(dfs_file->daos_fs, dfs_file->daos_file,
215+
&wsgl, cur_file_size, NULL);
217216
if (rc) {
218217
TF_SetStatus(status, TF_RESOURCE_EXHAUSTED, "");
219218
dfs_file->unset_file_size();

tensorflow_io/core/filesystems/dfs/dfs_utils.cc

Lines changed: 93 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33

44
std::unordered_map<std::string, daos_size_t> DFS::size_map;
55

6-
#include "absl/strings/str_cat.h"
7-
#include "absl/synchronization/mutex.h"
86
#include <dlfcn.h>
97
#include <stdio.h>
8+
9+
#include "absl/strings/str_cat.h"
10+
#include "absl/synchronization/mutex.h"
1011
#undef NDEBUG
1112
#include <cassert>
1213

@@ -592,7 +593,7 @@ int DFS::DisconnectContainer(std::string pool_string, std::string cont_string) {
592593
return rc;
593594
}
594595

595-
ReadBuffer::ReadBuffer(size_t aId, DFS *daos, daos_handle_t aEqh, size_t size)
596+
ReadBuffer::ReadBuffer(size_t aId, DFS* daos, daos_handle_t aEqh, size_t size)
596597
: id(aId), daos(daos), buffer_size(size), eqh(aEqh) {
597598
buffer = new char[size];
598599
buffer_offset = ULONG_MAX;
@@ -651,9 +652,8 @@ int ReadBuffer::ReadAsync(dfs_t* daos_fs, dfs_obj_t* file, const size_t off,
651652
assert(rc == 0);
652653
rc = daos->libdfs->daos_event_init(event, eqh, nullptr);
653654
assert(rc == 0);
654-
event->ev_error =
655-
daos->libdfs->dfs_read(daos_fs, file, &rsgl, buffer_offset, &read_size,
656-
event);
655+
event->ev_error = daos->libdfs->dfs_read(daos_fs, file, &rsgl, buffer_offset,
656+
&read_size, event);
657657
return 0;
658658
}
659659

@@ -691,51 +691,49 @@ int64_t ReadBuffer::CopyFromCache(char* ret, const size_t ret_offset,
691691
return static_cast<int64_t>(aRead_size);
692692
}
693693

694-
static void*
695-
LoadSharedLibrary(const char* library_filename, TF_Status* status)
696-
{
697-
std::string full_path;
698-
char* libdir;
699-
void* handle;
700-
701-
if ((libdir = std::getenv("TF_IO_DAOS_LIBRARY_DIR")) != nullptr) {
702-
full_path = libdir;
703-
if (full_path.back() != '/') full_path.push_back('/');
704-
full_path.append(library_filename);
705-
handle = dlopen(full_path.c_str(), RTLD_NOW | RTLD_LOCAL);
706-
if (handle != nullptr) {
707-
TF_SetStatus(status, TF_OK, "");
708-
return handle;
709-
}
710-
}
694+
static void* LoadSharedLibrary(const char* library_filename,
695+
TF_Status* status) {
696+
std::string full_path;
697+
char* libdir;
698+
void* handle;
711699

712-
// Check for the library in the installation location used by rpms.
713-
full_path = "/usr/lib64/";
714-
full_path += library_filename;
700+
if ((libdir = std::getenv("TF_IO_DAOS_LIBRARY_DIR")) != nullptr) {
701+
full_path = libdir;
702+
if (full_path.back() != '/') full_path.push_back('/');
703+
full_path.append(library_filename);
715704
handle = dlopen(full_path.c_str(), RTLD_NOW | RTLD_LOCAL);
716705
if (handle != nullptr) {
717-
TF_SetStatus(status, TF_OK, "");
718-
return handle;
706+
TF_SetStatus(status, TF_OK, "");
707+
return handle;
719708
}
709+
}
720710

721-
// Check for the library in the location used when building DAOS fom source.
722-
full_path = "/opt/daos/lib64/";
723-
full_path += library_filename;
724-
handle = dlopen(full_path.c_str(), RTLD_NOW | RTLD_LOCAL);
725-
if (handle != nullptr) {
726-
TF_SetStatus(status, TF_OK, "");
727-
return handle;
728-
}
711+
// Check for the library in the installation location used by rpms.
712+
full_path = "/usr/lib64/";
713+
full_path += library_filename;
714+
handle = dlopen(full_path.c_str(), RTLD_NOW | RTLD_LOCAL);
715+
if (handle != nullptr) {
716+
TF_SetStatus(status, TF_OK, "");
717+
return handle;
718+
}
729719

730-
std::string error_message =
731-
absl::StrCat("Library (", library_filename, ") not found: ", dlerror());
732-
TF_SetStatus(status, TF_NOT_FOUND, error_message.c_str());
733-
return nullptr;
720+
// Check for the library in the location used when building DAOS fom source.
721+
full_path = "/opt/daos/lib64/";
722+
full_path += library_filename;
723+
handle = dlopen(full_path.c_str(), RTLD_NOW | RTLD_LOCAL);
724+
if (handle != nullptr) {
725+
TF_SetStatus(status, TF_OK, "");
726+
return handle;
727+
}
728+
729+
std::string error_message =
730+
absl::StrCat("Library (", library_filename, ") not found: ", dlerror());
731+
TF_SetStatus(status, TF_NOT_FOUND, error_message.c_str());
732+
return nullptr;
734733
}
735734

736-
static void*
737-
GetSymbolFromLibrary(void* handle, const char* symbol_name, TF_Status* status)
738-
{
735+
static void* GetSymbolFromLibrary(void* handle, const char* symbol_name,
736+
TF_Status* status) {
739737
if (handle == nullptr) {
740738
TF_SetStatus(status, TF_INVALID_ARGUMENT, "library handle cannot be null");
741739
return nullptr;
@@ -759,70 +757,67 @@ void BindFunc(void* handle, const char* name, std::function<R(Args...)>* func,
759757
GetSymbolFromLibrary(handle, name, status));
760758
}
761759

762-
libDFS::
763-
~libDFS()
764-
{
765-
if (libdaos_handle_ != nullptr) {
766-
dlclose(libdaos_handle_);
767-
}
768-
if (libdfs_handle_ != nullptr) {
769-
dlclose(libdfs_handle_);
770-
}
771-
if (libduns_handle_ != nullptr) {
772-
dlclose(libduns_handle_);
773-
}
760+
libDFS::~libDFS() {
761+
if (libdaos_handle_ != nullptr) {
762+
dlclose(libdaos_handle_);
763+
}
764+
if (libdfs_handle_ != nullptr) {
765+
dlclose(libdfs_handle_);
766+
}
767+
if (libduns_handle_ != nullptr) {
768+
dlclose(libduns_handle_);
769+
}
774770
}
775771

776-
void libDFS::LoadAndBindDaosLibs(TF_Status* status)
777-
{
778-
#define LOAD_DFS_LIBRARY(handle, library_filename, status) \
779-
do { \
780-
handle = LoadSharedLibrary(library_filename, status); \
781-
if (TF_GetCode(status) != TF_OK) return; \
772+
void libDFS::LoadAndBindDaosLibs(TF_Status* status) {
773+
#define LOAD_DFS_LIBRARY(handle, library_filename, status) \
774+
do { \
775+
handle = LoadSharedLibrary(library_filename, status); \
776+
if (TF_GetCode(status) != TF_OK) return; \
782777
} while (0);
783778

784-
LOAD_DFS_LIBRARY(libdaos_handle_, "libdaos.so", status);
785-
LOAD_DFS_LIBRARY(libdfs_handle_, "libdfs.so", status);
786-
LOAD_DFS_LIBRARY(libduns_handle_, "libduns.so", status);
779+
LOAD_DFS_LIBRARY(libdaos_handle_, "libdaos.so", status);
780+
LOAD_DFS_LIBRARY(libdfs_handle_, "libdfs.so", status);
781+
LOAD_DFS_LIBRARY(libduns_handle_, "libduns.so", status);
787782

788783
#undef LOAD_DFS_LIBRARY
789784

790-
#define BIND_DFS_FUNC(handle, function) \
791-
do { \
792-
BindFunc(handle, #function, &function, status); \
793-
if (TF_GetCode(status) != TF_OK) return; \
785+
#define BIND_DFS_FUNC(handle, function) \
786+
do { \
787+
BindFunc(handle, #function, &function, status); \
788+
if (TF_GetCode(status) != TF_OK) return; \
794789
} while (0);
795790

796-
BIND_DFS_FUNC(libdaos_handle_, daos_cont_close);
797-
BIND_DFS_FUNC(libdaos_handle_, daos_cont_open2);
798-
BIND_DFS_FUNC(libdaos_handle_, daos_cont_query);
799-
BIND_DFS_FUNC(libdaos_handle_, daos_event_init);
800-
BIND_DFS_FUNC(libdaos_handle_, daos_event_fini);
801-
BIND_DFS_FUNC(libdaos_handle_, daos_event_test);
802-
BIND_DFS_FUNC(libdaos_handle_, daos_eq_create);
803-
BIND_DFS_FUNC(libdaos_handle_, daos_eq_destroy);
804-
BIND_DFS_FUNC(libdaos_handle_, daos_fini);
805-
BIND_DFS_FUNC(libdaos_handle_, daos_init);
806-
BIND_DFS_FUNC(libdaos_handle_, daos_pool_connect2);
807-
BIND_DFS_FUNC(libdaos_handle_, daos_pool_disconnect);
808-
BIND_DFS_FUNC(libdaos_handle_, daos_pool_query);
809-
810-
BIND_DFS_FUNC(libdfs_handle_, dfs_cont_create_with_label);
811-
BIND_DFS_FUNC(libdfs_handle_, dfs_get_size);
812-
BIND_DFS_FUNC(libdfs_handle_, dfs_mkdir);
813-
BIND_DFS_FUNC(libdfs_handle_, dfs_mount);
814-
BIND_DFS_FUNC(libdfs_handle_, dfs_move);
815-
BIND_DFS_FUNC(libdfs_handle_, dfs_open);
816-
BIND_DFS_FUNC(libdfs_handle_, dfs_ostat);
817-
BIND_DFS_FUNC(libdfs_handle_, dfs_read);
818-
BIND_DFS_FUNC(libdfs_handle_, dfs_readdir);
819-
BIND_DFS_FUNC(libdfs_handle_, dfs_release);
820-
BIND_DFS_FUNC(libdfs_handle_, dfs_remove);
821-
BIND_DFS_FUNC(libdfs_handle_, dfs_umount);
822-
BIND_DFS_FUNC(libdfs_handle_, dfs_write);
823-
824-
BIND_DFS_FUNC(libduns_handle_, duns_destroy_attr);
825-
BIND_DFS_FUNC(libduns_handle_, duns_resolve_path);
791+
BIND_DFS_FUNC(libdaos_handle_, daos_cont_close);
792+
BIND_DFS_FUNC(libdaos_handle_, daos_cont_open2);
793+
BIND_DFS_FUNC(libdaos_handle_, daos_cont_query);
794+
BIND_DFS_FUNC(libdaos_handle_, daos_event_init);
795+
BIND_DFS_FUNC(libdaos_handle_, daos_event_fini);
796+
BIND_DFS_FUNC(libdaos_handle_, daos_event_test);
797+
BIND_DFS_FUNC(libdaos_handle_, daos_eq_create);
798+
BIND_DFS_FUNC(libdaos_handle_, daos_eq_destroy);
799+
BIND_DFS_FUNC(libdaos_handle_, daos_fini);
800+
BIND_DFS_FUNC(libdaos_handle_, daos_init);
801+
BIND_DFS_FUNC(libdaos_handle_, daos_pool_connect2);
802+
BIND_DFS_FUNC(libdaos_handle_, daos_pool_disconnect);
803+
BIND_DFS_FUNC(libdaos_handle_, daos_pool_query);
804+
805+
BIND_DFS_FUNC(libdfs_handle_, dfs_cont_create_with_label);
806+
BIND_DFS_FUNC(libdfs_handle_, dfs_get_size);
807+
BIND_DFS_FUNC(libdfs_handle_, dfs_mkdir);
808+
BIND_DFS_FUNC(libdfs_handle_, dfs_mount);
809+
BIND_DFS_FUNC(libdfs_handle_, dfs_move);
810+
BIND_DFS_FUNC(libdfs_handle_, dfs_open);
811+
BIND_DFS_FUNC(libdfs_handle_, dfs_ostat);
812+
BIND_DFS_FUNC(libdfs_handle_, dfs_read);
813+
BIND_DFS_FUNC(libdfs_handle_, dfs_readdir);
814+
BIND_DFS_FUNC(libdfs_handle_, dfs_release);
815+
BIND_DFS_FUNC(libdfs_handle_, dfs_remove);
816+
BIND_DFS_FUNC(libdfs_handle_, dfs_umount);
817+
BIND_DFS_FUNC(libdfs_handle_, dfs_write);
818+
819+
BIND_DFS_FUNC(libduns_handle_, duns_destroy_attr);
820+
BIND_DFS_FUNC(libduns_handle_, duns_resolve_path);
826821

827822
#undef BIND_DFS_FUNC
828823
}

0 commit comments

Comments
 (0)