-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgenpostings.patch
More file actions
70 lines (62 loc) · 1.82 KB
/
genpostings.patch
File metadata and controls
70 lines (62 loc) · 1.82 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
Index: src/sphinx.cpp
===================================================================
--- src/sphinx.cpp (revision 3296)
+++ src/sphinx.cpp (working copy)
@@ -9079,6 +9079,9 @@
}
+FILE * g_fpPost = NULL;
+CSphVector<int> g_Docids;
+
void CSphHitBuilder::cidxHit ( CSphAggregateHit * pHit, const CSphRowitem * pAttrs )
{
assert (
@@ -9093,6 +9096,19 @@
( m_pDict->GetSettings().m_bWordDict && strcmp ( (char*)m_tLastHit.m_sKeyword, (char*)pHit->m_sKeyword ) ) ); // OPTIMIZE?
bool bNextDoc = bNextWord || ( m_tLastHit.m_iDocID!=pHit->m_iDocID );
+ if ( pHit->m_iWordID )
+ {
+ fwrite ( &bNextWord, 1, 1, g_fpPost );
+ if ( bNextWord )
+ {
+ BYTE uLen = strlen((char*)pHit->m_sKeyword);
+ fwrite ( &uLen, 1, 1, g_fpPost );
+ fwrite ( pHit->m_sKeyword, 1, uLen, g_fpPost );
+ }
+ fwrite ( &pHit->m_iDocID, 1, 4, g_fpPost );
+ fwrite ( &pHit->m_iWordPos, 1, 4, g_fpPost );
+ }
+
if ( bNextDoc )
{
// finish hitlist, if any
@@ -10631,6 +10647,10 @@
int CSphIndex_VLN::Build ( const CSphVector<CSphSource*> & dSources, int iMemoryLimit, int iWriteBuffer )
{
+ g_fpPost = fopen("postings.bin", "wb+");
+ if ( !g_fpPost )
+ sphDie("failed to write postings");
+
PROFILER_INIT ();
assert ( dSources.GetLength() );
@@ -10976,6 +10996,8 @@
if ( !pSource->m_tDocInfo.m_iDocID )
break;
+ g_Docids.Add ( pSource->m_tDocInfo.m_iDocID );
+
if ( bGotJoined )
dAllIds.Add ( pSource->m_tDocInfo.m_iDocID );
@@ -11992,6 +12014,15 @@
ARRAY_FOREACH ( i, dSources )
dSources[i]->PostIndex ();
+ fclose(g_fpPost);
+
+ ARRAY_FOREACH(i, g_Docids)
+ g_Docids[i] -= m_iMinDocid; // adjust to match what cidxHit() logged
+
+ FILE * fp = fopen("docids.bin", "wb+");
+ fwrite(&g_Docids[0], 1, sizeof(int)*g_Docids.GetLength(), fp);
+ fclose(fp);
+
PROFILER_DONE ();
PROFILE_SHOW ();
dFileWatchdog.AllIsDone();