public int closeLowLevelField() { int len = length(); Pipe.addAndGetBlobWorkingHeadPosition(p, len); Pipe.addBytePosAndLenSpecial(p,startPosition,len); p.closeBlobFieldWrite(); return len; }
public int closeLowLevelField() { int len = length(); Pipe.addAndGetBlobWorkingHeadPosition(p, len); Pipe.addBytePosAndLenSpecial(p,startPosition,len); p.closeBlobFieldWrite(); return len; }
private static boolean buildFieldFromInputStream(Pipe pipe, InputStream inputStream, final int byteCount, int startPosition, int byteMask, byte[] buffer, int sizeOfBlobRing) throws IOException { boolean result = copyFromInputStreamLoop(inputStream, byteCount, startPosition, byteMask, buffer, sizeOfBlobRing, 0); Pipe.addBytePosAndLen(pipe, startPosition, byteCount); Pipe.addAndGetBlobWorkingHeadPosition(pipe, byteCount); assert(Pipe.validateVarLength(pipe, byteCount)); return result; }
public int closeLowLevelField() { int len = length(); Pipe.addAndGetBlobWorkingHeadPosition(p, len); Pipe.addBytePosAndLenSpecial(p,startPosition,len); p.closeBlobFieldWrite(); return len; }
private static boolean buildFieldFromInputStream(Pipe pipe, InputStream inputStream, final int byteCount, int startPosition, int byteMask, byte[] buffer, int sizeOfBlobRing) throws IOException { boolean result = copyFromInputStreamLoop(inputStream, byteCount, startPosition, byteMask, buffer, sizeOfBlobRing, 0); Pipe.addBytePosAndLen(pipe, startPosition, byteCount); Pipe.addAndGetBlobWorkingHeadPosition(pipe, byteCount); assert(Pipe.validateVarLength(pipe, byteCount)); return result; }
private static boolean buildFieldFromInputStream(Pipe pipe, InputStream inputStream, final int byteCount, int startPosition, int byteMask, byte[] buffer, int sizeOfBlobRing) throws IOException { boolean result = copyFromInputStreamLoop(inputStream, byteCount, startPosition, byteMask, buffer, sizeOfBlobRing, 0); Pipe.addBytePosAndLen(pipe, startPosition, byteCount); Pipe.addAndGetBlobWorkingHeadPosition(pipe, byteCount); assert(Pipe.validateVarLength(pipe, byteCount)); return result; }
public static void addLocalHeapValue(int heapId, int sourceLen, LocalHeap byteHeap, Pipe rbRingBuffer) { final int p = Pipe.getWorkingBlobHeadPosition((Pipe<?>) rbRingBuffer); if (sourceLen > 0) { final int offset = heapId << 2; final int pos = byteHeap.tat[offset]; final int len = byteHeap.tat[offset + 1] - pos; copyToRingBuffer(Pipe.blob((Pipe<?>) rbRingBuffer), p, rbRingBuffer.blobMask, pos, len, byteHeap.data); Pipe.addAndGetBlobWorkingHeadPosition(rbRingBuffer,len); } Pipe.addBytePosAndLen(rbRingBuffer, p, sourceLen); }
public static void addLocalHeapValue(int heapId, int sourceLen, LocalHeap byteHeap, Pipe rbRingBuffer) { final int p = Pipe.getWorkingBlobHeadPosition((Pipe<?>) rbRingBuffer); if (sourceLen > 0) { final int offset = heapId << 2; final int pos = byteHeap.tat[offset]; final int len = byteHeap.tat[offset + 1] - pos; copyToRingBuffer(Pipe.blob((Pipe<?>) rbRingBuffer), p, rbRingBuffer.blobMask, pos, len, byteHeap.data); Pipe.addAndGetBlobWorkingHeadPosition(rbRingBuffer,len); } Pipe.addBytePosAndLen(rbRingBuffer, p, sourceLen); }
public static void addLocalHeapValue(int heapId, int sourceLen, LocalHeap byteHeap, Pipe rbRingBuffer) { final int p = Pipe.getWorkingBlobHeadPosition((Pipe<?>) rbRingBuffer); if (sourceLen > 0) { final int offset = heapId << 2; final int pos = byteHeap.tat[offset]; final int len = byteHeap.tat[offset + 1] - pos; copyToRingBuffer(Pipe.blob((Pipe<?>) rbRingBuffer), p, rbRingBuffer.blobMask, pos, len, byteHeap.data); Pipe.addAndGetBlobWorkingHeadPosition(rbRingBuffer,len); } Pipe.addBytePosAndLen(rbRingBuffer, p, sourceLen); }
private void publishBockOut(final int targetPos, int length) { int size= Pipe.addMsgIdx(output, RawDataSchema.MSG_CHUNKEDSTREAM_1); Pipe.addBytePosAndLen(output, targetPos, length); Pipe.addAndGetBlobWorkingHeadPosition(output, length); Pipe.confirmLowLevelWrite(output, size); Pipe.publishWrites(output); }
/** * Writes a long as a String in given pipe * @param pipe to be updated * @param loc for field to be updated * @param value long to write to specified location */ public static void writeLongAsText(Pipe pipe, int loc, long value) { assert(LOCUtil.isLocOfAnyType(loc, TypeMask.TextASCII, TypeMask.TextASCIIOptional, TypeMask.ByteVector, TypeMask.ByteVectorOptional)): "Value found "+LOCUtil.typeAsString(loc); int max = 21+Pipe.getWorkingBlobHeadPosition((Pipe<?>) pipe); int len = Pipe.leftConvertLongToASCII(pipe, value, max); finishWriteBytesAlreadyStarted(pipe, loc, len); Pipe.addAndGetBlobWorkingHeadPosition(pipe,len); }
/** * Writes given int as String in specified pipe * @param pipe to be written to * @param loc field to write data * @param value int value to be converted */ public static void writeIntAsText(Pipe pipe, int loc, int value) { assert(LOCUtil.isLocOfAnyType(loc, TypeMask.TextASCII, TypeMask.TextASCIIOptional, TypeMask.ByteVector, TypeMask.ByteVectorOptional)): "Value found "+LOCUtil.typeAsString(loc); int max = 12+ Pipe.getWorkingBlobHeadPosition((Pipe<?>) pipe); int len = Pipe.leftConvertIntToASCII(pipe, value, max); finishWriteBytesAlreadyStarted(pipe, loc, len); Pipe.addAndGetBlobWorkingHeadPosition(pipe,len); }
/** * Writes given int as String in specified pipe * @param pipe to be written to * @param loc field to write data * @param value int value to be converted */ public static void writeIntAsText(Pipe pipe, int loc, int value) { assert(LOCUtil.isLocOfAnyType(loc, TypeMask.TextASCII, TypeMask.TextASCIIOptional, TypeMask.ByteVector, TypeMask.ByteVectorOptional)): "Value found "+LOCUtil.typeAsString(loc); int max = 12+ Pipe.getWorkingBlobHeadPosition((Pipe<?>) pipe); int len = Pipe.leftConvertIntToASCII(pipe, value, max); finishWriteBytesAlreadyStarted(pipe, loc, len); Pipe.addAndGetBlobWorkingHeadPosition(pipe,len); }
private static int copyBytes(final Pipe targetPipe, int targetLOC, int length) { assert(LOCUtil.isLocOfAnyType(targetLOC, TypeMask.TextASCII, TypeMask.TextASCIIOptional, TypeMask.TextUTF8, TypeMask.TextUTF8Optional, TypeMask.ByteVector, TypeMask.ByteVectorOptional)): "Value found "+LOCUtil.typeAsString(targetLOC); int byteWrkHdPos = Pipe.getWorkingBlobHeadPosition(targetPipe); Pipe.validateVarLength(targetPipe, length); Pipe.setBytePosAndLen(Pipe.slab(targetPipe), targetPipe.slabMask, targetPipe.ringWalker.activeWriteFragmentStack[STACK_OFF_MASK&(targetLOC>>STACK_OFF_SHIFT)]+(OFF_MASK&targetLOC), byteWrkHdPos, length, Pipe.bytesWriteBase(targetPipe)); Pipe.addAndGetBlobWorkingHeadPosition(targetPipe, length); return length; }
private static int copyBytes(final Pipe targetPipe, int targetLOC, int length) { assert(LOCUtil.isLocOfAnyType(targetLOC, TypeMask.TextASCII, TypeMask.TextASCIIOptional, TypeMask.TextUTF8, TypeMask.TextUTF8Optional, TypeMask.ByteVector, TypeMask.ByteVectorOptional)): "Value found "+LOCUtil.typeAsString(targetLOC); int byteWrkHdPos = Pipe.getWorkingBlobHeadPosition(targetPipe); Pipe.validateVarLength(targetPipe, length); Pipe.setBytePosAndLen(Pipe.slab(targetPipe), targetPipe.slabMask, targetPipe.ringWalker.activeWriteFragmentStack[STACK_OFF_MASK&(targetLOC>>STACK_OFF_SHIFT)]+(OFF_MASK&targetLOC), byteWrkHdPos, length, Pipe.bytesWriteBase(targetPipe)); Pipe.addAndGetBlobWorkingHeadPosition(targetPipe, length); return length; }
/** * Specifies to close the field * @param target pipe to use * @param loc field to close */ public static void wrappedUnstructuredLayoutBufferClose(Pipe<?> target, int loc, int length) { assert(length>=0); assert(LOCUtil.isLocOfAnyType(loc, TypeMask.TextASCII, TypeMask.TextASCIIOptional, TypeMask.TextUTF8, TypeMask.TextUTF8Optional, TypeMask.ByteVector, TypeMask.ByteVectorOptional)): "Value found "+LOCUtil.typeAsString(loc); Pipe.validateVarLength(target,length); long ringPos = target.ringWalker.activeWriteFragmentStack[PipeWriter.STACK_OFF_MASK&(loc>>PipeWriter.STACK_OFF_SHIFT)] + (PipeWriter.OFF_MASK&loc); Pipe.slab(target)[target.slabMask & (int)ringPos] = (int)(target.sizeOfBlobRing + Pipe.unstoreBlobWorkingHeadPosition(target)-Pipe.bytesWriteBase(target)) & target.blobMask; //mask is needed for the negative case, does no harm in positive case Pipe.slab(target)[target.slabMask & (int)(ringPos+1)] = length; Pipe.addAndGetBlobWorkingHeadPosition(target, length); }
private static int copyBytes(final Pipe targetPipe, int targetLOC, int length) { assert(LOCUtil.isLocOfAnyType(targetLOC, TypeMask.TextASCII, TypeMask.TextASCIIOptional, TypeMask.TextUTF8, TypeMask.TextUTF8Optional, TypeMask.ByteVector, TypeMask.ByteVectorOptional)): "Value found "+LOCUtil.typeAsString(targetLOC); int byteWrkHdPos = Pipe.getWorkingBlobHeadPosition(targetPipe); Pipe.validateVarLength(targetPipe, length); Pipe.setBytePosAndLen(Pipe.slab(targetPipe), targetPipe.slabMask, targetPipe.ringWalker.activeWriteFragmentStack[STACK_OFF_MASK&(targetLOC>>STACK_OFF_SHIFT)]+(OFF_MASK&targetLOC), byteWrkHdPos, length, Pipe.bytesWriteBase(targetPipe)); Pipe.addAndGetBlobWorkingHeadPosition(targetPipe, length); return length; }
/** * Specifies to close the field * @param target pipe to use * @param loc field to close */ public static void wrappedUnstructuredLayoutBufferClose(Pipe<?> target, int loc, int length) { assert(length>=0); assert(LOCUtil.isLocOfAnyType(loc, TypeMask.TextASCII, TypeMask.TextASCIIOptional, TypeMask.TextUTF8, TypeMask.TextUTF8Optional, TypeMask.ByteVector, TypeMask.ByteVectorOptional)): "Value found "+LOCUtil.typeAsString(loc); Pipe.validateVarLength(target,length); long ringPos = target.ringWalker.activeWriteFragmentStack[PipeWriter.STACK_OFF_MASK&(loc>>PipeWriter.STACK_OFF_SHIFT)] + (PipeWriter.OFF_MASK&loc); Pipe.slab(target)[target.slabMask & (int)ringPos] = (int)(target.sizeOfBlobRing + Pipe.unstoreBlobWorkingHeadPosition(target)-Pipe.bytesWriteBase(target)) & target.blobMask; //mask is needed for the negative case, does no harm in positive case Pipe.slab(target)[target.slabMask & (int)(ringPos+1)] = length; Pipe.addAndGetBlobWorkingHeadPosition(target, length); }
private static void copyFragment2(Pipe inputRing, Pipe outputRing, int start, int spaceNeeded, int bytesToCopy) { Pipe.copyIntsFromToRing(Pipe.slab(inputRing), start, inputRing.slabMask, Pipe.slab(outputRing), (int)Pipe.workingHeadPosition(outputRing), outputRing.slabMask, spaceNeeded); Pipe.addAndGetWorkingHead(outputRing, spaceNeeded); Pipe.copyBytesFromToRing(Pipe.blob(inputRing), Pipe.getWorkingBlobTailPosition(inputRing), inputRing.blobMask, Pipe.blob(outputRing), Pipe.getWorkingBlobHeadPosition((Pipe<?>) outputRing), outputRing.blobMask, bytesToCopy); Pipe.addAndGetBlobWorkingHeadPosition(outputRing, bytesToCopy); //release the input fragment, we are using working tail and next working tail so batch release should work on walker. //prepReadFragment and tryReadFragment do the batched release, so it is not done here. //NOTE: writes are using low-level calls and we must publish them. Pipe.publishHeadPositions(outputRing); //we use the working head pos so batching still works here. }
private static void copyFragment2(Pipe inputRing, Pipe outputRing, int start, int spaceNeeded, int bytesToCopy) { Pipe.copyIntsFromToRing(Pipe.slab(inputRing), start, inputRing.slabMask, Pipe.slab(outputRing), (int)Pipe.workingHeadPosition(outputRing), outputRing.slabMask, spaceNeeded); Pipe.addAndGetWorkingHead(outputRing, spaceNeeded); Pipe.copyBytesFromToRing(Pipe.blob(inputRing), Pipe.getWorkingBlobTailPosition(inputRing), inputRing.blobMask, Pipe.blob(outputRing), Pipe.getWorkingBlobHeadPosition((Pipe<?>) outputRing), outputRing.blobMask, bytesToCopy); Pipe.addAndGetBlobWorkingHeadPosition(outputRing, bytesToCopy); //release the input fragment, we are using working tail and next working tail so batch release should work on walker. //prepReadFragment and tryReadFragment do the batched release, so it is not done here. //NOTE: writes are using low-level calls and we must publish them. Pipe.publishHeadPositions(outputRing); //we use the working head pos so batching still works here. }