BytesAllocated() private method

private BytesAllocated ( long numBytes ) : void
numBytes long
return void
Ejemplo n.º 1
0
        public override bool FreeRAM()
        {
            lock (this)
            {
                if (!trackAllocations)
                {
                    return(false);
                }

                bool any;
                int  numToFree;
                if (postingsFreeCount >= postingsFreeChunk)
                {
                    numToFree = postingsFreeChunk;
                }
                else
                {
                    numToFree = postingsFreeCount;
                }
                any = numToFree > 0;
                if (any)
                {
                    for (int i = postingsFreeCount - numToFree; i < postingsFreeCount; i++)
                    {
                        postingsFreeList[i] = null;
                    }
                    postingsFreeCount  -= numToFree;
                    postingsAllocCount -= numToFree;
                    docWriter.BytesAllocated((-numToFree) * bytesPerPosting);
                    any = true;
                }

                if (nextTermsHash != null)
                {
                    any |= nextTermsHash.FreeRAM();
                }

                return(any);
            }
        }
Ejemplo n.º 2
0
        internal void  ShrinkFreePostings(IDictionary <InvertedDocConsumerPerThread, ICollection <InvertedDocConsumerPerField> > threadsAndFields, SegmentWriteState state)
        {
            System.Diagnostics.Debug.Assert(postingsFreeCount == postingsAllocCount, "Thread.currentThread().getName()" + ": postingsFreeCount=" + postingsFreeCount + " postingsAllocCount=" + postingsAllocCount + " consumer=" + consumer);

            int newSize = 1;

            if (newSize != postingsFreeList.Length)
            {
                if (postingsFreeCount > newSize)
                {
                    if (trackAllocations)
                    {
                        docWriter.BytesAllocated(-(postingsFreeCount - newSize) * bytesPerPosting);
                    }
                    postingsFreeCount  = newSize;
                    postingsAllocCount = newSize;
                }

                RawPostingList[] newArray = new RawPostingList[newSize];
                Array.Copy(postingsFreeList, 0, newArray, 0, postingsFreeCount);
                postingsFreeList = newArray;
            }
        }
Ejemplo n.º 3
0
        internal override bool freeRAM()
        {
            lock (this)
            {
                if (!trackAllocations)
                {
                    return(false);
                }

                bool any;
                int  numToFree;
                if (postingsFreeCount >= postingsFreeChunk)
                {
                    numToFree = postingsFreeChunk;
                }
                else
                {
                    numToFree = postingsFreeCount;
                }
                any = numToFree > 0;
                if (any)
                {
                    SupportClass.CollectionsSupport.ArrayFill(postingsFreeList, postingsFreeCount - numToFree, postingsFreeCount, null);
                    postingsFreeCount  -= numToFree;
                    postingsAllocCount -= numToFree;
                    docWriter.BytesAllocated(-numToFree * bytesPerPosting);
                    any = true;
                }

                if (nextTermsHash != null)
                {
                    any |= nextTermsHash.freeRAM();
                }

                return(any);
            }
        }