问题描述
学生党问一个问题。。。c/c++程序中要把大文件存储到hadoop平台上要怎么选择呢?1.readfile、openfileinhadoop、while(write())2.调用linux的系统操作命令
解决方案
解决方案二:
http://hadoop.apache.org/docs/r0.19.1/libhdfs.html#include"hdfs.h"intmain(intargc,char**argv){hdfsFSfs=hdfsConnect("default",0);constchar*writePath="/tmp/testfile.txt";hdfsFilewriteFile=hdfsOpenFile(fs,writePath,O_WRONLY|O_CREAT,0,0,0);if(!writeFile){fprintf(stderr,"Failedtoopen%sforwriting!n",writePath);exit(-1);}char*buffer="Hello,World!";tSizenum_written_bytes=hdfsWrite(fs,writeFile,(void*)buffer,strlen(buffer)+1);if(hdfsFlush(fs,writeFile)){fprintf(stderr,"Failedto'flush'%sn",writePath);exit(-1);}hdfsCloseFile(fs,writeFile);}
时间: 2024-08-31 21:32:01