Beispiel #1
0
        /// <summary>
        /// Returns the current value for this id, or null if the
        ///  id isn't in the index or was deleted.
        /// </summary>
        public virtual T Get(string id)
        {
            // First try to get the "live" value:
            T value;

            current.TryGetValue(id, out value);
            if (EqualityComparer <T> .Default.Equals(value, missingValue))
            {
                // Deleted but the deletion is not yet reflected in
                // the reader:
                return(default(T));
            }
            else if (!EqualityComparer <T> .Default.Equals(value, default(T)))
            {
                return(value);
            }
            else
            {
                old.TryGetValue(id, out value);
                if (EqualityComparer <T> .Default.Equals(value, missingValue))
                {
                    // Deleted but the deletion is not yet reflected in
                    // the reader:
                    return(default(T));
                }
                else if (!EqualityComparer <T> .Default.Equals(value, default(T)))
                {
                    return(value);
                }
                else
                {
                    // It either does not exist in the index, or, it was
                    // already flushed & NRT reader was opened on the
                    // segment, so fallback to current searcher:
                    S s = mgr.Acquire();
                    try
                    {
                        return(LookupFromSearcher(s, id));
                    }
                    finally
                    {
                        mgr.Release(s);
                    }
                }
            }
        }
        /// <summary>
        /// Returns the current value for this id, or null if the
        ///  id isn't in the index or was deleted.
        /// </summary>
        public virtual T Get(string id)
        {
            // First try to get the "live" value:
            T value = Current[id];

            if ((object)value == (object)MissingValue)
            {
                // Deleted but the deletion is not yet reflected in
                // the reader:
                return(default(T));
            }
            else if ((object)value != (object)default(T))
            {
                return(value);
            }
            else
            {
                value = Old[id];
                if ((object)value == (object)MissingValue)
                {
                    // Deleted but the deletion is not yet reflected in
                    // the reader:
                    return(default(T));
                }
                else if ((object)value != (object)default(T))
                {
                    return(value);
                }
                else
                {
                    // It either does not exist in the index, or, it was
                    // already flushed & NRT reader was opened on the
                    // segment, so fallback to current searcher:
                    S s = Mgr.Acquire();
                    try
                    {
                        return(LookupFromSearcher(s, id));
                    }
                    finally
                    {
                        Mgr.Release(s);
                    }
                }
            }
        }
Beispiel #3
0
 internal ReferenceContext(ReferenceManager <T> referenceManager)
 {
     this.referenceManager = referenceManager;
     this.reference        = referenceManager.Acquire();
 }