18 using Lucene.Net.Analysis.Tokenattributes;
19 using Lucene.Net.Search;
25 namespace Lucene.Net.Analysis
86 private void InitBlock()
88 termAtt = AddAttribute<ITermAttribute>();
89 typeAtt = AddAttribute<ITypeAttribute>();
90 posIncrAtt = AddAttribute<IPositionIncrementAttribute>();
94 public const System.String TOKEN_TYPE_FULL_PREC =
"fullPrecNumeric";
97 public const System.String TOKEN_TYPE_LOWER_PREC =
"lowerPrecNumeric";
114 this.precisionStep = precisionStep;
115 if (precisionStep < 1)
116 throw new System.ArgumentException(
"precisionStep must be >=1");
127 this.precisionStep = precisionStep;
128 if (precisionStep < 1)
129 throw new System.ArgumentException(
"precisionStep must be >=1");
141 this.precisionStep = precisionStep;
142 if (precisionStep < 1)
143 throw new System.ArgumentException(
"precisionStep must be >=1");
154 this.value_Renamed = value_Renamed;
168 this.value_Renamed = (long) value_Renamed;
182 this.value_Renamed =
NumericUtils.DoubleToSortableLong(value_Renamed);
196 this.value_Renamed = (long)
NumericUtils.FloatToSortableInt(value_Renamed);
203 public override void Reset()
206 throw new System.SystemException(
"call set???Value() before usage");
210 protected override void Dispose(
bool disposing)
216 public override bool IncrementToken()
219 throw new System.SystemException(
"call set???Value() before usage");
220 if (shift >= valSize)
229 buffer = termAtt.ResizeTermBuffer(
NumericUtils.BUF_SIZE_LONG);
230 termAtt.SetTermLength(
NumericUtils.LongToPrefixCoded(value_Renamed, shift, buffer));
235 buffer = termAtt.ResizeTermBuffer(
NumericUtils.BUF_SIZE_INT);
236 termAtt.SetTermLength(
NumericUtils.IntToPrefixCoded((
int) value_Renamed, shift, buffer));
242 throw new System.ArgumentException(
"valSize must be 32 or 64");
246 typeAtt.Type = (shift == 0)?TOKEN_TYPE_FULL_PREC:TOKEN_TYPE_LOWER_PREC;
247 posIncrAtt.PositionIncrement = (shift == 0)?1:0;
248 shift += precisionStep;
253 public override System.String ToString()
255 System.Text.StringBuilder sb =
new System.Text.StringBuilder(
"(numeric,valSize=").Append(valSize);
256 sb.Append(
",precisionStep=").Append(precisionStep).Append(
')');
257 return sb.ToString();
265 private int shift = 0, valSize = 0;
266 private readonly
int precisionStep;
268 private long value_Renamed = 0L;