@Override public <A extends Appendable> A consumeValue(ChannelReader reader, A target) { reader.readPackedLong(); reader.readUTF(target); return target; }
if (type < 0x0A) { reader.readPackedLong(); } else { short length = reader.readShort(); if (length>0) { reader.skipBytes(length); short length = reader.readShort(); if (length>0) { reader.skipBytes(length); reader.readByte(); reader.readPackedLong(); } else { reader.readPackedLong(); reader.readPackedLong();
public static String decodeString(ChannelReader reader, Boolean isOptional){ if (reader.readPackedInt() == INCOMING_VARIABLE){ return reader.readUTF(); } else return null; } //longs
@Override public boolean restRequest(HTTPRequestReader request) { int argInt = request.structured().readInt(nameFieldId); Appendables.appendValue(console, "Arg Int: ", argInt, "\n"); request.structured().identityVisit(HTTPHeaderDefaults.COOKIE, (id,reader,field)-> { console.append("COOKIE: "); reader.readUTF(console).append('\n'); }); if (request.isVerbPost()) { request.openPayloadData((reader)->{ console.append("POST: "); reader.readUTFOfLength(reader.available(), console); console.append('\n'); }); } //no body just a 200 ok response. return cmd.publishHTTPResponse(request, 200); }
case TypeBoolean: try { Appendables.appendValue(out, "Boolean recorded as: ", reader.readByte()); out.append("\n"); } catch (IOException ex) { case TypeDecimal: try{ long m = reader.readPackedLong(); byte e = reader.readByte(); case TypeInteger: try { Appendables.appendValue(out, "Integer recorded as: ", reader.readPackedLong()); out.append("\n"); } catch (IOException ex) { case TypeString: try { int length = reader.readPackedInt(); reader.readUTFOfLength(length,out);
public boolean receiveMqttMessage(CharSequence topic, ChannelReader payload) { // this received when mosquitto_pub is invoked - see MQTTClient System.out.print("\ningress body: "); // Read the message payload and output it to System.out payload.readUTFOfLength(payload.available(), System.out); System.out.println(); // Create the on-demand mqtt payload writer Writable mqttPayload = writer -> writer.writeUTF("\nsecond step test message"); // On the 'localtest' topic publish the mqtt payload cmd.publishTopic(mqttPayload, WaitFor.None); // We consumed the message return true; } }
final int startPos = payload.absolutePosition(); StructuredReader reader = payload.structured(); if (!reader.hasAttachedObject(fieldIdAssoc)) { payload.absolutePosition(startPos);//we already positioned and consumed the value so reposition now. payload.readInto(writer, payload.available()); //copies all the field data
assert(TypeMask.Rational == 0x1A);// rational while (reader.hasRemainingBytes()) { int token = reader.readPackedInt(); int fieldNameLength = reader.readShort(); assert(fieldNameLength == -1);
@Override public void skipValue(ChannelReader reader) { reader.readPackedLong(); short len = reader.readShort(); reader.skipBytes(len); }
private boolean readLoadData(Pipe<RawDataSchema> pipe, boolean isEnd, ChannelReader reader) { if (loadPosition==-1) { if (reader.available()<((5 * ChannelReader.PACKED_INT_SIZE) +(2 * ChannelReader.BOOLEAN_SIZE))) { return false;//not enough data yet to read header cleanly int loadedBlockSize = reader.readPackedInt(); assert(loadedBlockSize==blockSize) : "Can not load, not same block size"; if (loadedBlockSize!=blockSize) { throw new UnsupportedOperationException("Unable to load due to block size mismatch"); supportBitMaps = reader.readBoolean(); supportRLE = reader.readBoolean(); blockLimit = reader.readPackedInt(); recycledCount = reader.readPackedInt(); listCount = reader.readPackedInt(); final int dataLength = reader.readPackedInt(); if (data==null || data.length!=dataLength) { data = new int[dataLength]; while (((reader.available()>=ChannelReader.PACKED_INT_SIZE) || isEnd) && loadPosition<data.length) { data[loadPosition++] = reader.readPackedInt();
@Override public void read(HTTPHeader header, ChannelReader reader) { short type = reader.available()>=2 ? reader.readShort() : -1; if ((type<0) || (type>=httpSpec.contentTypes.length)) { this.type = HTTPContentTypeDefaults.UNKNOWN; } else { this.type = (HTTPContentType)httpSpec.contentTypes[type]; } }
public static long decodePresentLong(ChannelReader reader, long map, long bitMask, Boolean isOptional){ if (isOptional && MOST_FREQUENT_CASE == (map & bitMask)) { bitMask = bitMask << 1; return (MOST_FREQUENT_CASE == (map & bitMask)) ? reader.readPackedLong() : null; } else { return (MOST_FREQUENT_CASE == (map & bitMask)) ? reader.readPackedLong() : null; } } //decode default long
@Override public void read(ChannelReader reader) { if (reader.available()<1) { //error return; } int age = reader.structured().readInt(Fields.AGE); String name = reader.structured().readText(Fields.NAME); Appendables.appendValue(console.append(name).append(" "),age).append("\n"); } };
public static void releaseConsumed(Pipe<RawDataSchema> pipe, ChannelReader reader, int startingAvail) { //release the number of bytes we consumed Pipe.releasePendingAsReadLock(pipe, startingAvail-reader.available()); }
@Override public <A extends Appendable> A writeValue(A target, HTTPSpecification<?,?,?,?> httpSpec, ChannelReader reader) { reader.readUTF(target); return target; }
assert(inStream.isStructured()); ChannelWriter outStream = Pipe.openOutputStream(output); BlockingWorkerOperation<T> operation = inStream.structured().structAssociatedObject(); assert( inStream.structured().associatedFieldObject(StructuredReader.structType(inStream.structured()), 0).toString().equalsIgnoreCase("connection")); assert( inStream.structured().associatedFieldObject(StructuredReader.structType(inStream.structured()), 1).toString().equalsIgnoreCase("sequence")); int copyLimit = inStream.structured().dataPositionFromIndexOffset(2); assert(inStream.structured().dataPositionFromIndexOffset(0)<copyLimit) : "Connection must appear before business fields"; assert(inStream.structured().dataPositionFromIndexOffset(1)<copyLimit) : "Sequence must appear before business fields"; inStream.readInto(outStream, copyLimit); ((DataInputBlobReader<?>)inStream).readFromEndInto((DataOutputBlobWriter<?>) outStream); DataOutputBlobWriter.setStructType((DataOutputBlobWriter<?>)outStream,-1); //clear out copied type
public static int decodeCopyInt(int[] intDictionary, ChannelReader reader, long map, int idx, long bitMask, Boolean isOptional) { if (isOptional && MOST_FREQUENT_CASE == (map & bitMask)) { bitMask = bitMask << 1; return (MOST_FREQUENT_CASE == (map & bitMask)) ? intDictionary[idx] : (intDictionary[idx] = reader.readPackedInt()); } else { return (MOST_FREQUENT_CASE == (map & bitMask)) ? intDictionary[idx] : (intDictionary[idx] = reader.readPackedInt()); } }
@Override protected boolean payload(AppendableByteWriter<?> payload, GraphManager gm, ChannelReader params, HTTPVerbDefaults verb) { jsonRenderer.render(payload, params.structured()); return true; }