quickstep-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zuyu <...@git.apache.org>
Subject [GitHub] incubator-quickstep pull request #19: Improve text scan operator
Date Thu, 09 Jun 2016 15:04:59 GMT
Github user zuyu commented on a diff in the pull request:

    https://github.com/apache/incubator-quickstep/pull/19#discussion_r66458585
  
    --- Diff: relational_operators/TextScanOperator.cpp ---
    @@ -274,439 +116,293 @@ TextScanWorkOrder::TextScanWorkOrder(const std::size_t query_id,
     
     void TextScanWorkOrder::execute() {
       const CatalogRelationSchema &relation = output_destination_->getRelation();
    +  std::vector<Tuple> tuples;
     
    -  string current_row_string;
    -  if (is_file_) {
    -    FILE *file = std::fopen(filename_.c_str(), "r");
    -    if (file == nullptr) {
    -      throw TextScanReadError(filename_);
    -    }
    +  constexpr std::size_t kSmallBufferSize = 0x4000;
    +  char *buffer = reinterpret_cast<char *>(malloc(std::max(text_segment_size_, kSmallBufferSize)));
     
    -    bool have_row = false;
    -    do {
    -      current_row_string.clear();
    -      have_row = readRowFromFile(file, &current_row_string);
    -      if (have_row) {
    -        Tuple tuple = parseRow(current_row_string, relation);
    -        output_destination_->insertTupleInBatch(tuple);
    -      }
    -    } while (have_row);
    -
    -    std::fclose(file);
    -  } else {
    -    BlobReference blob = storage_manager_->getBlob(text_blob_);
    -    const char *blob_pos = static_cast<const char*>(blob->getMemory());
    -    const char *blob_end = blob_pos + text_size_;
    -    bool have_row = false;
    -    do {
    -      current_row_string.clear();
    -      have_row = readRowFromBlob(&blob_pos, blob_end, &current_row_string);
    -      if (have_row) {
    -        Tuple tuple = parseRow(current_row_string, relation);
    -        output_destination_->insertTupleInBatch(tuple);
    -      }
    -    } while (have_row);
    -
    -    // Drop the consumed blob produced by TextSplitWorkOrder.
    -    blob.release();
    -    storage_manager_->deleteBlockOrBlobFile(text_blob_);
    +  // Read text segment into buffer.
    +  FILE *file = std::fopen(filename_.c_str(), "rb");
    +  std::fseek(file, text_offset_, SEEK_SET);
    +  std::size_t bytes_read = std::fread(buffer, 1, text_segment_size_, file);
    --- End diff --
    
    Please mark `const`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message