Throw this inside a Visitor's handler functions to fail the processing of JSON.
Signals failure processsing JSON after parsing.
Visits the elements of a json array.
Models a growable buffer of Bytes, which are Chars or Bytes.
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)
Models a growable buffer of Chars, which are Chars or Bytes.
Models a growable buffer of Chars, which are Chars or Bytes. We maintain an Array[Char] as a buffer, and read Chars into it using readDataIntoBuffer and drop old Chars using dropBufferUntil.
In general, BufferingCharParser 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 Chars 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 Chars; instead, we wait until we need to call growBuffer, and use that as a chance to copy the remaining un-dropped Chars to either the start of the current buffer or the start of a newly-allocated bigger buffer (if necessary)
Defines common functionality to any parser that works on a java.io.InputStream
Defines common functionality to any parser that works on a java.io.InputStream
Allows you to look up individual bytes by index, take slices of byte ranges or strings, and drop old portions of buffered data once you are certain you no longer need them.
The buffer
size is managed by allowing it to grow in size until it exceeds its
capacity. When that happens, one of two things happen:
- If the buffer has enough space, we left-shift the data in the buffer to over-write the portion that has already been dropped.
- If the buffer does not have enough space, we allocate a new buffer big enough to hold the new data we need to store (size a power of two multiple of the old size) and copy the data over, again shifted left .
A fast buffer that can be used to store Bytes (Bytes or Chars).
A fast buffer that can be used to store Bytes (Bytes or Chars).
Generally faster than the equivalent StringBuilder or java.io.ByteArrayOutputStream, since:
- It is specialized and without the overhead of polymorphism or synchronization.
- It allows the user to call ensureLength
and appendUnsafe
separately, e.g.
callign ensureLength
once before appendUnsafe
-ing multiple Bytes
- It provides fast methods like makeString or writeOutToIfLongerThan, that
let you push the data elsewhere with minimal unnecessary copying
A fast buffer that can be used to store Chars (Bytes or Chars).
A fast buffer that can be used to store Chars (Bytes or Chars).
Generally faster than the equivalent StringBuilder or java.io.ByteArrayOutputStream, since:
- It is specialized and without the overhead of polymorphism or synchronization.
- It allows the user to call ensureLength
and appendUnsafe
separately, e.g.
callign ensureLength
once before appendUnsafe
-ing multiple Chars
- It provides fast methods like makeString or writeOutToIfLongerThan, that
let you push the data elsewhere with minimal unnecessary copying
A visitor that wraps another but prints out what methods get called, useful for debugging
Base class for visiting elements of json arrays and objects.
Base class for visiting elements of json arrays and objects.
???
the result of visiting elements (e.g. a json AST or side-effecting writer)
Visits the elements of a json object.
A visitor that throws an error for all the visit methods which it does not define, letting you only define the handlers you care about.
Basic functionality to be able to read and write objects.
Basic functionality to be able to read and write objects. Kept as a trait so
other internal files can use it, while also mixing it into the upickle
package to form the public API1
Standard set of hooks uPickle uses to traverse over a structured data.
Standard set of hooks uPickle uses to traverse over a structured data. A superset of the JSON, MessagePack, and Scala object hierarchies, since it needs to support efficiently processing all of them.
Note that some parameters are un-set (-1) when not available; e.g.
visitArray
's length
is not set when parsing JSON input (since it cannot
be known up front) and the various index
parameters are not set when
traversing Scala object hierarchies.
When expecting to deal with a subset of the methods; it is common to
forward the ones you don't care about to the ones you do; e.g. JSON visitors
would forward all visitFloat32
/visitInt
/etc. methods to visitFloat64
???
the result of visiting elements (e.g. a json AST or side-effecting writer)
A CharSequence that wraps an array of elements without any copying.
A CharSequence that wraps an array of elements without any copying.
Note that the arr is mutable, and so the WrapByteArrayCharSeq
should not itself be stored: either use it immediately when given it
or call .toString
if you want to store the data for later use.
A CharSequence that wraps an array of elements without any copying.
A CharSequence that wraps an array of elements without any copying.
Note that the arr is mutable, and so the WrapCharArrayCharSeq
should not itself be stored: either use it immediately when given it
or call .toString
if you want to store the data for later use.
NullFacade discards all JSON AST information.
NullFacade discards all JSON AST information.
This is the simplest possible facade. It could be useful for checking JSON for correctness (via parsing) without worrying about saving the data.
It will always return () on any successful parse, no matter the content.
Adds a JSON Path to exceptions thrown by the delegate Visitor.
Adds a JSON Path to exceptions thrown by the delegate Visitor.
Useful for debugging failures. Adds ~10% overhead depending on the parser.
https://goessner.net/articles/JsonPath/
Throw this inside a Visitor's handler functions to fail the processing of JSON. The Facade just needs to provide the error message, and it is up to the driver to ensure it is properly wrapped in a AbortException with the relevant source information.