Free all data associated with graph
| 865 | |
| 866 | // Free all data associated with graph |
| 867 | static void _GraphContext_Free(void *arg) { |
| 868 | GraphContext *gc = (GraphContext *)arg; |
| 869 | uint len; |
| 870 | |
| 871 | // disable matrix synchronization for graph deletion |
| 872 | Graph_SetMatrixPolicy(gc->g, SYNC_POLICY_NOP); |
| 873 | |
| 874 | if(gc->decoding_context == NULL || |
| 875 | GraphDecodeContext_Finished(gc->decoding_context)) { |
| 876 | Graph_Free(gc->g); |
| 877 | } else { |
| 878 | Graph_PartialFree(gc->g); |
| 879 | } |
| 880 | |
| 881 | // Redis main thread is 0 |
| 882 | RedisModuleCtx *ctx = NULL; |
| 883 | bool main_thread = ThreadPools_GetThreadID() == 0; |
| 884 | bool should_lock = !main_thread && RedisModule_GetThreadSafeContext != NULL; |
| 885 | |
| 886 | if(should_lock) { |
| 887 | ctx = RedisModule_GetThreadSafeContext(NULL); |
| 888 | // GIL need to be acquire because RediSearch change Redis data structure |
| 889 | RedisModule_ThreadSafeContextLock(ctx); |
| 890 | } |
| 891 | |
| 892 | //-------------------------------------------------------------------------- |
| 893 | // delete graph telemetry stream |
| 894 | //-------------------------------------------------------------------------- |
| 895 | |
| 896 | if(gc->telemetry_stream != NULL) { |
| 897 | bool should_create = (ctx == NULL); |
| 898 | if(should_create) { |
| 899 | ctx = RedisModule_GetThreadSafeContext(NULL); |
| 900 | } |
| 901 | _DeleteTelemetryStream(ctx, gc); |
| 902 | RedisModule_FreeString(ctx, gc->telemetry_stream); |
| 903 | if (should_create) { |
| 904 | RedisModule_FreeThreadSafeContext(ctx); |
| 905 | ctx = NULL; |
| 906 | } |
| 907 | } |
| 908 | |
| 909 | //-------------------------------------------------------------------------- |
| 910 | // free node schemas |
| 911 | //-------------------------------------------------------------------------- |
| 912 | |
| 913 | if(gc->node_schemas) { |
| 914 | len = array_len(gc->node_schemas); |
| 915 | for(uint32_t i = 0; i < len; i ++) { |
| 916 | Schema_Free(gc->node_schemas[i]); |
| 917 | } |
| 918 | array_free(gc->node_schemas); |
| 919 | } |
| 920 | |
| 921 | //-------------------------------------------------------------------------- |
| 922 | // free relation schemas |
| 923 | //-------------------------------------------------------------------------- |
| 924 |
no test coverage detected