public static void consumePublish(Pipe<MQTTServerToClientSchema> input) { long fieldTime = PipeReader.readLong(input,MSG_PUBLISH_3_FIELD_TIME_37); int fieldQOS = PipeReader.readInt(input,MSG_PUBLISH_3_FIELD_QOS_21); int fieldRetain = PipeReader.readInt(input,MSG_PUBLISH_3_FIELD_RETAIN_22); int fieldDup = PipeReader.readInt(input,MSG_PUBLISH_3_FIELD_DUP_36); StringBuilder fieldTopic = PipeReader.readUTF8(input,MSG_PUBLISH_3_FIELD_TOPIC_23,new StringBuilder(PipeReader.readBytesLength(input,MSG_PUBLISH_3_FIELD_TOPIC_23))); int fieldPacketId = PipeReader.readInt(input,MSG_PUBLISH_3_FIELD_PACKETID_20); DataInputBlobReader<MQTTServerToClientSchema> fieldPayload = PipeReader.inputStream(input, MSG_PUBLISH_3_FIELD_PAYLOAD_25); } public static void consumeDisconnect(Pipe<MQTTServerToClientSchema> input) {
public static void dispose(EventProducer consumer, Object dq) { assert(null==consumer.cached || dq==consumer.cached); PipeReader.releaseReadLock(consumer.input); }
public static void parseSetup(TrieParserReader trieReader, int loc, Pipe<?> input) { parseSetup(trieReader, PipeReader.readBytesBackingArray(input, loc), PipeReader.readBytesPosition(input, loc), PipeReader.readBytesLength(input, loc), PipeReader.readBytesMask(input, loc)); }
public static void consumeIntAndChunkedStream(Pipe<TestDataSchema> input) { int fieldIntValue = PipeReader.readInt(input,MSG_INTANDCHUNKEDSTREAM_20_FIELD_INTVALUE_21); DataInputBlobReader<TestDataSchema> fieldByteArray = PipeReader.inputStream(input, MSG_INTANDCHUNKEDSTREAM_20_FIELD_BYTEARRAY_22); } public static void consumeLongAndChunkedStream(Pipe<TestDataSchema> input) {
public static void consumeSelection(Pipe<ProbabilitySchema> input) { long fieldTotalSum = PipeReader.readLong(input,MSG_SELECTION_1_FIELD_TOTALSUM_12); int fieldTotalBuckets = PipeReader.readInt(input,MSG_SELECTION_1_FIELD_TOTALBUCKETS_13); DataInputBlobReader<ProbabilitySchema> fieldOrderedSelections = PipeReader.inputStream(input, MSG_SELECTION_1_FIELD_ORDEREDSELECTIONS_14); }
public void openHighLevelAPIField(int loc) { this.length = PipeReader.readBytesLength(pipe, loc); this.position = PipeReader.readBytesPosition(pipe, loc); this.backing = PipeReader.readBytesBackingArray(pipe, loc); this.bytesLimit = pipe.blobMask & (position + length); }
public static void consume(Pipe<PipeMonitorSchema> input) { while (PipeReader.tryReadFragment(input)) { int msgIdx = PipeReader.getMsgIdx(input); switch(msgIdx) { case MSG_RINGSTATSAMPLE_100: consumeRingStatSample(input); break; case -1: //requestShutdown(); break; } PipeReader.releaseReadLock(input); } }
while (PipeReader.tryReadFragment(stage.inputRing)) { assert(PipeReader.isNewMessage(stage.inputRing)) : "There are no multi fragment message found in the MetaFields"; int msgLoc = PipeReader.getMsgIdx(stage.inputRing); long uint = PipeReader.readInt(stage.inputRing, MetaMessageDefs.UINT32_VALUE_LOC); Pipe outputRing = stage.outputRing; long uint = PipeReader.readInt(stage.inputRing, MetaMessageDefs.NAMEDUINT32_VALUE_LOC); Pipe outputRing = stage.outputRing; int sint = PipeReader.readInt(stage.inputRing, MetaMessageDefs.INT32_VALUE_LOC); Pipe outputRing = stage.outputRing; int sint = PipeReader.readInt(stage.inputRing, MetaMessageDefs.NAMEDINT32_VALUE_LOC); Pipe outputRing = stage.outputRing; long ulong = PipeReader.readLong(stage.inputRing, MetaMessageDefs.UINT64_VALUE_LOC); Pipe outputRing = stage.outputRing; long ulong = PipeReader.readLong(stage.inputRing, MetaMessageDefs.NAMEDUINT64_VALUE_LOC); Pipe outputRing = stage.outputRing; DataOutputBlobWriter out = Pipe.openOutputStream(outputRing); long slong = PipeReader.readLong(stage.inputRing, MetaMessageDefs.INT64_VALUE_LOC); Pipe outputRing = stage.outputRing; DataOutputBlobWriter out = Pipe.openOutputStream(outputRing); long slong = PipeReader.readLong(stage.inputRing, MetaMessageDefs.NAMEDINT64_VALUE_LOC);
while (PipeReader.tryReadFragment(fieldsRing)) { assertTrue(PipeReader.isNewMessage(fieldsRing)); int msgLoc = PipeReader.getMsgIdx(fieldsRing); break; case 128: //UInt32 int iValue = PipeReader.readInt(fieldsRing, UINT32_VALUE_LOC); if (fileSpecificTestValues) assertEquals(expectedInt[i32++],iValue); break; case 130: //Int32 int isValue = PipeReader.readInt(fieldsRing, INT32_VALUE_LOC); if (fileSpecificTestValues) assertEquals(expectedInt[i32++],isValue); break; case 132: //UInt64 long lValue = PipeReader.readLong(fieldsRing, UINT64_VALUE_LOC); if (fileSpecificTestValues) assertEquals(expectedLong[i64++],lValue); break; case 134: //Int64 long lsValue = PipeReader.readLong(fieldsRing, INT64_VALUE_LOC); if (fileSpecificTestValues) assertEquals(expectedLong[i64++],lsValue); break; case 140: //Decimal int exp = PipeReader.readDecimalExponent(fieldsRing, DOUBLE_VALUE_LOC); assertEquals("Test file only uses 2 places of accuracy",2,exp); long mant = PipeReader.readDecimalMantissa(fieldsRing, DOUBLE_VALUE_LOC); float value = PipeReader.readFloat(fieldsRing, DOUBLE_VALUE_LOC); long computedValue = (long)(Math.rint(value*100f));
while (PipeReader.tryReadFragment(inputRing)) { assert(PipeReader.isNewMessage(inputRing)) : "This test should only have one simple message made up of one fragment"; int msgId = PipeReader.getMsgIdx(inputRing); int len = PipeReader.readBytesLength(inputRing, FIELD_ID); assertEquals(testArray.length,len); int pos = PipeReader.readBytesPosition(inputRing, FIELD_ID); PipeReader.releaseReadLock(inputRing); } else if (-1 == msgId) { PipeReader.releaseReadLock(inputRing); requestShutdown(); return;
private boolean dataToRead(long[] counts) { int msgIdx = 0; boolean data = false; while (PipeReader.tryReadFragment(input)) { if (PipeReader.isNewMessage(input)) { msgIdx = PipeReader.getMsgIdx(input); if (msgIdx<0) { PipeReader.releaseReadLock(input); requestShutdown(); break; } else { counts[msgIdx]++; data = true; } } totalBytes += (PipeReader.sizeOfFragment(input)*4) + PipeReader.bytesConsumedByFragment(input); //logger.info("reading new input total bytes :"+totalBytes); PipeReader.releaseReadLock(input); } return data; }
@SuppressWarnings("unchecked") public static <T> T take(final EventProducer consumer, Class<T> clazz) { //re-use old proxy if possible if (null!=consumer.cached && clazz.isAssignableFrom(consumer.cached.getClass())) { if (PipeReader.tryReadFragment(consumer.input)) { assert(consumer.cachedMsgId == PipeReader.getMsgIdx(consumer.input)); return (T)consumer.cached; } else { return null; } } return slowCreate(consumer, clazz); }
public int openHighLevelAPIField(int loc) { this.isStructured = PipeReader.isStructured(pipe, loc); this.length = Math.max(0, PipeReader.readBytesLength(pipe, loc)); this.bytesLowBound = this.position = PipeReader.readBytesPosition(pipe, loc); this.backing = PipeReader.readBytesBackingArray(pipe, loc); assert(this.backing!=null) : "The pipe must be init before use."; this.bytesHighBound = pipe.blobMask & (position + length); assert(Pipe.validatePipeBlobHasDataToRead(pipe, position, length)); return this.length; }
public static void readFieldIntoDataOutput(int loc, Pipe pipe, DataOutput out) throws IOException { int length = readBytesLength(pipe, loc); if (length>0) { int off = readBytesPosition(pipe, loc) & Pipe.blobMask(pipe); copyFieldToDataOutput(out, length, readBytesBackingArray(pipe, loc), off, pipe.sizeOfBlobRing-off); } }
/** * Writes field from data input in given pipe and location * @param pipe to write to * @param loc location to write field * @param dataInput data used to write field * @param byteCount max bytes in field */ public static void writeFieldFromDataInput(Pipe pipe, int loc, DataInput dataInput, final int byteCount) throws IOException { buildFieldFromDataInput(pipe, loc, dataInput, byteCount, PipeReader.readBytesPosition(pipe, loc), PipeReader.readBytesMask(pipe, loc), PipeReader.readBytesBackingArray(pipe, loc), pipe.sizeOfBlobRing, PipeReader.readBytesPosition(pipe, loc), byteCount, 0); }
do { if (msgId<0) { if (PipeReader.tryReadFragment(inputRing)) { assert(PipeReader.isNewMessage(inputRing)) : "This test should only have one simple message made up of one fragment"; msgId = PipeReader.getMsgIdx(inputRing); } else { return; PipeReader.copyBytes(inputRing, outputRing, FIELD_ID, FIELD_ID); PipeWriter.publishWrites(outputRing); PipeReader.releaseReadLock(inputRing); msgId = -2; } else { PipeReader.releaseReadLock(inputRing); assert(Pipe.contentRemaining(inputRing)==0); requestShutdown();
/** * * @param input arg used for PipeReader.readUTF8, PipeReader.readBytesLength and PipeReader.readIntPipeReader.readUTF8, PipeReader.readBytesLength and PipeReader.readInt */ public static void consumeUnsubscribe(Pipe<MessagePubSub> input) { StringBuilder fieldTopic = PipeReader.readUTF8(input,MSG_UNSUBSCRIBE_101_FIELD_TOPIC_1,new StringBuilder(PipeReader.readBytesLength(input,MSG_UNSUBSCRIBE_101_FIELD_TOPIC_1))); int fieldSubscriberIdentityHash = PipeReader.readInt(input,MSG_UNSUBSCRIBE_101_FIELD_SUBSCRIBERIDENTITYHASH_4); }
public static void consumeError(Pipe<BlockStorageReceiveSchema> input) { long fieldPosition = PipeReader.readLong(input,MSG_ERROR_3_FIELD_POSITION_12); StringBuilder fieldMessage = PipeReader.readUTF8(input,MSG_ERROR_3_FIELD_MESSAGE_10,new StringBuilder(PipeReader.readBytesLength(input,MSG_ERROR_3_FIELD_MESSAGE_10))); } public static void consumeWriteAck(Pipe<BlockStorageReceiveSchema> input) {
/** * Reads specified field in given pipe into the OutputStream * @param loc field to read to stream * @param pipe to be read from * @param out stream to read into */ public static void readFieldIntoOutputStream(int loc, Pipe pipe, OutputStream out) throws IOException { int length = readBytesLength(pipe, loc); if (length>0) { int off = readBytesPosition(pipe, loc) & Pipe.blobMask(pipe); copyFieldToOutputStream(out, length, readBytesBackingArray(pipe, loc), off, pipe.sizeOfBlobRing-off); } }
public static void consumeLongAndChunkedStream(Pipe<TestDataSchema> input) { long fieldLongValue = PipeReader.readLong(input,MSG_LONGANDCHUNKEDSTREAM_30_FIELD_LONGVALUE_31); DataInputBlobReader<TestDataSchema> fieldByteArray = PipeReader.inputStream(input, MSG_LONGANDCHUNKEDSTREAM_30_FIELD_BYTEARRAY_32); } public static void consumeInt(Pipe<TestDataSchema> input) {