quickstep-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jianq...@apache.org
Subject [01/11] incubator-quickstep git commit: Extract getFilesize as a method. [Forced Update!]
Date Sun, 05 Feb 2017 03:53:52 GMT
Repository: incubator-quickstep
Updated Branches:
  refs/heads/collision-free-agg 387275f74 -> 68be4a614 (forced update)


Extract getFilesize as a method.


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

Branch: refs/heads/collision-free-agg
Commit: 43a9b3981146ffaa6da125faf7bc0fa2a918834d
Parents: 61391ca
Author: Zuyu Zhang <zuyuz@apache.org>
Authored: Sat Feb 4 16:08:02 2017 -0800
Committer: Zuyu Zhang <zuyuz@apache.org>
Committed: Sat Feb 4 16:08:02 2017 -0800

----------------------------------------------------------------------
 relational_operators/TextScanOperator.cpp | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/43a9b398/relational_operators/TextScanOperator.cpp
----------------------------------------------------------------------
diff --git a/relational_operators/TextScanOperator.cpp b/relational_operators/TextScanOperator.cpp
index aa734d3..6650319 100644
--- a/relational_operators/TextScanOperator.cpp
+++ b/relational_operators/TextScanOperator.cpp
@@ -78,6 +78,20 @@ static bool ValidateTextScanTextSegmentSize(const char *flagname,
 static const volatile bool text_scan_text_segment_size_dummy = gflags::RegisterFlagValidator(
     &FLAGS_textscan_text_segment_size, &ValidateTextScanTextSegmentSize);
 
+namespace {
+
+size_t getFileSize(const string &file_name) {
+  // Use standard C libary to retrieve the file size.
+  FILE *fp = std::fopen(file_name.c_str(), "rb");
+  std::fseek(fp, 0, SEEK_END);
+  const std::size_t file_size = std::ftell(fp);
+  std::fclose(fp);
+
+  return file_size;
+}
+
+}  // namespace
+
 bool TextScanOperator::getAllWorkOrders(
     WorkOrdersContainer *container,
     QueryContext *query_context,
@@ -105,10 +119,7 @@ bool TextScanOperator::getAllWorkOrders(
           << "File " << file << " is not readable due to permission issues.";
 #endif  // QUICKSTEP_HAVE_UNISTD
 
-      FILE *fp = std::fopen(file.c_str(), "rb");
-      std::fseek(fp, 0, SEEK_END);
-      const std::size_t file_size = std::ftell(fp);
-      std::fclose(fp);
+      const std::size_t file_size = getFileSize(file);
 
       std::size_t text_offset = 0;
       for (size_t num_full_segments = file_size / FLAGS_textscan_text_segment_size;
@@ -148,11 +159,7 @@ bool TextScanOperator::getAllWorkOrderProtos(WorkOrderProtosContainer
*container
   const std::vector<std::string> files = utility::file::GlobExpand(file_pattern_);
   if (blocking_dependencies_met_ && !work_generated_) {
     for (const string &file : files) {
-      // Use standard C libary to retrieve the file size.
-      FILE *fp = std::fopen(file.c_str(), "rb");
-      std::fseek(fp, 0, SEEK_END);
-      const std::size_t file_size = std::ftell(fp);
-      std::fclose(fp);
+      const std::size_t file_size = getFileSize(file);
 
       size_t text_offset = 0;
       for (size_t num_full_segments = file_size / FLAGS_textscan_text_segment_size;


Mime
View raw message