@Override public boolean equalBytes(byte[] bytes, int bytesPos, int bytesLen) { int len = available(); if (len<bytesLen) { //if its too short then it can not be equal, this is a stream so longer is ok. return false; } int pp = position; while (--bytesLen>=0) { if (bytes[bytesPos++]!=backing[byteMask & pp++]) { return false; } } //only moves forward when equal. position = pp; return true; }
@Override public boolean equalBytes(byte[] bytes, int bytesPos, int bytesLen) { int len = available(); if (len<bytesLen) { //if its too short then it can not be equal, this is a stream so longer is ok. return false; } int pp = position; while (--bytesLen>=0) { if (bytes[bytesPos++]!=backing[byteMask & pp++]) { return false; } } //only moves forward when equal. position = pp; return true; }
@Override public boolean equalBytes(byte[] bytes, int bytesPos, int bytesLen) { int len = available(); if (len<bytesLen) { //if its too short then it can not be equal, this is a stream so longer is ok. return false; } int pp = position; while (--bytesLen>=0) { if (bytes[bytesPos++]!=backing[byteMask & pp++]) { return false; } } //only moves forward when equal. position = pp; return true; }
@Override public String readUTFFully() { workspace.setLength(0); try { return readUTF(this, available(), workspace).toString(); } catch (Exception e) { throw new RuntimeException(e); } }
@Override public String readUTFFully() { workspace.setLength(0); try { return readUTF(this, available(), workspace).toString(); } catch (Exception e) { throw new RuntimeException(e); } }
@Override public String readUTFFully() { workspace.setLength(0); try { return readUTF(this, available(), workspace).toString(); } catch (Exception e) { throw new RuntimeException(e); } }
private void readHeaderForNextBlock(DataInputBlobReader<RawDataSchema> inputStream) { if (inputStream.available( ) >= (ChannelReader.PACKED_INT_SIZE + ChannelReader.PACKED_LONG_SIZE) || isEndOfFile || isShuttingDown ) { int orig = inputStream.available(); targetPipeIdx = inputStream.readPackedInt(); targetRemaining = inputStream.readPackedLong(); RawDataSchemaUtil.releaseConsumed(source, inputStream, orig); } }
public static double readUTFAsDecimal(DataInputBlobReader<?> reader) { return convertTextToDouble(reader.parserReader(), reader.backing, reader.position, reader.available(), reader.byteMask); }
public static long readUTFAsLong(DataInputBlobReader<?> reader) { return convertTextToLong(reader.parserReader(), reader.backing, reader.position, reader.byteMask, reader.available()); }
public static double readUTFAsDecimal(DataInputBlobReader<?> reader) { return convertTextToDouble(reader.parserReader(), reader.backing, reader.position, reader.available(), reader.byteMask); }
public static long readUTFAsLong(DataInputBlobReader<?> reader) { return convertTextToLong(reader.parserReader(), reader.backing, reader.position, reader.byteMask, reader.available()); }
public static long readUTFAsLong(DataInputBlobReader<?> reader) { return convertTextToLong(reader.parserReader(), reader.backing, reader.position, reader.byteMask, reader.available()); }
public static double readUTFAsDecimal(DataInputBlobReader<?> reader) { return convertTextToDouble(reader.parserReader(), reader.backing, reader.position, reader.available(), reader.byteMask); }
/** * Checks to see if passed bytes are equal to field * @param fieldId field to compare * @param utf8EncodedBytes bytes to compare * @return <code>true</code> if equal, else <code>false</code> */ public boolean isEqual(long fieldId, byte[] utf8EncodedBytes) { assert(0==Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).dims(fieldId)) : "This method only used for non dim fields."; final int index = channelReader.readFromEndLastInt(StructRegistry.FIELD_MASK&(int)fieldId); if (index>=0) { channelReader.position(index); if (channelReader.available()>=2) { int length = channelReader.readShort(); return utf8EncodedBytes.length==length && channelReader.equalBytes(utf8EncodedBytes); } } return false; }
/** * Checks to see if passed bytes are equal to field * @param fieldId field to compare * @param utf8EncodedBytes bytes to compare * @return <code>true</code> if equal, else <code>false</code> */ public boolean isEqual(long fieldId, byte[] utf8EncodedBytes) { assert(0==Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).dims(fieldId)) : "This method only used for non dim fields."; final int index = channelReader.readFromEndLastInt(StructRegistry.FIELD_MASK&(int)fieldId); if (index>=0) { channelReader.position(index); if (channelReader.available()>=2) { int length = channelReader.readShort(); return utf8EncodedBytes.length==length && channelReader.equalBytes(utf8EncodedBytes); } } return false; }
/** * Checks to see if passed bytes are equal to field * @param fieldId field to compare * @param utf8EncodedBytes bytes to compare * @return <code>true</code> if equal, else <code>false</code> */ public boolean isEqual(long fieldId, byte[] utf8EncodedBytes) { assert(0==Pipe.structRegistry(DataInputBlobReader.getBackingPipe(channelReader)).dims(fieldId)) : "This method only used for non dim fields."; final int index = channelReader.readFromEndLastInt(StructRegistry.FIELD_MASK&(int)fieldId); if (index>=0) { channelReader.position(index); if (channelReader.available()>=2) { int length = channelReader.readShort(); return utf8EncodedBytes.length==length && channelReader.equalBytes(utf8EncodedBytes); } } return false; }
private void logRequestNow(Pipe<HTTPLogRequestSchema> p, Pipe<RawDataSchema> output) { int msgId = Pipe.takeMsgIdx(p); assert(msgId == HTTPLogRequestSchema.MSG_REQUEST_1); long timeNS = Pipe.takeLong(p); //time long chnl = Pipe.takeLong(p); //channelId int seq = Pipe.takeInt(p); //sequenceId DataInputBlobReader<HTTPLogRequestSchema> header = Pipe.openInputStream(p); //head //batch the writes.. int esitmate = 100+header.available(); batchMessages(output, esitmate); publishLogMessage(timeNS, chnl, seq, -1, BYTES_REQUEST, header, Pipe.outputStream(output)); Pipe.confirmLowLevelRead(p, Pipe.sizeOf(p, HTTPLogRequestSchema.MSG_REQUEST_1)); Pipe.releaseReadLock(p); }
/** * Copies bytes from specified pipe to target pipe * @param sourcePipe to copy from * @param targetPipe to copy to * @param sourceLOC location of bytes to copy * @param targetLOC location to put bytes * @return length of copied bytes */ public static int copyBytes(final Pipe sourcePipe, final Pipe targetPipe, int sourceLOC, int targetLOC) { assert(LOCUtil.isLocOfAnyType(sourceLOC, TypeMask.TextASCII, TypeMask.TextASCIIOptional, TypeMask.TextUTF8, TypeMask.TextUTF8Optional, TypeMask.ByteVector, TypeMask.ByteVectorOptional)): "Value found "+LOCUtil.typeAsString(sourceLOC); assert(LOCUtil.isLocOfAnyType(targetLOC, TypeMask.TextASCII, TypeMask.TextASCIIOptional, TypeMask.TextUTF8, TypeMask.TextUTF8Optional, TypeMask.ByteVector, TypeMask.ByteVectorOptional)): "Value found "+LOCUtil.typeAsString(targetLOC); //alternate implementation DataInputBlobReader src = PipeReader.inputStream(sourcePipe, sourceLOC); DataOutputBlobWriter tgt = PipeWriter.outputStream(targetPipe); DataOutputBlobWriter.openField(tgt); int len = src.available(); tgt.writeStream(src, len); if (src.isStructured) { src.readFromEndInto(tgt); } DataOutputBlobWriter.closeHighLevelField(tgt, targetLOC); return len; }
/** * Copies bytes from specified pipe to target pipe * @param sourcePipe to copy from * @param targetPipe to copy to * @param sourceLOC location of bytes to copy * @param targetLOC location to put bytes * @return length of copied bytes */ public static int copyBytes(final Pipe sourcePipe, final Pipe targetPipe, int sourceLOC, int targetLOC) { assert(LOCUtil.isLocOfAnyType(sourceLOC, TypeMask.TextASCII, TypeMask.TextASCIIOptional, TypeMask.TextUTF8, TypeMask.TextUTF8Optional, TypeMask.ByteVector, TypeMask.ByteVectorOptional)): "Value found "+LOCUtil.typeAsString(sourceLOC); assert(LOCUtil.isLocOfAnyType(targetLOC, TypeMask.TextASCII, TypeMask.TextASCIIOptional, TypeMask.TextUTF8, TypeMask.TextUTF8Optional, TypeMask.ByteVector, TypeMask.ByteVectorOptional)): "Value found "+LOCUtil.typeAsString(targetLOC); //alternate implementation DataInputBlobReader src = PipeReader.inputStream(sourcePipe, sourceLOC); DataOutputBlobWriter tgt = PipeWriter.outputStream(targetPipe); DataOutputBlobWriter.openField(tgt); int len = src.available(); tgt.writeStream(src, len); if (src.isStructured) { src.readFromEndInto(tgt); } DataOutputBlobWriter.closeHighLevelField(tgt, targetLOC); return len; }
private void logResponseNow(Pipe<HTTPLogResponseSchema> p, Pipe<RawDataSchema> output) { int msgId = Pipe.takeMsgIdx(p); assert(msgId == HTTPLogResponseSchema.MSG_RESPONSE_1); long timeNS = Pipe.takeLong(p); //time long chnl = Pipe.takeLong(p); //channelId int seq = Pipe.takeInt(p); //sequenceId DataInputBlobReader<HTTPLogResponseSchema> header = Pipe.openInputStream(p); //head long durationNS = Pipe.takeLong(p); //batch the writes.. int esitmate = 100+header.available(); batchMessages(output, esitmate); publishLogMessage(timeNS, chnl, seq, durationNS, BYTES_RESPONSE, header, Pipe.outputStream(output)); Pipe.confirmLowLevelRead(p, Pipe.sizeOf(p, HTTPLogResponseSchema.MSG_RESPONSE_1)); Pipe.releaseReadLock(p); }