public override MergeSpecification FindForcedMerges(SegmentInfos segmentInfos, int maxSegmentCount, IDictionary<SegmentCommitInfo, bool?> segmentsToMerge)
        {
            IList<SegmentCommitInfo> eligibleSegments = new List<SegmentCommitInfo>();
            foreach (SegmentCommitInfo info in segmentInfos.Segments)
            {
                if (segmentsToMerge.ContainsKey(info))
                {
                    eligibleSegments.Add(info);
                }
            }

            //System.out.println("MRMP: findMerges sis=" + segmentInfos + " eligible=" + eligibleSegments);
            MergeSpecification mergeSpec = null;
            if (eligibleSegments.Count > 1 || (eligibleSegments.Count == 1 && eligibleSegments[0].HasDeletions()))
            {
                mergeSpec = new MergeSpecification();
                // Already shuffled having come out of a set but
                // shuffle again for good measure:
                eligibleSegments = CollectionsHelper.Shuffle(eligibleSegments);
                int upto = 0;
                while (upto < eligibleSegments.Count)
                {
                    int max = Math.Min(10, eligibleSegments.Count - upto);
                    int inc = max <= 2 ? max : TestUtil.NextInt(Random, 2, max);
                    mergeSpec.Add(new OneMerge(eligibleSegments.SubList(upto, upto + inc)));
                    upto += inc;
                }
            }

            if (mergeSpec != null)
            {
                foreach (OneMerge merge in mergeSpec.Merges)
                {
                    foreach (SegmentCommitInfo info in merge.Segments)
                    {
                        Debug.Assert(segmentsToMerge.ContainsKey(info));
                    }
                }
            }
            return mergeSpec;
        }
        public override MergeSpecification FindMerges(MergeTrigger? mergeTrigger, SegmentInfos segmentInfos)
        {
            MergeSpecification mergeSpec = null;
            //System.out.println("MRMP: findMerges sis=" + segmentInfos);

            int numSegments = segmentInfos.Size();

            IList<SegmentCommitInfo> segments = new List<SegmentCommitInfo>();
            ICollection<SegmentCommitInfo> merging = Writer.Get().MergingSegments;

            foreach (SegmentCommitInfo sipc in segmentInfos.Segments)
            {
                if (!merging.Contains(sipc))
                {
                    segments.Add(sipc);
                }
            }

            numSegments = segments.Count;

            if (numSegments > 1 && (numSegments > 30 || Random.Next(5) == 3))
            {
                segments = CollectionsHelper.Shuffle(segments);

                // TODO: sometimes make more than 1 merge?
                mergeSpec = new MergeSpecification();
                int segsToMerge = TestUtil.NextInt(Random, 1, numSegments);
                mergeSpec.Add(new OneMerge(segments.SubList(0, segsToMerge)));
            }

            return mergeSpec;
        }
Example #3
0
        public virtual T_Type RenderView(IndentStringBuilder builder, List<string> call_stack, IndentStringBuilder paras,AssignOperatorInfo? op, IndentStringBuilder opValue,
            PostfixPartType? postfixPartType, IndentStringBuilder func_paras, IndentStringBuilder index_para)
        {
            //if(call_stack == null)

            var member = call_stack[0];
            AssignOperatorInfo? op2 = null;
            IndentStringBuilder opValue2 = null;
            if (call_stack.Count == 1)
            {
                op2 = op;
                opValue2 = opValue;
            }

            T_Type nextType = null;
            if (!this.IsInstance)
            {
                foreach (var f in this.Static_Fields)
                {
                    if (f.Name == member)
                    {
                        this.RenderView(builder, f, op2, opValue2);
                        nextType = f.Type;
                        break;
                    }
                }
                if (nextType == null)
                {
                    foreach (var m in this.Static_Methods)
                    {
                        if (m.Name == member)
                        {
                            this.RenderView(builder, m, paras);
                            nextType = m.Type;
                            break;
                        }
                    }
                }
            }
            else
            {
                foreach (var f in this.Fields)
                {
                    if (f.Name == member)
                    {
                        this.RenderView(builder, f, op2, opValue2);
                        nextType = f.Type;
                        break;
                    }
                }
                if (nextType == null)
                {
                    foreach (var m in this.Methods)
                    {
                        if (m.Name == member)
                        {
                            this.RenderView(builder, m, paras);
                            nextType = m.Type;
                            break;
                        }
                    }
                }
            }
            if (call_stack.Count > 1)
            {
                //var call_stack2 = new List<string>();
                //call_stack2.AddRange(call_stack);
                //call_stack2.RemoveAt(0);
                return nextType.RenderView(builder, call_stack.SubList(1), paras, op, opValue, postfixPartType, func_paras, index_para);
            }

            return nextType;
        }