public int Compare(string bstrValue1, string bstrValue2, LgCollatingOptions colopt) { EnsureCollator(); var key1 = m_collator.GetSortKey(bstrValue1).KeyData; var key2 = m_collator.GetSortKey(bstrValue2).KeyData; return(CompareVariant(key1, key2, colopt)); }
public override void SetUp() { base.SetUp(); this.analyzer = new ICUCollationKeyAnalyzer(TEST_VERSION_CURRENT, collator); this.firstRangeBeginning = new BytesRef (collator.GetSortKey(FirstRangeBeginningOriginal).KeyData); this.firstRangeEnd = new BytesRef (collator.GetSortKey(FirstRangeEndOriginal).KeyData); this.secondRangeBeginning = new BytesRef (collator.GetSortKey(SecondRangeBeginningOriginal).KeyData); this.secondRangeEnd = new BytesRef (collator.GetSortKey(SecondRangeEndOriginal).KeyData); }
public override void SetUp() { base.SetUp(); this.analyzer = new TestAnalyzer(collator); this.firstRangeBeginning = new BytesRef(EncodeCollationKey (collator.GetSortKey(FirstRangeBeginningOriginal).KeyData)); this.firstRangeEnd = new BytesRef(EncodeCollationKey (collator.GetSortKey(FirstRangeEndOriginal).KeyData)); this.secondRangeBeginning = new BytesRef(EncodeCollationKey (collator.GetSortKey(SecondRangeBeginningOriginal).KeyData)); this.secondRangeEnd = new BytesRef(EncodeCollationKey (collator.GetSortKey(SecondRangeEndOriginal).KeyData)); }
public override void SetStringValue(string value) { key = collator.GetSortKey(value); bytes.Bytes = key.KeyData; bytes.Offset = 0; bytes.Length = key.KeyData.Length; }
public void TestRanges() { Directory dir = NewDirectory(); RandomIndexWriter iw = new RandomIndexWriter(Random(), dir, Similarity, TimeZone); Document doc = new Document(); Field field = NewField("field", "", StringField.TYPE_STORED); Collator collator = Collator.Create(CultureInfo.CurrentCulture, Collator.Fallback.FallbackAllowed); // uses -Dtests.locale if (Random().nextBoolean()) { collator.Strength = CollationStrength.Primary; } ICUCollationDocValuesField collationField = new ICUCollationDocValuesField("collated", collator); doc.Add(field); doc.Add(collationField); int numDocs = AtLeast(500); for (int i = 0; i < numDocs; i++) { String value = TestUtil.RandomSimpleString(Random()); field.SetStringValue(value); collationField.SetStringValue(value); iw.AddDocument(doc); } IndexReader ir = iw.Reader; iw.Dispose(); IndexSearcher @is = NewSearcher(ir); int numChecks = AtLeast(100); for (int i = 0; i < numChecks; i++) { String start = TestUtil.RandomSimpleString(Random()); String end = TestUtil.RandomSimpleString(Random()); BytesRef lowerVal = new BytesRef(collator.GetSortKey(start).KeyData); BytesRef upperVal = new BytesRef(collator.GetSortKey(end).KeyData); Query query = new ConstantScoreQuery(FieldCacheRangeFilter.NewBytesRefRange("collated", lowerVal, upperVal, true, true)); DoTestRanges(@is, start, end, query, collator); } ir.Dispose(); dir.Dispose(); }
public override void FillBytesRef() { BytesRef bytes = this.BytesRef; key = collator.GetSortKey(ToString()); bytes.Bytes = key.KeyData; bytes.Offset = 0; bytes.Length = key.KeyData.Length; }
public override bool IncrementToken() { if (m_input.IncrementToken()) { char[] termBuffer = termAtt.Buffer; string termText = new string(termBuffer, 0, termAtt.Length); reusableKey = collator.GetSortKey(termText); int encodedLength = IndexableBinaryStringTools.GetEncodedLength( reusableKey.KeyData, 0, reusableKey.KeyData.Length); if (encodedLength > termBuffer.Length) { termAtt.ResizeBuffer(encodedLength); } termAtt.SetLength(encodedLength); IndexableBinaryStringTools.Encode(reusableKey.KeyData, 0, reusableKey.KeyData.Length, termAtt.Buffer, 0, encodedLength); return(true); } else { return(false); } }