19 using System.Collections;
20 using System.Collections.Generic;
21 using System.Collections.Specialized;
22 using System.Configuration;
24 using Lucene.Net.Distributed;
26 using Lucene.Net.Distributed.Configuration;
28 using Lucene.Net.Analysis;
29 using Lucene.Net.Analysis.Standard;
30 using Lucene.Net.Index;
32 namespace Lucene.Net.Distributed.Indexing
57 private int _intId = -1;
58 private string _strLocalPath;
59 private string _strIdColumn;
60 private int _intBottomId;
61 private int _intTopId;
65 private Hashtable _htDocuments =
new Hashtable();
66 private Hashtable _htIndexDocuments =
new Hashtable();
67 private List<string> _alFileSystemDocuments =
new List<string>();
78 this.LoadValues(node);
83 #region Internal voids
89 internal void LoadValues(XmlNode node)
91 XmlAttributeCollection attributeCollection = node.Attributes;
94 this._intId = Convert.ToInt32(attributeCollection[
"id"].Value);
98 throw new ConfigurationErrorsException(
"IndexSet id invalid: " + Environment.NewLine + node.OuterXml);
107 throw new ConfigurationErrorsException(
"IndexSet "+this._intId.ToString()+
" IndexAction invalid: " + Environment.NewLine + node.OuterXml);
112 if (attributeCollection[
"analyzer"] != null)
117 throw new ConfigurationErrorsException(
"IndexSet " + this._intId.ToString() +
" analyzer invalid: " + Environment.NewLine + node.OuterXml);
120 if (node.ChildNodes.Count==0)
121 throw new ConfigurationErrorsException(
"IndexSet " + this._intId.ToString() +
" configuration missing " + Environment.NewLine + node.OuterXml);
123 foreach (XmlNode c
in node.ChildNodes)
125 if (!c.HasChildNodes)
127 switch (c.Attributes[
"key"].Value.ToLower())
130 this._strLocalPath = c.Attributes[
"value"].Value;
133 this._strIdColumn = c.Attributes[
"value"].Value;
138 this._intBottomId = Convert.ToInt32(c.Attributes[
"value"].Value);
142 throw new ConfigurationErrorsException(
"IndexSet " + this._intId.ToString() +
" bottomid invalid: " + Environment.NewLine + node.OuterXml);
148 this._intTopId = Convert.ToInt32(c.Attributes[
"value"].Value);
152 throw new ConfigurationErrorsException(
"IndexSet " + this._intId.ToString() +
" topid invalid: " + Environment.NewLine + node.OuterXml);
159 switch(c.Name.ToLower())
162 if (this._strLocalPath!=null)
163 LoadCopy(c,this._strLocalPath);
170 this.CheckValidSet(node);
174 internal void LoadCopy(XmlNode node,
string localpath)
179 internal void LoadCopy(XmlNode node, XmlNode masternode)
181 foreach (XmlNode c
in node.ChildNodes)
183 if (c.Attributes[
"key"] != null)
185 switch (c.Attributes[
"key"].Value.ToLower())
188 this.LoadCopy(node, c.Attributes[
"value"].Value);
195 private void CheckValidSet(XmlNode node)
197 if (this._strLocalPath==null)
throw new ConfigurationErrorsException(
"IndexSet " + this._intId.ToString() +
" LocalPath invalid: " + Environment.NewLine + node.OuterXml);
198 if (this._eIndexAction==
IndexAction.NoAction)
throw new ConfigurationErrorsException(
"IndexSet " + this._intId.ToString() +
" IndexAction undefined: " + Environment.NewLine + node.OuterXml);
199 if (this._strIdColumn==null)
throw new ConfigurationErrorsException(
"IndexSet " + this._intId.ToString() +
" IdColumn undefined: " + Environment.NewLine + node.OuterXml);
210 get {
return this._intId;}
218 get {
return this._eIndexAction;}
226 get {
return this._eAnalyzerType;}
240 public string LocalPath
242 get {
return this._strLocalPath;}
248 public string IdColumn
250 get {
return this._strIdColumn;}
258 get {
return this._intBottomId;}
266 get {
return this._intTopId;}
276 get {
return this._oCurrentIndex;}
282 public List<string> FileSystemDocuments
284 get {
return this._alFileSystemDocuments; }
290 public Hashtable IndexDocuments
292 get {
return this._htIndexDocuments; }
302 this._htDocuments.Clear();
303 foreach (DictionaryEntry de
in this._htIndexDocuments)
307 this._htDocuments.Add(iDoc.Document, iDoc.GetAnalyzer());
309 return this._htDocuments;
320 public NameValueCollection GetDeletionCollection()
322 NameValueCollection nvc =
new NameValueCollection(this._htDocuments.Count);
323 foreach(DictionaryEntry de
in this._htIndexDocuments)
324 nvc.Add(this.IdColumn, ((
IndexDocument)de.Value).RecordId.ToString());
333 this._htIndexDocuments.Clear();
334 this._htDocuments.Clear();
340 public void Optimize()
345 idxWriter.SetMergeFactor(2);
357 public bool ContainsId(
int recordId)
359 return (this._intTopId >= recordId && this._intBottomId <= recordId);