@@ -40,10 +40,32 @@ int genomicsqlite_open(const char *dbfile, sqlite3 **ppDb, int flags, const char
4040char *genomicsqlite_vacuum_into_sql (const char *destfile, const char *config_json);
4141
4242/*
43- * Genomic range indexing
43+ * Generate SQL script to create a genomic range index on the specified table.
44+ * rid: column name for the reference sequence (chromosome) ID of each row
45+ * beg: column name or simple SQL expression for the interval begin position
46+ * end: column name or simple SQL expression for the interval end position
4447 */
4548char *create_genomic_range_index_sql (const char *table, const char *rid, const char *beg,
4649 const char *end, int max_depth);
50+
51+ /*
52+ * Generate parenthesized SELECT statement to query the existing genomic range index of the
53+ * specified table. The query finds table rows which overlap the query range, producing one column
54+ * of _rowid_'s.
55+ * dbconn: If provided, the procedure first inspects the index to collect information that may
56+ * allow it to optimize the generated query SQL. Recommended if the generated SQL will be
57+ * used repeatedly, which is the typical case.
58+ * A query optimized in this way must not be used after rows are added or updated, as it's
59+ * then liable to produce incomplete results. The SQL should be regenerated after such
60+ * changes.
61+ * Alternatively, if dbconn is NULL then a less-efficient version of the query is generated
62+ * which is safe to use across updates (also saving the small upfront cost of inspection).
63+ * qrid: query reference sequence (chromosome) ID; defaults to "?1" i.e. the first parameter of the
64+ * compiled statement. One could substitute a different parameter, a constant value, or a SQL
65+ * expression referring to columns of a joined table.
66+ * qbeg: query range begin position; defaults to "?2"
67+ * qend: query range end position; defaults to "?3"
68+ */
4769char *genomic_range_rowids_sql (const char *indexed_table, sqlite3 *dbconn, const char *qrid,
4870 const char *qbeg, const char *qend);
4971
@@ -78,6 +100,7 @@ int GenomicSQLiteOpen(const std::string &dbfile, sqlite3 **ppDb, int flags,
78100std::unique_ptr<SQLite::Database> GenomicSQLiteOpen (const std::string &dbfile, int flags,
79101 const std::string &config_json = " {}" );
80102#endif
103+
81104std::string GenomicSQLiteVacuumIntoSQL (const std::string &dbfile,
82105 const std::string &config_json = " {}" );
83106
@@ -96,6 +119,7 @@ std::string PutGenomicReferenceSequenceSQL(const std::string &name, sqlite3_int6
96119 sqlite3_int64 rid = -1 ,
97120 const std::string &attached_schema = " " );
98121
122+ /* Lookup helpers for stored reference sequence metadata (assumes it's finalized) */
99123struct gri_refseq_t {
100124 unsigned long long rid, length;
101125 std::string name, assembly, refget_id;
0 commit comments