private static void continueSequence(final StackStateWalker ringBufferConsumer) { //check top of the stack int stackHead = ringBufferConsumer.seqStackHead; int seq; if ( (seq = ringBufferConsumer.seqStack[stackHead]-1) >0) { ringBufferConsumer.seqStack[stackHead] = seq; //stay on cursor location we are counting down. ringBufferConsumer.nextCursor = ringBufferConsumer.seqCursors[stackHead]; // System.err.println("ENDING WITHsss :"+ringBufferConsumer.nextCursor); } else { ringBufferConsumer.seqStack[stackHead] = seq; closeSequence(ringBufferConsumer); } }
private static void openOrCloseSequenceWhileInsideFragment( Pipe ringBuffer, final StackStateWalker ringBufferConsumer, long tmpNextWorkingTail, int lastScriptPos, int lastTokenOfFragment) { //this is a group or groupLength that has appeared while inside a fragment that does not start a message //this single bit on indicates that this starts a sequence length 00100 if ( (lastTokenOfFragment & ( 0x04 <<TokenBuilder.SHIFT_TYPE)) == 0 ) { if (//if this is a closing sequence group. (lastTokenOfFragment & ( (OperatorMask.Group_Bit_Seq|OperatorMask.Group_Bit_Close) <<TokenBuilder.SHIFT_OPER)) == ((OperatorMask.Group_Bit_Seq|OperatorMask.Group_Bit_Close)<<TokenBuilder.SHIFT_OPER) ) { continueSequence(ringBufferConsumer); } } else { openSequenceWhileInsideFragment(ringBuffer, ringBufferConsumer, tmpNextWorkingTail, lastScriptPos); } }
static boolean copyFragment0(Pipe inputRing, Pipe outputRing, long start, long end) { return copyFragment1(inputRing, outputRing, start, (int)(end-start), Pipe.slab(inputRing)[inputRing.slabMask&(((int)end)-1)]); }
static void setMsgIdx(StackStateWalker rw, int idx, long llwHeadPosCache) { rw.msgIdxPrev = rw.msgIdx; rw.msgIdx = idx; assert(idx < rw.from.fragDataSize.length) : "Bad msgIdx out of range"; assert(idx>-3): "Bad msgIdx too small "; assert(isMsgIdxStartNewMessage(idx, rw)) : "Bad msgIdx is not a starting point. "; //This validation is very important, because all down stream consumers will assume it to be true. assert(-1 ==idx || (rw.from.hasSimpleMessagesOnly && 0==rw.msgIdx && rw.from.messageStarts.length==1) || TypeMask.Group == TokenBuilder.extractType(rw.from.tokens[rw.msgIdx])) : errorMessageForMessageStartValidation(rw, llwHeadPosCache); assert(-1 ==idx || (rw.from.hasSimpleMessagesOnly && 0==rw.msgIdx && rw.from.messageStarts.length==1) || (OperatorMask.Group_Bit_Close&TokenBuilder.extractOper(rw.from.tokens[rw.msgIdx])) == 0) : errorMessageForMessageStartValidation(rw, llwHeadPosCache); }
/** * Checks to see if pipe has content to read * @param pipe to be checked * @return <code>true</code> if pipe has content, else <code>false</code> */ public static boolean hasContentToRead(Pipe pipe) { return StackStateWalker.hasContentToRead(pipe); }
boolean copied = StackStateWalker.copyFragment0(pipeIn, pipeOut, Pipe.getWorkingTailPosition(pipeIn), pipeIn.ringWalker.nextWorkingTail); while (copied && !FieldReferenceOffsetManager.isTemplateStart(Pipe.from(pipeIn), pipeIn.ringWalker.nextCursor)) { copied = StackStateWalker.prepReadFragment(pipeIn, pipeIn.ringWalker) && StackStateWalker.copyFragment0(pipeIn, pipeOut, Pipe.getWorkingTailPosition(pipeIn), pipeIn.ringWalker.nextWorkingTail);
/** * blocks until there is enough room for the requested fragment on the output ring. * if the fragment needs a template id it is written and the workingHeadPosition is set to the first field. * */ @Deprecated public static void blockWriteFragment(Pipe pipe, int messageTemplateLOC) { //caution does not have same behavior as tryWrite. //maximize code re-use and unify behavior of the writeFragment methods. Pipe.writeTrailingCountOfBytesConsumed(pipe, pipe.ringWalker.nextWorkingHead -1 ); StackStateWalker.blockWriteFragment0(pipe, messageTemplateLOC, Pipe.from(pipe), pipe.ringWalker); }
private static boolean copyFragment1(Pipe inputRing, Pipe outputRing, long start, int spaceNeeded, int bytesToCopy) { if ((spaceNeeded > outputRing.sizeOfSlabRing-(int)(Pipe.workingHeadPosition(outputRing) - Pipe.tailPosition(outputRing)) )) { return false; } copyFragment2(inputRing, outputRing, (int)start, spaceNeeded, bytesToCopy); return true; }
static boolean hasContentToRead(Pipe pipe) { return (pipe.llWrite.llwHeadPosCache > 1+pipe.ringWalker.nextWorkingTail) || hasContentToReadSlow(pipe); }
this.ringWalker = new StackStateWalker(MessageSchema.from(schema), sizeOfSlabRing);
/** * Checks to see if pipe has content to read * @param pipe to be checked * @return <code>true</code> if pipe has content, else <code>false</code> */ public static boolean hasContentToRead(Pipe pipe) { return StackStateWalker.hasContentToRead(pipe); }
static void setMsgIdx(StackStateWalker rw, int idx, long llwHeadPosCache) { rw.msgIdxPrev = rw.msgIdx; rw.msgIdx = idx; assert(idx < rw.from.fragDataSize.length) : "Bad msgIdx out of range"; assert(idx>-3): "Bad msgIdx too small "; assert(isMsgIdxStartNewMessage(idx, rw)) : "Bad msgIdx is not a starting point. "; //This validation is very important, because all down stream consumers will assume it to be true. assert(-1 ==idx || (rw.from.hasSimpleMessagesOnly && 0==rw.msgIdx && rw.from.messageStarts.length==1) || TypeMask.Group == TokenBuilder.extractType(rw.from.tokens[rw.msgIdx])) : errorMessageForMessageStartValidation(rw, llwHeadPosCache); assert(-1 ==idx || (rw.from.hasSimpleMessagesOnly && 0==rw.msgIdx && rw.from.messageStarts.length==1) || (OperatorMask.Group_Bit_Close&TokenBuilder.extractOper(rw.from.tokens[rw.msgIdx])) == 0) : errorMessageForMessageStartValidation(rw, llwHeadPosCache); }
boolean copied = StackStateWalker.copyFragment0(pipeIn, pipeOut, Pipe.getWorkingTailPosition(pipeIn), pipeIn.ringWalker.nextWorkingTail); while (copied && !FieldReferenceOffsetManager.isTemplateStart(Pipe.from(pipeIn), pipeIn.ringWalker.nextCursor)) { copied = StackStateWalker.prepReadFragment(pipeIn, pipeIn.ringWalker) && StackStateWalker.copyFragment0(pipeIn, pipeOut, Pipe.getWorkingTailPosition(pipeIn), pipeIn.ringWalker.nextWorkingTail);
/** * blocks until there is enough room for the requested fragment on the output ring. * if the fragment needs a template id it is written and the workingHeadPosition is set to the first field. * */ @Deprecated public static void blockWriteFragment(Pipe pipe, int messageTemplateLOC) { //caution does not have same behavior as tryWrite. //maximize code re-use and unify behavior of the writeFragment methods. Pipe.writeTrailingCountOfBytesConsumed(pipe, pipe.ringWalker.nextWorkingHead -1 ); StackStateWalker.blockWriteFragment0(pipe, messageTemplateLOC, Pipe.from(pipe), pipe.ringWalker); }
private static boolean copyFragment1(Pipe inputRing, Pipe outputRing, long start, int spaceNeeded, int bytesToCopy) { if ((spaceNeeded > outputRing.sizeOfSlabRing-(int)(Pipe.workingHeadPosition(outputRing) - Pipe.tailPosition(outputRing)) )) { return false; } copyFragment2(inputRing, outputRing, (int)start, spaceNeeded, bytesToCopy); return true; }
static boolean hasContentToRead(Pipe pipe) { return (pipe.llWrite.llwHeadPosCache > 1+pipe.ringWalker.nextWorkingTail) || hasContentToReadSlow(pipe); }
this.ringWalker = new StackStateWalker(MessageSchema.from(schema), sizeOfSlabRing);
/** * Checks to see if pipe has content to read * @param pipe to be checked * @return <code>true</code> if pipe has content, else <code>false</code> */ public static boolean hasContentToRead(Pipe pipe) { return StackStateWalker.hasContentToRead(pipe); }
static void setMsgIdx(StackStateWalker rw, int idx, long llwHeadPosCache) { rw.msgIdxPrev = rw.msgIdx; rw.msgIdx = idx; assert(idx < rw.from.fragDataSize.length) : "Bad msgIdx out of range"; assert(idx>-3): "Bad msgIdx too small "; assert(isMsgIdxStartNewMessage(idx, rw)) : "Bad msgIdx is not a starting point. "; //This validation is very important, because all down stream consumers will assume it to be true. assert(-1 ==idx || (rw.from.hasSimpleMessagesOnly && 0==rw.msgIdx && rw.from.messageStarts.length==1) || TypeMask.Group == TokenBuilder.extractType(rw.from.tokens[rw.msgIdx])) : errorMessageForMessageStartValidation(rw, llwHeadPosCache); assert(-1 ==idx || (rw.from.hasSimpleMessagesOnly && 0==rw.msgIdx && rw.from.messageStarts.length==1) || (OperatorMask.Group_Bit_Close&TokenBuilder.extractOper(rw.from.tokens[rw.msgIdx])) == 0) : errorMessageForMessageStartValidation(rw, llwHeadPosCache); }
private static void openOrCloseSequenceWhileInsideFragment( Pipe ringBuffer, final StackStateWalker ringBufferConsumer, long tmpNextWorkingTail, int lastScriptPos, int lastTokenOfFragment) { //this is a group or groupLength that has appeared while inside a fragment that does not start a message //this single bit on indicates that this starts a sequence length 00100 if ( (lastTokenOfFragment & ( 0x04 <<TokenBuilder.SHIFT_TYPE)) == 0 ) { if (//if this is a closing sequence group. (lastTokenOfFragment & ( (OperatorMask.Group_Bit_Seq|OperatorMask.Group_Bit_Close) <<TokenBuilder.SHIFT_OPER)) == ((OperatorMask.Group_Bit_Seq|OperatorMask.Group_Bit_Close)<<TokenBuilder.SHIFT_OPER) ) { continueSequence(ringBufferConsumer); } } else { openSequenceWhileInsideFragment(ringBuffer, ringBufferConsumer, tmpNextWorkingTail, lastScriptPos); } }