@Override protected IntArrayPool initialValue() { return new IntArrayPool(maxSize); } };
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; }
public static int lockInstance(IntArrayPool that, int size) { if (that.lockedCount[size] < that.data[size].length) { //we know 1 is free so find it. boolean[] temp = that.locked[size]; int i = temp.length; //NOTE: if this becomes a long array we may want to start where we left off.. while (--i>=0) { if (!temp[i]) { temp[i] = true; that.lockedCount[size]++; return i; } } throw new RuntimeException("Internal error, count was off"); } else { //more rare case where we must grow that.locked[size] = grow(that.locked[size]); that.data[size] = grow(that.data[size], size); int result = that.data[size].length-1;//last index is always the new empty one that.locked[size][result] = true; that.lockedCount[size]++; return result; } }
public static void releaseDimArray(DataInputBlobReader reader, int size, int instance) { IntArrayPool.releaseLock(IntArrayPoolLocal.get(), size, instance); } ////////////////////////////////
public static int[] lookupDimArray(DataInputBlobReader reader, int size, int instance) { return IntArrayPool.getArray(IntArrayPoolLocal.get(), size, instance); } public static void releaseDimArray(DataInputBlobReader reader, int size, int 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 void releaseDimArray(DataInputBlobReader reader, int size, int instance) { IntArrayPool.releaseLock(IntArrayPoolLocal.get(), size, instance); } ////////////////////////////////
public static int[] lookupDimArray(DataInputBlobReader reader, int size, int instance) { return IntArrayPool.getArray(IntArrayPoolLocal.get(), size, instance); } public static void releaseDimArray(DataInputBlobReader reader, int size, int 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; }
public static void releaseDimArray(DataInputBlobReader reader, int size, int instance) { IntArrayPool.releaseLock(IntArrayPoolLocal.get(), size, instance); } ////////////////////////////////
public static int[] lookupDimArray(DataInputBlobReader reader, int size, int instance) { return IntArrayPool.getArray(IntArrayPoolLocal.get(), size, instance); } public static void releaseDimArray(DataInputBlobReader reader, int size, int instance) {
@Override protected IntArrayPool initialValue() { return new IntArrayPool(maxSize); } };
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 int lockInstance(IntArrayPool that, int size) { if (that.lockedCount[size] < that.data[size].length) { //we know 1 is free so find it. boolean[] temp = that.locked[size]; int i = temp.length; //NOTE: if this becomes a long array we may want to start where we left off.. while (--i>=0) { if (!temp[i]) { temp[i] = true; that.lockedCount[size]++; return i; } } throw new RuntimeException("Internal error, count was off"); } else { //more rare case where we must grow that.locked[size] = grow(that.locked[size]); that.data[size] = grow(that.data[size], size); int result = that.data[size].length-1;//last index is always the new empty one that.locked[size][result] = true; that.lockedCount[size]++; return result; } }
final int instanceKeyP = IntArrayPool.lockInstance(local, dims); final int instanceKeyS = IntArrayPool.lockInstance(local, dims); final int instanceKeyD = IntArrayPool.lockInstance(local, 1); final int[] curPos = IntArrayPool.getArray(local, dims, instanceKeyP); final int[] curSize = IntArrayPool.getArray(local, dims, instanceKeyS); final int[] curData = IntArrayPool.getArray(local, 1, instanceKeyD); curData[0] = channelReader.absolutePosition(); visitBlobs(visitor, totalCount, curPos, curSize, curData); } finally { IntArrayPool.releaseLock(local, dims, instanceKeyP); IntArrayPool.releaseLock(local, dims, instanceKeyS); IntArrayPool.releaseLock(local, 1, instanceKeyD);
@Override protected IntArrayPool initialValue() { return new IntArrayPool(maxSize); } };
public static int lockInstance(IntArrayPool that, int size) { if (that.lockedCount[size] < that.data[size].length) { //we know 1 is free so find it. boolean[] temp = that.locked[size]; int i = temp.length; //NOTE: if this becomes a long array we may want to start where we left off.. while (--i>=0) { if (!temp[i]) { temp[i] = true; that.lockedCount[size]++; return i; } } throw new RuntimeException("Internal error, count was off"); } else { //more rare case where we must grow that.locked[size] = grow(that.locked[size]); that.data[size] = grow(that.data[size], size); int result = that.data[size].length-1;//last index is always the new empty one that.locked[size][result] = true; that.lockedCount[size]++; return result; } }
final int instanceKeyP = IntArrayPool.lockInstance(local, dims); final int instanceKeyS = IntArrayPool.lockInstance(local, dims); final int instanceKeyD = IntArrayPool.lockInstance(local, 1); final int[] curPos = IntArrayPool.getArray(local, dims, instanceKeyP); final int[] curSize = IntArrayPool.getArray(local, dims, instanceKeyS); final int[] curData = IntArrayPool.getArray(local, 1, instanceKeyD); curData[0] = channelReader.absolutePosition(); visitBlobs(visitor, totalCount, curPos, curSize, curData); } finally { IntArrayPool.releaseLock(local, dims, instanceKeyP); IntArrayPool.releaseLock(local, dims, instanceKeyS); IntArrayPool.releaseLock(local, 1, instanceKeyD);
final int instanceKeyP = IntArrayPool.lockInstance(local, dims); final int instanceKeyS = IntArrayPool.lockInstance(local, dims); final int instanceKeyD = IntArrayPool.lockInstance(local, 1); final int[] curPos = IntArrayPool.getArray(local, dims, instanceKeyP); final int[] curSize = IntArrayPool.getArray(local, dims, instanceKeyS); final int[] curData = IntArrayPool.getArray(local, 1, instanceKeyD); curData[0] = channelReader.absolutePosition(); visitTexts(visitor, totalCount, curPos, curSize, curData); } finally { IntArrayPool.releaseLock(local, dims, instanceKeyP); IntArrayPool.releaseLock(local, dims, instanceKeyS); IntArrayPool.releaseLock(local, 1, instanceKeyD);