trait BufferingByteParser extends AnyRef
Models a growable buffer of Bytes, which are Chars or Bytes. We maintain an Array[Byte] as a buffer, and read Bytes into it using readDataIntoBuffer and drop old Bytes using dropBufferUntil.
In general, BufferingByteParser allows us to keep the fast path fast:
- Reading elem-by-elem from the buffer is a bounds check and direct Array
access, without any indirection or polymorphism.
- We load Bytes in batches into the buffer, which allows us to take advantage
of batching APIs like InputStream.read
- We amortize the overhead of the indirect/polymorphic readDataIntoBuffer
call over the size of each batch
Note that dropBufferUntil only advances a dropped index and does not actually zero out the dropped Bytes; instead, we wait until we need to call growBuffer, and use that as a chance to copy the remaining un-dropped Bytes to either the start of the current buffer or the start of a newly-allocated bigger buffer (if necessary)
- Alphabetic
- By Inheritance
- BufferingByteParser
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
- abstract def readDataIntoBuffer(buffer: Array[Byte], bufferOffset: Int): (Array[Byte], Boolean, Int)
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def appendBytesToBuilder(elems: ByteBuilder, elemsStart: Int, elemsLength: Int): Unit
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def dropBufferUntil(i: Int): Unit
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def getBufferCopyCount(): Int
- def getBufferGrowCount(): Int
- def getBufferLength(): Int
- def getByteSafe(i: Int): Byte
- def getByteUnsafe(i: Int): Byte
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def getLastIdx: Int
- def growBuffer(until: Int): Unit
Copies the non-dropped Bytes in the current buffer to the start of either the current buffer, or a newly-allocated larger buffer if necessary.
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def requestUntil(until: Int): Boolean
Used to ensure that elements up to until are available to read; returns whether or not we have read off the end of the input.
Used to ensure that elements up to until are available to read; returns whether or not we have read off the end of the input.
In the fast path, when until is less than the lastIdx we have buffered, there is no work to do and we return false.
In the slow path, when until is more than lastIdx, we then run growBuffer to grow the buffer if necessary, and then readDataIntoBuffer to populate it. readDataIntoBuffer returns a
newDone
value to indicate whether we have read off the end of the input or not.Note that for some subclasses, growBuffer may be a no-op when we already know we have reached the end of input.
- Attributes
- protected
- def sliceArr(i: Int, n: Int): (Array[Byte], Int, Int)
- def sliceString(i: Int, k: Int): String
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- def unsafeCharSeqForRange(start: Int, length: Int): WrapByteArrayCharSeq
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()