コード例 #1
0
        public override void RecycleByteBlocks(byte[][] blocks, int start, int end)
        {
            int numBlocks = Math.Min(MaxBufferedBlocks_Renamed - FreeBlocks_Renamed, end - start);
            int size      = FreeBlocks_Renamed + numBlocks;

            if (size >= FreeByteBlocks.Length)
            {
                var newBlocks = new byte[ArrayUtil.Oversize(size, RamUsageEstimator.NUM_BYTES_OBJECT_REF)][];
                Array.Copy(FreeByteBlocks, 0, newBlocks, 0, FreeBlocks_Renamed);
                FreeByteBlocks = newBlocks;
            }
            int stop = start + numBlocks;

            for (int i = start; i < stop; i++)
            {
                FreeByteBlocks[FreeBlocks_Renamed++] = blocks[i];
                blocks[i] = null;
            }
            for (int i = stop; i < end; i++)
            {
                blocks[i] = null;
            }
            BytesUsed_Renamed.AddAndGet(-(end - stop) * BlockSize);
            Debug.Assert(BytesUsed_Renamed.Get() >= 0);
        }
コード例 #2
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);
 }
コード例 #3
0
        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);
        }
コード例 #4
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;
 }
コード例 #5
0
ファイル: BytesRefArray.cs プロジェクト: Cefa68000/lucenenet
 /// <summary>
 /// Creates a new <seealso 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_INT);
     this.BytesUsed = bytesUsed;
 }
コード例 #6
0
ファイル: ByteBlockPool.cs プロジェクト: zfxsss/lucenenet
 public override void RecycleByteBlocks(byte[][] blocks, int start, int end)
 {
     BytesUsed.AddAndGet(-((end - start) * BlockSize));
     for (var i = start; i < end; i++)
     {
         blocks[i] = null;
     }
 }
コード例 #7
0
 public SortedDocValuesWriter(FieldInfo fieldInfo, Counter iwBytesUsed)
 {
     this.FieldInfo = fieldInfo;
     this.IwBytesUsed = iwBytesUsed;
     Hash = new BytesRefHash(new ByteBlockPool(new ByteBlockPool.DirectTrackingAllocator(iwBytesUsed)), BytesRefHash.DEFAULT_CAPACITY, new BytesRefHash.DirectBytesStartArray(BytesRefHash.DEFAULT_CAPACITY, iwBytesUsed));
     Pending = new AppendingDeltaPackedLongBuffer(PackedInts.COMPACT);
     BytesUsed = Pending.RamBytesUsed();
     iwBytesUsed.AddAndGet(BytesUsed);
 }
コード例 #8
0
 /// <summary>
 /// Creates a new <seealso 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() == null ? Counter.NewCounter() : bytesStartArray.BytesUsed();
     BytesUsed.AddAndGet(HashSize * RamUsageEstimator.NUM_BYTES_INT);
 }
コード例 #9
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);
 }
コード例 #10
0
ファイル: ByteBlockPool.cs プロジェクト: ywscr/lucenenet
 public override byte[] GetByteBlock()
 {
     bytesUsed.AddAndGet(m_blockSize);
     return(new byte[m_blockSize]);
 }