5#include <portals/document_encoding.hpp>
6#include <portals/document_source.hpp>
32 std::optional<DocumentDecodeResult>
decode;
47 friend class DocumentSearchSession;
54 std::string
text = std::string(0,
'\0');
55 std::string
snippet = std::string(0,
'\0');
62 return credit_.usage().bytes;
72 std::shared_ptr<const DocumentSearchMatch>
match;
90class DocumentSearchSession {
100 create(std::shared_ptr<ByteDocumentSource> source, std::string_view utf8Query,
127 std::unique_ptr<State> state_;
Bounded worker cursor for exact, case-sensitive literal search without normalization....
Definition document_search.hpp:90
~DocumentSearchSession()
Release retained pages/maps before their accounting owners.
SourceBudgetUsage retainedUsage() const noexcept
static std::expected< std::shared_ptr< DocumentSearchSession >, DocumentSearchFailure > create(std::shared_ptr< ByteDocumentSource > source, std::string_view utf8Query, DocumentDecoderOptions decoderOptions={.hint=DocumentEncoding::UTF8}, DocumentSearchOptions options={})
std::expected< DocumentSearchStep, DocumentSearchFailure > advance(std::stop_token stop={})
std::expected< void, DocumentSearchFailure > start(DocumentSearchDirection direction, std::uint64_t anchorByte=0)
Move-only credit; backing storage must be destroyed before this final credit owner.
Definition source_budget.hpp:64
Public Portals API.
Definition action.hpp:8
@ PENDING
Complete or abandon the owning session before submitting another frame.
Definition diff.hpp:108
DocumentOperationFailure DocumentSearchFailure
Search-specific spelling of the shared document operation failure.
Definition document_search.hpp:36
DocumentSearchState
One bounded advance; PENDING is ordinary continuation, not source backpressure.
Definition document_search.hpp:16
@ FOUND
A selected owning match is available.
Definition document_search.hpp:18
@ PENDING
The work quantum finished; call advance again for this same request.
Definition document_search.hpp:17
DocumentSearchDirection
Literal navigation order; wrapping belongs to the caller.
Definition document_search.hpp:10
@ PREVIOUS
Last whole-grapheme match starting strictly before the requested anchor.
Definition document_search.hpp:12
@ NEXT
First whole-grapheme match starting at or after the requested anchor.
Definition document_search.hpp:11
@ UTF8
UTF-8.
Definition document_encoding.hpp:16
Encoding selection, malformed-input policy and per-call work bound.
Definition document_encoding.hpp:62
Failure with an optional native provider cause, preserved by source operations.
Definition document_source.hpp:13
Source/admission cause and, when applicable, the precise decoder failure.
Definition document_search.hpp:30
DocumentError error
Original source error or typed query/storage failure; budgetDemand remains exact.
Definition document_search.hpp:31
std::optional< DocumentDecodeResult > decode
Present for decoder status, original error offset and length.
Definition document_search.hpp:32
Exact document namespace and provider revision.
Definition document_source.hpp:24
Immutable owning selection; remains readable after session/source replacement. text is the exact deco...
Definition document_search.hpp:45
std::size_t retainedBytes() const noexcept
Definition document_search.hpp:61
std::string snippet
Whole-grapheme context, bounded by maxSnippetBytes.
Definition document_search.hpp:55
std::uint64_t byteLength
Original byte length, with an exclusive whole-grapheme end.
Definition document_search.hpp:53
std::uint64_t byteOffset
Inclusive offset in the original source encoding.
Definition document_search.hpp:52
bool snippetTruncated
The complete match cannot fit inside the configured snippet cap.
Definition document_search.hpp:58
std::string text
Complete UTF-8 match, bounded by maxQueryBytes.
Definition document_search.hpp:54
std::size_t snippetMatchOffset
Inclusive UTF-8 match offset inside snippet.
Definition document_search.hpp:56
DocumentRevision revision
Exact source namespace and provider revision.
Definition document_search.hpp:51
std::size_t snippetMatchLength
UTF-8 match length inside snippet; zero for an omitted snippet.
Definition document_search.hpp:57
Query/work/result limits, independent of document extent or total match count.
Definition document_search.hpp:23
std::size_t maxSnippetBytes
Positive whole-grapheme UTF-8 context cap, including the shown match.
Definition document_search.hpp:26
std::size_t maxQueryBytes
Positive UTF-8 query admission cap.
Definition document_search.hpp:24
std::size_t workBytes
Positive original source admission/processing quantum per advance.
Definition document_search.hpp:25
Value-only progress with at most one selected owning result.
Definition document_search.hpp:67
std::uint64_t scannedByteOffset
Exact original-byte decoder progress, not a total hit count.
Definition document_search.hpp:70
DocumentRevision revision
Revision qualified at the current worker advance.
Definition document_search.hpp:69
DocumentSearchState state
Explicit bounded-search outcome.
Definition document_search.hpp:68
std::optional< std::uint64_t > byteExtent
Current exact extent when known, without a forced EOF scan.
Definition document_search.hpp:71
std::shared_ptr< const DocumentSearchMatch > match
Present only for FOUND.
Definition document_search.hpp:72
Simultaneous source reservations; bytes are requested capacities, not process RSS.
Definition source_budget.hpp:41