MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / build_edge_indexes

Function build_edge_indexes

internal/cbm/sqlite_writer.c:2008–2031  ·  view source on GitHub ↗

Build all 7 edge index B-trees. Returns 0 on success, ERR_SORT_FAILED on failure. */

Source from the content-addressed store, hash-verified

2006
2007/* Build all 7 edge index B-trees. Returns 0 on success, ERR_SORT_FAILED on failure. */
2008static int build_edge_indexes(FILE *fp, uint32_t *next_page, CBMDumpEdge *edges, int edge_count,
2009 SortJob *esorts, uint32_t *source_root, uint32_t *target_root,
2010 uint32_t *type_root, uint32_t *tgt_type_root, uint32_t *src_type_root,
2011 uint32_t *url_path_root, uint32_t *auto_root) {
2012 *source_root =
2013 build_edge_index_sorted(fp, next_page, edges, edge_count, esorts[0].perm, ecell_source);
2014 *target_root = build_edge_index_sorted(fp, next_page, edges, edge_count,
2015 esorts[ESORT_TARGET].perm, ecell_target);
2016 *type_root = build_edge_index_sorted(fp, next_page, edges, edge_count, esorts[ESORT_TYPE].perm,
2017 ecell_type);
2018 *tgt_type_root = build_edge_index_sorted(
2019 fp, next_page, edges, edge_count, esorts[ESORT_PROJ_TGT_TYPE].perm, ecell_proj_target_type);
2020 *src_type_root = build_edge_index_sorted(
2021 fp, next_page, edges, edge_count, esorts[ESORT_PROJ_SRC_TYPE].perm, ecell_proj_source_type);
2022 *url_path_root = build_edge_index_sorted(fp, next_page, edges, edge_count,
2023 esorts[ESORT_URL_PATH].perm, ecell_url_path);
2024 *auto_root = build_edge_index_sorted(fp, next_page, edges, edge_count,
2025 esorts[ESORT_SRC_TGT_TYPE].perm, ecell_src_tgt_type);
2026 if (edge_count > 0 && (!*source_root || !*target_root || !*type_root || !*tgt_type_root ||
2027 !*src_type_root || !*url_path_root || !*auto_root)) {
2028 return ERR_SORT_FAILED;
2029 }
2030 return 0;
2031}
2032
2033/* Launch parallel sort threads for all index permutations. */
2034static void parallel_sort_indexes(SortJob *nsorts, int n_node, SortJob *esorts, int n_edge) {

Callers 1

write_db_after_nodesFunction · 0.85

Calls 1

build_edge_index_sortedFunction · 0.85

Tested by

no test coverage detected