bool HybridScanExecutor::DExecute() {

  // SEQUENTIAL SCAN
  if (type_ == HYBRID_SCAN_TYPE_SEQUENTIAL) {
    LOG_TRACE("Sequential Scan");
    return SeqScanUtil();
  }
  // INDEX SCAN
  else if (type_ == HYBRID_SCAN_TYPE_INDEX) {
    LOG_TRACE("Index Scan");
    PL_ASSERT(children_.size() == 0);

    if (index_done_ == false) {
      if (index_->GetIndexType() == INDEX_CONSTRAINT_TYPE_PRIMARY_KEY) {
        auto status = ExecPrimaryIndexLookup();
        if (status == false) {
          return false;
        }
      }
      else {
        return false;
      }
    }

    return IndexScanUtil();
  }
  // HYBRID SCAN
  else if (type_ == HYBRID_SCAN_TYPE_HYBRID) {
    LOG_TRACE("Hybrid Scan");

    // do two part search
    if (index_done_ == false) {
      if (indexed_tile_offset_ == INVALID_OID) {
        index_done_ = true;
      } else {
        ExecPrimaryIndexLookup();
        LOG_TRACE("Using index -- tile count : %lu", result_.size());
      }
    }

    if (IndexScanUtil() == true) {
      return true;
    }
    // Scan seq
    return SeqScanUtil();
  }
  // FALLBACK
  else {
    throw Exception("Invalid hybrid scan type : " + std::to_string(type_));
  }

}
Exemplo n.º 2
0
bool HybridScanExecutor::DExecute() {
  if (type_ == planner::SEQ) {
      return SeqScanUtil();
  } else if (type_ == planner::INDEX) {
  //  LOG_INFO("Hybrrd Scan executor, Index Scan :: 0 child");
    assert(children_.size() == 0);
    if (!index_done_) {
      if (index_->GetIndexType() == INDEX_CONSTRAINT_TYPE_PRIMARY_KEY) {
        auto status = ExecPrimaryIndexLookup();
        if (status == false) return false;
      } else {
          return false;
      }

    }

    return IndexScanUtil();
  } else {
    // do two part search
    if (index_done_ == false) {

      //Timer<> timer;
      //timer.Start();

      if (indexed_tile_offset_ == INVALID_OID) {
        index_done_ = true;
      } else {
        ExecPrimaryIndexLookup();
      }

    }

    if (IndexScanUtil() == true) {
      return true;
    }
    // Scan seq
    return SeqScanUtil();
  }
}