public static boolean checkBufRefs(final ValueVector vv) { for(final DrillBuf buffer : vv.getBuffers(false)) { if (buffer.refCnt() <= 0) { throw new IllegalStateException("zero refcount"); } } return true; }
private static void checkIndex(DrillBuf buf, int index, int fieldLength) { Preconditions.checkNotNull(buf); if (checkAccessible && buf.refCnt() == 0) { Formatter formatter = new Formatter().format("%s, refCnt: 0", buf); if (BaseAllocator.DEBUG) { formatter.format("%n%s", buf.toVerboseString()); } throw new IllegalReferenceCountException(formatter.toString()); } if (fieldLength < 0) { throw new IllegalArgumentException(String.format("length: %d (expected: >= 0)", fieldLength)); } if (index < 0 || index > buf.capacity() - fieldLength) { Formatter formatter = new Formatter().format("%s, index: %d, length: %d (expected: range(0, %d))", buf, index, fieldLength, buf.capacity()); if (BaseAllocator.DEBUG) { formatter.format("%n%s", buf.toVerboseString()); } throw new IndexOutOfBoundsException(formatter.toString()); } }
/** * Helper method to check if the buffer we are accessing * has a minimum reference count and has not been deallocated * @param b working drill buffer */ private void checkBuf(DrillBuf b){ if(b.refCnt() < 1){ throw new IllegalStateException("Cannot access a dereferenced buffer."); } }
public static boolean checkBufRefs(final ValueVector vv) { for(final DrillBuf buffer : vv.getBuffers(false)) { if (buffer.refCnt() <= 0) { throw new IllegalStateException("zero refcount"); } } return true; }
private static void checkIndex(DrillBuf buf, int index, int fieldLength) { Preconditions.checkNotNull(buf); if (checkAccessible && buf.refCnt() == 0) { Formatter formatter = new Formatter().format("%s, refCnt: 0", buf); if (BaseAllocator.DEBUG) { formatter.format("%n%s", buf.toVerboseString()); } throw new IllegalReferenceCountException(formatter.toString()); } if (fieldLength < 0) { throw new IllegalArgumentException(String.format("length: %d (expected: >= 0)", fieldLength)); } if (index < 0 || index > buf.capacity() - fieldLength) { Formatter formatter = new Formatter().format("%s, index: %d, length: %d (expected: range(0, %d))", buf, index, fieldLength, buf.capacity()); if (BaseAllocator.DEBUG) { formatter.format("%n%s", buf.toVerboseString()); } throw new IndexOutOfBoundsException(formatter.toString()); } }