Gets the number of memory segments used by this partition, which includes build side
memory buffers and overflow memory segments.

@return The number of occupied memory segments.
343868
int getNumOccupiedMemorySegments() {
		// either the number of memory segments, or one for spilling
		final int numPartitionBuffers = this.partitionBuffers != null ?
				this.partitionBuffers.length
				: this.buildSideWriteBuffer.getNumOccupiedMemorySegments();
		return numPartitionBuffers + bucketArea.buckets.length + bucketArea.numOverflowSegments;
	}
696708
@Override
  public long getAllocatedMemory() {
    long sum = 0;
    for (MapInternals m : segments) {
      sum += m.getAllocatedMemory();
    }
    return sum;
  }
333139
public long getFreeMemory() {
    try {
      return (long) mBeanServer.getAttribute(new ObjectName("java.lang", "type", "OperatingSystem"), "FreePhysicalMemorySize");
    } catch (Exception e) {
      if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("An exception occurred during memory check", e);
      }
    }
    return -1;
  }
147223
public static byte getByte(MemorySegment[] segments, int offset) {
		if (inFirstSegment(segments, offset, 1)) {
			return segments[0].get(offset);
		} else {
			return getByteMultiSegments(segments, offset);
		}
	}
724137
public void allocateSegments(int numberOfSegments) {
		while (getBlockCount() < numberOfSegments) {
			MemorySegment next = this.availableMemory.nextSegment();
			if (next != null) {
				this.partitionPages.add(next);
			} else {
				return;
			}
		}
	}
1252568
public Segment nextSegment() {
		if (m_currentSegmentIndex != m_nextSegmentIndex)
			_updateSegment();

		if (m_bCirculator) {
			m_nextSegmentIndex = (m_nextSegmentIndex + 1) % m_segmentCount;
		} else {
			if (m_nextSegmentIndex == m_segmentCount)
				throw new IndexOutOfBoundsException();

			m_nextSegmentIndex++;
		}

		return m_currentSegment;
	}
441399
public int delete() {
        close();
       int count = segments.trunc(Integer.MAX_VALUE).size();
       Utils.deleteDirectory(dir);
       return count;
    }
668202
public String getMemoryUsageAsString() {
        long len = weights.length;
        return ((8L + 4L + 4L) * len
                + changedNodes.getCapacity() * 4L
                + heap.getCapacity() * (4L + 4L)) / Helper.MB
                + "MB";
    }
89990
public int numChars() {
    int len = 0;
    for (int i = 0; i < numBytes; i += numBytesForFirstByte(getByte(i))) {
      len += 1;
    }
    return len;
  }
1346482
public byte[] getLastSegment() {
    if (segments.isEmpty()) {
      return null;
    }
    BufferSegment seg = segments.get(segments.size() - 1);
    return Arrays.copyOfRange(seg.buf, seg.offset, seg.offset + seg.len);
  }
1176111
@Override
	protected MemorySegment nextSegment(MemorySegment current, int positionInCurrent) throws EOFException
	{	
		final MemorySegment next = this.memorySource.nextSegment();
		if (next != null) {
			this.fullSegments.add(next);
			this.segmentNum++;
			return next;
		} else {
			throw new EOFException();
		}
	}
1119977
public static long getEstimatedMemoryUsage (Raster raster)
    {
        // we assume that the data buffer stores each element in a byte-rounded memory element;
        // maybe the buffer is smarter about things than this, but we're better to err on the safe
        // side
        DataBuffer db = raster.getDataBuffer();
        int bpe = (int)Math.ceil(DataBuffer.getDataTypeSize(db.getDataType()) / 8f);
        return bpe * db.getSize();
    }
425787
protected int numFreeEntries() {
        int res = 0;
        for (int i = 0; i < entries.length; i++) {
            Entry entry = entries[i];
            if (entry.isEmpty()) {
                res++;
            }
        }

        assert (NUMBER_ENTRIES == entries.length);
        return res;
    }
746924
public long getTotalSpace() {
        try {
            StructStatVfs sb = Libcore.os.statvfs(path);
            return sb.f_blocks * sb.f_bsize; // total block count * block size in bytes.
        } catch (ErrnoException errnoException) {
            return 0;
        }
    }
1018659
public long size() {
        int size = 0;
        for (LogSegment seg : segments.getView()) {
            size += seg.size();
        }
        return size;
    }
545971
public static int getInt(MemorySegment[] segments, int offset) {
		if (inFirstSegment(segments, offset, 4)) {
			return segments[0].getInt(offset);
		} else {
			return getIntMultiSegments(segments, offset);
		}
	}
1166799
public int size() {
        int count = 0;

        for (int i = 0, size = mScrapLength.size(); i < size; i++) {
            int val = mScrapLength.valueAt(i);
            count += val;
        }

        return count;
    }