GetCommitUserData() public static method

Reads commitUserData, previously passed to IndexWriter.Commit(System.Collections.Generic.IDictionary{string, string}), from current index segments file. This will return null if IndexWriter.Commit(System.Collections.Generic.IDictionary{string, string}) has never been called for this index.
public static GetCommitUserData ( Directory directory ) : IDictionary,System.Collections.Generic
directory System.IO.Directory where the index resides. ///
return IDictionary,System.Collections.Generic
Exemplo n.º 1
0
        internal static CommitUserData ReadCommitUserData(IndexReader reader)
        {
            int lastActivityId = 0;
            var gap = new List<int>();

            var cud = reader.GetCommitUserData();
            if (cud != null)
            {
                if (cud.ContainsKey(IndexManager.LastActivityIdKey))
                {
                    var lastID = cud[IndexManager.LastActivityIdKey];
                    if (!string.IsNullOrEmpty(lastID))
                        int.TryParse(lastID, out lastActivityId);
                }
                if (cud.ContainsKey(IndexManager.MissingActivitiesKey))
                {
                    var gapstring = cud[IndexManager.MissingActivitiesKey];
                    int g;
                    if (!string.IsNullOrEmpty(gapstring))
                        foreach (var s in gapstring.Split(','))
                            if (Int32.TryParse(s, out g))
                                gap.Add(g);
                }
            }
            return new CommitUserData { LastActivityId = lastActivityId, Gap = gap };
        }