/// <summary>
            /// Copy constructor for a <b>IPartialResult</b>.
            /// </summary>
            /// <param name="colResult">
            /// The <b>IPartialResult</b> to copy.
            /// </param>
            public PartialResult(IPartialResult colResult)
            {
                m_partMask = colResult.Partitions;

                IList listSteps = m_listSteps;

                foreach (IStep step in colResult.Steps)
                {
                    listSteps.Add(new Step(step));
                }
            }
            /// <summary>
            /// Merge the given result with this one.
            /// </summary>
            /// <param name="result">
            /// The result to merge.
            /// </param>
            public void Merge(IPartialResult result)
            {
                Partitions.Add(result.Partitions);

                IList listStepsThis = m_listSteps;
                IList listStepsThat = result.Steps;

                for (int i = 0; i < listStepsThat.Count; i++)
                {
                    IStep step      = (IStep)listStepsThat[i];
                    Step  mergeStep = (Step)listStepsThis[i];

                    mergeStep.Merge(step);
                }
            }
            /// <summary>
            /// Determine whether or not the given result is capable of being
            /// placed in one-to-one correspondence with this result.  Results are
            /// matching if their owned lists of steps have the same size, and
            /// all pairs of steps in the two lists are matching.
            /// </summary>
            /// <param name="result">
            /// The result to be checked.
            /// </param>
            /// <returns>
            /// True iff the given result matches with this result.
            /// </returns>
            public bool IsMatching(IPartialResult result)
            {
                IList listStepsThis = m_listSteps;
                IList listStepsThat = result.Steps;

                if (listStepsThis.Count != listStepsThat.Count)
                {
                    return(false);
                }

                for (int i = 0; i < listStepsThis.Count; i++)
                {
                    if (!((Step)listStepsThis[i]).IsMatching((IStep)listStepsThat[i]))
                    {
                        return(false);
                    }
                }
                return(true);
            }
Example #4
0
        /// <summary>
        /// Report the given result.
        /// </summary>
        /// <param name="result">
        /// The result.
        /// </param>
        /// <param name="type">
        /// The record type.
        /// </param>
        /// <param name="listIndexLookups">
        /// The list of lookup ids.
        /// </param>
        /// <param name="fReportPartition">
        /// Indicates whether or not to report partitions.
        /// </param>
        /// <returns>
        /// A report for the given result.
        /// </returns>
        protected static string ReportResult(IPartialResult result,
                                             QueryRecorder.RecordType type,
                                             IList listIndexLookups,
                                             bool fReportPartition)
        {
            StringBuilder sb = new StringBuilder();

            if (type == QueryRecorder.RecordType.Trace)
            {
                sb.Append(String.Format(REPORT_TRACE_HEADER_FORMAT,
                                        "Name", "Index", "Effectiveness", "Duration"));
            }
            else
            {
                sb.Append(String.Format(REPORT_EXPLAIN_HEADER_FORMAT,
                                        "Name", "Index", "Cost"));
            }

            sb.Append(String.Format(REPORT_DIVIDER));


            foreach (IStep childStep in result.Steps)
            {
                sb.Append(ReportStep(childStep, type, listIndexLookups, 0));
                sb.Append(String.Format("\n"));
            }

            sb.Append(String.Format("\n"));

            if (fReportPartition)
            {
                sb.Append(String.Format(REPORT_PARTITION_FORMAT,
                                        result.Partitions.ToString()));
            }

            return(sb.ToString());
        }