コード例 #1
0
ファイル: TStoreProcessor.cs プロジェクト: zbxzc35/BoostTree
        // if inner==true, does inner Join else does leftOuter Join
        private RecordSource _Join(RecordSource left, RecordSource right, bool inner)
        {
            bool requiresSorting = true;
            bool ascending = true;

            PairFilter filter = null;

            if (inner) filter = new InnerJoin(TableColumnSeparator);
            else filter = new LeftOuterJoin(TableColumnSeparator);

            // T = TypeSort asked for, either Ascending or Descending

            //			     Right
            //		    !T		T
            // l	!T	sbT 	slT
            // e
            // f	T	srT		X
            // t

            if (requiresSorting) {
                if (!left.InternalSource.Sorting.IsSorted || left.InternalSource.Sorting.IsSortedAscending != ascending) {
                    left.SortReduce(ascending, false);
                }

                if (!right.InternalSource.Sorting.IsSorted || right.InternalSource.Sorting.IsSortedAscending != ascending) {
                    right.SortReduce(ascending, false);
                }
            }

            RecordSource source2BoperatedOn = new RecordSource(this);
            source2BoperatedOn.InternalSource = filter;
            filter.AddInput(left.InternalSource);
            filter.AddInput(right.InternalSource);
            return source2BoperatedOn;
        }
コード例 #2
0
ファイル: TStoreProcessor.cs プロジェクト: zbxzc35/BoostTree
        /// <summary>
        /// Pair performs operations two input RecordSources, left and right.  These are, for
        /// example, CatLeftThenRight, SortedMerge, FilterLeftByRightKey.
        /// </summary>
        /// <param name="left">One of two RecordSources</param>
        /// <param name="right">One of two RecordSources</param>
        /// <param name="pairOperation">The operation to perform on the input sources</param>
        /// <returns>A RecordSource for further processing</returns>
        public RecordSource Pair(RecordSource left, RecordSource right, PairOperation pairOperation)
        {
            PairFilter filter = null;
            bool requiresSorting = false; // not all pair operations require inputs sorted
            bool ascending = true;

            switch (pairOperation) {
                case PairOperation.FilterLeftInRight:
                    filter = new FilterLeftByRightKey(true);
                    requiresSorting = true;
                    break;

                case PairOperation.FilterLeftNotInRight:
                    filter = new FilterLeftByRightKey(false);
                    requiresSorting = true;
                    break;

                case PairOperation.MergeAscend:
                    filter = new SortedMerge(true);
                    requiresSorting = true;
                    ascending = true;
                    break;

                case PairOperation.MergeDescend:
                    filter = new SortedMerge(false);
                    requiresSorting = true;
                    ascending = false;
                    break;

                case PairOperation.CatLeftThenRight:
                    filter = new CatLeftThenRight();
                    requiresSorting = false;
                    break;
            }

            // T = TypeSort asked for, either Ascending or Descending

            //			     Right
            //		    !T		T
            // l	!T	sbT 	slT
            // e
            // f	T	srT		X
            // t

            if (requiresSorting) {
                if (!left.InternalSource.Sorting.IsSorted || left.InternalSource.Sorting.IsSortedAscending != ascending) {
                    left.SortReduce(ascending, false);
                }

                if (!right.InternalSource.Sorting.IsSorted || right.InternalSource.Sorting.IsSortedAscending != ascending) {
                    right.SortReduce(ascending, false);
                }
            }

            RecordSource source2BoperatedOn = new RecordSource(this);
            source2BoperatedOn.InternalSource = filter;
            filter.AddInput(left.InternalSource);
            filter.AddInput(right.InternalSource);
            return source2BoperatedOn;
        }