學生黨問一個問題。。。
c/c++程式中要把大檔案存盤到hadoop平臺上
要怎么選擇呢?
1.read file 、open file in hadoop 、while(write())
2.呼叫linux 的系統操作命令
uj5u.com熱心網友回復:
http://hadoop.apache.org/docs/r0.19.1/libhdfs.html#include "hdfs.h"
int main(int argc, char **argv) {
hdfsFS fs = hdfsConnect("default", 0);
const char* writePath = "/tmp/testfile.txt";
hdfsFile writeFile = hdfsOpenFile(fs, writePath, O_WRONLY|O_CREAT, 0, 0, 0);
if(!writeFile) {
fprintf(stderr, "Failed to open %s for writing!\n", writePath);
exit(-1);
}
char* buffer = "Hello, World!";
tSize num_written_bytes = hdfsWrite(fs, writeFile, (void*)buffer, strlen(buffer)+1);
if (hdfsFlush(fs, writeFile)) {
fprintf(stderr, "Failed to 'flush' %s\n", writePath);
exit(-1);
}
hdfsCloseFile(fs, writeFile);
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/108628.html
標籤:云存儲
上一篇:omnet++
