/** * Gives the size of the fragment from input to the end of pipe * @param input starting point from which to measure fragment * @return size of fragment */ public static int sizeOfFragment(Pipe input) { return Pipe.from(input).fragDataSize[input.ringWalker.cursor]; }
public RingOutputStream(Pipe pipe) { this.pipe = pipe; blockSize = pipe.maxVarLen; if (Pipe.from(pipe) != RawDataSchema.FROM) { throw new UnsupportedOperationException("This class can only be used with the very simple RAW_BYTES catalog of messages."); } }
public RingOutputStream(Pipe pipe) { this.pipe = pipe; blockSize = pipe.maxVarLen; if (Pipe.from(pipe) != RawDataSchema.FROM) { throw new UnsupportedOperationException("This class can only be used with the very simple RAW_BYTES catalog of messages."); } }
public AppendableUTF8Ring(Pipe ringBuffer) { this.ringBuffer = ringBuffer; if (Pipe.from(ringBuffer) != RawDataSchema.FROM) { throw new UnsupportedOperationException("This class can only be used with the very simple RAW_BYTES catalog of messages."); } int messagesPerRing = (1<<(ringBuffer.bitsOfSlabRing-1)); outputTarget = step-messagesPerRing;//this value is negative tailPosCache = tailPosition(ringBuffer); }
/** * Return true if there is room for the desired fragment in the output buffer. * Places working head in place for the first field to be written (eg after the template Id, which is written by this method) * */ public static boolean tryWriteFragment(Pipe pipe, final int fragmentId) { assert(null!=pipe); assert(fragmentId<Pipe.from(pipe).fragDataSize.length) : "Is this pipe for the schema holding this message?"; assert(Pipe.singleThreadPerPipeWrite(pipe.id)); assert(Pipe.isInit(pipe)) : "Pipe must be initialized before use: "+pipe+" call the method initBuffers"; return StackStateWalker.tryWriteFragment0(pipe, fragmentId, Pipe.from(pipe).fragDataSize[fragmentId], pipe.ringWalker.nextWorkingHead - (pipe.sizeOfSlabRing - Pipe.from(pipe).fragDataSize[fragmentId])); }
public AppendableASCIIRing(Pipe ringBuffer) { this.ringBuffer = ringBuffer; if (Pipe.from(ringBuffer) != RawDataSchema.FROM) { throw new UnsupportedOperationException("This class can only be used with the very simple RAW_BYTES catalog of messages."); } int messagesPerRing = (1<<(ringBuffer.bitsOfSlabRing-1)); outputTarget = step-messagesPerRing;//this value is negative tailPosCache = tailPosition(ringBuffer); countDownInit = messagesPerRing>>2; countDown = countDownInit; }
public AppendableUTF8Ring(Pipe ringBuffer) { this.ringBuffer = ringBuffer; if (Pipe.from(ringBuffer) != RawDataSchema.FROM) { throw new UnsupportedOperationException("This class can only be used with the very simple RAW_BYTES catalog of messages."); } int messagesPerRing = (1<<(ringBuffer.bitsOfSlabRing-1)); outputTarget = step-messagesPerRing;//this value is negative tailPosCache = tailPosition(ringBuffer); }
public StreamingVisitorReader(Pipe<?> inputRing, StreamingReadVisitor visitor, boolean processUTF8) { this.inputRing = inputRing; this.visitor = visitor; this.processUTF8 = processUTF8; this.from = Pipe.from(inputRing); this.navState = new LowLevelStateManager(from); }
/** * Take optional Long which may be null. Null is defined as specific long value in FROM * @param pipe Ping source * @return Long value */ public static <S extends MessageSchema<S>> Long takeOptionalLong(Pipe<S> pipe) { long absent64Value = FieldReferenceOffsetManager.getAbsent64Value(Pipe.from(pipe)); return takeOptionalLong(pipe, absent64Value); }
/** * * @param messageCount number of messages */ public boolean hasRoomFor(int messageCount) { return null==msgCommandChannel.goPipe || Pipe.hasRoomForWrite(msgCommandChannel.goPipe, FieldReferenceOffsetManager.maxFragmentSize(Pipe.from(msgCommandChannel.goPipe))*messageCount); }
public StreamingVisitorWriter(Pipe outputRing, StreamingWriteVisitor visitor) { this.visitor = visitor; this.outputRing = outputRing; this.from = Pipe.from(outputRing); this.maxFragmentSize = FieldReferenceOffsetManager.maxFragmentSize(this.from); this.navState = new LowLevelStateManager(from); }
/** * take optional Integer, this may be null. null is defined as a specific int value in FROM * @param pipe Pipe source * @return Integer value */ public static <S extends MessageSchema<S>> Integer takeOptionalValue(Pipe<S> pipe) { int absent32Value = FieldReferenceOffsetManager.getAbsent32Value(Pipe.from(pipe)); return takeOptionalValue(pipe, absent32Value); }
public static <S extends MessageSchema<S>> void write(Pipe<S> pipe, int msgIdx) { assert(FieldReferenceOffsetManager.isValidMsgIdx(Pipe.from(pipe), msgIdx)); assert(2==Pipe.from(pipe).fragDataSize[msgIdx]) : "This constant does not this fragment size"; int size = Pipe.addMsgIdx(pipe, msgIdx); Pipe.confirmLowLevelWrite(pipe, size); Pipe.publishWrites(pipe); }
public static <S extends MessageSchema<S>> void writeI(Pipe<S> pipe, int msgIdx, int field1) { assert(FieldReferenceOffsetManager.isValidMsgIdx(Pipe.from(pipe), msgIdx)); assert(3==Pipe.from(pipe).fragDataSize[msgIdx]) : "This constant does not this fragment size"; int size = Pipe.addMsgIdx(pipe, msgIdx); Pipe.addIntValue(field1, pipe); Pipe.confirmLowLevelWrite(pipe, size); Pipe.publishWrites(pipe); } }
public static <S extends MessageSchema<S>> void writeL(Pipe<S> pipe, int msgIdx, long field1) { assert(FieldReferenceOffsetManager.isValidMsgIdx(Pipe.from(pipe), msgIdx)); assert(4==Pipe.from(pipe).fragDataSize[msgIdx]) : "This constant does not this fragment size"; int size = Pipe.addMsgIdx(pipe, msgIdx); Pipe.addLongValue(field1, pipe); Pipe.confirmLowLevelWrite(pipe, size); Pipe.publishWrites(pipe); }
public static <S extends MessageSchema<S>> void writeLL(Pipe<S> pipe, int msgIdx, long field1, long field2) { assert(FieldReferenceOffsetManager.isValidMsgIdx(Pipe.from(pipe), msgIdx)); assert(6==Pipe.from(pipe).fragDataSize[msgIdx]) : "This constant does not this fragment size"; int size = Pipe.addMsgIdx(pipe, msgIdx); Pipe.addLongValue(field1, pipe); Pipe.addLongValue(field2, pipe); Pipe.confirmLowLevelWrite(pipe, size); Pipe.publishWrites(pipe); }
public static <S extends MessageSchema<S>> void writeLI(Pipe<S> pipe, int msgIdx, long field1, int field2) { assert(FieldReferenceOffsetManager.isValidMsgIdx(Pipe.from(pipe), msgIdx)); assert(5==Pipe.from(pipe).fragDataSize[msgIdx]) : "This constant does not this fragment size"; int size = Pipe.addMsgIdx(pipe, msgIdx); Pipe.addLongValue(field1, pipe); Pipe.addIntValue(field2, pipe); Pipe.confirmLowLevelWrite(pipe, size); Pipe.publishWrites(pipe); }
public static <S extends MessageSchema<S>> void writeLII(Pipe<S> pipe, int msgIdx, long field1, int field2, int field3) { assert(FieldReferenceOffsetManager.isValidMsgIdx(Pipe.from(pipe), msgIdx)); assert(6==Pipe.from(pipe).fragDataSize[msgIdx]) : "This constant does not this fragment size"; int size = Pipe.addMsgIdx(pipe, msgIdx); Pipe.addLongValue(field1, pipe); Pipe.addIntValue(field2, pipe); Pipe.addIntValue(field3, pipe); Pipe.confirmLowLevelWrite(pipe, size); Pipe.publishWrites(pipe); }
public static <S extends MessageSchema<S>> int readI(Pipe<S> pipe) { int msgIdx = Pipe.takeMsgIdx(pipe); assert(3==Pipe.from(pipe).fragDataSize[msgIdx]) : "This constant does not this fragment size"; int value = Pipe.takeInt(pipe); Pipe.confirmLowLevelRead(pipe, 3); Pipe.releaseReadLock(pipe); return value; }
/** * Check to see if specified pipe has room to write * @param pipe to be checked * @return <code>true</code> if pipe has room else <code>false</code> */ public static boolean hasRoomForWrite(Pipe pipe) { assert(Pipe.singleThreadPerPipeWrite(pipe.id)); assert(pipe!=null); assert(Pipe.isInit(pipe)); assert(pipe.usingHighLevelAPI); return StackStateWalker.hasRoomForFragmentOfSizeX(pipe, pipe.ringWalker.nextWorkingHead - (pipe.sizeOfSlabRing - FieldReferenceOffsetManager.maxFragmentSize( Pipe.from(pipe)))); }