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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
/*
* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
*
* Distributable under the terms of either the Apache License (Version 2.0) or
* the GNU Lesser General Public License, as specified in the COPYING file.
*
* Changes are Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies), all rights reserved.
*/
#ifndef _lucene_index_TermInfosWriter_
#define _lucene_index_TermInfosWriter_
#if defined(_LUCENE_PRAGMA_ONCE)
# pragma once
#endif
#include <QtCore/QString>
#include "CLucene/store/Directory.h"
#include "FieldInfos.h"
#include "TermInfo.h"
#include "Term.h"
CL_NS_DEF(index)
// This stores a monotonically increasing set of <Term, TermInfo> pairs in a
// Directory. A TermInfos can be written once, in order.
class TermInfosWriter : LUCENE_BASE
{
private:
FieldInfos* fieldInfos;
CL_NS(store)::IndexOutput* output;
Term* lastTerm;
TermInfo* lastTi;
int64_t size;
int64_t lastIndexPointer;
bool isIndex;
TermInfosWriter* other;
//inititalize
TermInfosWriter(CL_NS(store)::Directory* directory,
const QString& segment, FieldInfos* fis, int32_t interval, bool isIndex);
public:
/** The file format version, a negative number. */
LUCENE_STATIC_CONSTANT(int32_t,FORMAT=-2);
/**
* Expert: The fraction of terms in the "dictionary" which should be stored
* in RAM. Smaller values use more memory, but make searching slightly
* faster, while larger values use less memory and make searching slightly
* slower. Searching is typically not dominated by dictionary lookup, so
* tweaking this is rarely useful.
*/
int32_t indexInterval;// = 128
/**
* Expert: The fraction of {@link TermDocs} entries stored in skip tables,
* used to accellerate {@link TermDocs#SkipTo(int32_t)}. Larger values result in
* smaller indexes, greater acceleration, but fewer accelerable cases, while
* smaller values result in bigger indexes, less acceleration and more
* accelerable cases. More detailed experiments would be useful here.
*/
int32_t skipInterval;// = 16
TermInfosWriter(CL_NS(store)::Directory* directory,
const QString& segment, FieldInfos* fis, int32_t interval);
~TermInfosWriter();
/**
* Adds a new <Term, TermInfo> pair to the set.
* Term must be lexicographically greater than all previous Terms added.
* TermInfo pointers must be positive and greater than all previous.
*/
void add(Term* term, const TermInfo* ti);
/** Called to complete TermInfos creation. */
void close();
private:
/** Helps constructors to initialize instances */
void initialise(CL_NS(store)::Directory* directory,
const QString& segment, int32_t interval, bool IsIndex);
void writeTerm(Term* term);
};
CL_NS_END
#endif
|