public ByteValue toKilobytesValue() { return new ByteValue(unit.toKilobytes(value), KILOBYTES); }
@Override public void delete() { FileUtil.closeSilently(inputStream); FileUtil.deleteFile(dataFile); FileUtil.deleteFile(checksumFile); }
public ByteValue toGigabytesValue() { return new ByteValue(unit.toGigabytes(value), ByteUnit.GIGABYTES); }
public ByteValue toMegabytesValue() { return new ByteValue(unit.toMegabytes(value), MEGABYTES); }
public DispatcherBuilder initialPartitionId(int initialPartitionId) { EnsureUtil.ensureGreaterThanOrEqual("initial partition id", initialPartitionId, 0); this.initialPartitionId = initialPartitionId; return this; }
/** * The number of bytes the buffer is be able to contain. Represents the size of the data section. * Additional space will be allocated for the meta-data sections */ public DispatcherBuilder bufferSize(final ByteValue byteValue) { this.bufferSize = (int) byteValue.toBytes(); return this; }
@SuppressWarnings("unchecked") public P peek() { final int size = size(); Object object = null; if (size > 0) { final int index = (int) (head & mask); object = array[index]; } return (P) object; }
@Override public Iterator<P> iterator() { iterator.open(); return iterator; }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((unit == null) ? 0 : unit.hashCode()); result = prime * result + (int) (value ^ (value >>> 32)); return result; }
public static byte[] readBytes(final VarDataReader reader, final int offset, final int length) { final byte[] buffer = new byte[length]; reader.decode(buffer, offset, length); return buffer; }
public static void ensureArrayBacked(final DirectBuffer... buffers) { for (final DirectBuffer buffer : buffers) { ensureArrayBacked(buffer); } } }
@Override public void abort() { FileUtil.closeSilently(dataOutputStream); FileUtil.deleteFile(dataFile); FileUtil.deleteFile(checksumFile); }
public ByteValue toKilobytesValue() { return new ByteValue(unit.toKilobytes(value), KILOBYTES); }
public ByteValue toGigabytesValue() { return new ByteValue(unit.toGigabytes(value), ByteUnit.GIGABYTES); }
public ByteValue toMegabytesValue() { return new ByteValue(unit.toMegabytes(value), MEGABYTES); }
@SuppressWarnings("unchecked") public P poll() { final int size = size(); Object object = null; if (size > 0) { final int index = (int) (head & mask); object = array[index]; array[index] = null; ++head; } return (P) object; }
public boolean offer(P object) { final int remainingSpace = capacity - size(); if (remainingSpace > 0) { final int index = (int) (tail & mask); array[index] = object; ++tail; return true; } else { return false; } }