public int Compare(string value1, string value2) { return(NullSafeComparer.Compare(value1, value2)); }
public void IndexField(string fieldName) { lock (transactionLockObject) { if (isDisposed) { throw new ObjectDisposedException("Can't use IndexField() after Dispose() or Delete()"); } if (isFieldIndexesInUse) { throw new InvalidOperationException("Can't use IndexField() before disposing the enumerable from a FindDocumentIds call"); } if (DebugLogHandler != null) { DebugLogHandler("IndexField: fieldName=" + fieldName); } journalWriter.Start(); try { fieldIndexes.ClearField(fieldName); List <KeyValuePair <uint, IComparable> > list = new List <KeyValuePair <uint, IComparable> >(); foreach (KeyValuePair <uint, byte[]> document2 in packedFile.Documents) { if (document2.Key != metadataDocumentId) { TDocument document = DecryptAndDeserialize(document2.Value, document2.Key); IComparable fieldValue = fieldIndexes.GetFieldValue(fieldName, document); list.Add(new KeyValuePair <uint, IComparable>(document2.Key, fieldValue)); } } list.Sort((KeyValuePair <uint, IComparable> a, KeyValuePair <uint, IComparable> b) => NullSafeComparer.Compare(a.Value, b.Value)); fieldIndexes.InsertPreSorted(fieldName, list); journalWriter.Finish(); journalPlayer.Play(); } catch (Exception) { journalWriter.Discard(); throw; } } }
public static IEnumerable <KeyValuePair <uint, TField> > FindDocumentsGreaterThanOrEqualTo <TDocument, TField>(this IDocumentCollection <TDocument> collection, string fieldName, TField value) where TDocument : AbstractDocument, new()where TField : IComparable <TField> { return(collection.FindDocuments(fieldName, value, (TField v) => NullSafeComparer.Compare(v, value) >= 0)); }
public static IEnumerable <KeyValuePair <uint, TField> > FindDocumentsRangeExclusiveInclusive <TDocument, TField>(this IDocumentCollection <TDocument> collection, string fieldName, TField startValue, TField endValue) where TDocument : AbstractDocument, new()where TField : IComparable <TField> { return(collection.FindDocuments(fieldName, startValue, (TField v) => NullSafeComparer.Compare(v, startValue) > 0 && NullSafeComparer.Compare(v, endValue) <= 0)); }
public static IEnumerable <uint> FindDocumentIdsEqual <TDocument, TField>(this IDocumentCollection <TDocument> collection, string fieldName, TField value) where TDocument : AbstractDocument, new()where TField : IComparable <TField> { return(collection.FindDocumentIds(fieldName, value, (TField v) => NullSafeComparer.Compare(v, value) == 0)); }