void WireBestMatchStage(FindBestStandaloneMatchStage stage)
        {
            var transform = stage.Transformation;

            transform.Input2 = Data.ReducedConditionRatings;
            transform.Input3 = Data.Exclusivities;
            transform.Input4 = Data.Priority;
            transform.Output = Data.BestMatchDataIds;
        }
        internal void SetupData()
        {
            configuration  = QueryPipelineConfiguration.instance;
            Data           = new ParallelQueryData(MARSMemoryOptions.instance.QueryDataCapacity);
            Data.OnResize += WireStages;

            CacheTraitReferencesStage = SetupTraitCacheStage();
            ConditionRatingStage      = SetupMatchRating();
            FindMatchProposalsStage   = SetupMatchIntersection();
            DataAvailabilityStage     = SetupAvailabilityCheckStage();
            TraitFilterStage          = SetupTraitFilterStage();
            MatchReductionStage       = SetupMatchReduction();
            BestStandaloneMatchStage  = SetupBestStandaloneMatchStage();
            ResultFillStage           = SetupQueryResultFill();
            MarkUsedStage             = SetupMarkUsedStage();
            AcquireHandlingStage      = SetupAcquireHandlingStage();
        }
        internal FindBestStandaloneMatchStage SetupBestStandaloneMatchStage()
        {
            var dataIdCollection = Data.BestMatchDataIds;
            // assign all match Ids to an invalid value when we initialize the pipeline,
            // so that we do not get queries matching against ID 0 by mistake.
            const int invalidId = (int)ReservedDataIDs.Invalid;

            for (var i = 0; i < dataIdCollection.Length; i++)
            {
                dataIdCollection[i] = invalidId;
            }

            var transformation = new FindBestMatchTransform(MARSMemoryOptions.instance.QueryDataCapacity)
            {
                WorkingIndices = Data.PotentialMatchAcquiringIndices,
                Input1         = Data.DefiniteMatchAcquireIndices,
            };

            var stage = new FindBestStandaloneMatchStage(transformation);

            WireBestMatchStage(stage);
            return(stage);
        }