19 using System.Collections.Generic;
23 using Lucene.Net.Search;
24 using Lucene.Net.Index;
25 using Lucene.Net.Util;
27 namespace Lucene.Net.Search
37 int keepMode = KM_USE_FIRST_OCCURRENCE;
38 public static int KM_USE_FIRST_OCCURRENCE = 1;
39 public static int KM_USE_LAST_OCCURRENCE = 2;
52 int processingMode = PM_FULL_VALIDATION;
53 public static int PM_FULL_VALIDATION = 1;
54 public static int PM_FAST_INVALIDATION = 2;
58 public DuplicateFilter(String fieldName) : this(fieldName, KM_USE_LAST_OCCURRENCE, PM_FULL_VALIDATION)
65 this.fieldName = fieldName;
66 this.keepMode = keepMode;
67 this.processingMode = processingMode;
72 if (processingMode == PM_FAST_INVALIDATION)
74 return FastBits(reader);
78 return CorrectBits(reader);
85 Term startTerm =
new Term(fieldName);
90 while ((currTerm != null) && (currTerm.
Field == startTerm.
Field))
97 if (keepMode == KM_USE_FIRST_OCCURRENCE)
124 Term startTerm =
new Term(fieldName);
130 while ((currTerm != null) && (currTerm.
Field == startTerm.
Field))
138 if (keepMode == KM_USE_FIRST_OCCURRENCE)
147 if (keepMode == KM_USE_LAST_OCCURRENCE)
163 public string FieldName
165 get {
return fieldName; }
166 set { this.fieldName = value; }
171 get {
return keepMode; }
172 set { this.keepMode = value; }
175 public override bool Equals(Object obj)
179 if ((obj == null) || (obj.GetType()!= this.GetType()))
182 return keepMode == other.keepMode &&
183 processingMode == other.processingMode &&
184 (fieldName == other.fieldName || (fieldName != null && fieldName.Equals(other.fieldName)));
187 public override int GetHashCode()
190 hash = 31 * hash + keepMode;
191 hash = 31 * hash + processingMode;
192 hash = 31 * hash + fieldName.GetHashCode();
196 public int ProcessingMode
198 get {
return processingMode; }
199 set { this.processingMode = value; }