概述:開發記憶體服務程式,儲存2億資料的索引,用程序通訊管道的管道池進行服務,每次只應付10個請求、
服務端:
#include
#include
#include
#include
#include
#include
#include
#define totaldata 201515740//資料總量
#define buffersize 4096
#define findthread 128
int pipethread = 10;//10個管道
char pipename[20] = "\\\\.\\pipe\\cloudpipe";
char datapath[20] = "d:\\personinfo.txt";
char indexpath[20] = "d:\\info.txt";
char outputinfo[512] = ;//儲存查詢到的資訊
struct dataindex //索引
bigdataindex = ;
struct threadinfo
;typedef struct info
pipe_st;
pipe_st pipeinst[findthread];
void generateindex(char *path)
else
;fgets(data, 500, pf);//獲取字串
bigdataindex.pindex[i] = indexposition;
int datalength = strlen(data);
indexposition += datalength;//索引位置
}fclose(pf);
}printf("\n大資料索引生成結束");
file *pfw = fopen(indexpath, "wb");
fwrite(bigdataindex.pindex, sizeof(int), bigdataindex.length, pfw);
fclose(pfw);
}void loadmemary()//載入索引檔案記憶體
void memfind(void *pthread)
;fgets(readstr, 512, pf);
char *px = strstr(readstr, thread_task->findstr);
if (px != null)
}fclose(pf);
}void creaetfindthread(char *str)
}else
int nwrite;
int nread;
char winfo[1024] = ;
printf("請輸入要查詢的資訊:");
scanf("%s", winfo);
writefile(m_pipe, winfo, strlen(winfo), &nwrite, null);
memset(winfo, 0, sizeof(winfo));//清零
readfile(m_pipe, winfo, 1024, &nread, null);
char res[100];
sscanf(winfo, "%s", res);
printf("\n%s", res);
return 0;
}
海量資料分頁查詢
select top 25 id,registerid,filenameid,createtime from tbfilenamerecord where id select min id from select top 100 id from tbfilenamerecord where regi...
多執行緒生成海量資料和多執行緒海量資料查詢
using system using system.collections.generic using system.linq using system.text using system.threading using system.diagnostics namespace multithrea...
Sphinx 實現海量資料的快速查詢
執行測試 cd usr local sphinx etc cp sphinx.conf dist sphinx.conf vi sphinx.confcd usr local sphinx etc 進入sphinx的配置檔案目錄 cp sphinx.conf dist sphinx.conf 新建s...