The invention provides a graph calculation method and
system based on dynamic
code generation, and the method comprises the steps of constructing an intermediate graph structure containing a graph operation primitive according to a graph building request, enabling the intermediate graph structure to be associated with a graph name, and then storing the associated intermediate graph structure into an intermediate graph buffer; according to the graph
algorithm request, generating a graph
algorithm structure composed of the external code
byte codes, and sending the graph
algorithm structure to a graph algorithm buffer; retrieving the intermediate graph buffer and the graph algorithm buffer according to the execution request to obtain a triple composed of the intermediate graph structure to be executed, the graph algorithm structure to be executed and the parameter
list, and retrieving the triple in the local code buffer to obtain an execution object in the local code buffer so as to obtain a result through execution. According to the present invention, the generated codes are injected into a local
code space, so that the overhead of
data exchange is eliminated; the intermediate graph structure capable of being secondarily compiled is constructed, so that access codes of the graph data can be compiled and optimized; meanwhile, the intermediate graph structure cache and the graph algorithm cache are added, so that the preprocessing expenditure of the graph calculation is avoided.