quickstep-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zu...@apache.org
Subject [3/6] incubator-quickstep git commit: Refactored block loading order in StorageManager::loadBlockOrBlob.
Date Sat, 11 Feb 2017 20:56:18 GMT
Refactored block loading order in StorageManager::loadBlockOrBlob.


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

Branch: refs/heads/dist-patch
Commit: 975fb613c6c91b9ce5e5062da422d97cf6baa7ea
Parents: afdd412
Author: Zuyu Zhang <zuyuz@apache.org>
Authored: Sat Feb 11 11:24:54 2017 -0800
Committer: Zuyu Zhang <zuyuz@apache.org>
Committed: Sat Feb 11 12:55:48 2017 -0800

----------------------------------------------------------------------
 storage/StorageManager.cpp | 60 ++++++++++++++++++++---------------------
 1 file changed, 29 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/975fb613/storage/StorageManager.cpp
----------------------------------------------------------------------
diff --git a/storage/StorageManager.cpp b/storage/StorageManager.cpp
index 872e8cc..6f051eb 100644
--- a/storage/StorageManager.cpp
+++ b/storage/StorageManager.cpp
@@ -666,45 +666,43 @@ StorageManager::BlockHandle StorageManager::loadBlockOrBlob(
   // already loaded before this function gets called.
   BlockHandle loaded_handle;
 
-#ifdef QUICKSTEP_DISTRIBUTED
-  // TODO(quickstep-team): Use a cost model to determine whether to load from
-  // a remote peer or the disk.
-  if (BlockIdUtil::Domain(block) != block_domain_) {
-    DLOG(INFO) << "Pulling Block " << BlockIdUtil::ToString(block) << "
from a remote peer";
-    const vector<string> peer_domain_network_addresses = getPeerDomainNetworkAddresses(block);
-    for (const string &peer_domain_network_address : peer_domain_network_addresses) {
-      DataExchangerClientAsync client(
-          grpc::CreateChannel(peer_domain_network_address, grpc::InsecureChannelCredentials()),
-          this);
-
-      if (client.Pull(block, numa_node, &loaded_handle)) {
-        sendBlockLocationMessage(block, kAddBlockLocationMessage);
-        return loaded_handle;
-      }
-    }
+  const size_t num_slots = file_manager_->numSlots(block);
+  if (num_slots != 0) {
+    void *block_buffer = allocateSlots(num_slots, numa_node);
 
-    DLOG(INFO) << "Failed to pull Block " << BlockIdUtil::ToString(block)
-               << " from remote peers, so try to load from disk.";
-  }
-#endif
+    const bool status = file_manager_->readBlockOrBlob(block, block_buffer, kSlotSizeBytes
* num_slots);
+    CHECK(status) << "Failed to read block from persistent storage: " << block;
 
-  const size_t num_slots = file_manager_->numSlots(block);
-  DEBUG_ASSERT(num_slots != 0);
-  void *block_buffer = allocateSlots(num_slots, numa_node);
+    loaded_handle.block_memory = block_buffer;
+    loaded_handle.block_memory_size = num_slots;
 
-  const bool status = file_manager_->readBlockOrBlob(block, block_buffer, kSlotSizeBytes
* num_slots);
-  CHECK(status) << "Failed to read block from persistent storage: " << block;
+#ifdef QUICKSTEP_DISTRIBUTED
+    if (bus_) {
+      sendBlockLocationMessage(block, kAddBlockLocationMessage);
+    }
+#endif
 
-  loaded_handle.block_memory = block_buffer;
-  loaded_handle.block_memory_size = num_slots;
+    return loaded_handle;
+  }
 
 #ifdef QUICKSTEP_DISTRIBUTED
-  if (bus_) {
-    sendBlockLocationMessage(block, kAddBlockLocationMessage);
+  // TODO(quickstep-team): Use a cost model to determine whether to load from
+  // a remote peer or the disk.
+  DLOG(INFO) << "Pulling Block " << BlockIdUtil::ToString(block) << " from
a remote peer";
+  const vector<string> peer_domain_network_addresses = getPeerDomainNetworkAddresses(block);
+  for (const string &peer_domain_network_address : peer_domain_network_addresses) {
+    DataExchangerClientAsync client(
+        grpc::CreateChannel(peer_domain_network_address, grpc::InsecureChannelCredentials()),
+        this);
+
+    if (client.Pull(block, numa_node, &loaded_handle)) {
+      sendBlockLocationMessage(block, kAddBlockLocationMessage);
+      return loaded_handle;
+    }
   }
+  LOG(FATAL) << "Failed to pull Block " << BlockIdUtil::ToString(block)
+             << " from remote peers.";
 #endif
-
-  return loaded_handle;
 }
 
 void StorageManager::insertBlockHandleAfterLoad(const block_id block,


Mime
View raw message