-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsecondary_index.cpp
More file actions
51 lines (49 loc) · 1009 Bytes
/
secondary_index.cpp
File metadata and controls
51 lines (49 loc) · 1009 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#include<fstream>
using namespace std;
int main()
{
char word[1000];
ifstream in;
ofstream out;
int string_length;
long long int offset= 0, pos = 0;
in.open("Index/Dense_Index", ios::in | ios::binary);
out.open("Index/Secondary_Index", ios::out | ios::binary);
int count = 0, secondary_count = 0;
while(1)
{
if(in.read((char*)&string_length, 4) == 0)
break;
if(count%1000 == 0)
{
secondary_count++;
in.read(word, string_length);
word[string_length] = '\0';
in.read((char*)&pos, 8);
out.write((char*)&string_length, 4);
out.write(word, string_length);
out.write((char*)&offset, 8);
}
else
{
in.seekg(string_length+8, ios::cur);
}
offset = offset + 4 + string_length + 8;
count++;
}
cout<<secondary_count<<" "<<count<<endl;
in.close();
out.close();
return 0;
}