public long getSize(ValueVector v, SizeType type){ long size = 0; ArrowBuf[] buffers = v.getBuffers(false); for(ArrowBuf b : buffers){ switch(type){ case ACCOUNTED: size += b.getActualMemoryConsumed(); break; case WORSE_CASE: UnsafeDirectLittleEndian udle = (UnsafeDirectLittleEndian) b.unwrap(); // avoid counting the same underlying buffer multiple times if (accountedBuffers.containsKey(udle)) { continue; } size += b.getPossibleMemoryConsumed(); accountedBuffers.put(udle, null); break; default: throw new UnsupportedOperationException("Invalid case: " + type.name()); } } return size; }
private void dumpBuffers(final StringBuilder sb, final Set<BufferLedger> ledgerSet) { for (final BufferLedger ledger : ledgerSet) { if (!ledger.isOwningLedger()) { continue; } final UnsafeDirectLittleEndian udle = ledger.getUnderlying(); sb.append("UnsafeDirectLittleEndian[dentityHashCode == "); sb.append(Integer.toString(System.identityHashCode(udle))); sb.append("] size "); sb.append(Integer.toString(udle.capacity())); sb.append('\n'); } }
/** * Package visible for debugging/verification only. */ @VisibleForTesting protected UnsafeDirectLittleEndian getUnderlying() { return underlying; }
/** * Verifies the accounting state of the allocator. Only works for DEBUG. * * @throws IllegalStateException * when any problems are found */ void verifyAllocator() { final IdentityHashMap<UnsafeDirectLittleEndian, BaseAllocator> buffersSeen = new IdentityHashMap<>(); verifyAllocator(buffersSeen); }