abstract class
Memo::Queries
- Memo::Queries
- Reference
- Object
Overview
Abstract query interface for database-backend-specific SQL.
Each backend (SQLite, PostgreSQL) implements all query methods with SQL native to that backend. This avoids placeholder translation and keeps SQL explicit per backend.
Direct Known Subclasses
Defined in:
memo/queries/base.crConstructors
Class Method Summary
Instance Method Summary
- #clear_completed_queue : Int32
- #clear_default_service : Nil
- #clear_query_cache(service_id : Int64) : Nil
- #clear_queue : Int32
- #count_chunks_by_hash(hash : Bytes) : Int64
- #count_chunks_for_service(service_id : Int64) : Int64
- #count_embeddings_for_service(service_id : Int64) : Int64
- #count_files : Int64
- #count_query_cache(service_id : Int64) : Int64
- #count_service_chunks(service_id : Int64) : Int64
- #count_service_embeddings(service_id : Int64) : Int64
- #count_service_sources(service_id : Int64) : Int64
- #count_services : Int64
- #count_vocab(service_id : Int64) : Int64
- #db : DB::Database
- #delete_chunks(hash : Bytes, source_id : Int64, source_type : String) : Int32
- #delete_chunks(hash : Bytes, source_id : Int64) : Int32
- #delete_chunks_by_hash(hash : Bytes) : Nil
- #delete_embeddings_by_hash(hash : Bytes) : Nil
- #delete_embeddings_by_service(service_id : Int64) : Nil
- #delete_file(source_id : Int64) : Int64
- #delete_service(id : Int64) : Nil
- #delete_source_blob(source_type : String, external_id : Bytes) : Int64
- #delete_source_by_id(internal_id : Int64) : Int64
- #delete_source_int(source_type : String, external_id : Int64) : Int64
- #delete_source_text(source_type : String, external_id : String) : Int64
- #delete_text(source_id : Int64) : Nil
- #delete_vocab(service_id : Int64) : Nil
- #enqueue(source_id : Int64, text : String, created_at : Int64) : Nil
- #fetch_search_results(rowids : Array(Int64), service_id : Int64, include_text : Bool) : Array(Tuple(UInt64, Int64, Bytes, String, Int64, Int64 | Nil, String | Nil, Bytes | Nil, Int64 | Nil, Int64 | Nil, String | Nil, Bytes | Nil, Int64 | Nil, Int64 | Nil, String | Nil, Bytes | Nil, Int32 | Nil, Int32, Int32, Int32, String | Nil))
- #find_service_id(name : String) : Int64 | Nil
- #find_source_blob(source_type : String, external_id : Bytes) : Int64 | Nil
- #find_source_blob_any_type(external_id : Bytes) : Int64 | Nil
- #find_source_int(source_type : String, external_id : Int64) : Int64 | Nil
- #find_source_int_any_type(external_id : Int64) : Int64 | Nil
- #find_source_text(source_type : String, external_id : String) : Int64 | Nil
- #find_source_text_any_type(external_id : String) : Int64 | Nil
- #get_all_texts : Array(String)
- #get_chunk_hashes(source_id : Int64, source_type : String | Nil) : Array(Bytes)
- #get_chunk_id(source_id : Int64, offset : Int32 | Nil) : Int64
- #get_chunks_for_reindex(source_type : String, service_id : Int64) : Array(Tuple(Int64, Int64 | Nil, String | Nil, Int64 | Nil, Int64 | Nil))
- #get_default_service : ServiceProvider::Info | Nil
- #get_embedding_hashes_for_service(service_id : Int64) : Array(Bytes)
- #get_embedding_rowid(hash : Bytes, service_id : Int64) : Int64
- #get_embedding_rowid?(hash : Bytes, service_id : Int64) : Int64 | Nil
- #get_existing_words(service_id : Int64, words : Array(String)) : Set(String)
- #get_file_by_hash(hash : Bytes) : Files::FileRecord | Nil
- #get_file_by_path(path : String) : Files::FileRecord | Nil
- #get_file_by_source(source_id : Int64) : Files::FileRecord | Nil
- #get_pending_queue(limit : Int32) : Array(Tuple(Int64, Int64, String))
- #get_query_cache(query : String, service_id : Int64) : Tuple(Bytes, Int32) | Nil
- #get_queue_attempts(id : Int64) : Int32
- #get_queue_item(source_id : Int64) : Tuple(Int64, String) | Nil
- #get_recent_query_cache(service_id : Int64, limit : Int32) : Array(Tuple(String, Bytes, Int32))
- #get_service_by_format_model(format : String, model : String) : Tuple(Int64, String, String | Nil, String, Int32, Int32, Float64) | Nil
- #get_service_by_name(name : String) : Tuple(Int64, String, String | Nil, String, Int32, Int32, Float64) | Nil
- #get_service_info(id : Int64) : ServiceProvider::Info | Nil
- #get_service_info_by_name(name : String) : ServiceProvider::Info | Nil
- #get_service_tokens_per_byte(service_id : Int64) : Float64 | Nil
- #get_source_external(internal_id : Int64) : Tuple(String, Int64 | Nil, String | Nil, Bytes | Nil) | Nil
- #get_text(source_id : Int64) : String | Nil
- #get_text_hash(source_id : Int64) : Bytes | Nil
- #get_texts_for_reindex(source_type : String) : Array(Tuple(Int64, Int64 | Nil, Int64 | Nil, String))
- #get_tokens_per_byte(service_id : Int64) : Float64 | Nil
- #get_vocab(service_id : Int64, &block : DB::ResultSet -> ) : Nil
- #increment_match_count(chunk_ids : Array(Int64)) : Nil
- #increment_read_count(chunk_ids : Array(Int64)) : Nil
- #insert_chunk_ignore(hash : Bytes, source_id : Int64, source_type : String, pair_id : Int64 | Nil, parent_id : Int64 | Nil, offset : Int32 | Nil, size : Int32, created_at : Int64) : Int64
- #insert_embedding_ignore(hash : Bytes, service_id : Int64, token_count : Int32, created_at : Int64) : Int64
- #insert_service(name : String, format : String, base_url : String | Nil, model : String, dimensions : Int32, max_tokens : Int32, created_at : Int64) : Int64
-
#insert_service_full(name : String, format : String, base_url : String | Nil, model : String, dimensions : Int32, max_tokens : Int32, is_default : Int32, created_at : Int64) : Int64
Insert service with is_default and return ID (for ServiceProvider.create)
- #insert_source(source_type : String, created_at : Int64) : Int64
- #insert_source_blob(source_type : String, external_id : Bytes, created_at : Int64) : Int64
- #insert_source_int(source_type : String, external_id : Int64, created_at : Int64) : Int64
- #insert_source_text(source_type : String, external_id : String, created_at : Int64) : Int64
- #list_files(limit : Int32, offset : Int32) : Array(Files::FileRecord)
- #list_services : Array(ServiceProvider::Info)
- #list_services_by_format(format : String) : Array(ServiceProvider::Info)
- #list_sources(source_type : String, limit : Int32, offset : Int32) : Array(Tuple(Int64, Int64 | Nil, String | Nil, Bytes | Nil))
- #load_embedding_rowids(service_id : Int64, source_type : String, external_ids : Array(Int64)) : Array(Tuple(Int64, Int64))
- #mark_queue_failed(id : Int64, error_message : String | Nil, attempts : Int32, processed_at : Int64) : Nil
- #mark_queue_item_success(id : Int64, processed_at : Int64, attempts : Int32) : Nil
- #mark_queue_retry(id : Int64, attempts : Int32, error_message : String | Nil) : Nil
- #mark_queue_success(id : Int64, processed_at : Int64) : Nil
- #prune_query_cache(service_id : Int64, count : Int64) : Nil
- #queue_stats : Tuple(Int64, Int64)
- #search_filtered_rowids(service_id : Int64, params : Array(DB::Any), where_clauses : Array(String), text_join : String, fts_join : String) : Set(UInt64)
- #service_exists?(id : Int64) : Bool
- #set_default_service(id : Int64) : Nil
- #update_service(id : Int64, updates : Array(String), params : Array(DB::Any)) : Int64
- #update_tokens_per_byte(tokens_per_byte : Float64, service_id : Int64) : Nil
- #update_word_frequency(count : Int32, word : String, service_id : Int64) : Nil
- #upsert_file(source_id : Int64, path : String, content_hash : Bytes, mtime : Int64, size : Int64, created_at : Int64) : Nil
- #upsert_query_cache(query : String, service_id : Int64, embedding : Bytes, token_count : Int32, created_at : Int64) : Nil
- #upsert_text(source_id : Int64, content : String, content_hash : Bytes | Nil, created_at : Int64) : Nil
- #upsert_vocab(word : String, service_id : Int64, embedding : Bytes, frequency : Int32, created_at : Int64) : Nil
Constructor Detail
Class Method Detail
Instance Method Detail
abstract
def delete_chunks(hash : Bytes, source_id : Int64, source_type : String) : Int32
#
abstract
def fetch_search_results(rowids : Array(Int64), service_id : Int64, include_text : Bool) : Array(Tuple(UInt64, Int64, Bytes, String, Int64, Int64 | Nil, String | Nil, Bytes | Nil, Int64 | Nil, Int64 | Nil, String | Nil, Bytes | Nil, Int64 | Nil, Int64 | Nil, String | Nil, Bytes | Nil, Int32 | Nil, Int32, Int32, Int32, String | Nil))
#
abstract
def find_source_blob(source_type : String, external_id : Bytes) : Int64 | Nil
#
abstract
def find_source_int(source_type : String, external_id : Int64) : Int64 | Nil
#
abstract
def find_source_text(source_type : String, external_id : String) : Int64 | Nil
#
abstract
def get_chunk_hashes(source_id : Int64, source_type : String | Nil) : Array(Bytes)
#
abstract
def get_chunks_for_reindex(source_type : String, service_id : Int64) : Array(Tuple(Int64, Int64 | Nil, String | Nil, Int64 | Nil, Int64 | Nil))
#
abstract
def get_existing_words(service_id : Int64, words : Array(String)) : Set(String)
#
abstract
def get_query_cache(query : String, service_id : Int64) : Tuple(Bytes, Int32) | Nil
#
abstract
def get_recent_query_cache(service_id : Int64, limit : Int32) : Array(Tuple(String, Bytes, Int32))
#
abstract
def get_service_by_format_model(format : String, model : String) : Tuple(Int64, String, String | Nil, String, Int32, Int32, Float64) | Nil
#
abstract
def get_service_by_name(name : String) : Tuple(Int64, String, String | Nil, String, Int32, Int32, Float64) | Nil
#
abstract
def get_source_external(internal_id : Int64) : Tuple(String, Int64 | Nil, String | Nil, Bytes | Nil) | Nil
#
abstract
def get_texts_for_reindex(source_type : String) : Array(Tuple(Int64, Int64 | Nil, Int64 | Nil, String))
#
abstract
def insert_chunk_ignore(hash : Bytes, source_id : Int64, source_type : String, pair_id : Int64 | Nil, parent_id : Int64 | Nil, offset : Int32 | Nil, size : Int32, created_at : Int64) : Int64
#
abstract
def insert_embedding_ignore(hash : Bytes, service_id : Int64, token_count : Int32, created_at : Int64) : Int64
#
abstract
def insert_service(name : String, format : String, base_url : String | Nil, model : String, dimensions : Int32, max_tokens : Int32, created_at : Int64) : Int64
#
abstract
def insert_service_full(name : String, format : String, base_url : String | Nil, model : String, dimensions : Int32, max_tokens : Int32, is_default : Int32, created_at : Int64) : Int64
#
Insert service with is_default and return ID (for ServiceProvider.create)
abstract
def insert_source_blob(source_type : String, external_id : Bytes, created_at : Int64) : Int64
#
abstract
def insert_source_int(source_type : String, external_id : Int64, created_at : Int64) : Int64
#
abstract
def insert_source_text(source_type : String, external_id : String, created_at : Int64) : Int64
#
abstract
def list_services_by_format(format : String) : Array(ServiceProvider::Info)
#
abstract
def list_sources(source_type : String, limit : Int32, offset : Int32) : Array(Tuple(Int64, Int64 | Nil, String | Nil, Bytes | Nil))
#
abstract
def load_embedding_rowids(service_id : Int64, source_type : String, external_ids : Array(Int64)) : Array(Tuple(Int64, Int64))
#
abstract
def mark_queue_failed(id : Int64, error_message : String | Nil, attempts : Int32, processed_at : Int64) : Nil
#
abstract
def mark_queue_item_success(id : Int64, processed_at : Int64, attempts : Int32) : Nil
#
abstract
def mark_queue_retry(id : Int64, attempts : Int32, error_message : String | Nil) : Nil
#
abstract
def search_filtered_rowids(service_id : Int64, params : Array(DB::Any), where_clauses : Array(String), text_join : String, fts_join : String) : Set(UInt64)
#
abstract
def update_service(id : Int64, updates : Array(String), params : Array(DB::Any)) : Int64
#
abstract
def update_tokens_per_byte(tokens_per_byte : Float64, service_id : Int64) : Nil
#
abstract
def update_word_frequency(count : Int32, word : String, service_id : Int64) : Nil
#
abstract
def upsert_file(source_id : Int64, path : String, content_hash : Bytes, mtime : Int64, size : Int64, created_at : Int64) : Nil
#
abstract
def upsert_query_cache(query : String, service_id : Int64, embedding : Bytes, token_count : Int32, created_at : Int64) : Nil
#
abstract
def upsert_text(source_id : Int64, content : String, content_hash : Bytes | Nil, created_at : Int64) : Nil
#
abstract
def upsert_vocab(word : String, service_id : Int64, embedding : Bytes, frequency : Int32, created_at : Int64) : Nil
#