Lazy copy for database systems
A computing device comprising a processor is configured to perform the techniques of this disclosure. The processor may duplicate a first node of a tree data structure to create a duplicate node, and create an inbound edge of the duplicate node to a parent node of the first node and an outbound edge to at least one child node of the first node. The processor may receive an update to the at least one child node of the first node. In response to determining that the at least one child node has multiple parent nodes, the processor may duplicate the at least one child node to create a duplicate child node, create an outbound edge of the duplicate node to the duplicate child node, delete the outbound edge of the duplicate node to the at least one child node, and perform the update to the at least one child node.
1 . A method for copying a first node of a tree data structure, the method comprising:
storing, by processing circuitry and to a graph database that stores a template for a generic clinical research study as the tree data structure, the tree data structure representative of at least a portion of a clinical research study to be performed in support of a specific test for confirming a hypothesis concerning one or more of a utility, an impact, a pharmacological, a physiological, or a psychological effects of a particular treatment, procedure, drug, device, biological, food product, cosmetic, care plan, or subject characteristic, the tree data structure representing a form of a graph data structure that stores the template for objectives and endpoints, wherein when the tree data structure is modified, the tree data structure is used to generate a parameterized template specific to the clinical research study;
duplicating, by the processing circuitry according to a shallow copy, the first node to create a duplicate node within the tree data structure, wherein the first node comprises an inbound edge from a parent node of the first node and at least one outbound edge to at least one child node of the first node defined by reference pointers in the graph database, and wherein the first node comprises data for one of the clinical research study, a clinical research study protocol, a clinical research study protocol version, a clinical research study design, a clinical research study schedule, a clinical research study arm, a study, a study protocol, a study protocol version, a study design, or a study schedule;
creating, by the processing circuitry, an inbound edge of the duplicate node from the parent node of the first node and an outbound edge to the at least one child node of the first node by generating reference pointers linking the duplicate node to the parent node and the at least one child node;
receiving, by the processing circuitry, an update to the at least one child node of the first node that modifies the template to form the parameterized template specific to the clinical research study; and
in response to determining that the at least one child node has multiple parent nodes:
duplicating, by the processing circuitry according to a deep copy different from the shallow copy, the at least one child node to create a duplicate child node;
creating, by the processing circuitry, an outbound edge of the duplicate node to the duplicate child node;
deleting, by the processing circuitry, the outbound edge of the duplicate node to the at least one child node; and
performing, by the processing circuitry, the update to the at least one child node to generate, based on the tree data structure and after updating the at least one child node, the parameterized template specific to the clinical research study.
2 . The method of claim 1 , further comprising:
duplicating, by the processing circuitry, one or more child nodes of the at least one child node to create one or more duplicate child nodes of the child node; and
creating, by the processing circuitry, an outbound edge of the duplicate child node to each of the one or more duplicate child nodes of the child nodes.
3 . The method of claim 1 , further comprising:
determining, by the processing circuitry, that a second node of the tree data structure has multiple parent nodes, wherein the second node comprises multiple inbound edges from the multiple parent nodes of the second node and at least one outbound edge to at least one child node of the second node;
in response to determining that the second node has multiple parent nodes:
determining, by the processing circuitry, a closest superior ancestor node of the second node that has only a single parent node:
duplicating, by the processing circuitry, the superior ancestor node of the second node to create a duplicate superior ancestor node;
duplicating, by the processing circuitry, a branch descending from the superior ancestor node of the second node to create a duplicate branch descending from the duplicate superior ancestor node, wherein the duplicate branch descending from the duplicate superior ancestor node duplicates nodes and edges of the branch descending from the superior ancestor node of the second node; and
deleting, by the processing circuitry, the second node and any inferior descendent nodes of the first node.
4 . The method of claim 1 , further comprising:
determining, by processing circuitry, that the second node comprises at least one outbound edge to at least one child node of the second node, wherein the second node comprises an inbound edge to a parent node of the second node;
determining, by the processing circuitry and based on inbound edges of the at least one child node to the second node and to a third node, that the at least one child node has multiple parent nodes; and
deleting, by the processing circuitry, the second node, an outbound edge of the parent node to the second node, and the inbound edges of the at least one child node to the second node.
5 . The method of claim 1 , further comprising:
retrieving, by the processing circuitry, the tree data structure from a storage medium;
updating, by the processing circuitry, the tree data structure with data for the first node; and
storing, by the processing circuitry, the updated tree data structure.
6 . A computing device comprising:
a graph database that stores a template for a generic clinical research study as a tree data structure, the tree data structure representative of at least a portion of a clinical research study to be performed in support of a specific test for confirming a hypothesis concerning one or more of utility, impact, pharmacological, physiological, or psychological effects of a particular treatment, procedure, drug, device, biological, food product, cosmetic, care plan, or subject characteristic, the tree data structure representing a form of a graph data structure that stores the template for objectives and endpoints, wherein when the tree data structure is modified, the tree data structure is used to generate a parameterized template specific to the clinical research study; and
one or more processors configured to:
duplicate, according to a shallow copy, the first node to create a duplicate node within the tree data structure, wherein the first node comprises an inbound edge from a parent node of the first node and at least one outbound edge to at least one child node of the first node defined by reference pointers in the graph database, and wherein the first node comprises data for one of the clinical research study, a clinical research study protocol, a clinical research study protocol version, a clinical research study design, a clinical research study schedule, a clinical research study arm, a study, a study protocol, a study protocol version, a study design, or a study schedule;
create an inbound edge of the duplicate node from the parent node of the first node and an outbound edge to the at least one child node of the first node by generating reference pointers linking the duplicate node to the parent node and the at least one child node;
receive an update to the at least one child node of the first node that modifies the template to form the parameterized template specific to the clinical research study; and
in response to determining that the at least one child node has multiple parent nodes:
duplicate, according to a deep copy different from the shallow copy, the at least one child node to create a duplicate child node;
create an outbound edge of the duplicate node to the duplicate child node;
delete the outbound edge of the duplicate node to the at least one child node; and
perform the update to the at least one child node to generate, based on the tree data structure and after updating the at least one child node, the parameterized template specific to the clinical research study.
7 . The computing device of claim 6 , wherein the one or more processors are further configured to:
duplicate one or more child nodes of the at least one child node to create one or more duplicate child nodes of the child node; and
create an outbound edge of the duplicate child node to each of the one or more duplicate child nodes of the child nodes.
8 . The computing device of claim 6 , wherein the one or more processors are further configured to:
determine that a second node of the tree data structure has multiple parent nodes, wherein the second node comprises multiple inbound edges from the multiple parent nodes of the second node and at least one outbound edge to at least one child node of the second node;
in response to determining that the second node has multiple parent nodes:
determine a closest superior ancestor node of the second node that has only a single parent node:
duplicate the superior ancestor node of the second node to create a duplicate superior ancestor node;
duplicate a branch descending from the superior ancestor node of the second node to create a duplicate branch descending from the duplicate superior ancestor node, wherein the duplicate branch descending from the duplicate superior ancestor node duplicates nodes and edges of the branch descending from the superior ancestor node of the second node; and
delete the second node and any inferior descendent nodes of the first node.
9 . The computing device of claim 6 , wherein the one or more processors are further configured to:
determine that the second node comprises at least one outbound edge to at least one child node of the second node, wherein the second node comprises an inbound edge to a parent node of the second node;
determine, based on inbound edges of the at least one child node to the second node and to a third node, that the at least one child node has multiple parent nodes; and
delete the second node, an outbound edge of the parent node to the second node, and the inbound edges of the at least one child node to the second node.
10 . The computing device of claim 6 , wherein the one or more processors are further configured to:
retrieve the tree data structure from a storage medium;
update the tree data structure with data for the first node; and
store the updated tree data structure.
11 . A non-transitory computer-readable storage medium having instructions stored thereon that, when executed, cause one or more processors to:
store, to a graph database a template for a generic clinical research study as the tree data structure, the tree data structure representative of at least a portion of a clinical research study to be performed in support of a specific test for confirming a hypothesis concerning one or more of utility, impact, pharmacological, physiological, or psychological effects of a particular treatment, procedure, drug, device, biological, food product, cosmetic, care plan, or subject characteristic, the tree data structure representing a form of a graph data structure that stores the template for objectives and endpoints, wherein when the tree data structure is modified, the tree data structure is used to generate a parameterized template specific to the clinical research study;
duplicate, according to a shallow copy, the first node to create a duplicate node, wherein the first node comprises an inbound edge from a parent node of the first node and at least one outbound edge to at least one child node of the first node defined by reference pointers in the graph database, and wherein the first node comprises data for one of the clinical research study, a clinical research study protocol, a clinical research study protocol version, a clinical research study design, a clinical research study schedule, a clinical research study arm, a study, a study protocol, a study protocol version, a study design, or a study schedule;
create an inbound edge of the duplicate node from the parent node of the first node and an outbound edge to the at least one child node of the first node by generating reference pointers linking the duplicate node to the parent node and the at least one child node;
receive an update to the at least one child node of the first node that modifies the generic parameterized template to form the parameterized template specific to the clinical research study; and
in response to determining that the at least one child node has multiple parent nodes:
duplicate, according to a deep copy different from the shallow copy, the at least one child node to create a duplicate child node;
create an outbound edge of the duplicate node to the duplicate child node;
delete the outbound edge of the duplicate node to the at least one child node; and
perform the update to the at least one child node to generate, based on the tree data structure and after updating the at least one child node, the parameterized template specific to the clinical research study.
12 . The non-transitory computer-readable storage medium of claim 11 , further comprising instructions that, when executed, cause the one or more processors to:
duplicate one or more child nodes of the at least one child node to create one or more duplicate child nodes of the child node; and
create an outbound edge of the duplicate child node to each of the one or more duplicate child nodes of the child nodes.
13 . The non-transitory computer-readable storage medium of claim 11 , further comprising instructions that, when executed, cause the one or more processors to:
determine that a second node of the tree data structure has multiple parent nodes, wherein the second node comprises multiple inbound edges from the multiple parent nodes of the second node and at least one outbound edge to at least one child node of the second node;
in response to determining that the second node has multiple parent nodes:
determine a closest superior ancestor node of the second node that has only a single parent node;
duplicate the superior ancestor node of the second node to create a duplicate superior ancestor node;
duplicate a branch descending from the superior ancestor node of the second node to create a duplicate branch descending from the duplicate superior ancestor node, wherein the duplicate branch descending from the duplicate superior ancestor node duplicates nodes and edges of the branch descending from the superior ancestor node of the second node; and
delete the second node and any inferior descendent nodes of the first node.
14 . The non-transitory computer-readable storage medium of claim 11 , further comprising instructions that, when executed, cause the one or more processors to:
determine that the second node comprises at least one outbound edge to at least one child node of the second node, wherein the second node comprises an inbound edge to a parent node of the second node;
determine, based on inbound edges of the at least one child node to the second node and to a third node, that the at least one child node has multiple parent nodes; and
delete the second node, an outbound edge of the parent node to the second node, and the inbound edges of the at least one child node to the second node.
15 . The non-transitory computer-readable storage medium of claim 11 , further comprising instructions that, when executed, cause the one or more processors to:
retrieve the tree data structure from a storage medium;
update the tree data structure with data for the first node; and
store the updated tree data structure.