public bool TryGetSource(FileKey key, out ValueSource<AssemblyMetadata> source)
 {
     lock (_gate)
     {
         return _metadataCache.TryGetValue(key, out source);
     }
 }
 /// <summary>
 /// Aggreggates float facet values from the provided
 /// <see cref="ValueSource"/>, and pulls ordinals from the
 /// provided <see cref="OrdinalsReader"/>. 
 /// </summary>
 public TaxonomyFacetSumValueSource(OrdinalsReader ordinalsReader, TaxonomyReader taxoReader,
     FacetsConfig config, FacetsCollector fc, ValueSource valueSource)
     : base(ordinalsReader.IndexFieldName, taxoReader, config)
 {
     this.ordinalsReader = ordinalsReader;
     SumValues(fc.GetMatchingDocs(), fc.KeepScores, valueSource);
 }
Esempio n. 3
0
        private ProjectState(
            ProjectInfo projectInfo,
            HostLanguageServices languageServices,
            SolutionServices solutionServices,
            IEnumerable<DocumentId> documentIds,
            IEnumerable<DocumentId> additionalDocumentIds,
            ImmutableDictionary<DocumentId, DocumentState> documentStates,
            ImmutableDictionary<DocumentId, TextDocumentState> additionalDocumentStates,
            AsyncLazy<VersionStamp> lazyLatestDocumentVersion,
            AsyncLazy<VersionStamp> lazyLatestDocumentTopLevelChangeVersion,
            ValueSource<ProjectStateChecksums> lazyChecksums)
        {
            _projectInfo = projectInfo;
            _solutionServices = solutionServices;
            _languageServices = languageServices;
            _documentIds = documentIds.ToImmutableReadOnlyListOrEmpty();
            _additionalDocumentIds = additionalDocumentIds.ToImmutableReadOnlyListOrEmpty();
            _documentStates = documentStates;
            _additionalDocumentStates = additionalDocumentStates;
            _lazyLatestDocumentVersion = lazyLatestDocumentVersion;
            _lazyLatestDocumentTopLevelChangeVersion = lazyLatestDocumentTopLevelChangeVersion;

            // for now, let it re-calculate if anything changed.
            // TODO: optimize this so that we only re-calcuate checksums that are actually changed
            _lazyChecksums = new AsyncLazy<ProjectStateChecksums>(ComputeChecksumsAsync, cacheResult: true);
        }
 /// <summary>
 ///  f(source) = a/(m*float(source)+b)
 /// </summary>
 public ReciprocalFloatFunction(ValueSource source, float m, float a, float b)
 {
     this.source = source;
     this.m = m;
     this.a = a;
     this.b = b;
 }
Esempio n. 5
0
        private SolutionState(
            BranchId branchId,
            int workspaceVersion,
            SolutionServices solutionServices,
            SolutionInfo solutionInfo,
            IEnumerable<ProjectId> projectIds,
            ImmutableDictionary<ProjectId, ProjectState> idToProjectStateMap,
            ImmutableDictionary<ProjectId, CompilationTracker> projectIdToTrackerMap,
            ImmutableDictionary<string, ImmutableArray<DocumentId>> linkedFilesMap,
            ProjectDependencyGraph dependencyGraph,
            Lazy<VersionStamp> lazyLatestProjectVersion)
        {
            _branchId = branchId;
            _workspaceVersion = workspaceVersion;
            _solutionServices = solutionServices;
            _solutionInfo = solutionInfo;
            _projectIds = projectIds.ToImmutableReadOnlyListOrEmpty();
            _projectIdToProjectStateMap = idToProjectStateMap;
            _projectIdToTrackerMap = projectIdToTrackerMap;
            _linkedFilesMap = linkedFilesMap;
            _dependencyGraph = dependencyGraph;
            _lazyLatestProjectVersion = lazyLatestProjectVersion;

            // when solution state is changed, we re-calcuate its checksum
            _lazyChecksums = new AsyncLazy<SolutionStateChecksums>(ComputeChecksumsAsync, cacheResult: true);

            CheckInvariants();
        }
                protected State(ValueSource<Compilation> compilation, Compilation declarationOnlyCompilation)
                {
                    this.Compilation = compilation;
                    this.DeclarationOnlyCompilation = declarationOnlyCompilation;

                    // Declaration-only compilations should never have any references
                    Contract.ThrowIfTrue(declarationOnlyCompilation != null && declarationOnlyCompilation.ExternalReferences.Any());
                }
 public RangeMapFloatFunction(ValueSource source, float min, float max, ValueSource target, ValueSource def)
 {
     this.source = source;
     this.min = min;
     this.max = max;
     this.target = target;
     this.defaultVal = def;
 }
Esempio n. 8
0
 protected TextDocumentState(
     SolutionServices solutionServices,
     DocumentInfo info,
     ValueSource<TextAndVersion> textSource)
 {
     this.solutionServices = solutionServices;
     this.info = info;
     this.textSource = textSource;
 }
        private readonly double nullValue;//computed

        public DistanceToShapeValueSource(ValueSource shapeValueSource, IPoint queryPoint,
                                          double multiplier, SpatialContext ctx)
        {
            this.shapeValueSource = shapeValueSource;
            this.queryPoint = queryPoint;
            this.multiplier = multiplier;
            this.distCalc = ctx.DistCalc;
            this.nullValue =
                (ctx.IsGeo ? 180 * multiplier : double.MaxValue);
        }
Esempio n. 10
0
 private static ValueSource<TreeAndVersion> CreateLazyFullyParsedTree(
     ValueSource<TextAndVersion> newTextSource,
     string filePath,
     ParseOptions options,
     HostLanguageServices languageServices,
     PreservationMode mode = PreservationMode.PreserveValue)
 {
     return new AsyncLazy<TreeAndVersion>(
         c => FullyParseTreeAsync(newTextSource, filePath, options, languageServices, mode, c),
         cacheResult: true);
 }
                public InProgressState(
                    ValueSource<Compilation> inProgressCompilationSource,
                    ImmutableArray<ValueTuple<ProjectState, CompilationTranslationAction>> intermediateProjects)
                    : base(inProgressCompilationSource)
                {
                    Contract.ThrowIfNull(inProgressCompilationSource);
                    Contract.ThrowIfNull(inProgressCompilationSource.GetValue());
                    Contract.ThrowIfTrue(intermediateProjects.IsDefault);
                    Contract.ThrowIfFalse(intermediateProjects.Length > 0);

                    this.IntermediateProjects = intermediateProjects;
                }
 protected DocTermsIndexDocValues(ValueSource vs, AtomicReaderContext context, string field)
 {
     try
     {
         termsIndex = FieldCache.DEFAULT.GetTermsIndex(context.AtomicReader, field);
     }
     catch (Exception e)
     {
         throw new DocTermsIndexException(field, e);
     }
     this.vs = vs;
 }
Esempio n. 13
0
        public void find_values_invokes_the_fubu_request()
        {
            var request = new InMemoryFubuRequest();
            var address = new Address();

            request.Set(address);

            var source = new ValueSource<Address>(request);

            source.FindValues().ShouldBeOfType<SimpleValues<Address>>()
                .Subject.ShouldBeTheSameAs(address);
        }
                public InProgressState(
                    ValueSource<Compilation> inProgressCompilationSource,
                    ImmutableList<ValueTuple<ProjectState, CompilationTranslationAction>> intermediateProjects)
                    : base(inProgressCompilationSource)
                {
                    Contract.ThrowIfNull(inProgressCompilationSource);
                    Contract.ThrowIfNull(inProgressCompilationSource.GetValue());
                    Contract.ThrowIfNull(intermediateProjects);
                    Contract.ThrowIfFalse(intermediateProjects.Count > 0);

                    this.IntermediateProjects = intermediateProjects;
                }
            public override SyntaxTree CreateRecoverableTree(string filePath, ParseOptions options, ValueSource<TextAndVersion> text, SyntaxNode root, bool reparse)
            {
                options = options ?? GetDefaultParseOptions();

                if (reparse)
                {
                    return new ReparsedSyntaxTree(this, filePath, (CSharpParseOptions)options, text, (CompilationUnitSyntax)root);
                }
                else
                {
                    return new SerializedSyntaxTree(this, filePath, (CSharpParseOptions)options, text, (CompilationUnitSyntax)root);
                }
            }
Esempio n. 16
0
 private DocumentState(
     HostLanguageServices languageServices,
     SolutionServices solutionServices,
     DocumentInfo info,
     ParseOptions options,
     ValueSource<TextAndVersion> textSource,
     ValueSource<TreeAndVersion> treeSource)
     : base(solutionServices, info, textSource)
 {
     _languageServices = languageServices;
     _options = options;
     _treeSource = treeSource;
 }
                public static State Create(
                    ValueSource<Compilation> compilationSource,
                    ImmutableArray<ValueTuple<ProjectState, CompilationTranslationAction>> intermediateProjects)
                {
                    Contract.ThrowIfNull(compilationSource);
                    Contract.ThrowIfNull(compilationSource.GetValue());
                    Contract.ThrowIfTrue(intermediateProjects.IsDefault);

                    // If we don't have any intermediate projects to process, just initialize our
                    // DeclarationState now.
                    return intermediateProjects.Length == 0
                        ? (State)new FullDeclarationState(compilationSource)
                        : (State)new InProgressState(compilationSource, intermediateProjects);
                }
 internal ExpressionFunctionValues(ValueSource parent, Expression expression, FunctionValues
     [] functionValues)
     : base(parent)
 {
     if (expression == null)
     {
         throw new ArgumentNullException();
     }
     if (functionValues == null)
     {
         throw new ArgumentNullException();
     }
     this.expression = expression;
     this.functionValues = functionValues;
 }
Esempio n. 19
0
 private DocumentState(
     HostLanguageServices languageServices,
     SolutionServices solutionServices,
     DocumentInfo info,
     ParseOptions options,
     ValueSource<TextAndVersion> textSource,
     ValueSource<TreeAndVersion> treeSource)
 {
     this.languageServices = languageServices;
     this.solutionServices = solutionServices;
     this.info = info;
     this.options = options;
     this.textSource = textSource;
     this.treeSource = treeSource;
 }
Esempio n. 20
0
        protected TextDocumentState(
            SolutionServices solutionServices,
            DocumentInfo info,
            SourceText sourceTextOpt,
            ValueSource<TextAndVersion> textAndVersionSource,
            ValueSource<DocumentStateChecksums> lazyChecksums)
        {
            this.solutionServices = solutionServices;
            this.info = info;
            this.sourceTextOpt = sourceTextOpt;
            this.textAndVersionSource = textAndVersionSource;

            // for now, let it re-calculate if anything changed.
            // TODO: optimize this so that we only re-calcuate checksums that are actually changed
            _lazyChecksums = new AsyncLazy<DocumentStateChecksums>(ComputeChecksumsAsync, cacheResult: true);
        }
Esempio n. 21
0
        private DocumentState(
            HostLanguageServices languageServices,
            SolutionServices solutionServices,
            DocumentInfo info,
            ParseOptions options,
            ValueSource<TextAndVersion> textSource,
            ValueSource<TreeAndVersion> treeSource)
            : base(solutionServices, info, textSource)
        {
            _languageServices = languageServices;
            _options = options;

            // If this is document that doesn't support syntax, then don't even bother holding
            // onto any tree source.  It will never be used to get a tree, and can only hurt us
            // by possibly holding onto data that might cause a slow memory leak.
            _treeSource = this.SupportsSyntaxTree
                ? treeSource
                : ValueSource<TreeAndVersion>.Empty;
        }
            public bool TryGetOrAddMetadata(FileKey key, ValueSource<AssemblyMetadata> newMetadata, out AssemblyMetadata metadata)
            {
                lock (_gate)
                {
                    if (TryGetMetadata_NoLock(key, out metadata))
                    {
                        return false;
                    }

                    EnsureCapacity_NoLock();

                    metadata = newMetadata.GetValue();
                    Contract.ThrowIfNull(metadata);

                    // don't use "Add" since key might already exist with already released metadata
                    _metadataCache[key] = newMetadata;
                    return true;
                }
            }
 /// <summary>
 /// Test that FieldScoreQuery returns docs in expected order.
 /// </summary>
 /// <param name="valueSource"></param>
 private void DoTestRank(ValueSource valueSource)
 {
     FunctionQuery functionQuery = new FunctionQuery(valueSource);
     IndexReader r = DirectoryReader.Open(dir);
     IndexSearcher s = NewSearcher(r);
     Log("test: " + functionQuery);
     QueryUtils.Check(Random(), functionQuery, s, Similarity);
     ScoreDoc[] h = s.Search(functionQuery, null, 1000).ScoreDocs;
     assertEquals("All docs should be matched!", N_DOCS, h.Length);
     string prevID = "ID" + (N_DOCS + 1); // greater than all ids of docs in this test
     for (int i = 0; i < h.Length; i++)
     {
         string resID = s.Doc(h[i].Doc).Get(ID_FIELD);
         Log(i + ".   score=" + h[i].Score + "  -  " + resID);
         Log(s.Explain(functionQuery, h[i].Doc));
         assertTrue("res id " + resID + " should be < prev res id " + prevID, resID.CompareTo(prevID) < 0);
         prevID = resID;
     }
     r.Dispose();
 }
Esempio n. 24
0
        private ProjectState(
            ProjectInfo projectInfo,
            HostLanguageServices languageServices,
            SolutionServices solutionServices,
            IEnumerable<DocumentId> documentIds,
            IEnumerable<DocumentId> additionalDocumentIds,
            ImmutableDictionary<DocumentId, DocumentState> documentStates,
            ImmutableDictionary<DocumentId, TextDocumentState> additionalDocumentStates,
            AsyncLazy<VersionStamp> lazyLatestDocumentVersion,
            AsyncLazy<VersionStamp> lazyLatestDocumentTopLevelChangeVersion)
        {
            _projectInfo = projectInfo;
            _solutionServices = solutionServices;
            _languageServices = languageServices;
            _documentIds = documentIds.ToImmutableReadOnlyListOrEmpty();
            _additionalDocumentIds = additionalDocumentIds.ToImmutableReadOnlyListOrEmpty();
            _documentStates = documentStates;
            _additionalDocumentStates = additionalDocumentStates;
            _lazyLatestDocumentVersion = lazyLatestDocumentVersion;
            _lazyLatestDocumentTopLevelChangeVersion = lazyLatestDocumentTopLevelChangeVersion;

            _lazyChecksums = new AsyncLazy<ProjectStateChecksums>(ComputeChecksumsAsync, cacheResult: true);
        }
Esempio n. 25
0
 public abstract SyntaxTree CreateRecoverableTree(ProjectId cacheKey, string filePath, ParseOptions options, ValueSource <TextAndVersion> text, Encoding encoding, SyntaxNode root);
            private readonly ValueSource predicateValueSource;//we call boolVal(doc)

            public PredicateValueSourceFilter(ValueSource predicateValueSource)
            {
                this.predicateValueSource = predicateValueSource;
            }
 public ExpressionComparer(ValueSource source, int numHits)
 {
     values      = new double[numHits];
     this.source = source;
 }
Esempio n. 28
0
 public RecoverableWeakValueSource(ValueSource <T> initialValue)
 {
     _weakInstance   = s_noReference;
     _recoverySource = initialValue;
 }
Esempio n. 29
0
 internal ScoreFunctionValues(ValueSource parent, Scorer scorer)
     : base(parent)
 {
     this.scorer = scorer;
 }
Esempio n. 30
0
 public override Filter GetFilter(Filter fastMatchFilter, ValueSource valueSource)
 {
     return(new FilterAnonymousClass(this, fastMatchFilter, valueSource));
 }
Esempio n. 31
0
 private static void AssertValueSource(ValueSource valueSource, bool isCurrent = false, bool isExpression = false, BaseValueSource baseValueSource = BaseValueSource.Local)
 {
     Assert.AreEqual(isCurrent, valueSource.IsCurrent);
     Assert.AreEqual(isExpression, valueSource.IsExpression);
     Assert.AreEqual(baseValueSource, valueSource.BaseValueSource);
 }
Esempio n. 32
0
        private void Count(ValueSource valueSource, IEnumerable <MatchingDocs> matchingDocs)
        {
            DoubleRange[] ranges = (DoubleRange[])this.m_ranges;

            Int64Range[] longRanges = new Int64Range[ranges.Length];
            for (int i = 0; i < ranges.Length; i++)
            {
                DoubleRange range = ranges[i];
                longRanges[i] = new Int64Range(range.Label, NumericUtils.DoubleToSortableInt64(range.minIncl), true, NumericUtils.DoubleToSortableInt64(range.maxIncl), true);
            }

            Int64RangeCounter counter = new Int64RangeCounter(longRanges);

            int missingCount = 0;

            foreach (MatchingDocs hits in matchingDocs)
            {
                FunctionValues fv = valueSource.GetValues(new Dictionary <string, object>(), hits.Context);

                m_totCount += hits.TotalHits;
                IBits bits;
                if (m_fastMatchFilter != null)
                {
                    DocIdSet dis = m_fastMatchFilter.GetDocIdSet(hits.Context, null);
                    if (dis == null)
                    {
                        // No documents match
                        continue;
                    }
                    bits = dis.Bits;
                    if (bits == null)
                    {
                        throw new System.ArgumentException("fastMatchFilter does not implement DocIdSet.bits");
                    }
                }
                else
                {
                    bits = null;
                }

                DocIdSetIterator docs = hits.Bits.GetIterator();

                int doc;
                while ((doc = docs.NextDoc()) != DocIdSetIterator.NO_MORE_DOCS)
                {
                    if (bits != null && bits.Get(doc) == false)
                    {
                        doc++;
                        continue;
                    }
                    // Skip missing docs:
                    if (fv.Exists(doc))
                    {
                        counter.Add(NumericUtils.DoubleToSortableInt64(fv.DoubleVal(doc)));
                    }
                    else
                    {
                        missingCount++;
                    }
                }
            }

            missingCount += counter.FillCounts(m_counts);
            m_totCount   -= missingCount;
        }
Esempio n. 33
0
 public WorkspaceSyntaxTreeOptionsProvider(ValueSource <CachingAnalyzerConfigSet> lazyAnalyzerConfigSet)
 => _lazyAnalyzerConfigSet = lazyAnalyzerConfigSet;
Esempio n. 34
0
 internal ConstIntDocValues(int val, ValueSource parent)
     : base(parent)
 {
     ival = val;
     fval = val;
     dval = val;
     lval = val;
     sval = Convert.ToString(val);
     this.parent = parent;
 }
Esempio n. 35
0
 /// <summary>
 /// Aggreggates float facet values from the provided
 /// <see cref="ValueSource"/>, pulling ordinals using <see cref="DocValuesOrdinalsReader"/>
 /// against the default indexed
 /// facet field <see cref="FacetsConfig.DEFAULT_INDEX_FIELD_NAME"/>.
 /// </summary>
 public TaxonomyFacetSumValueSource(TaxonomyReader taxoReader, FacetsConfig config,
                                    FacetsCollector fc, ValueSource valueSource)
     : this(new DocValuesOrdinalsReader(FacetsConfig.DEFAULT_INDEX_FIELD_NAME),
            taxoReader, config, fc, valueSource)
 {
 }
Esempio n. 36
0
        private void DoTestCustomScore(ValueSource valueSource, double dboost)
        {
            float boost = (float)dboost;
            FunctionQuery functionQuery = new FunctionQuery(valueSource);
            IndexReader r = DirectoryReader.Open(dir);
            IndexSearcher s = NewSearcher(r);

            // regular (boolean) query.
            BooleanQuery q1 = new BooleanQuery();
            q1.Add(new TermQuery(new Term(TEXT_FIELD, "first")), BooleanClause.Occur.SHOULD);
            q1.Add(new TermQuery(new Term(TEXT_FIELD, "aid")), BooleanClause.Occur.SHOULD);
            q1.Add(new TermQuery(new Term(TEXT_FIELD, "text")), BooleanClause.Occur.SHOULD);
            Log(q1);

            // custom query, that should score the same as q1.
            BooleanQuery q2CustomNeutral = new BooleanQuery(true);
            Query q2CustomNeutralInner = new CustomScoreQuery(q1);
            q2CustomNeutral.Add(q2CustomNeutralInner, BooleanClause.Occur.SHOULD);
            // a little tricky: we split the boost across an outer BQ and CustomScoreQuery
            // this ensures boosting is correct across all these functions (see LUCENE-4935)
            q2CustomNeutral.Boost = (float)Math.Sqrt(dboost);
            q2CustomNeutralInner.Boost = (float)Math.Sqrt(dboost);
            Log(q2CustomNeutral);

            // custom query, that should (by default) multiply the scores of q1 by that of the field
            CustomScoreQuery q3CustomMul = new CustomScoreQuery(q1, functionQuery);
            q3CustomMul.Strict = true;
            q3CustomMul.Boost = boost;
            Log(q3CustomMul);

            // custom query, that should add the scores of q1 to that of the field
            CustomScoreQuery q4CustomAdd = new CustomAddQuery(q1, functionQuery);
            q4CustomAdd.Strict = true;
            q4CustomAdd.Boost = boost;
            Log(q4CustomAdd);

            // custom query, that multiplies and adds the field score to that of q1
            CustomScoreQuery q5CustomMulAdd = new CustomMulAddQuery(q1, functionQuery, functionQuery);
            q5CustomMulAdd.Strict = true;
            q5CustomMulAdd.Boost = boost;
            Log(q5CustomMulAdd);

            // do al the searches
            TopDocs td1 = s.Search(q1, null, 1000);
            TopDocs td2CustomNeutral = s.Search(q2CustomNeutral, null, 1000);
            TopDocs td3CustomMul = s.Search(q3CustomMul, null, 1000);
            TopDocs td4CustomAdd = s.Search(q4CustomAdd, null, 1000);
            TopDocs td5CustomMulAdd = s.Search(q5CustomMulAdd, null, 1000);

            // put results in map so we can verify the scores although they have changed
            IDictionary<int, float> h1 = TopDocsToMap(td1);
            IDictionary<int, float> h2CustomNeutral = TopDocsToMap(td2CustomNeutral);
            IDictionary<int, float> h3CustomMul = TopDocsToMap(td3CustomMul);
            IDictionary<int, float> h4CustomAdd = TopDocsToMap(td4CustomAdd);
            IDictionary<int, float> h5CustomMulAdd = TopDocsToMap(td5CustomMulAdd);

            VerifyResults(boost, s, h1, h2CustomNeutral, h3CustomMul, h4CustomAdd, h5CustomMulAdd, q1, q2CustomNeutral, q3CustomMul, q4CustomAdd, q5CustomMulAdd);
            r.Dispose();
        }
 /// <summary>
 /// Create <see cref="RangeFacetCounts"/>, using the provided
 /// <see cref="ValueSource"/>, and using the provided Filter as
 /// a fastmatch: only documents passing the filter are
 /// checked for the matching ranges.  The filter must be
 /// random access (implement <see cref="DocIdSet.GetBits"/>). 
 /// </summary>
 public LongRangeFacetCounts(string field, ValueSource valueSource, 
     FacetsCollector hits, Filter fastMatchFilter, params LongRange[] ranges)
     : base(field, ranges, fastMatchFilter)
 {
     Count(valueSource, hits.GetMatchingDocs());
 }
Esempio n. 38
0
 public CachingDoubleValueSource(ValueSource source)
 {
     this.m_source = source;
     m_cache       = new JCG.Dictionary <int, double>();
 }
Esempio n. 39
0
 public SimpleBoolFunction(ValueSource source)
 {
     this.m_source = source;
 }
Esempio n. 40
0
 internal static SyntaxTree CreateRecoverableTree(AbstractSyntaxTreeFactoryService service, ProjectId cacheKey, string filePath, ParseOptions options, ValueSource <TextAndVersion> text, Encoding encoding, CompilationUnitSyntax root)
 {
     return(new RecoverableSyntaxTree(service, cacheKey, root, new SyntaxTreeInfo(filePath, options, text, encoding, root.FullSpan.Length)));
 }
Esempio n. 41
0
 public LinearSingleFunction(ValueSource source, float slope, float intercept)
 {
     this.m_source    = source;
     this.m_slope     = slope;
     this.m_intercept = intercept;
 }
Esempio n. 42
0
 /// <summary>
 /// Returns a new <see cref="Filter"/> accepting only documents
 /// in this range.  This filter is not general-purpose;
 /// you should either use it with <see cref="DrillSideways"/> by
 /// adding it to <see cref="DrillDownQuery.Add(string, Filter)"/>, or pass it to
 /// <see cref="Search.FilteredQuery"/> using its
 /// <see cref="Search.FilteredQuery.QUERY_FIRST_FILTER_STRATEGY"/>.
 /// If the <see cref="ValueSource"/> is static, e.g. an indexed numeric
 /// field, then it may be more efficient to use
 /// <see cref="Search.NumericRangeFilter"/>.  The provided <paramref name="fastMatchFilter"/>,
 /// if non-null, will first be consulted, and only if
 /// that is set for each document will the range then be
 /// checked.
 /// </summary>
 public abstract Filter GetFilter(Filter fastMatchFilter, ValueSource valueSource);
Esempio n. 43
0
 public FilterAnonymousClass(DoubleRange outerInstance, Filter fastMatchFilter, ValueSource valueSource)
 {
     this.outerInstance   = outerInstance;
     this.fastMatchFilter = fastMatchFilter;
     this.valueSource     = valueSource;
 }
Esempio n. 44
0
 /// <summary>
 /// Returns a new <see cref="Filter"/> accepting only documents
 ///  in this range.  This filter is not general-purpose;
 ///  you should either use it with <see cref="DrillSideways"/> by
 ///  adding it to <see cref="DrillDownQuery.Add(string, Filter)"/>, or pass it to
 ///  <see cref="Search.FilteredQuery"/> using its
 ///  <see cref="Search.FilteredQuery.QUERY_FIRST_FILTER_STRATEGY"/>.  If the
 ///  <see cref="ValueSource"/> is static, e.g. an indexed numeric
 ///  field, then it may be more efficient to use <see cref="Search.NumericRangeFilter"/>.
 /// </summary>
 public virtual Filter GetFilter(ValueSource valueSource)
 {
     return(GetFilter(null, valueSource));
 }
Esempio n. 45
0
 public SingleDocValues(ValueSource vs)
 {
     this.m_vs = vs;
 }
Esempio n. 46
0
 public Int32DocValues(ValueSource vs)
 {
     this.m_vs = vs;
 }
Esempio n. 47
0
 internal RadPropertyChangedEventArgs(RadProperty property, RadPropertyMetadata metadata, object oldValue, object newValue, bool isOldValueDeferred, bool isNewValueDeferred, ValueSource oldValueSource, ValueSource newValueSource)
     : this(property, metadata, oldValue, newValue)
 {
     this._isOldValueDeferred = isOldValueDeferred;
     this._isNewValueDeferred = isNewValueDeferred;
     this._oldValueSource     = oldValueSource;
     this._newValueSource     = newValueSource;
 }
Esempio n. 48
0
 public override EvaluationResult Evaluate(NumericPrecision numericPrecision, ValueSource values, FunctionSource functions)
 => ToString();
Esempio n. 49
0
 public DrillSidewaysAnonymousInnerClassHelper2(TestRangeFacetCounts outerInstance, IndexSearcher indexSearcher, FacetsConfig facetsConfig, TaxonomyReader org, ValueSource valueSource, DoubleRange[] doubleRanges, Filter filter)
     : base(indexSearcher, facetsConfig, org)
 {
     this.outerInstance   = outerInstance;
     this.vs              = valueSource;
     this.ranges          = doubleRanges;
     this.fastMatchFilter = filter;
 }
Esempio n. 50
0
 protected DoubleDocValues(ValueSource vs) // LUCENENET: CA1012: Abstract types should not have constructors (marked protected)
 {
     this.m_vs = vs;
 }
            public override SyntaxTree CreateRecoverableTree(string filePath, ParseOptions options, ValueSource <TextAndVersion> text, SyntaxNode root, bool reparse)
            {
                options = options ?? GetDefaultParseOptions();

                if (reparse)
                {
                    return(new ReparsedSyntaxTree(this, filePath, (CSharpParseOptions)options, text, (CompilationUnitSyntax)root));
                }
                else
                {
                    return(new SerializedSyntaxTree(this, filePath, (CSharpParseOptions)options, text, (CompilationUnitSyntax)root));
                }
            }
Esempio n. 52
0
 public CachingDoubleValueSource(ValueSource source)
 {
     this.source = source;
     cache       = new Dictionary <int, double>();
 }
Esempio n. 53
0
 /// <param name="a">  the base. </param>
 /// <param name="b">  the exponent. </param>
 public DualSingleFunction(ValueSource a, ValueSource b)
 {
     this.m_a = a;
     this.m_b = b;
 }
Esempio n. 54
0
            private readonly ValueSource predicateValueSource;//we call boolVal(doc)

            public PredicateValueSourceFilter(ValueSource predicateValueSource)
            {
                // LUCENENET specific - added guard clause
                this.predicateValueSource = predicateValueSource ?? throw new ArgumentNullException(nameof(predicateValueSource));
            }
        private void Count(ValueSource valueSource, IList<MatchingDocs> matchingDocs)
        {

            LongRange[] ranges = (LongRange[])this.ranges;

            LongRangeCounter counter = new LongRangeCounter(ranges);

            int missingCount = 0;
            foreach (MatchingDocs hits in matchingDocs)
            {
                FunctionValues fv = valueSource.GetValues(new Dictionary<string, object>(), hits.Context);

                totCount += hits.TotalHits;
                Bits bits;
                if (fastMatchFilter != null)
                {
                    DocIdSet dis = fastMatchFilter.GetDocIdSet(hits.Context, null);
                    if (dis == null)
                    {
                        // No documents match
                        continue;
                    }
                    bits = dis.GetBits();
                    if (bits == null)
                    {
                        throw new System.ArgumentException("fastMatchFilter does not implement DocIdSet.bits");
                    }
                }
                else
                {
                    bits = null;
                }

                DocIdSetIterator docs = hits.Bits.GetIterator();
                int doc;
                while ((doc = docs.NextDoc()) != DocIdSetIterator.NO_MORE_DOCS)
                {
                    if (bits != null && bits.Get(doc) == false)
                    {
                        doc++;
                        continue;
                    }
                    // Skip missing docs:
                    if (fv.Exists(doc))
                    {
                        counter.Add(fv.LongVal(doc));
                    }
                    else
                    {
                        missingCount++;
                    }
                }
            }

            int x = counter.FillCounts(counts);

            missingCount += x;

            //System.out.println("totCount " + totCount + " missingCount " + counter.missingCount);
            totCount -= missingCount;
        }
Esempio n. 56
0
 /// <summary>
 /// Create <see cref="Int64RangeFacetCounts"/>, using the provided
 /// <see cref="ValueSource"/>.
 /// </summary>
 public Int64RangeFacetCounts(string field, ValueSource valueSource, FacetsCollector hits, params Int64Range[] ranges)
     : this(field, valueSource, hits, null, ranges)
 {
 }
Esempio n. 57
0
 internal ConstDoubleDocValues(double val, ValueSource parent)
     : base(parent)
 {
     ival = (int)val;
     fval = (float)val;
     dval = val;
     lval = (long)val;
     sval = Convert.ToString(val);
     this.parent = parent;
 }
Esempio n. 58
0
 /// <summary>
 /// Create <see cref="Int64RangeFacetCounts"/>, using the provided
 /// <see cref="ValueSource"/>, and using the provided Filter as
 /// a fastmatch: only documents passing the filter are
 /// checked for the matching ranges.  The filter must be
 /// random access (implement <see cref="DocIdSet.Bits"/>).
 /// </summary>
 public Int64RangeFacetCounts(string field, ValueSource valueSource,
                              FacetsCollector hits, Filter fastMatchFilter, params Int64Range[] ranges)
     : base(field, ranges, fastMatchFilter)
 {
     Count(valueSource, hits.GetMatchingDocs());
 }
Esempio n. 59
0
 public MaxFloatFunction(ValueSource[] sources)
     : base(sources)
 {
 }
Esempio n. 60
0
        private void Count(ValueSource valueSource, IList <MatchingDocs> matchingDocs)
        {
            Int64Range[] ranges = (Int64Range[])this.m_ranges;

            Int64RangeCounter counter = new Int64RangeCounter(ranges);

            int missingCount = 0;

            foreach (MatchingDocs hits in matchingDocs)
            {
                FunctionValues fv = valueSource.GetValues(Collections.EmptyMap <string, object>(), hits.Context);

                m_totCount += hits.TotalHits;
                IBits bits;
                if (m_fastMatchFilter != null)
                {
                    DocIdSet dis = m_fastMatchFilter.GetDocIdSet(hits.Context, null);
                    if (dis is null)
                    {
                        // No documents match
                        continue;
                    }
                    bits = dis.Bits;
                    if (bits is null)
                    {
                        throw new ArgumentException("fastMatchFilter does not implement DocIdSet.Bits");
                    }
                }
                else
                {
                    bits = null;
                }

                DocIdSetIterator docs = hits.Bits.GetIterator();
                int doc;
                while ((doc = docs.NextDoc()) != DocIdSetIterator.NO_MORE_DOCS)
                {
                    if (bits != null && bits.Get(doc) == false)
                    {
                        doc++;
                        continue;
                    }
                    // Skip missing docs:
                    if (fv.Exists(doc))
                    {
                        counter.Add(fv.Int64Val(doc));
                    }
                    else
                    {
                        missingCount++;
                    }
                }
            }

            int x = counter.FillCounts(m_counts);

            missingCount += x;

            //System.out.println("totCount " + totCount + " missingCount " + counter.missingCount);
            m_totCount -= missingCount;
        }