public void fetchFinished() { if (!byPass()) { processFinal(); } super.flush(); fetchStarted = false; } }
/** Splits current element in the list, using DiskRange::slice. * @param cOffset the position to split the list * @return the split list */ public final DiskRangeList split(long cOffset) { DiskRangeList right = insertAfterInternal((DiskRangeList)this.sliceAndShift(cOffset, end, 0)); DiskRangeList left = replaceSelfWith((DiskRangeList)this.sliceAndShift(offset, cOffset, 0)); checkOrder(left, right, left); // Prev/next are already checked in the calls. return left; }
public void println(String out) { if (byPass()) { printDirect(out); } else { process(out); } }
private void allocateMultiple(MemoryBuffer[] dest, int size) { if (allocator != null) { allocator.allocateMultiple(dest, size, cacheWrapper.getDataBufferFactory(), isStopped); } else { cacheWrapper.getAllocator().allocateMultiple(dest, size, cacheWrapper.getDataBufferFactory()); } }
/** Resets the data that the buffer reads. */ public void reset(byte[] input, int length) { buffer.reset(input, 0, length); }
/** * Returns the current contents of the buffer. Data is only valid to * {@link #getLength()}. */ public byte[] getData() { return buffer.getData(); }
/** Resets the buffer to empty. */ public NonSyncDataOutputBuffer reset() { written = 0; buffer.reset(); return this; }
/** Returns the length of the input. */ public int getLength() { return buffer.getLength(); }
/** Constructs a new empty buffer. */ public NonSyncDataOutputBuffer() { this(new NonSyncByteArrayOutputStream()); }
@Override public void handleCacheCollision(DataCache cacheWrapper, MemoryBuffer replacementBuffer, List<MemoryBuffer> cacheBuffers) { assert cacheBuffers == null; // This is done at pre-read stage where there's nothing special w/refcounts. Just release. cacheWrapper.getAllocator().deallocate(getBuffer()); // Replace the buffer in our big range list, as well as in current results. this.setBuffer(replacementBuffer); }
/** * {@inheritDoc} */ @Override public void write(int b) { enLargeBuffer(1); buf[count] = (byte) b; count += 1; }
/** * Inserts an element after current in the list. * @param other the new element to insert * @return the new element. * */ public DiskRangeList insertAfter(DiskRangeList other) { checkArg(other); checkOrder(this, other, this); return insertAfterInternal(other); }
private DiskRange[] gaps(int... offsets) { DiskRange[] result = new DiskRange[offsets.length - 1]; for (int i = 0; i < result .length; ++i) { result[i] = new DiskRange(offsets[i], offsets[i + 1]); } return result; }
public DiskRangeList[] listToArray() { DiskRangeList[] result = new DiskRangeList[listSize()]; int i = 0; DiskRangeList current = this.next; while (current != null) { result[i] = current; ++i; current = current.next; } return result; }
private DiskRangeList insertAfterInternal(DiskRangeList other) { other.next = this.next; other.prev = this; if (this.next != null) { checkOrder(other, this.next, this); this.next.prev = other; } this.next = other; return other; }
/** Resets the data that the buffer reads. */ public void reset(byte[] input, int start, int length) { buffer.reset(input, start, length); }
private DiskRange[] drs(int... offsets) { DiskRange[] result = new DiskRange[offsets.length]; for (int i = 0; i < offsets.length; ++i) { result[i] = new DiskRange(offsets[i], offsets[i] + 1); } return result; }
public void setEnd(long newEnd) { assert newEnd >= this.offset; assert this.next == null || this.next.offset >= newEnd; this.end = newEnd; if (this.next != null) { checkOrder(this, this.next, this); } } }