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

Function cypher_edge_props_concurrently

tests/test_cypher.c:2705–2771  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2703} cypher_edge_thread_ctx_t;
2704
2705static void *cypher_edge_props_concurrently(void *opaque) {
2706 cypher_edge_thread_ctx_t *ctx = opaque;
2707 cbm_store_t *store = setup_cypher_http_store();
2708 if (!store) {
2709 return NULL;
2710 }
2711
2712 /* Keep projection busy after the store scan has completed. A single-edge
2713 * query can be incidentally ordered by SQLite's internal mutexes, masking
2714 * the independent Cypher scratch-buffer race from TSan. */
2715 cbm_node_t source = {.project = "test",
2716 .label = "Function",
2717 .name = "HandleOrder",
2718 .qualified_name = "test.main.HandleOrder",
2719 .file_path = "main.go",
2720 .start_line = 10,
2721 .end_line = 30};
2722 int64_t source_id = cbm_store_upsert_node(store, &source);
2723 for (int i = 0; i < 256; i++) {
2724 char name[64];
2725 char qualified_name[96];
2726 snprintf(name, sizeof(name), "ConcurrentTarget%d", i);
2727 snprintf(qualified_name, sizeof(qualified_name), "test.concurrent.%s", name);
2728 cbm_node_t target = {.project = "test",
2729 .label = "Function",
2730 .name = name,
2731 .qualified_name = qualified_name,
2732 .file_path = "concurrent.go"};
2733 int64_t target_id = cbm_store_upsert_node(store, &target);
2734 cbm_edge_t edge = {
2735 .project = "test",
2736 .source_id = source_id,
2737 .target_id = target_id,
2738 .type = "HTTP_CALLS",
2739 .properties_json =
2740 "{\"url_path\":\"/api/orders\",\"confidence\":0.85,\"method\":\"POST\"}"};
2741 if (source_id < 0 || target_id < 0 || cbm_store_insert_edge(store, &edge) < 0) {
2742 cbm_store_close(store);
2743 return NULL;
2744 }
2745 }
2746
2747 atomic_fetch_add_explicit(ctx->ready, 1, memory_order_release);
2748 while (atomic_load_explicit(ctx->start, memory_order_acquire) == 0) {
2749 cbm_usleep(1000);
2750 }
2751 ctx->succeeded = true;
2752 for (int i = 0; i < 128; i++) {
2753 cbm_cypher_result_t result = {0};
2754 int rc = cbm_cypher_execute(store,
2755 "MATCH (a:Function)-[r:HTTP_CALLS]->(b:Function) "
2756 "RETURN r.url_path, r.confidence, r.method",
2757 "test", 0, &result);
2758 if (rc != 0 || result.row_count != 257 ||
2759 strcmp(cypher_get_col(&result, 0, "r.url_path"), "/api/orders") != 0 ||
2760 strcmp(cypher_get_col(&result, 0, "r.confidence"), "0.85") != 0 ||
2761 strcmp(cypher_get_col(&result, 0, "r.method"), "POST") != 0) {
2762 ctx->succeeded = false;

Callers

nothing calls this directly

Calls 7

setup_cypher_http_storeFunction · 0.85
cbm_store_upsert_nodeFunction · 0.85
cbm_store_insert_edgeFunction · 0.85
cbm_store_closeFunction · 0.85
cbm_cypher_executeFunction · 0.85
cypher_get_colFunction · 0.85
cbm_cypher_result_freeFunction · 0.85

Tested by

no test coverage detected