| 742 | enum { TRACE_MAX_DEPTH = 12 }; |
| 743 | |
| 744 | static int32_t fl_resolve_endpoint(struct sqlite3 *db, const char *project, int64_t id, |
| 745 | const char *qn) { |
| 746 | if (id < 0 && qn && qn[0] && db) { |
| 747 | sqlite3_stmt *st = NULL; |
| 748 | if (sqlite3_prepare_v2(db, |
| 749 | "SELECT id FROM nodes WHERE project=?1 AND " |
| 750 | "qualified_name=?2 ORDER BY id LIMIT 1", |
| 751 | -1, &st, NULL) == SQLITE_OK) { |
| 752 | sqlite3_bind_text(st, 1, project, -1, SQLITE_STATIC); |
| 753 | sqlite3_bind_text(st, 2, qn, -1, SQLITE_STATIC); |
| 754 | if (sqlite3_step(st) == SQLITE_ROW) |
| 755 | id = sqlite3_column_int64(st, 0); |
| 756 | sqlite3_finalize(st); |
| 757 | } |
| 758 | } |
| 759 | if (id < 0) |
| 760 | return -1; |
| 761 | /* Map the store id into the cache index (nodes are ordered by id). */ |
| 762 | int lo = 0, hi = g_flow_cache.node_count - 1; |
| 763 | while (lo <= hi) { |
| 764 | int mid = lo + (hi - lo) / 2; |
| 765 | if (g_flow_cache.nodes[mid].id == id) |
| 766 | return mid; |
| 767 | if (g_flow_cache.nodes[mid].id < id) |
| 768 | lo = mid + 1; |
| 769 | else |
| 770 | hi = mid - 1; |
| 771 | } |
| 772 | return -1; |
| 773 | } |
| 774 | |
| 775 | char *cbm_atlas_trace_json(cbm_store_t *store, const char *project, int64_t from_id, |
| 776 | const char *from_qn, int64_t to_id, const char *to_qn, |
no outgoing calls
no test coverage detected