Package-level declarations

Types

Link copied to clipboard

The operations of JsonStore without coroutines, obtained from JsonStore.blocking. Thread-safe.

Link copied to clipboard

The operations of ReadableJsonStore without coroutines, obtained from ReadableJsonStore.blocking. Thread-safe.

Link copied to clipboard
Link copied to clipboard
sealed interface CompareOperand

One side of a comparison (SPEC.md §9): a node of a stored document, or a JSON value given as text.

Link copied to clipboard
class CompareOptions(val includeTypes: Boolean = false, val ignoreKeys: Set<String> = emptySet(), val ignorePaths: Set<String> = emptySet())

How values are compared (SPEC.md §9.2).

Link copied to clipboard
class CorruptionException(val location: String, val detail: String, cause: Throwable? = null) : DelvaException

Stored bytes don't match their format: a CRC mismatch, a truncated structure, an out-of-range field or an inconsistent index entry. location names the file or structure and the byte position.

Link copied to clipboard

The options a store is created with, fixed for its whole life: they shape the stored data and the index terms. They are given to JsonStore.create and JsonStore.openOrCreate, recorded in the store, and read back by JsonStore.open, so opening a store never needs them; JsonStore.creationOptions tells what a store was created with. The options that may differ at every open are StoreOptions.

Link copied to clipboard
class CreationOptionsMismatchException(val directory: Path, val stored: CreationOptions, val requested: CreationOptions) : DelvaException

JsonStore.openOrCreate found a store in directory created with other CreationOptions than requested; it was left as it was. JsonStore.open opens it with the stored options.

Link copied to clipboard
class Cursor

An opaque position in a result sequence: the hits strictly past (docId, nodePre) in the order of the search that produced it — after it for SearchOrder.ASCENDING, before it for SearchOrder.DESCENDING. toString gives a compact URL-safe text, and parse reads it back. A cursor resumes only what produced it: a search of the same SearchOrder and kind, or JsonStore.objectsOfTypePage for the cursor of a TypePage; anything else throws InvalidCursorException.

Link copied to clipboard

Base class of every exception Delva throws for data, state or storage problems. It is sealed, but the constructors of its subclasses are public, so a fake JsonStore in a test (DelvaImplementationApi) can throw what the store throws.

Link copied to clipboard
@RequiresOptIn(message = "Delva adds members to this interface in minor releases, which an implementation has to follow; opt in with @OptIn(DelvaImplementationApi::class).", level = RequiresOptIn.Level.ERROR)
@Target(allowedTargets = [AnnotationTarget.CLASS])
annotation class DelvaImplementationApi

Marks the interfaces that are Delva's to implement: ReadableJsonStore, JsonStore, SecondaryJsonStore, their blocking faces (BlockingReadableJsonStore, BlockingJsonStore, BlockingSecondaryJsonStore), SearchResult, SearchHit, SelectResult and SelectedNode. Calling them needs no opt-in. Implementing one, typically as a fake in a test, requires @OptIn(DelvaImplementationApi::class) and accepts that later minor releases add members to it, which an implementation then has to add too.

Link copied to clipboard

One difference between the left and the right value: at path (an RFC 9535 Normalized Path such as $['a'][0], SPEC.md §9.3, $ being the compared values), what kind of difference, and the values involved: left is null for DifferenceKind.ADDED, right for DifferenceKind.REMOVED.

Link copied to clipboard

What a Difference reports (SPEC.md §9.3).

Link copied to clipboard
class DiffOptions(val includeTypes: Boolean = false, val ignoreKeys: Set<String> = emptySet(), val ignorePaths: Set<String> = emptySet(), val maxDifferences: Int = 1000, val maxValueBytes: Int = 1024, val verifySkippedSubtrees: Boolean = false)

How a diff is computed and reported (SPEC.md §9.3): includeTypes, ignoreKeys and ignorePaths compare values as in CompareOptions, and

Link copied to clipboard
class DiffValue

A value a Difference involves.

Link copied to clipboard
value class DocId(val raw: Long)

Identifier of a stored document. Dense and increasing in insert start order; aborted inserts leave gaps. raw is the number itself.

Link copied to clipboard

A condition on a whole document, which limits a JsonPathQuery to the documents that meet it (JsonPathQuery.documentFilter, SPEC.md §10.5): an RFC 9535 logical expression, what a filter selector holds after its ?, evaluated once on each document with both @ and $ standing for the document's root.

Link copied to clipboard

A DocumentFilter with named placeholders, compiled once and bound to values any number of times (SPEC.md §10.6), as JsonPathTemplate is for a query: @.kind == ${kind} && @.version >= ${version}.

Link copied to clipboard
class DocumentKeyQuery(val prefix: String = "", val limit: Int = 100, val maxBytes: Long = Long.MAX_VALUE, val after: Cursor? = null, val order: SearchOrder = SearchOrder.ASCENDING)

A search of documents in key order (SPEC.md §3.3), in a store with a CreationOptions.documentKey: every visible document whose key starts with prefix ("" for all), once, with its root as the hit and SearchHit.documentKey set. Keys compare by code points, which is the order of their UTF-8 bytes; with Normalization.NFC the prefix is normalized as keys are.

Link copied to clipboard

The document doesn't exist or the caller can't see it: never inserted, deleted, still being inserted, or the docId of an insert that was rejected.

Link copied to clipboard
class DocumentRejectedException(val reason: RejectReason, val byteOffset: Long, val jsonPath: String? = null, detail: String? = null) : DelvaException

An insert was rejected; nothing of the document is visible.

Link copied to clipboard
sealed interface Durability

When acknowledged writes become durable.

Link copied to clipboard
class EngineFailedException(message: String, cause: Throwable? = null) : DelvaException

The engine hit an unrecoverable error (for example a failed fsync) and refuses every further operation. Reopening the store runs recovery.

Link copied to clipboard
@RequiresOptIn(message = "This part of Delva's API may still change in a minor release; opt in with @OptIn(ExperimentalDelvaApi::class).", level = RequiresOptIn.Level.ERROR)
annotation class ExperimentalDelvaApi

Marks API that is new in this release and may still change, in its signature or its behaviour, in a minor release. Using it requires @OptIn(ExperimentalDelvaApi::class). The mark is lifted from a declaration once a release has shipped it unchanged; the CHANGELOG says when.

Link copied to clipboard
sealed interface InsertOutcome

What JsonStore.insertAll did with one document.

Link copied to clipboard
class InsertSource @ExperimentalDelvaApi constructor(val source: InputStream, val types: Map<String, String> = emptyMap(), replaces: Collection<DocId>, onExistingKey: KeyConflict = KeyConflict.FAIL)

One document for JsonStore.insertAll: the stream its JSON is read from, which isn't closed, the types to assign with it, JSON paths to type names as JsonStore.insert takes them, the documents it replaces, and in a store with a CreationOptions.documentKey what it does when its key is taken (onExistingKey).

Link copied to clipboard

Text that isn't a Cursor (Cursor.parse), or a cursor that doesn't fit where it's used: from a search of the other SearchOrder, or from another kind of result. An IllegalArgumentException, as Cursor.parse has always thrown.

Link copied to clipboard
class InvalidJsonPathException(val text: String, val offset: Int, val reason: String) : IllegalArgumentException

A JSONPath query or document filter that doesn't compile (SPEC.md §10.1, §10.5): a syntax or type error, or text beyond the limits. An IllegalArgumentException, as JsonPath.compile and the type paths of JsonStore.insert have always thrown.

Link copied to clipboard

A type name doesn't meet the rules of SPEC.md §6.1.

Link copied to clipboard

How a node's JSON is laid out when it's read (SearchHit.writeJsonTo, SelectedNode.writeJsonTo and their readJsonAsString). COMPACT, the default, is the exact output form of SPEC.md §5, with no whitespace. Any other format writes the same tokens with whitespace between them (SPEC.md §5.1), so removing the whitespace outside strings gives the compact text back byte for byte, unless maxLevels cuts nested containers out. Formatting is applied as the node is read; it's never stored.

Link copied to clipboard
class JsonPath

A compiled RFC 9535 JSONPath query (SPEC.md §10): the whole grammar, with the functions length, count, match, search and value. Compile once, then use it for any number of JsonStore.select and JsonStore.search calls. Immutable and thread-safe; two queries are equal when their texts are.

Link copied to clipboard
class JsonPathQuery @ExperimentalDelvaApi constructor(val path: JsonPath, val mode: ResultMode = ResultMode.CONTAINING_ELEMENT, val nested: NestedHits = NestedHits.ALL, val limit: Int = 100, val maxBytes: Long = Long.MAX_VALUE, val after: Cursor? = null, val type: String? = null, val scan: ScanPolicy = ScanPolicy.REJECT, val order: SearchOrder = SearchOrder.ASCENDING, documentFilter: DocumentFilter?)

A JSONPath search (SPEC.md §10.4): the nodes path selects from the documents of the store. Hits are the distinct selected nodes in (docId, nodePre) order, ascending or descending by order — each node once, unlike an RFC 9535 nodelist, which JsonStore.select gives for one value.

Link copied to clipboard

An RFC 9535 JSONPath query with named placeholders, compiled once and bound to values any number of times (SPEC.md §10.6). A placeholder ${name} stands where the RFC allows a literal: an operand of a comparison, or a value argument of a function such as the pattern of match.

Link copied to clipboard
sealed interface JsonQueryValue

A query value (SPEC.md §2): equality is typed, numbers compare by decimal value, strings by code points.

Link copied to clipboard

An embedded JSON document store. Inserts stream their input, searches return lazily read results (SPEC.md). This is the store's writer, which holds the directory's lock until it's closed, with the read operations of ReadableJsonStore; other processes can read the store beside it with openSecondary. After a failed write or sync, operations throw EngineFailedException until the store is reopened (SPEC.md §8).

Link copied to clipboard

What an insert does when a visible document already has its document key (CreationOptions.documentKey).

Link copied to clipboard
class KeyValueQuery(val key: String, val value: JsonQueryValue, val mode: ResultMode = ResultMode.WHOLE_DOCUMENT, val nested: NestedHits = NestedHits.ALL, val limit: Int = 100, val maxBytes: Long = Long.MAX_VALUE, val after: Cursor? = null, val type: String? = null, val order: SearchOrder = SearchOrder.ASCENDING)

A key–value search (SPEC.md §4): objects with a member key whose value, or an element of whose array value, equals value.

Link copied to clipboard
class LockHolder(val pid: Long, val startedAt: Instant?, val host: String?)

The process that has a store open, as it recorded itself when it opened the store (StoreLockedException.holder). The record is advisory: a process that can't write it still holds the store.

Link copied to clipboard

Handling of hits nested inside other hits of the same document (SPEC.md §4.5).

Link copied to clipboard
class NodeRef(val docId: DocId, val nodePre: Long) : Comparable<NodeRef>

A node of a stored document (SPEC.md §3.2): its document, docId, and its pre-order number, nodePre, and nothing more. The pair is the whole of a node reference, now and in later versions: it can be stored, compared and rebuilt from its two numbers.

Link copied to clipboard

How a store treats the spelling of strings and keys (SPEC.md §2.1). Fixed when the store is created, because it decides the bytes that are stored and the terms that are indexed.

Link copied to clipboard

Evaluating a JSONPath query exceeded one of the limits that keep evaluation bounded (SPEC.md §10.2), such as the steps a regular expression of match or search may take.

Link copied to clipboard
class QueryPlan

How a JSONPath search finds its candidate documents, as JsonStore.explain reports it.

Link copied to clipboard

A search the store can't answer, refused for reason before anything is read (SPEC.md §4.6, §10.4). Nothing is wrong with the query as such: another store, a narrower query, ScanPolicy.ALLOW_SCAN, or a select of each document answers it.

Link copied to clipboard

The read operations of a store, shared by the JsonStore that writes it and the SecondaryJsonStores that read it beside its writer: code that only reads takes a ReadableJsonStore and serves both.

Link copied to clipboard

Why an insert was rejected (SPEC.md §1.2).

Link copied to clipboard

What a hit stands for (SPEC.md §4.3).

Link copied to clipboard

A value is longer than the maxChars characters the caller allowed, for example in SearchHit.readJsonAsString.

Link copied to clipboard

What a JSONPath search does when no index term narrows it down (SPEC.md §10.4).

Link copied to clipboard

One hit: an object (CONTAINING_ELEMENT) or a document root (WHOLE_DOCUMENT). Readable while its result is open.

Link copied to clipboard

The order of a search's hits (SPEC.md §4.4).

Link copied to clipboard

One page of hits.

Link copied to clipboard

The hits of one KeyValueQuery or JsonPathQuery, read lazily page by page from one snapshot of the store (SPEC.md §4.6, §8, §10.4): the result sees every operation acknowledged before the search started and nothing later, so its pages together return every hit exactly once.

Link copied to clipboard

A store read beside its writer, opened with JsonStore.openSecondary: it offers every read of ReadableJsonStore and never writes. It takes no lock, so it works while another process has the store open as a JsonStore, and with no writer at all (SPEC.md §8.1).

Link copied to clipboard

One node of a SelectResult. Readable while its result is open.

Link copied to clipboard

The nodes one JSONPath query selects from one value, as JsonStore.select returns them: an RFC 9535 nodelist, in the RFC's order and with its duplicates, read lazily from one snapshot of the store (SPEC.md §10.3). Nodes can be read until the result is closed. A result is consumed once: iterator and nodes share one position. Not thread-safe.

Link copied to clipboard

The store was closed; reopen it to use it again.

Link copied to clipboard
class StoreExistsException(val directory: Path) : DelvaException

JsonStore.create found a store already in directory; it was left as it was.

Link copied to clipboard
class StoreInfo

What a store holds, as of the moment ReadableJsonStore.info was called; read from memory, without a scan.

Link copied to clipboard
class StoreLockedException(val directory: Path, val holder: LockHolder? = null) : DelvaException

Another open store (in this or another process) holds the directory. holder names the process that has it open, as that process recorded itself; it is null when the record is missing, unreadable, or left by a process that is gone.

Link copied to clipboard

JsonStore.open found no store in directory; nothing was created there.

Link copied to clipboard
class StoreOptions(val encoderBudgetBytes: Int? = null, val maxDepth: Int = 1024, val maxDocumentBytes: Long = Long.MAX_VALUE, val maxStringBytes: Long = Long.MAX_VALUE, val ioParallelism: Int = 16, val durability: Durability = Durability.SyncEachBatch, val compression: Boolean = true, val mmapReads: Boolean = false)

The options of one open store, which may differ at every open. Every option has a safe default, so StoreOptions() opens a store that works on any heap; the values below bound what a store does, never how much of the JVM's heap it needs, which the engine derives from the heap it runs on. The options fixed when a store is created are CreationOptions.

Link copied to clipboard
class TypeInfo

A type name and roughly how many objects have it (SPEC.md §6.2), as ReadableJsonStore.listTypes lists them.

Link copied to clipboard
class TypePage

One page of the objects of a type, from JsonStore.objectsOfTypePage.

Link copied to clipboard

One problem JsonStore.verify found. location names the file and byte position, as CorruptionException.location does; damagedBytes is how many bytes the damage spans where that's known, and 0 otherwise.

Link copied to clipboard

What kind of structure a VerifyIssue was found in.

Link copied to clipboard

What JsonStore.verify is reading, in the order the phases run.

Link copied to clipboard
fun interface VerifyProgress

Called by JsonStore.verify as it works, at least once per phase and then every few MiB.

Link copied to clipboard

What JsonStore.verify read and what it found. A store is intact when issues is empty; every issue names data that reads would fail on, not a reason to stop using the store, which keeps serving everything else.

Link copied to clipboard
class WriteConflictException(val conflicting: List<DocId>, val key: String? = null) : DelvaException

An insert conflicts with the state it would take effect on. Nothing of the insert is visible and nothing was deleted. Nothing is wrong with the document itself: read the current state and try again. Either: