#include <query_service.hpp>
|
| | QueryService (DeliverFn deliver) |
| | ~QueryService () |
| | QueryService (const QueryService &)=delete |
| QueryService & | operator= (const QueryService &)=delete |
| void | build (std::string dataset_id, std::vector< std::string > items, std::string callback_id={}) |
| | Build (or replace) the index for dataset_id off the UI thread from items.
|
| void | query (std::string dataset_id, std::string query_text, std::string callback_id, QueryOptions options={}) |
| | Search dataset_id off the UI thread.
|
| void | release (const std::string &dataset_id) |
| | Drop a dataset's index. Frees the memory once no in-flight job holds it.
|
| std::size_t | dataset_count () const |
| | Number of datasets with a currently-installed index (UI-thread view).
|
◆ DeliverFn
Initial value:
std::function<void(const std::string& callback_id, std::string json_payload)>
Delivers a completed result.
callback_id is the JS-side callback token and json_payload is a JSON string: for a search, an array of matched item indices; for a completed build, the item count as a decimal string. Called ON THE WORKER THREAD, so the implementation must be thread-safe and must not touch UI state directly — it should enqueue for the UI thread to drain.
◆ QueryService() [1/2]
| pulp::view::QueryService::QueryService |
( |
DeliverFn | deliver | ) |
|
|
explicit |
◆ ~QueryService()
| pulp::view::QueryService::~QueryService |
( |
| ) |
|
◆ QueryService() [2/2]
| pulp::view::QueryService::QueryService |
( |
const QueryService & | | ) |
|
|
delete |
◆ build()
| void pulp::view::QueryService::build |
( |
std::string | dataset_id, |
|
|
std::vector< std::string > | items, |
|
|
std::string | callback_id = {} ) |
Build (or replace) the index for dataset_id off the UI thread from items.
When callback_id is non-empty, the indexed item count (as a decimal string) is delivered once the index is installed.
Builds are deliberately fire-and-forget: they are not tracked for supersession or cancellation (unlike queries). A rebuild simply installs a newer index that overwrites the previous one; the single FIFO worker guarantees the later-submitted build wins.
◆ dataset_count()
| std::size_t pulp::view::QueryService::dataset_count |
( |
| ) |
const |
Number of datasets with a currently-installed index (UI-thread view).
◆ operator=()
◆ query()
| void pulp::view::QueryService::query |
( |
std::string | dataset_id, |
|
|
std::string | query_text, |
|
|
std::string | callback_id, |
|
|
QueryOptions | options = {} ) |
Search dataset_id off the UI thread.
The matched item indices (a JSON array, ranked best-first) are delivered to callback_id. Supersedes any still-running query for the same dataset (search-as-you-type): the older query is cancelled and never delivers.
◆ release()
| void pulp::view::QueryService::release |
( |
const std::string & | dataset_id | ) |
|
Drop a dataset's index. Frees the memory once no in-flight job holds it.
The documentation for this class was generated from the following file: