Ejemplo n.º 1
0
            public override bool Equals(object other)
            {
                if (!(other is TermAndShardVersion))
                {
                    return(false);
                }

                TermAndShardVersion other_ = (TermAndShardVersion)other;

                return(term.Equals(other_.term) && version == other_.version && nodeID == other_.nodeID);
            }
Ejemplo n.º 2
0
            public override bool Equals(object _other)
            {
                if (!(_other is TermAndShardVersion))
                {
                    return(false);
                }

                TermAndShardVersion other = (TermAndShardVersion)_other;

                return(Term.Equals(other.Term) && Version == other.Version && NodeID == other.NodeID);
            }
Ejemplo n.º 3
0
                public override TermStatistics TermStatistics(Term term, TermContext context)
                {
                    if (Debugging.AssertsEnabled)
                    {
                        Debugging.Assert(term != null);
                    }
                    long docFreq       = 0;
                    long totalTermFreq = 0;

                    for (int nodeID = 0; nodeID < nodeVersions.Length; nodeID++)
                    {
                        TermStatistics subStats;
                        if (nodeID == MyNodeID)
                        {
                            subStats = base.TermStatistics(term, context);
                        }
                        else
                        {
                            TermAndShardVersion key = new TermAndShardVersion(nodeID, nodeVersions[nodeID], term);
                            subStats = outerInstance.termStatsCache[key];
                            // We pre-cached during rewrite so all terms
                            // better be here...
                            if (Debugging.AssertsEnabled)
                            {
                                Debugging.Assert(subStats != null);
                            }
                        }

                        long nodeDocFreq = subStats.DocFreq;
                        if (docFreq >= 0 && nodeDocFreq >= 0)
                        {
                            docFreq += nodeDocFreq;
                        }
                        else
                        {
                            docFreq = -1;
                        }

                        long nodeTotalTermFreq = subStats.TotalTermFreq;
                        if (totalTermFreq >= 0 && nodeTotalTermFreq >= 0)
                        {
                            totalTermFreq += nodeTotalTermFreq;
                        }
                        else
                        {
                            totalTermFreq = -1;
                        }
                    }

                    return(new TermStatistics(term.Bytes, docFreq, totalTermFreq));
                }
Ejemplo n.º 4
0
                public override Query Rewrite(Query original)
                {
                    Query       rewritten = base.Rewrite(original);
                    ISet <Term> terms     = new JCG.HashSet <Term>();

                    rewritten.ExtractTerms(terms);

                    // Make a single request to remote nodes for term
                    // stats:
                    for (int nodeID = 0; nodeID < nodeVersions.Length; nodeID++)
                    {
                        if (nodeID == MyNodeID)
                        {
                            continue;
                        }

                        ISet <Term> missing = new JCG.HashSet <Term>();
                        foreach (Term term in terms)
                        {
                            TermAndShardVersion key = new TermAndShardVersion(nodeID, nodeVersions[nodeID], term);
                            if (!outerInstance.termStatsCache.ContainsKey(key))
                            {
                                missing.Add(term);
                            }
                        }
                        if (missing.Count != 0)
                        {
                            foreach (KeyValuePair <Term, TermStatistics> ent in outerInstance.outerInstance.GetNodeTermStats(missing, nodeID, nodeVersions[nodeID]))
                            {
                                TermAndShardVersion key = new TermAndShardVersion(nodeID, nodeVersions[nodeID], ent.Key);
                                outerInstance.termStatsCache[key] = ent.Value;
                            }
                        }
                    }

                    return(rewritten);
                }