Lucene.Net.Index.DocumentsWriter.GetCharBlock C# (CSharp) Method

GetCharBlock() private method

private GetCharBlock ( ) : char[]
return char[]
		internal char[] GetCharBlock()
		{
			lock (this)
			{
				int size = freeCharBlocks.Count;
				char[] c;
				if (0 == size)
				{
					numBytesAlloc += CHAR_BLOCK_SIZE * CHAR_NUM_BYTE;
					c = new char[CHAR_BLOCK_SIZE];
				}
				else
				{
				    c = freeCharBlocks[size - 1];
				    freeCharBlocks.RemoveAt(size - 1);
				}
				// We always track allocations of char blocks, for now,
				// because nothing that skips allocation tracking
				// (currently only term vectors) uses its own char
				// blocks.
				numBytesUsed += CHAR_BLOCK_SIZE * CHAR_NUM_BYTE;
				System.Diagnostics.Debug.Assert(numBytesUsed <= numBytesAlloc);
				return c;
			}
		}
		

Usage Example

Beispiel #1
0
        public void  NextBuffer()
        {
            if (1 + bufferUpto == buffers.Length)
            {
                Array.Resize(ref buffers, (int)(buffers.Length * 1.5));
            }
            buffer = buffers[1 + bufferUpto] = docWriter.GetCharBlock();
            bufferUpto++;

            charUpto    = 0;
            charOffset += DocumentsWriter.CHAR_BLOCK_SIZE;
        }
All Usage Examples Of Lucene.Net.Index.DocumentsWriter::GetCharBlock