コード例 #1
0
ファイル: SonesLuceneIndex.cs プロジェクト: zhouweiaccp/sones
        public bool TryGetValuesPartial(IEnumerable <ICompoundIndexKey> myKeys, out ICloseableEnumerable <long> myVertexIDs)
        {
            LuceneReturn results          = null;
            var          results_compound = new List <Tuple <long, IComparable, long> >();

            foreach (var key in myKeys)
            {
                results = _LuceneIndex.GetEntriesInnerByField(_MaxResultsFirst, key.Key as String, key.PropertyID.ToString(), LuceneIndex.Fields.PROPERTY_ID);
                if (results.TotalHits > _MaxResultsFirst)
                {
                    results.Close();
                    results = _LuceneIndex.GetEntriesInnerByField(_MaxResultsFirst, key.Key as String, key.PropertyID.ToString(), LuceneIndex.Fields.PROPERTY_ID);
                }

                results_compound.AddRange(results.Where((e) => e.PropertyId != null).Select((e) => new Tuple <long, IComparable, long>((long)e.PropertyId, e.Text, e.VertexId)));
            }

            var grouped = from myresults in results_compound group myresults by myresults.Item3;

            if (grouped.Count() > 0)
            {
                myVertexIDs = new CloseableEnumerable <long>(grouped.Select <IGrouping <long, Tuple <long, IComparable, long> >, long>((g) => g.Key), results.Close);
                return(true);
            }
            else
            {
                myVertexIDs = null;
                return(false);
            }
        }
コード例 #2
0
ファイル: SonesLuceneIndex.cs プロジェクト: zhouweiaccp/sones
        public override bool TryGetValues(IComparable myKey, out ICloseableEnumerable <long> myVertexIDs)
        {
            if (myKey == null)
            {
                myVertexIDs = null;
                return(false);
            }


            myVertexIDs = this[myKey];
            return(myVertexIDs.Count() > 0);
        }
コード例 #3
0
ファイル: SonesLuceneIndex.cs プロジェクト: zhouweiaccp/sones
 public ICloseableEnumerable <long> this[IEnumerable <ICompoundIndexKey> myKeys]
 {
     get
     {
         ICloseableEnumerable <long> myVertexIDs = null;
         if (TryGetValues(myKeys, out myVertexIDs))
         {
             return(myVertexIDs);
         }
         else
         {
             return(null);
         }
     }
 }
コード例 #4
0
        /// <summary>
        /// Returns all values associated with given key, if it exists.
        /// </summary>
        /// <param name="myKey">Search key</param>
        /// <param name="myVertexIDs">Associated values</param>
        /// <returns>True, if the key exists</returns>
        public override bool TryGetValues(IComparable myKey, out ICloseableEnumerable <long> myVertexIDs)
        {
            if (!KeyNullSupportCheck(myKey))
            {
                throw new NullKeysNotSupportedException("This index does not support >null< as key.");
            }

            var values = new HashSet <long>();
            var done   = _Index.TryGetValue(myKey, out values);

            if (values == null)
            {
                myVertexIDs = null;
            }
            else
            {
                myVertexIDs = new CloseableEnumerable <long>(values);
            }
            return(done);
        }
コード例 #5
0
ファイル: ASonesIndex.cs プロジェクト: anukat2015/sones
 public abstract bool TryGetValues(IComparable myKey, out ICloseableEnumerable<long> myVertexIDs);
コード例 #6
0
ファイル: SonesIndex.cs プロジェクト: anukat2015/sones
        /// <summary>
        /// Returns all values associated with given key, if it exists.
        /// </summary>
        /// <param name="myKey">Search key</param>
        /// <param name="myVertexIDs">Associated values</param>
        /// <returns>True, if the key exists</returns>
        public override bool TryGetValues(IComparable myKey, out ICloseableEnumerable<long> myVertexIDs)
        {
            if (!KeyNullSupportCheck(myKey))
            {
                throw new NullKeysNotSupportedException("This index does not support >null< as key.");
            }

            var values = new HashSet<long>();
            var done = _Index.TryGetValue(myKey, out values);
            if (values == null)
            {
                myVertexIDs = null;
            }
            else
            {
                myVertexIDs = new CloseableEnumerable<long>(values);
            }
            return done;
        }
コード例 #7
0
ファイル: SonesLuceneIndex.cs プロジェクト: zhouweiaccp/sones
        public bool TryGetValues(IEnumerable <ICompoundIndexKey> myKeys, out ICloseableEnumerable <long> myVertexIDs)
        {
            LuceneReturn results          = null;
            var          results_compound = new List <Tuple <long, IComparable, long> >();

            foreach (var key in myKeys)
            {
                results = _LuceneIndex.GetEntriesInnerByField(_MaxResultsFirst, key.Key as String, key.PropertyID.ToString(), LuceneIndex.Fields.PROPERTY_ID);
                if (results.TotalHits > _MaxResultsFirst)
                {
                    results.Close();
                    results = _LuceneIndex.GetEntriesInnerByField(results.TotalHits, key.Key as String, key.PropertyID.ToString(), LuceneIndex.Fields.PROPERTY_ID);
                }

                results_compound.AddRange(results
                                          .Where((e) => e.PropertyId != null)
                                          .Select((e) => new Tuple <long, IComparable, long>((long)e.PropertyId, e.Text, e.VertexId)));
            }

            var grouped = from myresults in results_compound group myresults by myresults.Item3;

            if (grouped.Count() > 0)
            {
                var _myVertexIDs = grouped
                                   .Where((myGroup) =>
                {
                    var join =
                        from entry in myGroup
                        join key in myKeys
                        on new
                    {
                        JoinField1 = entry.Item2,
                        JoinField2 = entry.Item1
                    }
                    equals new
                    {
                        JoinField1 = key.Key,
                        JoinField2 = key.PropertyID
                    }
                    select entry;

                    if (join.Count() == myKeys.Count())
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                })
                                   .Select <IGrouping <long, Tuple <long, IComparable, long> >, long>((g) => g.Key);

                if (_myVertexIDs.Count() > 0)
                {
                    myVertexIDs = new CloseableEnumerable <long>(_myVertexIDs, results.Close);
                    return(true);
                }
                else
                {
                    myVertexIDs = null;
                    return(false);
                }
            }
            else
            {
                myVertexIDs = null;
                return(false);
            }
        }
コード例 #8
0
 public abstract bool TryGetValues(IComparable myKey, out ICloseableEnumerable <long> myVertexIDs);
コード例 #9
0
ファイル: SonesLuceneIndex.cs プロジェクト: anukat2015/sones
        public bool TryGetValuesPartial(IEnumerable<ICompoundIndexKey> myKeys, out ICloseableEnumerable<long> myVertexIDs)
        {
            LuceneReturn results = null;
            var results_compound = new List<Tuple<long, IComparable, long>>();
            foreach (var key in myKeys)
            {
                results = _LuceneIndex.GetEntriesInnerByField(_MaxResultsFirst, key.Key as String, key.PropertyID.ToString(), LuceneIndex.Fields.PROPERTY_ID);
                if (results.TotalHits > _MaxResultsFirst)
                {
                    results.Close();
                    results = _LuceneIndex.GetEntriesInnerByField(_MaxResultsFirst, key.Key as String, key.PropertyID.ToString(), LuceneIndex.Fields.PROPERTY_ID);
                }

                results_compound.AddRange(results.Where((e) => e.PropertyId != null).Select((e) => new Tuple<long, IComparable, long>((long)e.PropertyId, e.Text, e.VertexId)));
            }

            var grouped = from myresults in results_compound group myresults by myresults.Item3;

            if (grouped.Count() > 0)
            {
                myVertexIDs = new CloseableEnumerable<long>(grouped.Select<IGrouping<long, Tuple<long, IComparable, long>>, long>((g) => g.Key), results.Close);
                return true;
            }
            else
            {
                myVertexIDs = null;
                return false;
            }
        }
コード例 #10
0
ファイル: SonesLuceneIndex.cs プロジェクト: anukat2015/sones
        public override bool TryGetValues(IComparable myKey, out ICloseableEnumerable<long> myVertexIDs)
        {
            if (myKey == null)
            {
                myVertexIDs = null;
                return false;
            }

            myVertexIDs = this[myKey];
            return myVertexIDs.Count() > 0;
        }
コード例 #11
0
ファイル: SonesLuceneIndex.cs プロジェクト: anukat2015/sones
        public bool TryGetValues(IEnumerable<ICompoundIndexKey> myKeys, out ICloseableEnumerable<long> myVertexIDs)
        {
            LuceneReturn results = null;
            var results_compound = new List<Tuple<long, IComparable, long>>();
            foreach (var key in myKeys)
            {
                results = _LuceneIndex.GetEntriesInnerByField(_MaxResultsFirst, key.Key as String, key.PropertyID.ToString(), LuceneIndex.Fields.PROPERTY_ID);
                if (results.TotalHits > _MaxResultsFirst)
                {
                    results.Close();
                    results = _LuceneIndex.GetEntriesInnerByField(results.TotalHits, key.Key as String, key.PropertyID.ToString(), LuceneIndex.Fields.PROPERTY_ID);
                }

                results_compound.AddRange(results
                             .Where((e) => e.PropertyId != null)
                             .Select((e) => new Tuple<long, IComparable, long>((long)e.PropertyId, e.Text, e.VertexId)));
            }

            var grouped = from myresults in results_compound group myresults by myresults.Item3;

            if (grouped.Count() > 0)
            {
                var _myVertexIDs = grouped
                    .Where((myGroup) =>
                    {
                        var join =
                            from entry in myGroup
                            join key in myKeys
                            on new
                            {
                                JoinField1 = entry.Item2,
                                JoinField2 = entry.Item1
                            }
                            equals new
                            {
                                JoinField1 = key.Key,
                                JoinField2 = key.PropertyID
                            }
                            select entry;

                        if (join.Count() == myKeys.Count())
                        {
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    })
                    .Select<IGrouping<long, Tuple<long, IComparable, long>>, long>((g) => g.Key);

                if (_myVertexIDs.Count() > 0)
                {
                    myVertexIDs = new CloseableEnumerable<long>(_myVertexIDs, results.Close);
                    return true;
                }
                else
                {
                    myVertexIDs = null;
                    return false;
                }
            }
            else
            {
                myVertexIDs = null;
                return false;
            }
        }