Documentation
¶
Overview ¶
Package simdscan provides SIMD-accelerated JSON field extraction.
It uses AVX2 instructions to scan 32 bytes at a time, classifying structural characters (quotes, backslashes, braces, brackets, colons, commas) in parallel. This enables finding JSON field values ~5-10x faster than traditional byte-by-byte parsers.
The package handles escaped characters correctly — backslash sequences like \" and \\ are properly tracked across SIMD chunk boundaries.
On non-amd64 architectures or CPUs without AVX2, a scalar fallback is used automatically.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("field not found") ErrBadJSON = errors.New("invalid JSON") )
Functions ¶
Types ¶
type Field ¶
type Field struct {
Key []byte // raw key: without quotes and not unescaped
KeyStart int // index of the opening quote of the key
ValueStart int
ValueEnd int // exclusive; strings include their quotes
Type Type
}
Field describes a top-level field of a JSON object by its byte positions in the original data.
type ObjectScan ¶
type ObjectScan struct {
Data []byte
Keys []string
Coords []ValueCoord
}
ObjectScan holds the result of scanning a JSON object. Keys and Coords are parallel slices — Coords[i] describes the value for Keys[i]. Data is a reference to the original JSON bytes (zero-copy).
func ScanObject ¶
func ScanObject(data []byte) (*ObjectScan, error)
ScanObject scans a JSON object and returns coordinates for all top-level fields. This is the SIMD-accelerated equivalent of stonejson.ParseToOffsets. No values are copied — only their positions within the original data.
type Type ¶
type Type int
Type represents the JSON value type.
type ValueCoord ¶
ValueCoord stores the position and type of a JSON value within the original byte slice — no copies, just coordinates.