Skip to content

Commit

Permalink
ARROW-7515: [C++] Rename nonexistent and non_existent to not_found
Browse files Browse the repository at this point in the history
Closes #6139 from mrkn/ARROW-7515

Lead-authored-by: Kenta Murata <mrkn@mrkn.jp>
Co-authored-by: Sutou Kouhei <kou@clear-code.com>
Signed-off-by: Antoine Pitrou <antoine@python.org>
  • Loading branch information
2 people authored and pitrou committed Mar 23, 2020
1 parent 76198c3 commit c43e235
Show file tree
Hide file tree
Showing 51 changed files with 255 additions and 261 deletions.
26 changes: 13 additions & 13 deletions c_glib/arrow-glib/file-system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ typedef struct GArrowFileSelectorPrivate_ {

enum {
PROP_FILE_SELECTOR_BASE_DIR = 1,
PROP_FILE_SELECTOR_ALLOW_NONEXISTENT,
PROP_FILE_SELECTOR_ALLOW_NOT_FOUND,
PROP_FILE_SELECTOR_RECURSIVE,
PROP_FILE_SELECTOR_MAX_RECURSION
};
Expand Down Expand Up @@ -412,8 +412,8 @@ garrow_file_selector_set_property(GObject *object,
case PROP_FILE_SELECTOR_BASE_DIR:
priv->file_selector.base_dir = g_value_get_string(value);
break;
case PROP_FILE_SELECTOR_ALLOW_NONEXISTENT:
priv->file_selector.allow_non_existent = g_value_get_boolean(value);
case PROP_FILE_SELECTOR_ALLOW_NOT_FOUND:
priv->file_selector.allow_not_found = g_value_get_boolean(value);
break;
case PROP_FILE_SELECTOR_RECURSIVE:
priv->file_selector.recursive = g_value_get_boolean(value);
Expand All @@ -439,8 +439,8 @@ garrow_file_selector_get_property(GObject *object,
case PROP_FILE_SELECTOR_BASE_DIR:
g_value_set_string(value, priv->file_selector.base_dir.c_str());
break;
case PROP_FILE_SELECTOR_ALLOW_NONEXISTENT:
g_value_set_boolean(value, priv->file_selector.allow_non_existent);
case PROP_FILE_SELECTOR_ALLOW_NOT_FOUND:
g_value_set_boolean(value, priv->file_selector.allow_not_found);
break;
case PROP_FILE_SELECTOR_RECURSIVE:
g_value_set_boolean(value, priv->file_selector.recursive);
Expand Down Expand Up @@ -493,20 +493,20 @@ garrow_file_selector_class_init(GArrowFileSelectorClass *klass)
spec);

/**
* GArrowFileSelector:allow-nonexistent:
* GArrowFileSelector:allow-not-found:
*
* The behavior if `base_dir` doesn't exist in the file system.
* The behavior if `base_dir` isn't found in the file system.
* If false, an error is returned. If true, an empty selection is returned.
*
* Since: 1.0.0
*/
spec = g_param_spec_boolean("allow-nonexistent",
"Allow nonexistent",
"The behavior if `base_dir` doesn't exist in the file system",
file_selector.allow_non_existent,
spec = g_param_spec_boolean("allow-not-found",
"Allow not found",
"The behavior if `base_dir` isn't found in the file system",
file_selector.allow_not_found,
static_cast<GParamFlags>(G_PARAM_READWRITE));
g_object_class_install_property(gobject_class,
PROP_FILE_SELECTOR_ALLOW_NONEXISTENT,
PROP_FILE_SELECTOR_ALLOW_NOT_FOUND,
spec);

/**
Expand Down Expand Up @@ -645,7 +645,7 @@ garrow_file_system_get_type_name(GArrowFileSystem *file_system)
*
* Any symlink is automatically dereferenced, recursively.
* A non-existing or unreachable file returns an OK status and has
* a #GArrowFileType of value %GARROW_FILE_TYPE_NONEXISTENT.
* a #GArrowFileType of value %GARROW_FILE_TYPE_NOT_FOUND.
* An error status indicates a truly exceptional condition
* (low-level I/O error, etc.).
*
Expand Down
4 changes: 2 additions & 2 deletions c_glib/arrow-glib/file-system.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ typedef gint64 GArrowTimePoint;

/**
* GArrowFileType
* @GARROW_FILE_TYPE_NONEXISTENT: Entry does not exist
* @GARROW_FILE_TYPE_NOT_FOUND: Entry is not found
* @GARROW_FILE_TYPE_UNKNOWN: Entry exists but its type is unknown
* @GARROW_FILE_TYPE_FILE: Entry is a regular file
* @GARROW_FILE_TYPE_DIR: Entry is a directory
Expand All @@ -44,7 +44,7 @@ typedef gint64 GArrowTimePoint;
* Since: 1.0.0
*/
typedef enum {
GARROW_FILE_TYPE_NONEXISTENT,
GARROW_FILE_TYPE_NOT_FOUND,
GARROW_FILE_TYPE_UNKNOWN,
GARROW_FILE_TYPE_FILE,
GARROW_FILE_TYPE_DIR
Expand Down
10 changes: 5 additions & 5 deletions c_glib/test/test-file-selector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ def setup
end
end

sub_test_case("#allow_nonexistent?") do
sub_test_case("#allow_not_found?") do
test("default") do
assert do
not @file_selector.allow_nonexistent?
not @file_selector.allow_not_found?
end
end
end

test("#allow_nonexistent=") do
@file_selector.allow_nonexistent = true
test("#allow_not_found=") do
@file_selector.allow_not_found = true
assert do
@file_selector.allow_nonexistent?
@file_selector.allow_not_found?
end
end

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/array_struct_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void ValidateBasicStructArray(const StructArray* result,
auto char_arr = std::dynamic_pointer_cast<Int8Array>(list_char_arr->values());
auto int32_arr = std::dynamic_pointer_cast<Int32Array>(result->field(1));

ASSERT_EQ(nullptr, result->GetFieldByName("non-existing"));
ASSERT_EQ(nullptr, result->GetFieldByName("nonexistent"));
ASSERT_TRUE(list_char_arr->Equals(result->GetFieldByName("list")));
ASSERT_TRUE(int32_arr->Equals(result->GetFieldByName("int")));

Expand Down
6 changes: 3 additions & 3 deletions cpp/src/arrow/filesystem/filesystem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ using internal::ToSlashes;

std::string ToString(FileType ftype) {
switch (ftype) {
case FileType::NonExistent:
return "non-existent";
case FileType::NotFound:
return "not-found";
case FileType::Unknown:
return "unknown";
case FileType::File:
Expand All @@ -75,7 +75,7 @@ ARROW_EXPORT std::ostream& operator<<(std::ostream& os, FileType ftype) {
break;

switch (ftype) {
FILE_TYPE_CASE(NonExistent)
FILE_TYPE_CASE(NotFound)
FILE_TYPE_CASE(Unknown)
FILE_TYPE_CASE(File)
FILE_TYPE_CASE(Directory)
Expand Down
12 changes: 6 additions & 6 deletions cpp/src/arrow/filesystem/filesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ using TimePoint =

/// \brief FileSystem entry type
enum class FileType : int8_t {
/// Entry does not exist
NonExistent,
/// Entry is not found
NotFound,
/// Entry exists but its type is unknown
///
/// This can designate a special file such as a Unix socket or character
Expand Down Expand Up @@ -144,9 +144,9 @@ struct ARROW_EXPORT FileSelector {
/// The directory in which to select files.
/// If the path exists but doesn't point to a directory, this should be an error.
std::string base_dir;
/// The behavior if `base_dir` doesn't exist in the filesystem. If false,
/// The behavior if `base_dir` isn't found in the filesystem. If false,
/// an error is returned. If true, an empty selection is returned.
bool allow_non_existent = false;
bool allow_not_found = false;
/// Whether to recurse into subdirectories.
bool recursive = false;
/// The maximum number of subdirectories to recurse into.
Expand All @@ -171,8 +171,8 @@ class ARROW_EXPORT FileSystem {
/// Get info for the given target.
///
/// Any symlink is automatically dereferenced, recursively.
/// A non-existing or unreachable file returns an Ok status and
/// has a FileType of value NonExistent. An error status indicates
/// A nonexistent or unreachable file returns an Ok status and
/// has a FileType of value NotFound. An error status indicates
/// a truly exceptional condition (low-level I/O error, etc.).
virtual Result<FileInfo> GetTargetInfo(const std::string& path) = 0;
/// Same, for many targets at once.
Expand Down
24 changes: 12 additions & 12 deletions cpp/src/arrow/filesystem/filesystem_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,9 @@ TEST_F(TestMockFS, GetTargetInfosVector) {
ASSERT_EQ(infos.size(), 6);
AssertFileInfo(infos[0], "AB", FileType::Directory, time_);
AssertFileInfo(infos[1], "AB/CD", FileType::Directory, time_);
AssertFileInfo(infos[2], "AB/zz", FileType::NonExistent);
AssertFileInfo(infos[3], "zz", FileType::NonExistent);
AssertFileInfo(infos[4], "XX/zz", FileType::NonExistent);
AssertFileInfo(infos[2], "AB/zz", FileType::NotFound);
AssertFileInfo(infos[3], "zz", FileType::NotFound);
AssertFileInfo(infos[4], "XX/zz", FileType::NotFound);
AssertFileInfo(infos[5], "AB/CD/ef", FileType::File, time_, 9);

// Invalid path
Expand Down Expand Up @@ -544,7 +544,7 @@ TEST_F(TestSubTreeFileSystem, DeleteFile) {
ASSERT_OK(subfs_->DeleteFile("AB/cd"));
CheckFiles({});

ASSERT_RAISES(IOError, subfs_->DeleteFile("non-existent"));
ASSERT_RAISES(IOError, subfs_->DeleteFile("nonexistent"));
ASSERT_RAISES(IOError, subfs_->DeleteFile(""));
}

Expand Down Expand Up @@ -604,7 +604,7 @@ TEST_F(TestSubTreeFileSystem, OpenInputStream) {
AssertBufferEqual(*buffer, "data");
ASSERT_OK(stream->Close());

ASSERT_RAISES(IOError, subfs_->OpenInputStream("non-existent"));
ASSERT_RAISES(IOError, subfs_->OpenInputStream("nonexistent"));
ASSERT_RAISES(IOError, subfs_->OpenInputStream(""));
}

Expand All @@ -617,7 +617,7 @@ TEST_F(TestSubTreeFileSystem, OpenInputFile) {
AssertBufferEqual(*buffer, "data");
ASSERT_OK(stream->Close());

ASSERT_RAISES(IOError, subfs_->OpenInputFile("non-existent"));
ASSERT_RAISES(IOError, subfs_->OpenInputFile("nonexistent"));
ASSERT_RAISES(IOError, subfs_->OpenInputFile(""));
}

Expand All @@ -635,7 +635,7 @@ TEST_F(TestSubTreeFileSystem, OpenOutputStream) {
ASSERT_OK(stream->Close());
CheckFiles({{"sub/tree/AB/cd", time_, "other"}, {"sub/tree/ab", time_, "data"}});

ASSERT_RAISES(IOError, subfs_->OpenOutputStream("non-existent/xxx"));
ASSERT_RAISES(IOError, subfs_->OpenOutputStream("nonexistent/xxx"));
ASSERT_RAISES(IOError, subfs_->OpenOutputStream("AB"));
ASSERT_RAISES(IOError, subfs_->OpenOutputStream(""));
CheckFiles({{"sub/tree/AB/cd", time_, "other"}, {"sub/tree/ab", time_, "data"}});
Expand Down Expand Up @@ -664,7 +664,7 @@ TEST_F(TestSubTreeFileSystem, GetTargetInfo) {
CreateFile("ab", "data");
AssertFileInfo(subfs_.get(), "ab", FileType::File, time_, 4);

AssertFileInfo(subfs_.get(), "non-existent", FileType::NonExistent);
AssertFileInfo(subfs_.get(), "nonexistent", FileType::NotFound);
}

TEST_F(TestSubTreeFileSystem, GetTargetInfosVector) {
Expand All @@ -675,12 +675,12 @@ TEST_F(TestSubTreeFileSystem, GetTargetInfosVector) {
CreateFile("AB/cd", "other data");

ASSERT_OK_AND_ASSIGN(infos,
subfs_->GetTargetInfos({"ab", "AB", "AB/cd", "non-existent"}));
subfs_->GetTargetInfos({"ab", "AB", "AB/cd", "nonexistent"}));
ASSERT_EQ(infos.size(), 4);
AssertFileInfo(infos[0], "ab", FileType::File, time_, 4);
AssertFileInfo(infos[1], "AB", FileType::Directory, time_);
AssertFileInfo(infos[2], "AB/cd", FileType::File, time_, 10);
AssertFileInfo(infos[3], "non-existent", FileType::NonExistent);
AssertFileInfo(infos[3], "nonexistent", FileType::NotFound);
}

TEST_F(TestSubTreeFileSystem, GetTargetInfosSelector) {
Expand Down Expand Up @@ -722,9 +722,9 @@ TEST_F(TestSubTreeFileSystem, GetTargetInfosSelector) {
AssertFileInfo(infos[3], "AB/cd", FileType::File, time_, 5);
AssertFileInfo(infos[4], "ab", FileType::File, time_, 4);

selector.base_dir = "non-existent";
selector.base_dir = "nonexistent";
ASSERT_RAISES(IOError, subfs_->GetTargetInfos(selector));
selector.allow_non_existent = true;
selector.allow_not_found = true;
ASSERT_OK_AND_ASSIGN(infos, subfs_->GetTargetInfos(selector));
ASSERT_EQ(infos.size(), 0);
}
Expand Down
6 changes: 3 additions & 3 deletions cpp/src/arrow/filesystem/hdfs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class HadoopFileSystem::Impl {
auto status = client_->GetPathInfo(path, &path_info);
info.set_path(path);
if (status.IsIOError()) {
info.set_type(FileType::NonExistent);
info.set_type(FileType::NotFound);
return info;
}

Expand All @@ -83,9 +83,9 @@ class HadoopFileSystem::Impl {
std::vector<io::HdfsPathInfo> children;
Status st = client_->ListDirectory(path, &children);
if (!st.ok()) {
if (select.allow_non_existent) {
if (select.allow_not_found) {
ARROW_ASSIGN_OR_RAISE(auto info, GetTargetInfo(path));
if (info.type() == FileType::NonExistent) {
if (info.type() == FileType::NotFound) {
return Status::OK();
}
}
Expand Down
22 changes: 11 additions & 11 deletions cpp/src/arrow/filesystem/hdfs_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class TestHadoopFileSystem : public ::testing::Test {
ASSERT_OK(uri_fs->CreateDir("AB"));
AssertFileInfo(uri_fs.get(), "AB", FileType::Directory);
ASSERT_OK(uri_fs->DeleteDir("AB"));
AssertFileInfo(uri_fs.get(), "AB", FileType::NonExistent);
AssertFileInfo(uri_fs.get(), "AB", FileType::NotFound);
}

void TestGetTargetInfos(const std::string& base_dir) {
Expand Down Expand Up @@ -158,15 +158,15 @@ class TestHadoopFileSystem : public ::testing::Test {
AssertFileInfo(infos[3], base_dir + "AB/data", FileType::File);

selector.base_dir = base_dir + "XYZ";
selector.allow_non_existent = true;
selector.allow_not_found = true;
ASSERT_OK_AND_ASSIGN(infos, fs_->GetTargetInfos(selector));
ASSERT_EQ(infos.size(), 0);

selector.allow_non_existent = false;
selector.allow_not_found = false;
ASSERT_RAISES(IOError, fs_->GetTargetInfos(selector));

ASSERT_OK(fs_->DeleteDir(base_dir + "AB"));
AssertFileInfo(fs_.get(), base_dir + "AB", FileType::NonExistent);
AssertFileInfo(fs_.get(), base_dir + "AB", FileType::NotFound);
}

protected:
Expand All @@ -192,15 +192,15 @@ TEST_F(TestHadoopFileSystem, CreateDirDeleteDir) {
AssertFileInfo(this->fs_.get(), "AB/CD/data", FileType::File, 9);

ASSERT_OK(this->fs_->DeleteDir("AB"));
AssertFileInfo(this->fs_.get(), "AB", FileType::NonExistent);
AssertFileInfo(this->fs_.get(), "AB", FileType::NotFound);

// recursive = false
ASSERT_RAISES(IOError, this->fs_->CreateDir("AB/CD", /*recursive=*/false));
ASSERT_OK(this->fs_->CreateDir("AB", /*recursive=*/false));
ASSERT_OK(this->fs_->CreateDir("AB/CD", /*recursive=*/false));

ASSERT_OK(this->fs_->DeleteDir("AB"));
AssertFileInfo(this->fs_.get(), "AB", FileType::NonExistent);
AssertFileInfo(this->fs_.get(), "AB", FileType::NotFound);
ASSERT_RAISES(IOError, this->fs_->DeleteDir("AB"));
}

Expand All @@ -215,8 +215,8 @@ TEST_F(TestHadoopFileSystem, DeleteDirContents) {

ASSERT_OK(this->fs_->DeleteDirContents("AB"));
AssertFileInfo(this->fs_.get(), "AB", FileType::Directory);
AssertFileInfo(this->fs_.get(), "AB/CD", FileType::NonExistent);
AssertFileInfo(this->fs_.get(), "AB/CD/data", FileType::NonExistent);
AssertFileInfo(this->fs_.get(), "AB/CD", FileType::NotFound);
AssertFileInfo(this->fs_.get(), "AB/CD/data", FileType::NotFound);

ASSERT_OK(this->fs_->DeleteDirContents("AB"));
AssertFileInfo(this->fs_.get(), "AB", FileType::Directory);
Expand Down Expand Up @@ -267,11 +267,11 @@ TEST_F(TestHadoopFileSystem, RelativeVsAbsolutePaths) {

ASSERT_OK(this->fs_->CreateDir("AB"));
AssertFileInfo(this->fs_.get(), "AB", FileType::Directory);
AssertFileInfo(this->fs_.get(), "/AB", FileType::NonExistent);
AssertFileInfo(this->fs_.get(), "/AB", FileType::NotFound);

ASSERT_OK(this->fs_->CreateDir("/CD"));
AssertFileInfo(this->fs_.get(), "/CD", FileType::Directory);
AssertFileInfo(this->fs_.get(), "CD", FileType::NonExistent);
AssertFileInfo(this->fs_.get(), "CD", FileType::NotFound);
}

TEST_F(TestHadoopFileSystem, MoveDir) {
Expand All @@ -287,7 +287,7 @@ TEST_F(TestHadoopFileSystem, MoveDir) {
// move file
ASSERT_OK(this->fs_->Move(directory_name_src, directory_name_dest));
ASSERT_OK_AND_ASSIGN(info, this->fs_->GetTargetInfo(directory_name_src));
ASSERT_TRUE(info.type() == FileType::NonExistent);
ASSERT_TRUE(info.type() == FileType::NotFound);

ASSERT_OK_AND_ASSIGN(info, this->fs_->GetTargetInfo(directory_name_dest));
AssertFileInfo(info, directory_name_dest, FileType::Directory);
Expand Down
Loading

0 comments on commit c43e235

Please sign in to comment.