public static int decodeLength(DataInputBlobReader<NetPayloadSchema> inputStream) { //little endian, high bit is on until the end. int result = 0; int shift = 0; byte b = inputStream.readByte(); while (b<0) {//while high bit is set continue int temp = 0x7F & b; result |= (temp<<shift); b = inputStream.readByte(); shift+=7; } int temp = 0x7F & b; result |= (temp<<shift); return result; }
private void visitSingleByte(StructByteListener visitor, int totalCount, final int[] curPos, final int[] curSize, int c) { byte value = channelReader.readByte(); visitor.value(value, false, curPos, curSize, c, totalCount); }
private void visitSingleByte(StructByteListener visitor, int totalCount, final int[] curPos, final int[] curSize, int c) { byte value = channelReader.readByte(); visitor.value(value, false, curPos, curSize, c, totalCount); }
private void visitSingleByte(StructByteListener visitor, int totalCount, final int[] curPos, final int[] curSize, int c) { byte value = channelReader.readByte(); visitor.value(value, false, curPos, curSize, c, totalCount); }
@Override public byte readByte() { checkLimit(this,1); return super.readByte(); }
private void visitSingleDecimal(StructDecimalListener visitor, int totalCount, final int[] curPos, final int[] curSize, int c) { long m = channelReader.readPackedLong(); assert(channelReader.storeMostRecentPacked(m)); if (0!=m) { visitor.value(channelReader.readByte(), m, false, curPos, curSize, c, totalCount); } else { if (!channelReader.wasPackedNull()) { visitor.value(channelReader.readByte(), m, false, curPos, curSize, c, totalCount); } else { visitor.value((byte)0, 0, true, null, null, 0, 0); channelReader.readByte(); } } }
private void visitSingleDecimal(StructDecimalListener visitor, int totalCount, final int[] curPos, final int[] curSize, int c) { long m = channelReader.readPackedLong(); assert(channelReader.storeMostRecentPacked(m)); if (0!=m) { visitor.value(channelReader.readByte(), m, false, curPos, curSize, c, totalCount); } else { if (!channelReader.wasPackedNull()) { visitor.value(channelReader.readByte(), m, false, curPos, curSize, c, totalCount); } else { visitor.value((byte)0, 0, true, null, null, 0, 0); channelReader.readByte(); } } }
private void visitSingleDecimal(StructDecimalListener visitor, int totalCount, final int[] curPos, final int[] curSize, int c) { long m = channelReader.readPackedLong(); assert(channelReader.storeMostRecentPacked(m)); if (0!=m) { visitor.value(channelReader.readByte(), m, false, curPos, curSize, c, totalCount); } else { if (!channelReader.wasPackedNull()) { visitor.value(channelReader.readByte(), m, false, curPos, curSize, c, totalCount); } else { visitor.value((byte)0, 0, true, null, null, 0, 0); channelReader.readByte(); } } }
@Override public <A extends Appendable> A readDecimalAsText(A target) { long m = readPackedLong(); assert(storeMostRecentPacked(m)); return Appendables.appendDecimalValue(target, m, readByte()); }
@Override public long readDecimalAsLong() { //packed nulls will appear as zero in this case. long m = readPackedLong(); assert(storeMostRecentPacked(m)); return Decimal.asLong(m, readByte()); }
@Override public long readDecimalAsLong() { //packed nulls will appear as zero in this case. long m = readPackedLong(); assert(storeMostRecentPacked(m)); return Decimal.asLong(m, readByte()); }
@Override public long readDecimalAsLong() { //packed nulls will appear as zero in this case. long m = readPackedLong(); assert(storeMostRecentPacked(m)); return Decimal.asLong(m, readByte()); }
@Override public <A extends Appendable> A readDecimalAsText(A target) { long m = readPackedLong(); assert(storeMostRecentPacked(m)); return Appendables.appendDecimalValue(target, m, readByte()); }
@Override public double readDecimalAsDouble() { long m = readPackedLong(); assert(storeMostRecentPacked(m)); if (0!=m) { return Decimal.asDouble(m, readByte()); } else { position++;//must consume last byte (not needed); return wasPackedNull() ? Double.NaN: 0; } }
@Override public double readDecimalAsDouble() { long m = readPackedLong(); assert(storeMostRecentPacked(m)); if (0!=m) { return Decimal.asDouble(m, readByte()); } else { position++;//must consume last byte (not needed); return wasPackedNull() ? Double.NaN: 0; } }
@Override public double readDecimalAsDouble() { long m = readPackedLong(); assert(storeMostRecentPacked(m)); if (0!=m) { return Decimal.asDouble(m, readByte()); } else { position++;//must consume last byte (not needed); return wasPackedNull() ? Double.NaN: 0; } }
/** * Reads decimal as String and appends to target * @param attachedInstance field association showing where to read * @param target to append to * @return appended data */ public <A extends Appendable> A readDecimalAsText(Object attachedInstance, A target) { assert(matchOneOfTypes(attachedInstance, StructType.Decimal)); this.channelReader.position( this.channelReader.readFromEndLastInt( StructRegistry.FIELD_MASK & (int)Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).fieldLookupByIdentity(attachedInstance, DataInputBlobReader.getStructType(this.channelReader)))); long m = channelReader.readPackedLong(); assert(channelReader.storeMostRecentPacked(m)); return Appendables.appendDecimalValue(target, m, channelReader.readByte()); }
/** * Reads decimal exponent from specified field in pipe * @param fieldId field to read from * @return 0 when absent, else exponent */ public byte readDecimalExponent(long fieldId) { 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.Decimal); final int index = channelReader.readFromEndLastInt(StructRegistry.FIELD_MASK&(int)fieldId); if (index>=0) { channelReader.position(index); final long m = channelReader.readPackedLong(); assert(channelReader.storeMostRecentPacked(m)); return channelReader.readByte(); } else { return 0; } }
/** * Reads decimal exponent from specified field in pipe * @param fieldId field to read from * @return 0 when absent, else exponent */ public byte readDecimalExponent(long fieldId) { 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.Decimal); final int index = channelReader.readFromEndLastInt(StructRegistry.FIELD_MASK&(int)fieldId); if (index>=0) { channelReader.position(index); final long m = channelReader.readPackedLong(); assert(channelReader.storeMostRecentPacked(m)); return channelReader.readByte(); } else { return 0; } }
/** * 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; }