Package

upickle

core

Permalink

package core

Visibility
  1. Public
  2. All

Type Members

  1. case class Abort(msg: String) extends Exception with Product with Serializable

    Permalink

    Throw this inside a Visitor's handler functions to fail the processing of JSON.

    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.

  2. case class AbortException(clue: String, index: Int, line: Int, col: Int, cause: Throwable) extends Exception with Product with Serializable

    Permalink

    Signals failure processsing JSON after parsing.

  3. trait Annotator extends AnyRef

    Permalink
  4. trait ArrVisitor[-T, +J] extends ObjArrVisitor[T, J]

    Permalink

    Visits the elements of a json array.

  5. trait BufferingByteParser extends AnyRef

    Permalink

    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)

  6. trait BufferingCharParser extends AnyRef

    Permalink

    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)

  7. trait BufferingInputStreamParser extends BufferingByteParser

    Permalink

    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 .

  8. abstract class ByteAppendC extends AnyRef

    Permalink
  9. class ByteBuilder extends ByteAppendC

    Permalink

    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

  10. abstract class CharAppendC extends AnyRef

    Permalink
  11. class CharBuilder extends CharAppendC

    Permalink

    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

  12. class LogVisitor[-T, +V] extends Visitor[T, V]

    Permalink

    A visitor that wraps another but prints out what methods get called, useful for debugging

  13. sealed trait ObjArrVisitor[-T, +J] extends AnyRef

    Permalink

    Base class for visiting elements of json arrays and objects.

    Base class for visiting elements of json arrays and objects.

    T

    ???

    J

    the result of visiting elements (e.g. a json AST or side-effecting writer)

  14. trait ObjVisitor[-T, +J] extends ObjArrVisitor[T, J]

    Permalink

    Visits the elements of a json object.

  15. trait SimpleVisitor[-T, +V] extends Visitor[T, V]

    Permalink

    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.

  16. class TraceVisitor[T, J] extends Delegate[T, J]

    Permalink
  17. trait Types extends AnyRef

    Permalink

    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

  18. trait Visitor[-T, +J] extends AnyRef

    Permalink

    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

    T

    ???

    J

    the result of visiting elements (e.g. a json AST or side-effecting writer)

    See also

    http://www.lihaoyi.com/post/ZeroOverheadTreeProcessingwiththeVisitorPattern.html

  19. class WrapByteArrayCharSeq extends CharSequence

    Permalink

    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.

  20. class WrapCharArrayCharSeq extends CharSequence

    Permalink

    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.

Value Members

  1. object BufferingInputStreamParser

    Permalink
  2. object ByteOps

    Permalink
  3. object CharOps

    Permalink
  4. object NoOpVisitor extends Visitor[Unit, Unit]

    Permalink

    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.

  5. object RenderUtils

    Permalink
  6. object StringVisitor extends SimpleVisitor[Nothing, Any]

    Permalink
  7. object TraceVisitor

    Permalink

    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.

    See also

    https://goessner.net/articles/JsonPath/

  8. object Util

    Permalink
  9. object Visitor

    Permalink
  10. package compat

    Permalink

Ungrouped