You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@quickstep.apache.org by zu...@apache.org on 2016/04/19 18:44:36 UTC

[23/24] incubator-quickstep git commit: Better error messages for failed unix glob. (#174)

Better error messages for failed unix glob. (#174)

Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/19e74ab8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/19e74ab8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/19e74ab8

Branch: refs/heads/master
Commit: 19e74ab84a9bc28fc722c7f3b9ee834ed88cd595
Parents: a5e7d09
Author: Marc S <cr...@users.noreply.github.com>
Authored: Sun Apr 17 23:38:43 2016 -0500
Committer: Jignesh Patel <pa...@users.noreply.github.com>
Committed: Sun Apr 17 23:38:43 2016 -0500

----------------------------------------------------------------------
 relational_operators/TextScanOperator.cpp |  4 ++++
 utility/Glob.cpp                          | 18 ++++++++++++++----
 2 files changed, 18 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/19e74ab8/relational_operators/TextScanOperator.cpp
----------------------------------------------------------------------
diff --git a/relational_operators/TextScanOperator.cpp b/relational_operators/TextScanOperator.cpp
index a311a81..80cf953 100644
--- a/relational_operators/TextScanOperator.cpp
+++ b/relational_operators/TextScanOperator.cpp
@@ -148,6 +148,10 @@ bool TextScanOperator::getAllWorkOrders(
 
   const std::vector<std::string> files = utility::file::GlobExpand(file_pattern_);
 
+  if (files.size() == 0) {
+    LOG(FATAL) << "No files matched '" << file_pattern_ << "'. Exiting.";
+  }
+
   InsertDestination *output_destination =
       query_context->getInsertDestination(output_destination_index_);
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/19e74ab8/utility/Glob.cpp
----------------------------------------------------------------------
diff --git a/utility/Glob.cpp b/utility/Glob.cpp
index 98f5615..7e49c13 100644
--- a/utility/Glob.cpp
+++ b/utility/Glob.cpp
@@ -42,11 +42,21 @@ std::size_t GlobForEach(const std::string &pattern,
 #if defined(QUICKSTEP_HAVE_GLOB)
   glob_t glob_result;
 
-  int ret = glob(pattern.c_str(), 0, nullptr, &glob_result);
-  LOG_IF(ERROR, ret != 0) << "glob() returned non-zero";
-  std::size_t num_matches = glob_result.gl_pathc;
+  const int ret = glob(pattern.c_str(), 0, nullptr, &glob_result);
+  std::size_t num_matches = 0;
+  if (ret == GLOB_ABORTED) {
+    LOG(ERROR) << "An error occurred during glob.";
+  } else if (ret == GLOB_NOMATCH) {
+    LOG(WARNING) << "Glob function made zero matches.";
+  } else if (ret == GLOB_NOSPACE) {
+    LOG(ERROR) << "Glob function failed to allocate memory.";
+  } else {
+    // There should be no errors at this point.
+    DCHECK_EQ(ret, 0);
+    num_matches = glob_result.gl_pathc;
+  }
 
-  for (std::size_t i = 0; i < glob_result.gl_pathc; ++i) {
+  for (std::size_t i = 0; i < num_matches; ++i) {
     functor(glob_result.gl_pathv[i]);
   }