public static void releaseDimArray(DataInputBlobReader reader, int size, int instance) { IntArrayPool.releaseLock(IntArrayPoolLocal.get(), size, instance); } ////////////////////////////////
public static int reserveDimArray(DataInputBlobReader reader, int size, int maxSize) { return IntArrayPool.lockInstance(IntArrayPoolLocal.get(), size); } public static int[] lookupDimArray(DataInputBlobReader reader, int size, int instance) {
public static <S extends MessageSchema<S>> long readPackedLong(DataInputBlobReader<S> that) { byte v = that.backing[that.byteMask & that.position++]; long accumulator = (~((long)(((v>>6)&1)-1)))&0xFFFFFFFFFFFFFF80l; IntArrayPool temp = IntArrayPoolLocal.get(); int id = IntArrayPool.lockInstance(temp, 1); int[] pos = IntArrayPool.getArray(IntArrayPoolLocal.get(), 1, id); //thread local wrapper pos[0] = that.position; long result = (v >= 0) ? readPackedLong((accumulator | v) << 7,that.backing,that.byteMask,pos, 0) : (accumulator) |(v & 0x7F); that.position = pos[0]; IntArrayPool.releaseLock(temp, 1, id); return result; }
/** * Blocks until the desired time as passed to ensure this stream conforms to the requested bits per second. * Once the time has passed it returns so the InputStream can read the next chunk. */ public final boolean hasNextChunk() { if (!readChunk()) { return false; //No chunk now try again } waitAsNeededForRead(); return true; }
/** * Blocks until the desired time as passed to ensure this stream conforms to the requested bits per second. * Once the time has passed the output stream buffer will send its data and be ready for more writes. */ public final boolean hasRoomForChunk() { if (!openForWrite()) { return false; }; waitAsNeededForWrite(); return true; }
public static int copyToRingBuffer(int idx, byte[] target, final int targetIdx, final int targetMask, LocalHeap localHeap) {//Invoked 100's of millions of times, must be tight. final int offset = idx << 2; final int pos = localHeap.tat[offset]; final int len = localHeap.tat[offset + 1] - pos; copyToRingBuffer(target, targetIdx, targetMask, pos, len, localHeap.data); return targetIdx + len; }
public static void reset(int idx, LocalHeap heap) { int offset = idx << 1; // this shift left also removes the top bit! // sweet. int startFrom = heap.initTat[offset]; int len = heap.initTat[offset + 1] - startFrom; heap.setInternal(idx, heap.initBuffer, startFrom, len); }
public static void appendHead(int idx, int trimHead, byte[] source, int sourceIdx, int sourceLen, int sourceMask,LocalHeap heap) { int targetIdx = makeSpaceForPrepend(idx,trimHead,sourceLen,heap); int i = sourceLen; while (--i>=0) { heap.data[targetIdx+i] = source[sourceMask&(sourceIdx+i)]; } }
public static boolean equals(int idx, byte[] target, int targetIdx, int targetLen, int targetMask, LocalHeap heap) { if (idx < 0) { int offset = idx << 1; return eq(target, targetIdx, targetLen, targetMask, heap.initTat[offset], heap.initTat[offset + 1], heap.initBuffer); } else { int offset = idx << 2; return eq(target, targetIdx, targetLen, targetMask, heap.tat[offset], heap.tat[offset + 1], heap.data); } }
public int appendTail(int offset, int nextLimit, byte value) { // setZeroLength was called first so no need to check for null if (tat[offset + 1] >= nextLimit) { // System.err.println("make space for "+offset); makeSpaceForAppend(offset, 1); nextLimit = tat[offset + 4]; } // everything is now ready to trim and copy. data[tat[offset + 1]++] = value; return nextLimit; }
public static void set(int idx, byte[] source, int startFrom, int copyLength, int sourceMask, LocalHeap heap) { int offset = idx << 2; heap.totalContent += (copyLength - (heap.tat[offset + 1] - heap.tat[offset])); int target = heap.makeRoom(offset, copyLength); heap.tat[offset] = target; heap.tat[offset + 1] = target + copyLength; int i = copyLength; while (--i>=0) { heap.data[target+i] = source[sourceMask&(startFrom+i)]; } }
public static void releaseDimArray(DataInputBlobReader reader, int size, int instance) { IntArrayPool.releaseLock(IntArrayPoolLocal.get(), size, instance); } ////////////////////////////////
public static int reserveDimArray(DataInputBlobReader reader, int size, int maxSize) { return IntArrayPool.lockInstance(IntArrayPoolLocal.get(), size); } public static int[] lookupDimArray(DataInputBlobReader reader, int size, int instance) {
/** * Blocks until the desired time as passed to ensure this stream conforms to the requested bits per second. * Once the time has passed it returns so the InputStream can read the next chunk. */ public final boolean hasNextChunk() { if (!readChunk()) { return false; //No chunk now try again } waitAsNeededForRead(); return true; }
public static int copyToRingBuffer(int idx, byte[] target, final int targetIdx, final int targetMask, LocalHeap localHeap) {//Invoked 100's of millions of times, must be tight. final int offset = idx << 2; final int pos = localHeap.tat[offset]; final int len = localHeap.tat[offset + 1] - pos; copyToRingBuffer(target, targetIdx, targetMask, pos, len, localHeap.data); return targetIdx + len; }
public static void releaseDimArray(DataInputBlobReader reader, int size, int instance) { IntArrayPool.releaseLock(IntArrayPoolLocal.get(), size, instance); } ////////////////////////////////
public static int reserveDimArray(DataInputBlobReader reader, int size, int maxSize) { return IntArrayPool.lockInstance(IntArrayPoolLocal.get(), size); } public static int[] lookupDimArray(DataInputBlobReader reader, int size, int instance) {