@Override public int length() { return length(this); }
@Override public int length() { return length(this); }
@Override public int length() { return length(this); }
/** * Internal function only used when dependent classes want to add bounds check per method call. * @param that instance in use * @param x needed value */ protected static <T extends MessageSchema<T>> void checkLimit(DataOutputBlobWriter<T> that, int x) { if (that.length()+x > that.backingPipe.maxVarLen ) { throw new RuntimeException("The writer is limited to a maximum length of "+that.backingPipe.maxVarLen +". Write less data or declare a larger field. Already wrote " +(that.activePosition-that.startPosition)+" at position "+that.activePosition+" attempting to add "+x); } }
/** * Internal function only used when dependent classes want to add bounds check per method call. * @param that instance in use * @param x needed value */ protected static <T extends MessageSchema<T>> void checkLimit(DataOutputBlobWriter<T> that, int x) { if (that.length()+x > that.backingPipe.maxVarLen ) { throw new RuntimeException("The writer is limited to a maximum length of "+that.backingPipe.maxVarLen +". Write less data or declare a larger field. Already wrote " +(that.activePosition-that.startPosition)+" at position "+that.activePosition+" attempting to add "+x); } }
/** * Internal function only used when dependent classes want to add bounds check per method call. * @param that * @param x */ protected static <T extends MessageSchema<T>> void checkLimit(DataOutputBlobWriter<T> that, int x) { if (that.length()+x > that.backingPipe.maxVarLen ) { throw new RuntimeException("The writer is limited to a maximum length of "+that.backingPipe.maxVarLen +". Write less data or declare a larger field. Already wrote " +(that.activePosition-that.startPosition)+" at position "+that.activePosition+" attempting to add "+x); } }
/** * Close field and record its length as the number of bytes consumed by the BlobWriter * @param writer */ public static <T extends MessageSchema<T>> int closeLowLevelField(DataOutputBlobWriter<T> writer) { return closeLowLeveLField(writer, length(writer)); }
/** * Close field and record its length as the number of bytes consumed by the BlobWriter * @param writer */ public static <T extends MessageSchema<T>> int closeLowLevelField(DataOutputBlobWriter<T> writer) { return closeLowLeveLField(writer, length(writer)); }
@Override public byte[] toByteArray() { byte[] result = new byte[length()]; Pipe.copyBytesFromToRing(byteBuffer, startPosition, byteMask, result, 0, Integer.MAX_VALUE, result.length); return result; }
/** * Close field and record its length as the number of bytes consumed by the BlobWriter * @param writer */ public static <T extends MessageSchema<T>> int closeLowLevelField(DataOutputBlobWriter<T> writer) { return closeLowLeveLField(writer, length(writer)); }
@Override public byte[] toByteArray() { byte[] result = new byte[length()]; Pipe.copyBytesFromToRing(byteBuffer, startPosition, byteMask, result, 0, Integer.MAX_VALUE, result.length); return result; }
@Override public byte[] toByteArray() { byte[] result = new byte[length()]; Pipe.copyBytesFromToRing(byteBuffer, startPosition, byteMask, result, 0, Integer.MAX_VALUE, result.length); return result; }
@Override public void writeObject(Object object) { int pos = activePosition; try { //logger.info("creating new output stream"); ObjectOutputStream oos = new ObjectOutputStream(this); //writes stream header //logger.info("write the object"); oos.writeObject(object); //logger.info("flush"); oos.flush(); //logger.info("done"); } catch (IOException e) { throw new RuntimeException(e); } assert(Pipe.validateVarLength(this.backingPipe, length(this))); assert(collectObjectSizeData(activePosition-pos)); }
public static <T extends MessageSchema<T>> int closeHighLevelField(DataOutputBlobWriter<T> writer, int targetFieldLoc) { //this method will also validate the length was in bound and throw unsupported operation if the pipe was not large enough //instead of fail fast as soon as one field goes over we wait to the end and only check once. int len = length(writer); //Appendables.appendUTF8(System.err, writer.byteBuffer, writer.startPosition, len, writer.byteMask); PipeWriter.writeSpecialBytesPosAndLen(writer.backingPipe, targetFieldLoc, len, writer.startPosition); writer.backingPipe.closeBlobFieldWrite(); //Appendables.appendUTF8(System.out, writer.getPipe().blobRing, writer.startPosition, len, writer.getPipe().blobMask); return len; }
public static <T extends MessageSchema<T>> int closeHighLevelField(DataOutputBlobWriter<T> writer, int targetFieldLoc) { //this method will also validate the length was in bound and throw unsupported operation if the pipe was not large enough //instead of fail fast as soon as one field goes over we wait to the end and only check once. int len = length(writer); //Appendables.appendUTF8(System.err, writer.byteBuffer, writer.startPosition, len, writer.byteMask); PipeWriter.writeSpecialBytesPosAndLen(writer.backingPipe, targetFieldLoc, len, writer.startPosition); writer.backingPipe.closeBlobFieldWrite(); //Appendables.appendUTF8(System.out, writer.getPipe().blobRing, writer.startPosition, len, writer.getPipe().blobMask); return len; }
public static <T extends MessageSchema<T>> int closeHighLevelField(DataOutputBlobWriter<T> writer, int targetFieldLoc) { //this method will also validate the length was in bound and throw unsupported operation if the pipe was not large enough //instead of fail fast as soon as one field goes over we wait to the end and only check once. int len = length(writer); //Appendables.appendUTF8(System.err, writer.byteBuffer, writer.startPosition, len, writer.byteMask); PipeWriter.writeSpecialBytesPosAndLen(writer.backingPipe, targetFieldLoc, len, writer.startPosition); writer.backingPipe.closeBlobFieldWrite(); //Appendables.appendUTF8(System.out, writer.getPipe().blobRing, writer.startPosition, len, writer.getPipe().blobMask); return len; }
@Override public void write(Externalizable object) { int pos = activePosition; try { object.writeExternal(this); } catch (IOException e) { throw new RuntimeException(e); } assert(Pipe.validateVarLength(this.backingPipe, length(this))); assert(collectObjectSizeData(activePosition-pos)); }
@Override public void write(Externalizable object) { int pos = activePosition; try { object.writeExternal(this); } catch (IOException e) { throw new RuntimeException(e); } assert(Pipe.validateVarLength(this.backingPipe, length(this))); assert(collectObjectSizeData(activePosition-pos)); }
@Override public void write(Externalizable object) { int pos = activePosition; try { object.writeExternal(this); } catch (IOException e) { throw new RuntimeException(e); } assert(Pipe.validateVarLength(this.backingPipe, length(this))); assert(collectObjectSizeData(activePosition-pos)); }
public static void finalizeLengthOfFirstBlock(HTTPUtilResponse that, DataOutputBlobWriter<?> outputStream) { int propperLength = DataOutputBlobWriter.length(outputStream); Pipe.validateVarLength(outputStream.getPipe(), propperLength); Pipe.setIntValue(propperLength, outputStream.getPipe(), that.block1PositionOfLen); //go back and set the right length. outputStream.getPipe().closeBlobFieldWrite(); }