public boolean productUpdate(HTTPRequestReader request) { StructuredReader source = request.structured(); return publishService.publishTopic((w)->{ //write update message with new payload plus sequence and connectionID StructuredWriter target = w.structured(); target.writeInt(Field.ID, source.readInt(Field.ID)); target.writeInt(Field.QUANTITY, source.readInt(Field.QUANTITY)); target.writeBoolean(Field.DISABLED, source.readBoolean(Field.DISABLED)); //source.readText(Field.NAME, target.writeText(Field.NAME)); //Broken?? target.writeText(Field.NAME, source.readText(Field.NAME)); target.writeLong(Field.CONNECTION, request.getConnectionId()); target.writeLong(Field.SEQUENCE, request.getSequenceCode()); target.selectStruct(Struct.DB_PRODUCT_UPDATE); }); }
public DataOutputBlobWriter(Pipe<S> p) { this.backingPipe = p; assert(null!=p) : "requires non null pipe"; assert(Pipe.isInit(p)): "The pipe must be init before use."; this.byteBuffer = Pipe.blob(p); this.byteMask = Pipe.blobMask(p); assert(this.byteMask!=0): "mask is "+p.blobMask+" size of blob is "+p.sizeOfBlobRing; this.structuredWriter = new StructuredWriter(this); }
public boolean productAll(HTTPRequestReader request) { return publishService.publishTopic((w)->{ StructuredWriter target = w.structured(); target.writeLong(Field.CONNECTION, request.getConnectionId()); target.writeLong(Field.SEQUENCE, request.getSequenceCode()); target.selectStruct(Struct.DB_ALL_QUERY); }); }
public boolean productQuery(HTTPRequestReader request) { StructuredReader source = request.structured(); return publishService.publishTopic((w)->{ StructuredWriter target = w.structured(); target.writeInt(Field.ID, source.readInt(Field.ID)); target.writeLong(Field.CONNECTION, request.getConnectionId()); target.writeLong(Field.SEQUENCE, request.getSequenceCode()); target.selectStruct(Struct.DB_PRODUCT_QUERY); }); }
/** * Writes blob to specified field in pipe * calls selectStruct(id) only after setting all the object fields * @param assoc field association showing where to write * @return channelWriter */ public ChannelWriter writeBlob(Object assoc) { assert(DataOutputBlobWriter.getStructType(channelWriter)<=0) : "call selectStruct(id) only after setting all the object fields."; storeAssocAndPosition(assoc); return channelWriter; }
public void writeShortNull(long fieldId) { assert(Pipe.structRegistry(channelWriter.backingPipe).fieldType(fieldId) == StructType.Short); DataOutputBlobWriter.commitBackData(channelWriter, StructRegistry.extractStructId(fieldId)); DataOutputBlobWriter.setIntBackData( channelWriter, channelWriter.position(), StructRegistry.extractFieldPosition(fieldId)); channelWriter.writePackedNull(); assert confirmDataDoesNotWriteOverIndex(fieldId) : "Data has written over index data"; }
/** * Defines the record after fields are defined */ public void selectStruct(Object assoc) { selectStruct(Pipe.structRegistry(channelWriter.backingPipe).structLookupByIdentity(assoc)); }
/** * Reads long from specified field in pipe * @param association field association showing where to read * @return <code>true</code> if data exists, else <code>false</code> */ public boolean readLong(Object association, StructuredWriter output) { final long fieldId = Pipe.structRegistry(DataInputBlobReader.getBackingPipe(this.channelReader)).fieldLookupByIdentity(association, DataInputBlobReader.getStructType(this.channelReader)); assert(0==Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).dims(fieldId)) : "This method only used for non dim fields."; assert(Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).fieldType(fieldId) == StructType.Short || Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).fieldType(fieldId) == StructType.Integer || Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).fieldType(fieldId) == StructType.Long); int index = channelReader.readFromEndLastInt(StructRegistry.FIELD_MASK&(int)fieldId); if (index>=0) { channelReader.position(index); //TODO: new method copyPackedLong which moves bytes until end is found output.writeLong(association, channelReader.readPackedLong()); return true; } return false; }
/** * Reads int from specified field in pipe * @param association field association showing where to read * @return <code>true</code> if data exists, else <code>false</code> */ public boolean readInt(Object association, StructuredWriter output) { final long fieldId = Pipe.structRegistry(DataInputBlobReader.getBackingPipe(this.channelReader)).fieldLookupByIdentity(association, DataInputBlobReader.getStructType(this.channelReader)); assert(0==Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).dims(fieldId)) : "This method only used for non dim fields."; assert(Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).fieldType(fieldId) == StructType.Short || Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).fieldType(fieldId) == StructType.Integer || Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).fieldType(fieldId) == StructType.Long); int index = channelReader.readFromEndLastInt(StructRegistry.FIELD_MASK&(int)fieldId); if (index>=0) { channelReader.position(index); //TODO: new method copyPackedLong which moves bytes until end is found output.writeInt(association, channelReader.readPackedInt()); return true; } return false; }
/** * Reads boolean from specified field in pipe * @param association field association showing where to read * @return <code>true</code> if data exists, else <code>false</code> */ public boolean readBoolean(Object association, StructuredWriter output) { final long fieldId = Pipe.structRegistry(DataInputBlobReader.getBackingPipe(this.channelReader)).fieldLookupByIdentity(association, DataInputBlobReader.getStructType(this.channelReader)); assert(0==Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).dims(fieldId)) : "This method only used for non dim fields."; assert(Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).fieldType(fieldId) == StructType.Boolean); int index = channelReader.readFromEndLastInt(StructRegistry.FIELD_MASK&(int)fieldId); if (index>=0) { channelReader.position(index); //we know boolean is stored as a single byte so just copy it output.writeByte(association, channelReader.readByte()); return true; } return false; }
/** * Reads text from specified field in pipe * @param association field association showing where to read * @return <code>true</code> if data exists, else <code>false</code> */ public boolean readText(Object association, StructuredWriter output) { final long fieldId = Pipe.structRegistry(DataInputBlobReader.getBackingPipe(this.channelReader)).fieldLookupByIdentity(association, DataInputBlobReader.getStructType(this.channelReader)); assert(0==Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).dims(fieldId)) : "This method only used for non dim fields."; assert(Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).fieldType(fieldId) == StructType.Text); int index = channelReader.readFromEndLastInt(StructRegistry.FIELD_MASK&(int)fieldId); if (index>=0) { channelReader.position(index); int length = channelReader.readShort();//length of text ChannelWriter out = output.writeBlob(association); out.writeShort(length); channelReader.readInto(out, length); return true; } return false; }
} else { byte e = channelReader.readByte(); output.writeDecimal(association, m, e);
/** * Writes blob to specified field in pipe * calls selectStruct(id) only after setting all the object fields * @param assoc field association showing where to write * @return channelWriter */ public ChannelWriter writeBlob(Object assoc) { assert(DataOutputBlobWriter.getStructType(channelWriter)<=0) : "call selectStruct(id) only after setting all the object fields."; storeAssocAndPosition(assoc); return channelWriter; }
public void writeShortNull(long fieldId) { assert(Pipe.structRegistry(channelWriter.backingPipe).fieldType(fieldId) == StructType.Short); DataOutputBlobWriter.commitBackData(channelWriter, StructRegistry.extractStructId(fieldId)); DataOutputBlobWriter.setIntBackData( channelWriter, channelWriter.position(), StructRegistry.extractFieldPosition(fieldId)); channelWriter.writePackedNull(); assert confirmDataDoesNotWriteOverIndex(fieldId) : "Data has written over index data"; }
/** * Defines the record after fields are defined */ public void selectStruct(Object assoc) { selectStruct(Pipe.structRegistry(channelWriter.backingPipe).structLookupByIdentity(assoc)); }
/** * Reads long from specified field in pipe * @param association field association showing where to read * @return <code>true</code> if data exists, else <code>false</code> */ public boolean readLong(Object association, StructuredWriter output) { final long fieldId = Pipe.structRegistry(DataInputBlobReader.getBackingPipe(this.channelReader)).fieldLookupByIdentity(association, DataInputBlobReader.getStructType(this.channelReader)); assert(0==Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).dims(fieldId)) : "This method only used for non dim fields."; assert(Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).fieldType(fieldId) == StructType.Short || Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).fieldType(fieldId) == StructType.Integer || Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).fieldType(fieldId) == StructType.Long); int index = channelReader.readFromEndLastInt(StructRegistry.FIELD_MASK&(int)fieldId); if (index>=0) { channelReader.position(index); //TODO: new method copyPackedLong which moves bytes until end is found output.writeLong(association, channelReader.readPackedLong()); return true; } return false; }
/** * Reads int from specified field in pipe * @param association field association showing where to read * @return <code>true</code> if data exists, else <code>false</code> */ public boolean readInt(Object association, StructuredWriter output) { final long fieldId = Pipe.structRegistry(DataInputBlobReader.getBackingPipe(this.channelReader)).fieldLookupByIdentity(association, DataInputBlobReader.getStructType(this.channelReader)); assert(0==Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).dims(fieldId)) : "This method only used for non dim fields."; assert(Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).fieldType(fieldId) == StructType.Short || Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).fieldType(fieldId) == StructType.Integer || Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).fieldType(fieldId) == StructType.Long); int index = channelReader.readFromEndLastInt(StructRegistry.FIELD_MASK&(int)fieldId); if (index>=0) { channelReader.position(index); //TODO: new method copyPackedLong which moves bytes until end is found output.writeInt(association, channelReader.readPackedInt()); return true; } return false; }
/** * Reads boolean from specified field in pipe * @param association field association showing where to read * @return <code>true</code> if data exists, else <code>false</code> */ public boolean readBoolean(Object association, StructuredWriter output) { final long fieldId = Pipe.structRegistry(DataInputBlobReader.getBackingPipe(this.channelReader)).fieldLookupByIdentity(association, DataInputBlobReader.getStructType(this.channelReader)); assert(0==Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).dims(fieldId)) : "This method only used for non dim fields."; assert(Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).fieldType(fieldId) == StructType.Boolean); int index = channelReader.readFromEndLastInt(StructRegistry.FIELD_MASK&(int)fieldId); if (index>=0) { channelReader.position(index); //we know boolean is stored as a single byte so just copy it output.writeByte(association, channelReader.readByte()); return true; } return false; }
/** * Reads text from specified field in pipe * @param association field association showing where to read * @return <code>true</code> if data exists, else <code>false</code> */ public boolean readText(Object association, StructuredWriter output) { final long fieldId = Pipe.structRegistry(DataInputBlobReader.getBackingPipe(this.channelReader)).fieldLookupByIdentity(association, DataInputBlobReader.getStructType(this.channelReader)); assert(0==Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).dims(fieldId)) : "This method only used for non dim fields."; assert(Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).fieldType(fieldId) == StructType.Text); int index = channelReader.readFromEndLastInt(StructRegistry.FIELD_MASK&(int)fieldId); if (index>=0) { channelReader.position(index); int length = channelReader.readShort();//length of text ChannelWriter out = output.writeBlob(association); out.writeShort(length); channelReader.readInto(out, length); return true; } return false; }