Class/Object

fm.serializer

FMByteArrayOutputStream

Related Docs: object FMByteArrayOutputStream | package serializer

Permalink

final class FMByteArrayOutputStream extends OutputStream with Appendable

A ByteArrayOutputStream implementation optimized for writing binary serialized data (e.g. Protocol Buffers).

Tries to avoid excessive memory allocations and array resizing by using an Array of Byte Arrays to represent the data. Supports directly appending Byte Arrays (zero-copy), writing length prefixed data, optimized writing of ASCII and UTF-8 strings without going through a java.io.Writer.

Linear Supertypes
Appendable, OutputStream, Flushable, Closeable, AutoCloseable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. FMByteArrayOutputStream
  2. Appendable
  3. OutputStream
  4. Flushable
  5. Closeable
  6. AutoCloseable
  7. AnyRef
  8. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new FMByteArrayOutputStream(InitialArrayCapacity: Int = ..., BufferSize: Int = ..., MinUsefulBufferSize: Int = ..., CompactThresholdSize: Int = ..., SpliceThresholdSize: Int = ...)

    Permalink

    InitialArrayCapacity

    The initial capacity of the internal arrays

    BufferSize

    The size of each buffer

    MinUsefulBufferSize

    If we are splicing data keep using the existing buffer if there is at least this much space in it

    CompactThresholdSize

    If writing length prefixed data we have a gap then compact the array if the written data is less than this amount

    SpliceThresholdSize

    If writing a Byte Array that is over this length then splice it in. If it's under this length then just write it to our buffers

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def append(str: CharSequence, start: Int, end: Int): FMByteArrayOutputStream.this.type

    Permalink

    Appendable Implementation

    Appendable Implementation

    Definition Classes
    FMByteArrayOutputStream → Appendable
  5. def append(str: CharSequence): FMByteArrayOutputStream.this.type

    Permalink

    Appendable Implementation

    Appendable Implementation

    Definition Classes
    FMByteArrayOutputStream → Appendable
  6. def append(ch: Char): FMByteArrayOutputStream.this.type

    Permalink

    Appendable Implementation

    Appendable Implementation

    Definition Classes
    FMByteArrayOutputStream → Appendable
  7. def appendCodePoint(codePoint: Int): FMByteArrayOutputStream.this.type

    Permalink
  8. def appendDoubleAsString(value: Double): Unit

    Permalink
  9. def appendFloatAsString(value: Float): Unit

    Permalink
  10. def appendIntAsString(value: Int): Unit

    Permalink
  11. def appendLongAsString(value: Long): Unit

    Permalink
  12. final def array: Array[Byte]

    Permalink
    Annotations
    @inline()
  13. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  14. def available: Int

    Permalink

    How many bytes are available in the current buffer

    How many bytes are available in the current buffer

    Annotations
    @inline()
  15. final def bufferCount: Int

    Permalink

    Public accessor for tests

    Public accessor for tests

    Annotations
    @inline()
  16. def check(): Unit

    Permalink
    Annotations
    @elidable( elidable.ASSERTION )
  17. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate() @throws( ... )
  18. def close(): Unit

    Permalink
    Definition Classes
    OutputStream → Closeable → AutoCloseable
    Annotations
    @throws( classOf[java.io.IOException] )
  19. def countBytes(f: ⇒ Unit): Int

    Permalink
    Annotations
    @inline()
  20. def debug(msg: String): Unit

    Permalink
    Annotations
    @elidable( elidable.FINE )
  21. def debugInfo: String

    Permalink
    Annotations
    @elidable( elidable.FINE )
  22. def dumpOnAssert(f: ⇒ Unit): Unit

    Permalink
    Annotations
    @elidable( elidable.ASSERTION )
  23. def ensureAvailable(size: Int): Unit

    Permalink

    Ensure that there are at least size bytes available in the current buffer (or point to a new buffer).

    Ensure that there are at least size bytes available in the current buffer (or point to a new buffer).

    Annotations
    @inline()
  24. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  25. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  26. def flush(): Unit

    Permalink
    Definition Classes
    OutputStream → Flushable
    Annotations
    @throws( classOf[java.io.IOException] )
  27. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
    Annotations
    @HotSpotIntrinsicCandidate()
  28. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
    Annotations
    @HotSpotIntrinsicCandidate()
  29. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  30. final def length: Int

    Permalink
    Annotations
    @inline()
  31. def lengthPrefixed(maxPrefixSize: Int)(writeData: ⇒ Unit)(writePrefix: (Int) ⇒ Unit): Unit

    Permalink

    This is for writing data that needs to have it's length prefixed when the prefixed length is variable.

    This is for writing data that needs to have it's length prefixed when the prefixed length is variable. e.g. When write Protocol Buffers length delimited fields the length is a varint.

    This method takes the maximum prefix size we expect to write, a function that performs the writing the data, and a function that takes the number of bytes written via writeData and performs the length prefix write. If the length prefix write is less than the maxPrefixSize parameter then the array will either be compacted or split into two.

    Annotations
    @inline()
  32. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  33. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate()
  34. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate()
  35. final def offset: Int

    Permalink
    Annotations
    @inline()
  36. def offsetPlusPlus: Int

    Permalink
  37. final def offset_=(v: Int): Unit

    Permalink
    Annotations
    @inline()
  38. def reset(): Unit

    Permalink
  39. final def shiftArray(arr: Array[Boolean], start: Int, len: Int, shift: Int): Unit

    Permalink
  40. final def shiftArray(arr: Array[Int], start: Int, len: Int, shift: Int): Unit

    Permalink
  41. final def shiftArray(arr: Array[Byte], start: Int, len: Int, shift: Int): Unit

    Permalink
  42. final def shiftArray(arr: Array[Array[Byte]], start: Int, len: Int, shift: Int): Unit

    Permalink
  43. def skipBytes(globalIdx: Int, len: Int): Unit

    Permalink

    Remove or Skip over the bytes at the starting index to length.

    Remove or Skip over the bytes at the starting index to length.

    These are expected to be contiguous bytes in one of the buffers. The buffer will be looked up based on the start index and then data will either be compacted or spliced around based on how much data comes after the skipped bytes

  44. def splice(bytes: Array[Byte], off: Int, len: Int): Unit

    Permalink

    Directly use this byte array (zero-copy).

    Directly use this byte array (zero-copy). If there are bytes left in our current buffer to make it useful then we will splice this into our current array by saving the current array, saving this array, and then using the rest of the original array as our current buffer with updated start/offset/length

  45. final def start: Int

    Permalink
    Annotations
    @inline()
  46. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  47. def toByteArray: Array[Byte]

    Permalink

    Create a byte array out of the current data

  48. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  49. def totalSize: Int

    Permalink
  50. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  51. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  52. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  53. def write(str: String, start: Int, len: Int): Unit

    Permalink
  54. def write(str: String): Unit

    Permalink
  55. def write(bytes: Array[Byte], off: Int, len: Int): Unit

    Permalink

    OutputStream Implementation

    OutputStream Implementation

    Definition Classes
    FMByteArrayOutputStream → OutputStream
  56. def write(bytes: Array[Byte]): Unit

    Permalink

    OutputStream Implementation

    OutputStream Implementation

    Definition Classes
    FMByteArrayOutputStream → OutputStream
  57. def write(b: Int): Unit

    Permalink

    OutputStream Implementation

    OutputStream Implementation

    Definition Classes
    FMByteArrayOutputStream → OutputStream
  58. def writeASCII(str: String): Unit

    Permalink

    Optimized for when we know the characters are ASCII

  59. def writeTo(os: OutputStream): Unit

    Permalink

    Write the current data in the buffer to an OutputStream

  60. def writeUTF8Bytes(str: String, start: Int, len: Int): Int

    Permalink

    Returns the number of bytes written

  61. def writeUTF8Bytes(str: String): Int

    Permalink

    Returns the number of bytes written

Deprecated Value Members

  1. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @Deprecated @deprecated @throws( classOf[java.lang.Throwable] )
    Deprecated

    (Since version ) see corresponding Javadoc for more information.

Inherited from Appendable

Inherited from OutputStream

Inherited from Flushable

Inherited from Closeable

Inherited from AutoCloseable

Inherited from AnyRef

Inherited from Any

Ungrouped