Beispiel #1
0
 /// <summary>
 /// NOTE: This was getIntBlock() in Lucene
 /// </summary>
 public override int[] GetInt32Block()
 {
     if (freeBlocks == 0)
     {
         bytesUsed.AddAndGet(m_blockSize * RamUsageEstimator.NUM_BYTES_INT32);
         return(new int[m_blockSize]);
     }
     int[] b = freeByteBlocks[--freeBlocks];
     freeByteBlocks[freeBlocks] = null;
     return(b);
 }
        public override byte[] GetByteBlock()
        {
            if (freeBlocks == 0)
            {
                bytesUsed.AddAndGet(m_blockSize);
                return(new byte[m_blockSize]);
            }
            var b = freeByteBlocks[--freeBlocks];

            freeByteBlocks[freeBlocks] = null;
            return(b);
        }
Beispiel #3
0
 /// <summary>
 /// Creates a new <see cref="BytesRefArray"/> with a counter to track allocated bytes
 /// </summary>
 public BytesRefArray(Counter bytesUsed)
 {
     this.pool = new ByteBlockPool(new ByteBlockPool.DirectTrackingAllocator(bytesUsed));
     pool.NextBuffer();
     bytesUsed.AddAndGet(RamUsageEstimator.NUM_BYTES_ARRAY_HEADER + RamUsageEstimator.NUM_BYTES_INT32);
     this.bytesUsed = bytesUsed;
 }
Beispiel #4
0
 /// <summary>
 /// Creates a new <see cref="BytesRefHash"/>
 /// </summary>
 public BytesRefHash(ByteBlockPool pool, int capacity, BytesStartArray bytesStartArray)
 {
     hashSize     = capacity;
     hashHalfSize = hashSize >> 1;
     hashMask     = hashSize - 1;
     this.pool    = pool;
     ids          = new int[hashSize];
     Arrays.Fill(ids, -1);
     this.bytesStartArray = bytesStartArray;
     bytesStart           = bytesStartArray.Init();
     bytesUsed            = bytesStartArray.BytesUsed() ?? Counter.NewCounter();
     bytesUsed.AddAndGet(hashSize * RamUsageEstimator.NUM_BYTES_INT32);
 }
Beispiel #5
0
 public override byte[] GetByteBlock()
 {
     bytesUsed.AddAndGet(m_blockSize);
     return(new byte[m_blockSize]);
 }