repair_from_children.cpp
Go to the documentation of this file.
00001 #include <megatree/node_file.h>
00002 #include <megatree/storage_factory.h>
00003 
00004 int main(int argc, char** argv)
00005 {
00006   using namespace megatree;
00007   boost::shared_ptr<Storage> storage(openStorage("hbase://wgsc2/tahoe_all"));
00008   std::vector<boost::shared_ptr<NodeFile> > children;
00009 
00010   std::string broken_file = "f1611111131";
00011 
00012   children.resize(8);
00013   for(int i = 0; i < 8; ++i)
00014   {
00015     char buf[100];
00016     snprintf(buf, 100, "%s%d", broken_file.c_str(), i);
00017     std::string child_file = buf;
00018     ByteVec bytes;
00019     storage->get(child_file, bytes);
00020     if(!bytes.empty())
00021     {
00022       children[i].reset(new NodeFile(child_file));
00023       children[i]->deserialize(bytes);
00024       printf("Deserialize %d with %d nodes\n", i, children[i]->cacheSize());
00025     }
00026   }
00027 
00028   NodeFile broken_node_file(broken_file);
00029   broken_node_file.initializeFromChildren(broken_file, children);
00030   printf("Cache size of reconstructed file %d\n", broken_node_file.cacheSize());
00031 
00032   ByteVec data_to_write;
00033   broken_node_file.serialize(data_to_write);
00034   printf("Size of data to write %zu\n", data_to_write.size());
00035   storage->put(broken_file, data_to_write);
00036 
00037   return 0;
00038 }


megatree_cpp
Author(s): Stuart Glaser
autogenerated on Mon Dec 2 2013 13:01:28