write.cpp
Go to the documentation of this file.
00001 #include <megatree/storage_factory.h>
00002 #include <boost/filesystem/operations.hpp>
00003 #include <boost/filesystem/convenience.hpp>
00004 #include <boost/iostreams/device/mapped_file.hpp>
00005 #include <cstdio>
00006 
00007 
00008 int main(int argc, char** argv)
00009 {
00010   if (argc != 3)
00011   {
00012     printf("Usage: ./write tree file\n");
00013     return 0;
00014   }
00015 
00016   std::string tree_path(argv[1]);
00017   std::string filename(argv[2]);
00018 
00019   // safety
00020   if (filename != "metadata.ini" && filename != "views.ini" )
00021   {
00022     printf("For now write is restricted to metadata.ini\n");
00023     return 0;
00024   }
00025   
00026   // read file into bytevec
00027   boost::iostreams::mapped_file file(filename);
00028   megatree::ByteVec data(file.size());
00029   memcpy((void*)&data[0], file.const_data(), file.size());
00030   file.close();
00031 
00032   // write file to storage
00033   printf("Opening storage for writing\n");
00034   boost::shared_ptr<megatree::Storage> mystorage = megatree::openStorage(tree_path);
00035   printf("Opened storage for writing\n");
00036   mystorage->put(filename, data);
00037   printf("Wrote file from disk to hbase\n");
00038   
00039 
00040   return 0;
00041 }


megatree_storage
Author(s): Wim Meeussen
autogenerated on Thu Nov 28 2013 11:30:26